@bitcobblers/wod-wiki-tools 0.50.2190 → 0.50.2191

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.
Files changed (596) hide show
  1. package/dist/bin/wod.cjs +1 -1
  2. package/dist/bin/wod.cjs.map +1 -1
  3. package/dist/bin/wod.mjs +2 -2
  4. package/dist/{chunk-4TW3XOPT.mjs → chunk-LFTYRG2P.mjs} +3 -3
  5. package/dist/chunk-LFTYRG2P.mjs.map +1 -0
  6. package/dist/{chunk-UQN4UFJO.mjs → chunk-QI5TM33A.mjs} +4 -4
  7. package/dist/{chunk-UQN4UFJO.mjs.map → chunk-QI5TM33A.mjs.map} +1 -1
  8. package/dist/index.cjs +1 -1
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.mjs +2 -2
  11. package/dist/{scaffoldFeed-E3JXLYUB.mjs → scaffoldFeed-PNCMFELN.mjs} +3 -3
  12. package/dist/{scaffoldFeed-E3JXLYUB.mjs.map → scaffoldFeed-PNCMFELN.mjs.map} +1 -1
  13. package/dist/web/playground/assets/{main-CDz0sO7m.js → main-B5XfAg-F.js} +4 -4
  14. package/dist/web/playground/assets/{statementBuilderFlow-B-cSEEVk.js → statementBuilderFlow-BOTQvHtd.js} +2 -2
  15. package/dist/web/playground/index.html +1 -1
  16. package/dist/web/playground/seed/core/chunks/{canvas.244155fb.json → canvas.45303baa.json} +1 -1
  17. package/dist/web/playground/seed/core/chunks/{dashboards.0543e87b.json → dashboards.3fba44e2.json} +1 -1
  18. package/dist/web/playground/seed/core/chunks/{efforts.2dcc6b6b.json → efforts.ad4805cb.json} +1 -1
  19. package/dist/web/playground/seed/core/chunks/{equipment.59aa6ef7.json → equipment.01363a88.json} +1 -1
  20. package/dist/web/playground/seed/core/indexes/notebooks/canvas.json +180 -180
  21. package/dist/web/playground/seed/core/indexes/notebooks/dashboards.json +16 -16
  22. package/dist/web/playground/seed/core/indexes/notebooks/efforts.json +326 -326
  23. package/dist/web/playground/seed/core/indexes/notebooks/equipment.json +50 -50
  24. package/dist/web/playground/seed/core/manifest.json +27 -27
  25. package/dist/web/playground/seed/core/markdown/canvas/ai-first/README.json +1 -1
  26. package/dist/web/playground/seed/core/markdown/canvas/guide/README.json +4 -4
  27. package/dist/web/playground/seed/core/markdown/canvas/guide/clock.json +1 -1
  28. package/dist/web/playground/seed/core/markdown/canvas/guide/dashboards.json +2 -2
  29. package/dist/web/playground/seed/core/markdown/canvas/guide/metrics-summaries.json +2 -2
  30. package/dist/web/playground/seed/core/markdown/canvas/guide/metrics.json +12 -12
  31. package/dist/web/playground/seed/core/markdown/canvas/guide/protocols.json +20 -20
  32. package/dist/web/playground/seed/core/markdown/canvas/guide/sessions.json +33 -33
  33. package/dist/web/playground/seed/core/markdown/canvas/guide/start.json +11 -11
  34. package/dist/web/playground/seed/core/markdown/canvas/guide/structure.json +25 -25
  35. package/dist/web/playground/seed/core/markdown/canvas/guide/wql.json +5 -5
  36. package/dist/web/playground/seed/core/markdown/canvas/home/sample-script.json +4 -4
  37. package/dist/web/playground/seed/core/markdown/canvas/home/welcome-1.json +2 -2
  38. package/dist/web/playground/seed/core/markdown/canvas/syntax/actions-comments.json +4 -4
  39. package/dist/web/playground/seed/core/markdown/canvas/syntax/alternating-emom.json +5 -5
  40. package/dist/web/playground/seed/core/markdown/canvas/syntax/basic-emom.json +4 -4
  41. package/dist/web/playground/seed/core/markdown/canvas/syntax/calculated-metrics.json +4 -4
  42. package/dist/web/playground/seed/core/markdown/canvas/syntax/classic-amrap.json +6 -6
  43. package/dist/web/playground/seed/core/markdown/canvas/syntax/complex-barbell-cycling.json +4 -4
  44. package/dist/web/playground/seed/core/markdown/canvas/syntax/complex-full-session.json +10 -10
  45. package/dist/web/playground/seed/core/markdown/canvas/syntax/complex-nested-protocols.json +7 -7
  46. package/dist/web/playground/seed/core/markdown/canvas/syntax/complex-partner-workout.json +7 -7
  47. package/dist/web/playground/seed/core/markdown/canvas/syntax/complex-swimming.json +5 -5
  48. package/dist/web/playground/seed/core/markdown/canvas/syntax/core-rules.json +4 -4
  49. package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-and-calculated-metrics.json +4 -4
  50. package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-intervals.json +4 -4
  51. package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-metrics-1.json +4 -4
  52. package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-metrics-2.json +5 -5
  53. package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-metrics-3.json +3 -3
  54. package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-metrics-4.json +4 -4
  55. package/dist/web/playground/seed/core/markdown/canvas/syntax/custom-metrics-5.json +4 -4
  56. package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-climb-bouldering.json +2 -2
  57. package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-climb-hangboard.json +2 -2
  58. package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-climb-sport.json +2 -2
  59. package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-log.json +4 -4
  60. package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-plan.json +8 -8
  61. package/dist/web/playground/seed/core/markdown/canvas/syntax/dialect-wod.json +5 -5
  62. package/dist/web/playground/seed/core/markdown/canvas/syntax/distance-intervals.json +3 -3
  63. package/dist/web/playground/seed/core/markdown/canvas/syntax/document-1.json +4 -4
  64. package/dist/web/playground/seed/core/markdown/canvas/syntax/document-2.json +5 -5
  65. package/dist/web/playground/seed/core/markdown/canvas/syntax/document-3.json +10 -10
  66. package/dist/web/playground/seed/core/markdown/canvas/syntax/document-4.json +5 -5
  67. package/dist/web/playground/seed/core/markdown/canvas/syntax/effort-notes.json +5 -5
  68. package/dist/web/playground/seed/core/markdown/canvas/syntax/frontmatter-summaries.json +4 -4
  69. package/dist/web/playground/seed/core/markdown/canvas/syntax/groups-1.json +5 -5
  70. package/dist/web/playground/seed/core/markdown/canvas/syntax/groups-2.json +6 -6
  71. package/dist/web/playground/seed/core/markdown/canvas/syntax/groups-3.json +3 -3
  72. package/dist/web/playground/seed/core/markdown/canvas/syntax/groups-4.json +3 -3
  73. package/dist/web/playground/seed/core/markdown/canvas/syntax/longer-duration.json +4 -4
  74. package/dist/web/playground/seed/core/markdown/canvas/syntax/longer-intervals.json +4 -4
  75. package/dist/web/playground/seed/core/markdown/canvas/syntax/measurements.json +7 -7
  76. package/dist/web/playground/seed/core/markdown/canvas/syntax/metrics-1.json +5 -5
  77. package/dist/web/playground/seed/core/markdown/canvas/syntax/metrics-2.json +7 -7
  78. package/dist/web/playground/seed/core/markdown/canvas/syntax/metrics-3.json +8 -8
  79. package/dist/web/playground/seed/core/markdown/canvas/syntax/metrics-4.json +6 -6
  80. package/dist/web/playground/seed/core/markdown/canvas/syntax/metrics-5.json +5 -5
  81. package/dist/web/playground/seed/core/markdown/canvas/syntax/mixed-sections.json +10 -10
  82. package/dist/web/playground/seed/core/markdown/canvas/syntax/mixed-timers.json +5 -5
  83. package/dist/web/playground/seed/core/markdown/canvas/syntax/multiple-amrap-windows.json +7 -7
  84. package/dist/web/playground/seed/core/markdown/canvas/syntax/multiple-sets.json +4 -4
  85. package/dist/web/playground/seed/core/markdown/canvas/syntax/named-groups.json +6 -6
  86. package/dist/web/playground/seed/core/markdown/canvas/syntax/protocols-1.json +6 -6
  87. package/dist/web/playground/seed/core/markdown/canvas/syntax/protocols-2.json +4 -4
  88. package/dist/web/playground/seed/core/markdown/canvas/syntax/protocols-3.json +6 -6
  89. package/dist/web/playground/seed/core/markdown/canvas/syntax/protocols-4.json +3 -3
  90. package/dist/web/playground/seed/core/markdown/canvas/syntax/protocols-5.json +4 -4
  91. package/dist/web/playground/seed/core/markdown/canvas/syntax/single-movement.json +3 -3
  92. package/dist/web/playground/seed/core/markdown/canvas/syntax/supplemental-1.json +4 -4
  93. package/dist/web/playground/seed/core/markdown/canvas/syntax/supplemental-2.json +5 -5
  94. package/dist/web/playground/seed/core/markdown/canvas/syntax/supplemental-3.json +4 -4
  95. package/dist/web/playground/seed/core/markdown/canvas/syntax/supplemental-4.json +4 -4
  96. package/dist/web/playground/seed/core/markdown/canvas/syntax/time-cap.json +6 -6
  97. package/dist/web/playground/seed/core/markdown/canvas/syntax/timer-modifiers.json +6 -6
  98. package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-1.json +6 -6
  99. package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-2.json +4 -4
  100. package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-3.json +4 -4
  101. package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-4.json +4 -4
  102. package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-5.json +5 -5
  103. package/dist/web/playground/seed/core/markdown/canvas/syntax/timers-rest.json +4 -4
  104. package/dist/web/playground/seed/core/markdown/canvas/wql-presets/aggregate-by-effort.json +2 -2
  105. package/dist/web/playground/seed/core/markdown/canvas/wql-presets/aggregate-by-week.json +2 -2
  106. package/dist/web/playground/seed/core/markdown/canvas/wql-presets/content-fran.json +2 -2
  107. package/dist/web/playground/seed/core/markdown/canvas/wql-presets/filter-combos.json +2 -2
  108. package/dist/web/playground/seed/core/markdown/canvas/wql-presets/pipes-limit.json +2 -2
  109. package/dist/web/playground/seed/core/markdown/canvas/wql-presets/session-rpe.json +2 -2
  110. package/dist/web/playground/seed/core/markdown/canvas/wql-presets/source-journal.json +2 -2
  111. package/dist/web/playground/seed/core/markdown/canvas/wql-presets/tis-trend.json +2 -2
  112. package/dist/web/playground/seed/core/markdown/canvas/wql-presets/where-join.json +2 -2
  113. package/dist/web/playground/seed/core/markdown/dashboards/benchmark-pr-board.json +6 -6
  114. package/dist/web/playground/seed/core/markdown/dashboards/finger-strength-v8.json +5 -5
  115. package/dist/web/playground/seed/core/markdown/dashboards/polarized-base-marathon.json +9 -9
  116. package/dist/web/playground/seed/core/markdown/dashboards/recovery-readiness.json +7 -7
  117. package/dist/web/playground/seed/core/markdown/dashboards/road-to-560-total.json +9 -9
  118. package/dist/web/playground/seed/core/markdown/dashboards/training-block-review.json +11 -11
  119. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/air-squat.json +1 -1
  120. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/box-jump.json +1 -1
  121. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/broad-jump.json +1 -1
  122. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/burpee-box-jump-over.json +1 -1
  123. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/burpee-over-dumbbell.json +1 -1
  124. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/burpee.json +1 -1
  125. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/dumbbell-squat-clean.json +1 -1
  126. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/ghd-sit-up.json +1 -1
  127. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/ground-kong.json +1 -1
  128. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/jumping-jack.json +1 -1
  129. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/kong-walk.json +1 -1
  130. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/lunge.json +1 -1
  131. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/overhead-squat.json +1 -1
  132. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/parkour-roll.json +1 -1
  133. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/parkour-squat.json +1 -1
  134. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/pistol-squat.json +1 -1
  135. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/plank.json +1 -1
  136. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/precision-burpee.json +1 -1
  137. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/precision-jump.json +1 -1
  138. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/quadrupedal-movement.json +1 -1
  139. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/russian-twist.json +1 -1
  140. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/sit-up.json +1 -1
  141. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/squat-clean.json +1 -1
  142. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/squat-hold.json +1 -1
  143. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/squat-snatch.json +1 -1
  144. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/tuck-jump.json +1 -1
  145. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/wall-ball.json +1 -1
  146. package/dist/web/playground/seed/core/markdown/efforts/bodyweight/wall-burpee.json +1 -1
  147. package/dist/web/playground/seed/core/markdown/efforts/cycling/assault-bike.json +1 -1
  148. package/dist/web/playground/seed/core/markdown/efforts/cycling/cycling-moderate.json +1 -1
  149. package/dist/web/playground/seed/core/markdown/efforts/cycling/cycling-vigorous.json +1 -1
  150. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/assisted-pull-up.json +1 -1
  151. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/burpee-pull-up.json +1 -1
  152. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/chest-to-bar-pull-up.json +1 -1
  153. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/dip.json +1 -1
  154. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/double-under.json +1 -1
  155. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/handstand-hold.json +1 -1
  156. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/handstand-push-up.json +1 -1
  157. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/handstand-walk.json +1 -1
  158. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/jump-rope.json +1 -1
  159. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/jumping-pull-up.json +1 -1
  160. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/jumping-push-up.json +1 -1
  161. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/l-sit-pull-up.json +1 -1
  162. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/muscle-up.json +1 -1
  163. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/pull-up.json +1 -1
  164. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/push-up.json +1 -1
  165. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/reverse-wall-dip.json +1 -1
  166. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/rope-climb.json +1 -1
  167. package/dist/web/playground/seed/core/markdown/efforts/gymnastics/toes-to-bar.json +1 -1
  168. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-arm-bar.json +1 -1
  169. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-around-the-world.json +1 -1
  170. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-bent-over-row.json +1 -1
  171. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-clean-and-jerk.json +1 -1
  172. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-clean-and-press.json +1 -1
  173. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-clean.json +1 -1
  174. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-deadlift.json +1 -1
  175. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-floor-press.json +1 -1
  176. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-front-squat.json +1 -1
  177. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-goblet-squat.json +1 -1
  178. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-gorilla-row.json +1 -1
  179. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-halo.json +1 -1
  180. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-jerk.json +1 -1
  181. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-overhead-squat.json +1 -1
  182. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-press.json +1 -1
  183. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-snatch.json +1 -1
  184. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-swing.json +1 -1
  185. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/kettlebell-windmill.json +1 -1
  186. package/dist/web/playground/seed/core/markdown/efforts/kettlebell/turkish-get-up.json +1 -1
  187. package/dist/web/playground/seed/core/markdown/efforts/recovery/rest.json +1 -1
  188. package/dist/web/playground/seed/core/markdown/efforts/recovery/stretching.json +1 -1
  189. package/dist/web/playground/seed/core/markdown/efforts/rowing/rowing-sprint.json +1 -1
  190. package/dist/web/playground/seed/core/markdown/efforts/rowing/rowing.json +1 -1
  191. package/dist/web/playground/seed/core/markdown/efforts/rowing/ski-erg.json +1 -1
  192. package/dist/web/playground/seed/core/markdown/efforts/running/backward-running.json +1 -1
  193. package/dist/web/playground/seed/core/markdown/efforts/running/running-6-mph.json +1 -1
  194. package/dist/web/playground/seed/core/markdown/efforts/running/running-8-mph.json +1 -1
  195. package/dist/web/playground/seed/core/markdown/efforts/running/running-sprint.json +1 -1
  196. package/dist/web/playground/seed/core/markdown/efforts/snatch.json +2 -2
  197. package/dist/web/playground/seed/core/markdown/efforts/strength/back-squat.json +1 -1
  198. package/dist/web/playground/seed/core/markdown/efforts/strength/bench-press.json +1 -1
  199. package/dist/web/playground/seed/core/markdown/efforts/strength/box-step-up.json +1 -1
  200. package/dist/web/playground/seed/core/markdown/efforts/strength/carioca.json +1 -1
  201. package/dist/web/playground/seed/core/markdown/efforts/strength/clean-and-jerk.json +1 -1
  202. package/dist/web/playground/seed/core/markdown/efforts/strength/cluster.json +1 -1
  203. package/dist/web/playground/seed/core/markdown/efforts/strength/dead-hang.json +1 -1
  204. package/dist/web/playground/seed/core/markdown/efforts/strength/deadlift.json +1 -1
  205. package/dist/web/playground/seed/core/markdown/efforts/strength/devils-press.json +1 -1
  206. package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-box-step-up.json +1 -1
  207. package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-clean.json +1 -1
  208. package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-fly.json +1 -1
  209. package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-row.json +1 -1
  210. package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-snatch.json +1 -1
  211. package/dist/web/playground/seed/core/markdown/efforts/strength/dumbbell-thruster.json +1 -1
  212. package/dist/web/playground/seed/core/markdown/efforts/strength/elbows-to-knees.json +1 -1
  213. package/dist/web/playground/seed/core/markdown/efforts/strength/farmer-carry.json +1 -1
  214. package/dist/web/playground/seed/core/markdown/efforts/strength/frog-stand.json +1 -1
  215. package/dist/web/playground/seed/core/markdown/efforts/strength/front-squat.json +1 -1
  216. package/dist/web/playground/seed/core/markdown/efforts/strength/good-morning.json +1 -1
  217. package/dist/web/playground/seed/core/markdown/efforts/strength/hanging-leg-raise.json +1 -1
  218. package/dist/web/playground/seed/core/markdown/efforts/strength/hollow-rock.json +1 -1
  219. package/dist/web/playground/seed/core/markdown/efforts/strength/knees-to-elbows.json +1 -1
  220. package/dist/web/playground/seed/core/markdown/efforts/strength/l-sit.json +1 -1
  221. package/dist/web/playground/seed/core/markdown/efforts/strength/man-maker.json +1 -1
  222. package/dist/web/playground/seed/core/markdown/efforts/strength/medicine-ball-clean.json +1 -1
  223. package/dist/web/playground/seed/core/markdown/efforts/strength/overhead-press.json +1 -1
  224. package/dist/web/playground/seed/core/markdown/efforts/strength/parkour-vault.json +1 -1
  225. package/dist/web/playground/seed/core/markdown/efforts/strength/pig-flip.json +1 -1
  226. package/dist/web/playground/seed/core/markdown/efforts/strength/power-clean.json +1 -1
  227. package/dist/web/playground/seed/core/markdown/efforts/strength/power-snatch.json +1 -1
  228. package/dist/web/playground/seed/core/markdown/efforts/strength/push-jerk.json +1 -1
  229. package/dist/web/playground/seed/core/markdown/efforts/strength/push-press.json +1 -1
  230. package/dist/web/playground/seed/core/markdown/efforts/strength/romanian-deadlift.json +1 -1
  231. package/dist/web/playground/seed/core/markdown/efforts/strength/single-leg-deadlift.json +1 -1
  232. package/dist/web/playground/seed/core/markdown/efforts/strength/skull-crusher.json +1 -1
  233. package/dist/web/playground/seed/core/markdown/efforts/strength/slam-ball.json +1 -1
  234. package/dist/web/playground/seed/core/markdown/efforts/strength/sled-pull.json +1 -1
  235. package/dist/web/playground/seed/core/markdown/efforts/strength/sled-push.json +1 -1
  236. package/dist/web/playground/seed/core/markdown/efforts/strength/sumo-deadlift.json +1 -1
  237. package/dist/web/playground/seed/core/markdown/efforts/strength/thruster.json +1 -1
  238. package/dist/web/playground/seed/core/markdown/efforts/strength/triceps-extension.json +1 -1
  239. package/dist/web/playground/seed/core/markdown/efforts/strength/v-sit-hold.json +1 -1
  240. package/dist/web/playground/seed/core/markdown/efforts/strength/wall-walk.json +1 -1
  241. package/dist/web/playground/seed/core/markdown/efforts/strength/yoga-sun-salutation.json +1 -1
  242. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-assisted-sprint.json +1 -1
  243. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-backstroke.json +1 -1
  244. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-breaststroke-kick.json +1 -1
  245. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-breaststroke.json +1 -1
  246. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-butterfly.json +1 -1
  247. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-catch-up-drill.json +1 -1
  248. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-choice-stroke.json +1 -1
  249. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-dive-start.json +1 -1
  250. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-dolphin-kick.json +1 -1
  251. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-drafting.json +1 -1
  252. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-fingertip-drag.json +1 -1
  253. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-freestyle.json +1 -1
  254. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-individual-medley.json +1 -1
  255. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-kick.json +1 -1
  256. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-pull.json +1 -1
  257. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-resisted-sprint.json +1 -1
  258. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-rotation-drill.json +1 -1
  259. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-sighting.json +1 -1
  260. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-single-arm-drill.json +1 -1
  261. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-stroke-transition.json +1 -1
  262. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-two-kick-one-pull.json +1 -1
  263. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming-vigorous.json +1 -1
  264. package/dist/web/playground/seed/core/markdown/efforts/swimming/swimming.json +1 -1
  265. package/dist/web/playground/seed/core/markdown/efforts/unconventional/clubbell-arm-cast.json +1 -1
  266. package/dist/web/playground/seed/core/markdown/efforts/unconventional/clubbell-circles.json +1 -1
  267. package/dist/web/playground/seed/core/markdown/efforts/unconventional/clubbell-mill.json +1 -1
  268. package/dist/web/playground/seed/core/markdown/efforts/unconventional/clubbell-reverse-mill.json +1 -1
  269. package/dist/web/playground/seed/core/markdown/efforts/unconventional/clubbell-shield-cast.json +1 -1
  270. package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-10-to-2-swing.json +1 -1
  271. package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-360-swing.json +1 -1
  272. package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-barbarian-squat.json +1 -1
  273. package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-flow.json +1 -1
  274. package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-gravedigger.json +1 -1
  275. package/dist/web/playground/seed/core/markdown/efforts/unconventional/macebell-touchdown.json +1 -1
  276. package/dist/web/playground/seed/core/markdown/efforts/unconventional/sandbag-bear-hug-carry.json +1 -1
  277. package/dist/web/playground/seed/core/markdown/efforts/unconventional/sandbag-bear-hug-extension.json +1 -1
  278. package/dist/web/playground/seed/core/markdown/efforts/unconventional/sandbag-over-shoulder.json +1 -1
  279. package/dist/web/playground/seed/core/markdown/efforts/walking/walking-3-mph.json +1 -1
  280. package/dist/web/playground/seed/core/markdown/equipment/air-bike.json +1 -1
  281. package/dist/web/playground/seed/core/markdown/equipment/barbell.json +1 -1
  282. package/dist/web/playground/seed/core/markdown/equipment/bench.json +1 -1
  283. package/dist/web/playground/seed/core/markdown/equipment/bike-erg.json +1 -1
  284. package/dist/web/playground/seed/core/markdown/equipment/climbing-rope.json +1 -1
  285. package/dist/web/playground/seed/core/markdown/equipment/clubs.json +1 -1
  286. package/dist/web/playground/seed/core/markdown/equipment/dumbbell.json +1 -1
  287. package/dist/web/playground/seed/core/markdown/equipment/ghd.json +1 -1
  288. package/dist/web/playground/seed/core/markdown/equipment/gymnastic-rings.json +1 -1
  289. package/dist/web/playground/seed/core/markdown/equipment/jump-rope.json +1 -1
  290. package/dist/web/playground/seed/core/markdown/equipment/kettlebell.json +1 -1
  291. package/dist/web/playground/seed/core/markdown/equipment/macebell.json +1 -1
  292. package/dist/web/playground/seed/core/markdown/equipment/medicine-ball.json +1 -1
  293. package/dist/web/playground/seed/core/markdown/equipment/parallettes.json +1 -1
  294. package/dist/web/playground/seed/core/markdown/equipment/plyo-box.json +1 -1
  295. package/dist/web/playground/seed/core/markdown/equipment/pull-up-bar.json +1 -1
  296. package/dist/web/playground/seed/core/markdown/equipment/rower.json +1 -1
  297. package/dist/web/playground/seed/core/markdown/equipment/sandbag.json +1 -1
  298. package/dist/web/playground/seed/core/markdown/equipment/ski-erg.json +1 -1
  299. package/dist/web/playground/seed/core/markdown/equipment/slam-ball.json +1 -1
  300. package/dist/web/playground/seed/core/markdown/equipment/sled.json +1 -1
  301. package/dist/web/playground/seed/core/markdown/equipment/sledgehammer.json +1 -1
  302. package/dist/web/playground/seed/core/markdown/equipment/weight-vest.json +1 -1
  303. package/dist/web/playground/seed/core/report.html +13 -13
  304. package/dist/web/server/assets/{main-Dpu5LAEU.js → main-DjqhFoGB.js} +4 -4
  305. package/dist/web/server/assets/{statementBuilderFlow-DV-yv1de.js → statementBuilderFlow-CdnAYXCq.js} +2 -2
  306. package/dist/web/server/index.html +1 -1
  307. package/dist/web/server/seed/core/chunks/{canvas.244155fb.json → canvas.45303baa.json} +1 -1
  308. package/dist/web/server/seed/core/chunks/{dashboards.0543e87b.json → dashboards.3fba44e2.json} +1 -1
  309. package/dist/web/server/seed/core/chunks/{efforts.2dcc6b6b.json → efforts.ad4805cb.json} +1 -1
  310. package/dist/web/server/seed/core/chunks/{equipment.59aa6ef7.json → equipment.01363a88.json} +1 -1
  311. package/dist/web/server/seed/core/indexes/notebooks/canvas.json +180 -180
  312. package/dist/web/server/seed/core/indexes/notebooks/dashboards.json +16 -16
  313. package/dist/web/server/seed/core/indexes/notebooks/efforts.json +326 -326
  314. package/dist/web/server/seed/core/indexes/notebooks/equipment.json +50 -50
  315. package/dist/web/server/seed/core/manifest.json +27 -27
  316. package/dist/web/server/seed/core/markdown/canvas/ai-first/README.json +1 -1
  317. package/dist/web/server/seed/core/markdown/canvas/guide/README.json +4 -4
  318. package/dist/web/server/seed/core/markdown/canvas/guide/clock.json +1 -1
  319. package/dist/web/server/seed/core/markdown/canvas/guide/dashboards.json +2 -2
  320. package/dist/web/server/seed/core/markdown/canvas/guide/metrics-summaries.json +2 -2
  321. package/dist/web/server/seed/core/markdown/canvas/guide/metrics.json +12 -12
  322. package/dist/web/server/seed/core/markdown/canvas/guide/protocols.json +20 -20
  323. package/dist/web/server/seed/core/markdown/canvas/guide/sessions.json +33 -33
  324. package/dist/web/server/seed/core/markdown/canvas/guide/start.json +11 -11
  325. package/dist/web/server/seed/core/markdown/canvas/guide/structure.json +25 -25
  326. package/dist/web/server/seed/core/markdown/canvas/guide/wql.json +5 -5
  327. package/dist/web/server/seed/core/markdown/canvas/home/sample-script.json +4 -4
  328. package/dist/web/server/seed/core/markdown/canvas/home/welcome-1.json +2 -2
  329. package/dist/web/server/seed/core/markdown/canvas/syntax/actions-comments.json +4 -4
  330. package/dist/web/server/seed/core/markdown/canvas/syntax/alternating-emom.json +5 -5
  331. package/dist/web/server/seed/core/markdown/canvas/syntax/basic-emom.json +4 -4
  332. package/dist/web/server/seed/core/markdown/canvas/syntax/calculated-metrics.json +4 -4
  333. package/dist/web/server/seed/core/markdown/canvas/syntax/classic-amrap.json +6 -6
  334. package/dist/web/server/seed/core/markdown/canvas/syntax/complex-barbell-cycling.json +4 -4
  335. package/dist/web/server/seed/core/markdown/canvas/syntax/complex-full-session.json +10 -10
  336. package/dist/web/server/seed/core/markdown/canvas/syntax/complex-nested-protocols.json +7 -7
  337. package/dist/web/server/seed/core/markdown/canvas/syntax/complex-partner-workout.json +7 -7
  338. package/dist/web/server/seed/core/markdown/canvas/syntax/complex-swimming.json +5 -5
  339. package/dist/web/server/seed/core/markdown/canvas/syntax/core-rules.json +4 -4
  340. package/dist/web/server/seed/core/markdown/canvas/syntax/custom-and-calculated-metrics.json +4 -4
  341. package/dist/web/server/seed/core/markdown/canvas/syntax/custom-intervals.json +4 -4
  342. package/dist/web/server/seed/core/markdown/canvas/syntax/custom-metrics-1.json +4 -4
  343. package/dist/web/server/seed/core/markdown/canvas/syntax/custom-metrics-2.json +5 -5
  344. package/dist/web/server/seed/core/markdown/canvas/syntax/custom-metrics-3.json +3 -3
  345. package/dist/web/server/seed/core/markdown/canvas/syntax/custom-metrics-4.json +4 -4
  346. package/dist/web/server/seed/core/markdown/canvas/syntax/custom-metrics-5.json +4 -4
  347. package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-climb-bouldering.json +2 -2
  348. package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-climb-hangboard.json +2 -2
  349. package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-climb-sport.json +2 -2
  350. package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-log.json +4 -4
  351. package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-plan.json +8 -8
  352. package/dist/web/server/seed/core/markdown/canvas/syntax/dialect-wod.json +5 -5
  353. package/dist/web/server/seed/core/markdown/canvas/syntax/distance-intervals.json +3 -3
  354. package/dist/web/server/seed/core/markdown/canvas/syntax/document-1.json +4 -4
  355. package/dist/web/server/seed/core/markdown/canvas/syntax/document-2.json +5 -5
  356. package/dist/web/server/seed/core/markdown/canvas/syntax/document-3.json +10 -10
  357. package/dist/web/server/seed/core/markdown/canvas/syntax/document-4.json +5 -5
  358. package/dist/web/server/seed/core/markdown/canvas/syntax/effort-notes.json +5 -5
  359. package/dist/web/server/seed/core/markdown/canvas/syntax/frontmatter-summaries.json +4 -4
  360. package/dist/web/server/seed/core/markdown/canvas/syntax/groups-1.json +5 -5
  361. package/dist/web/server/seed/core/markdown/canvas/syntax/groups-2.json +6 -6
  362. package/dist/web/server/seed/core/markdown/canvas/syntax/groups-3.json +3 -3
  363. package/dist/web/server/seed/core/markdown/canvas/syntax/groups-4.json +3 -3
  364. package/dist/web/server/seed/core/markdown/canvas/syntax/longer-duration.json +4 -4
  365. package/dist/web/server/seed/core/markdown/canvas/syntax/longer-intervals.json +4 -4
  366. package/dist/web/server/seed/core/markdown/canvas/syntax/measurements.json +7 -7
  367. package/dist/web/server/seed/core/markdown/canvas/syntax/metrics-1.json +5 -5
  368. package/dist/web/server/seed/core/markdown/canvas/syntax/metrics-2.json +7 -7
  369. package/dist/web/server/seed/core/markdown/canvas/syntax/metrics-3.json +8 -8
  370. package/dist/web/server/seed/core/markdown/canvas/syntax/metrics-4.json +6 -6
  371. package/dist/web/server/seed/core/markdown/canvas/syntax/metrics-5.json +5 -5
  372. package/dist/web/server/seed/core/markdown/canvas/syntax/mixed-sections.json +10 -10
  373. package/dist/web/server/seed/core/markdown/canvas/syntax/mixed-timers.json +5 -5
  374. package/dist/web/server/seed/core/markdown/canvas/syntax/multiple-amrap-windows.json +7 -7
  375. package/dist/web/server/seed/core/markdown/canvas/syntax/multiple-sets.json +4 -4
  376. package/dist/web/server/seed/core/markdown/canvas/syntax/named-groups.json +6 -6
  377. package/dist/web/server/seed/core/markdown/canvas/syntax/protocols-1.json +6 -6
  378. package/dist/web/server/seed/core/markdown/canvas/syntax/protocols-2.json +4 -4
  379. package/dist/web/server/seed/core/markdown/canvas/syntax/protocols-3.json +6 -6
  380. package/dist/web/server/seed/core/markdown/canvas/syntax/protocols-4.json +3 -3
  381. package/dist/web/server/seed/core/markdown/canvas/syntax/protocols-5.json +4 -4
  382. package/dist/web/server/seed/core/markdown/canvas/syntax/single-movement.json +3 -3
  383. package/dist/web/server/seed/core/markdown/canvas/syntax/supplemental-1.json +4 -4
  384. package/dist/web/server/seed/core/markdown/canvas/syntax/supplemental-2.json +5 -5
  385. package/dist/web/server/seed/core/markdown/canvas/syntax/supplemental-3.json +4 -4
  386. package/dist/web/server/seed/core/markdown/canvas/syntax/supplemental-4.json +4 -4
  387. package/dist/web/server/seed/core/markdown/canvas/syntax/time-cap.json +6 -6
  388. package/dist/web/server/seed/core/markdown/canvas/syntax/timer-modifiers.json +6 -6
  389. package/dist/web/server/seed/core/markdown/canvas/syntax/timers-1.json +6 -6
  390. package/dist/web/server/seed/core/markdown/canvas/syntax/timers-2.json +4 -4
  391. package/dist/web/server/seed/core/markdown/canvas/syntax/timers-3.json +4 -4
  392. package/dist/web/server/seed/core/markdown/canvas/syntax/timers-4.json +4 -4
  393. package/dist/web/server/seed/core/markdown/canvas/syntax/timers-5.json +5 -5
  394. package/dist/web/server/seed/core/markdown/canvas/syntax/timers-rest.json +4 -4
  395. package/dist/web/server/seed/core/markdown/canvas/wql-presets/aggregate-by-effort.json +2 -2
  396. package/dist/web/server/seed/core/markdown/canvas/wql-presets/aggregate-by-week.json +2 -2
  397. package/dist/web/server/seed/core/markdown/canvas/wql-presets/content-fran.json +2 -2
  398. package/dist/web/server/seed/core/markdown/canvas/wql-presets/filter-combos.json +2 -2
  399. package/dist/web/server/seed/core/markdown/canvas/wql-presets/pipes-limit.json +2 -2
  400. package/dist/web/server/seed/core/markdown/canvas/wql-presets/session-rpe.json +2 -2
  401. package/dist/web/server/seed/core/markdown/canvas/wql-presets/source-journal.json +2 -2
  402. package/dist/web/server/seed/core/markdown/canvas/wql-presets/tis-trend.json +2 -2
  403. package/dist/web/server/seed/core/markdown/canvas/wql-presets/where-join.json +2 -2
  404. package/dist/web/server/seed/core/markdown/dashboards/benchmark-pr-board.json +6 -6
  405. package/dist/web/server/seed/core/markdown/dashboards/finger-strength-v8.json +5 -5
  406. package/dist/web/server/seed/core/markdown/dashboards/polarized-base-marathon.json +9 -9
  407. package/dist/web/server/seed/core/markdown/dashboards/recovery-readiness.json +7 -7
  408. package/dist/web/server/seed/core/markdown/dashboards/road-to-560-total.json +9 -9
  409. package/dist/web/server/seed/core/markdown/dashboards/training-block-review.json +11 -11
  410. package/dist/web/server/seed/core/markdown/efforts/bodyweight/air-squat.json +1 -1
  411. package/dist/web/server/seed/core/markdown/efforts/bodyweight/box-jump.json +1 -1
  412. package/dist/web/server/seed/core/markdown/efforts/bodyweight/broad-jump.json +1 -1
  413. package/dist/web/server/seed/core/markdown/efforts/bodyweight/burpee-box-jump-over.json +1 -1
  414. package/dist/web/server/seed/core/markdown/efforts/bodyweight/burpee-over-dumbbell.json +1 -1
  415. package/dist/web/server/seed/core/markdown/efforts/bodyweight/burpee.json +1 -1
  416. package/dist/web/server/seed/core/markdown/efforts/bodyweight/dumbbell-squat-clean.json +1 -1
  417. package/dist/web/server/seed/core/markdown/efforts/bodyweight/ghd-sit-up.json +1 -1
  418. package/dist/web/server/seed/core/markdown/efforts/bodyweight/ground-kong.json +1 -1
  419. package/dist/web/server/seed/core/markdown/efforts/bodyweight/jumping-jack.json +1 -1
  420. package/dist/web/server/seed/core/markdown/efforts/bodyweight/kong-walk.json +1 -1
  421. package/dist/web/server/seed/core/markdown/efforts/bodyweight/lunge.json +1 -1
  422. package/dist/web/server/seed/core/markdown/efforts/bodyweight/overhead-squat.json +1 -1
  423. package/dist/web/server/seed/core/markdown/efforts/bodyweight/parkour-roll.json +1 -1
  424. package/dist/web/server/seed/core/markdown/efforts/bodyweight/parkour-squat.json +1 -1
  425. package/dist/web/server/seed/core/markdown/efforts/bodyweight/pistol-squat.json +1 -1
  426. package/dist/web/server/seed/core/markdown/efforts/bodyweight/plank.json +1 -1
  427. package/dist/web/server/seed/core/markdown/efforts/bodyweight/precision-burpee.json +1 -1
  428. package/dist/web/server/seed/core/markdown/efforts/bodyweight/precision-jump.json +1 -1
  429. package/dist/web/server/seed/core/markdown/efforts/bodyweight/quadrupedal-movement.json +1 -1
  430. package/dist/web/server/seed/core/markdown/efforts/bodyweight/russian-twist.json +1 -1
  431. package/dist/web/server/seed/core/markdown/efforts/bodyweight/sit-up.json +1 -1
  432. package/dist/web/server/seed/core/markdown/efforts/bodyweight/squat-clean.json +1 -1
  433. package/dist/web/server/seed/core/markdown/efforts/bodyweight/squat-hold.json +1 -1
  434. package/dist/web/server/seed/core/markdown/efforts/bodyweight/squat-snatch.json +1 -1
  435. package/dist/web/server/seed/core/markdown/efforts/bodyweight/tuck-jump.json +1 -1
  436. package/dist/web/server/seed/core/markdown/efforts/bodyweight/wall-ball.json +1 -1
  437. package/dist/web/server/seed/core/markdown/efforts/bodyweight/wall-burpee.json +1 -1
  438. package/dist/web/server/seed/core/markdown/efforts/cycling/assault-bike.json +1 -1
  439. package/dist/web/server/seed/core/markdown/efforts/cycling/cycling-moderate.json +1 -1
  440. package/dist/web/server/seed/core/markdown/efforts/cycling/cycling-vigorous.json +1 -1
  441. package/dist/web/server/seed/core/markdown/efforts/gymnastics/assisted-pull-up.json +1 -1
  442. package/dist/web/server/seed/core/markdown/efforts/gymnastics/burpee-pull-up.json +1 -1
  443. package/dist/web/server/seed/core/markdown/efforts/gymnastics/chest-to-bar-pull-up.json +1 -1
  444. package/dist/web/server/seed/core/markdown/efforts/gymnastics/dip.json +1 -1
  445. package/dist/web/server/seed/core/markdown/efforts/gymnastics/double-under.json +1 -1
  446. package/dist/web/server/seed/core/markdown/efforts/gymnastics/handstand-hold.json +1 -1
  447. package/dist/web/server/seed/core/markdown/efforts/gymnastics/handstand-push-up.json +1 -1
  448. package/dist/web/server/seed/core/markdown/efforts/gymnastics/handstand-walk.json +1 -1
  449. package/dist/web/server/seed/core/markdown/efforts/gymnastics/jump-rope.json +1 -1
  450. package/dist/web/server/seed/core/markdown/efforts/gymnastics/jumping-pull-up.json +1 -1
  451. package/dist/web/server/seed/core/markdown/efforts/gymnastics/jumping-push-up.json +1 -1
  452. package/dist/web/server/seed/core/markdown/efforts/gymnastics/l-sit-pull-up.json +1 -1
  453. package/dist/web/server/seed/core/markdown/efforts/gymnastics/muscle-up.json +1 -1
  454. package/dist/web/server/seed/core/markdown/efforts/gymnastics/pull-up.json +1 -1
  455. package/dist/web/server/seed/core/markdown/efforts/gymnastics/push-up.json +1 -1
  456. package/dist/web/server/seed/core/markdown/efforts/gymnastics/reverse-wall-dip.json +1 -1
  457. package/dist/web/server/seed/core/markdown/efforts/gymnastics/rope-climb.json +1 -1
  458. package/dist/web/server/seed/core/markdown/efforts/gymnastics/toes-to-bar.json +1 -1
  459. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-arm-bar.json +1 -1
  460. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-around-the-world.json +1 -1
  461. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-bent-over-row.json +1 -1
  462. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-clean-and-jerk.json +1 -1
  463. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-clean-and-press.json +1 -1
  464. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-clean.json +1 -1
  465. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-deadlift.json +1 -1
  466. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-floor-press.json +1 -1
  467. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-front-squat.json +1 -1
  468. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-goblet-squat.json +1 -1
  469. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-gorilla-row.json +1 -1
  470. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-halo.json +1 -1
  471. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-jerk.json +1 -1
  472. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-overhead-squat.json +1 -1
  473. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-press.json +1 -1
  474. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-snatch.json +1 -1
  475. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-swing.json +1 -1
  476. package/dist/web/server/seed/core/markdown/efforts/kettlebell/kettlebell-windmill.json +1 -1
  477. package/dist/web/server/seed/core/markdown/efforts/kettlebell/turkish-get-up.json +1 -1
  478. package/dist/web/server/seed/core/markdown/efforts/recovery/rest.json +1 -1
  479. package/dist/web/server/seed/core/markdown/efforts/recovery/stretching.json +1 -1
  480. package/dist/web/server/seed/core/markdown/efforts/rowing/rowing-sprint.json +1 -1
  481. package/dist/web/server/seed/core/markdown/efforts/rowing/rowing.json +1 -1
  482. package/dist/web/server/seed/core/markdown/efforts/rowing/ski-erg.json +1 -1
  483. package/dist/web/server/seed/core/markdown/efforts/running/backward-running.json +1 -1
  484. package/dist/web/server/seed/core/markdown/efforts/running/running-6-mph.json +1 -1
  485. package/dist/web/server/seed/core/markdown/efforts/running/running-8-mph.json +1 -1
  486. package/dist/web/server/seed/core/markdown/efforts/running/running-sprint.json +1 -1
  487. package/dist/web/server/seed/core/markdown/efforts/snatch.json +2 -2
  488. package/dist/web/server/seed/core/markdown/efforts/strength/back-squat.json +1 -1
  489. package/dist/web/server/seed/core/markdown/efforts/strength/bench-press.json +1 -1
  490. package/dist/web/server/seed/core/markdown/efforts/strength/box-step-up.json +1 -1
  491. package/dist/web/server/seed/core/markdown/efforts/strength/carioca.json +1 -1
  492. package/dist/web/server/seed/core/markdown/efforts/strength/clean-and-jerk.json +1 -1
  493. package/dist/web/server/seed/core/markdown/efforts/strength/cluster.json +1 -1
  494. package/dist/web/server/seed/core/markdown/efforts/strength/dead-hang.json +1 -1
  495. package/dist/web/server/seed/core/markdown/efforts/strength/deadlift.json +1 -1
  496. package/dist/web/server/seed/core/markdown/efforts/strength/devils-press.json +1 -1
  497. package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-box-step-up.json +1 -1
  498. package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-clean.json +1 -1
  499. package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-fly.json +1 -1
  500. package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-row.json +1 -1
  501. package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-snatch.json +1 -1
  502. package/dist/web/server/seed/core/markdown/efforts/strength/dumbbell-thruster.json +1 -1
  503. package/dist/web/server/seed/core/markdown/efforts/strength/elbows-to-knees.json +1 -1
  504. package/dist/web/server/seed/core/markdown/efforts/strength/farmer-carry.json +1 -1
  505. package/dist/web/server/seed/core/markdown/efforts/strength/frog-stand.json +1 -1
  506. package/dist/web/server/seed/core/markdown/efforts/strength/front-squat.json +1 -1
  507. package/dist/web/server/seed/core/markdown/efforts/strength/good-morning.json +1 -1
  508. package/dist/web/server/seed/core/markdown/efforts/strength/hanging-leg-raise.json +1 -1
  509. package/dist/web/server/seed/core/markdown/efforts/strength/hollow-rock.json +1 -1
  510. package/dist/web/server/seed/core/markdown/efforts/strength/knees-to-elbows.json +1 -1
  511. package/dist/web/server/seed/core/markdown/efforts/strength/l-sit.json +1 -1
  512. package/dist/web/server/seed/core/markdown/efforts/strength/man-maker.json +1 -1
  513. package/dist/web/server/seed/core/markdown/efforts/strength/medicine-ball-clean.json +1 -1
  514. package/dist/web/server/seed/core/markdown/efforts/strength/overhead-press.json +1 -1
  515. package/dist/web/server/seed/core/markdown/efforts/strength/parkour-vault.json +1 -1
  516. package/dist/web/server/seed/core/markdown/efforts/strength/pig-flip.json +1 -1
  517. package/dist/web/server/seed/core/markdown/efforts/strength/power-clean.json +1 -1
  518. package/dist/web/server/seed/core/markdown/efforts/strength/power-snatch.json +1 -1
  519. package/dist/web/server/seed/core/markdown/efforts/strength/push-jerk.json +1 -1
  520. package/dist/web/server/seed/core/markdown/efforts/strength/push-press.json +1 -1
  521. package/dist/web/server/seed/core/markdown/efforts/strength/romanian-deadlift.json +1 -1
  522. package/dist/web/server/seed/core/markdown/efforts/strength/single-leg-deadlift.json +1 -1
  523. package/dist/web/server/seed/core/markdown/efforts/strength/skull-crusher.json +1 -1
  524. package/dist/web/server/seed/core/markdown/efforts/strength/slam-ball.json +1 -1
  525. package/dist/web/server/seed/core/markdown/efforts/strength/sled-pull.json +1 -1
  526. package/dist/web/server/seed/core/markdown/efforts/strength/sled-push.json +1 -1
  527. package/dist/web/server/seed/core/markdown/efforts/strength/sumo-deadlift.json +1 -1
  528. package/dist/web/server/seed/core/markdown/efforts/strength/thruster.json +1 -1
  529. package/dist/web/server/seed/core/markdown/efforts/strength/triceps-extension.json +1 -1
  530. package/dist/web/server/seed/core/markdown/efforts/strength/v-sit-hold.json +1 -1
  531. package/dist/web/server/seed/core/markdown/efforts/strength/wall-walk.json +1 -1
  532. package/dist/web/server/seed/core/markdown/efforts/strength/yoga-sun-salutation.json +1 -1
  533. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-assisted-sprint.json +1 -1
  534. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-backstroke.json +1 -1
  535. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-breaststroke-kick.json +1 -1
  536. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-breaststroke.json +1 -1
  537. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-butterfly.json +1 -1
  538. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-catch-up-drill.json +1 -1
  539. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-choice-stroke.json +1 -1
  540. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-dive-start.json +1 -1
  541. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-dolphin-kick.json +1 -1
  542. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-drafting.json +1 -1
  543. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-fingertip-drag.json +1 -1
  544. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-freestyle.json +1 -1
  545. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-individual-medley.json +1 -1
  546. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-kick.json +1 -1
  547. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-pull.json +1 -1
  548. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-resisted-sprint.json +1 -1
  549. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-rotation-drill.json +1 -1
  550. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-sighting.json +1 -1
  551. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-single-arm-drill.json +1 -1
  552. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-stroke-transition.json +1 -1
  553. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-two-kick-one-pull.json +1 -1
  554. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming-vigorous.json +1 -1
  555. package/dist/web/server/seed/core/markdown/efforts/swimming/swimming.json +1 -1
  556. package/dist/web/server/seed/core/markdown/efforts/unconventional/clubbell-arm-cast.json +1 -1
  557. package/dist/web/server/seed/core/markdown/efforts/unconventional/clubbell-circles.json +1 -1
  558. package/dist/web/server/seed/core/markdown/efforts/unconventional/clubbell-mill.json +1 -1
  559. package/dist/web/server/seed/core/markdown/efforts/unconventional/clubbell-reverse-mill.json +1 -1
  560. package/dist/web/server/seed/core/markdown/efforts/unconventional/clubbell-shield-cast.json +1 -1
  561. package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-10-to-2-swing.json +1 -1
  562. package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-360-swing.json +1 -1
  563. package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-barbarian-squat.json +1 -1
  564. package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-flow.json +1 -1
  565. package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-gravedigger.json +1 -1
  566. package/dist/web/server/seed/core/markdown/efforts/unconventional/macebell-touchdown.json +1 -1
  567. package/dist/web/server/seed/core/markdown/efforts/unconventional/sandbag-bear-hug-carry.json +1 -1
  568. package/dist/web/server/seed/core/markdown/efforts/unconventional/sandbag-bear-hug-extension.json +1 -1
  569. package/dist/web/server/seed/core/markdown/efforts/unconventional/sandbag-over-shoulder.json +1 -1
  570. package/dist/web/server/seed/core/markdown/efforts/walking/walking-3-mph.json +1 -1
  571. package/dist/web/server/seed/core/markdown/equipment/air-bike.json +1 -1
  572. package/dist/web/server/seed/core/markdown/equipment/barbell.json +1 -1
  573. package/dist/web/server/seed/core/markdown/equipment/bench.json +1 -1
  574. package/dist/web/server/seed/core/markdown/equipment/bike-erg.json +1 -1
  575. package/dist/web/server/seed/core/markdown/equipment/climbing-rope.json +1 -1
  576. package/dist/web/server/seed/core/markdown/equipment/clubs.json +1 -1
  577. package/dist/web/server/seed/core/markdown/equipment/dumbbell.json +1 -1
  578. package/dist/web/server/seed/core/markdown/equipment/ghd.json +1 -1
  579. package/dist/web/server/seed/core/markdown/equipment/gymnastic-rings.json +1 -1
  580. package/dist/web/server/seed/core/markdown/equipment/jump-rope.json +1 -1
  581. package/dist/web/server/seed/core/markdown/equipment/kettlebell.json +1 -1
  582. package/dist/web/server/seed/core/markdown/equipment/macebell.json +1 -1
  583. package/dist/web/server/seed/core/markdown/equipment/medicine-ball.json +1 -1
  584. package/dist/web/server/seed/core/markdown/equipment/parallettes.json +1 -1
  585. package/dist/web/server/seed/core/markdown/equipment/plyo-box.json +1 -1
  586. package/dist/web/server/seed/core/markdown/equipment/pull-up-bar.json +1 -1
  587. package/dist/web/server/seed/core/markdown/equipment/rower.json +1 -1
  588. package/dist/web/server/seed/core/markdown/equipment/sandbag.json +1 -1
  589. package/dist/web/server/seed/core/markdown/equipment/ski-erg.json +1 -1
  590. package/dist/web/server/seed/core/markdown/equipment/slam-ball.json +1 -1
  591. package/dist/web/server/seed/core/markdown/equipment/sled.json +1 -1
  592. package/dist/web/server/seed/core/markdown/equipment/sledgehammer.json +1 -1
  593. package/dist/web/server/seed/core/markdown/equipment/weight-vest.json +1 -1
  594. package/dist/web/server/seed/core/report.html +13 -13
  595. package/package.json +6 -6
  596. package/dist/chunk-4TW3XOPT.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-BiwvmytJ.js","assets/rolldown-runtime-C0FnF6B9.js","assets/vendor-CelWxf33.css","assets/statementBuilderFlow-DV-yv1de.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-BiwvmytJ.js","assets/rolldown-runtime-C0FnF6B9.js","assets/vendor-CelWxf33.css","assets/statementBuilderFlow-CdnAYXCq.js"])))=>i.map(i=>d[i]);
2
2
  import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{$ as n,$n as r,$r as i,$t as a,A as o,An as s,Ar as c,B as l,Bn as u,Br as d,Bt as f,C as p,Cn as m,Cr as h,Ct as g,D as _,Dn as v,Dr as y,Dt as b,E as x,En as S,Er as C,Et as w,F as T,Fn as E,Fr as D,G as O,Gn as k,Gr as A,Gt as j,H as M,Hn as N,Hr as P,Ht as F,I,In as L,Ir as R,J as z,Jn as ee,Jr as te,Jt as ne,K as re,Kn as B,Kr as ie,Kt as ae,L as oe,Ln as se,Lr as ce,M as V,Mn as le,Mr as ue,Mt as de,N as fe,Nn as pe,O as me,On as H,Or as he,P as ge,Pn as _e,Pr as ve,Q as ye,Qn as be,Qr as xe,Qt as Se,R as Ce,Rn as we,Rr as Te,S as Ee,Sn as De,Sr as Oe,St as ke,T as Ae,Tn as je,Tr as Me,Tt as Ne,U as Pe,Un as Fe,Ur as Ie,Ut as Le,V as Re,Vn as ze,Vr as Be,Vt as Ve,W as He,Wn as Ue,Wr as We,Wt as Ge,X as Ke,Xn as qe,Xr as Je,Xt as Ye,Y as Xe,Yn as Ze,Yr as Qe,Yt as $e,Z as et,Zn as tt,Zr as nt,Zt as rt,_ as it,_i as at,_n as ot,_r as st,_t as ct,a as lt,ai as ut,an as dt,ar as ft,at as pt,b as mt,bi as ht,bn as gt,br as _t,bt as vt,c as yt,ci as bt,cn as xt,cr as St,ct as Ct,d as wt,di as Tt,dn as Et,dr as Dt,dt as Ot,ei as kt,en as At,er as jt,et as Mt,f as Nt,fi as Pt,fn as Ft,fr as It,ft as Lt,g as eee,gi as Rt,gn as zt,gr as Bt,gt as Vt,h as Ht,hi as Ut,hn as Wt,hr as Gt,ht as Kt,i as qt,ii as Jt,in as Yt,it as Xt,j as Zt,jn as Qt,jr as $t,jt as en,k as tn,kn as tee,kr as nn,kt as rn,l as an,li as on,ln as sn,lr as cn,lt as ln,m as un,mi as dn,mn as fn,mr as pn,mt as mn,n as hn,ni as gn,nn as _n,nr as vn,nt as yn,o as bn,oi as xn,on as Sn,or as Cn,ot as wn,p as Tn,pi as En,pn as Dn,pr as On,pt as kn,q as An,qn as jn,qr as Mn,qt as Nn,r as Pn,ri as Fn,rn as In,rr as Ln,rt as Rn,s as nee,si as ree,sn as zn,sr as Bn,st as Vn,t as Hn,ti as Un,tn as Wn,tr as Gn,tt as Kn,u as qn,ui as Jn,un as Yn,ur as Xn,ut as Zn,v as Qn,vi as $n,vn as er,vr as tr,vt as nr,w as rr,wn as ir,wr as ar,wt as or,x as sr,xn as cr,xr as lr,xt as ur,y as dr,yi as fr,yn as pr,yr as mr,yt as hr,z as gr,zn as _r,zr as vr,zt as yr}from"./vendor-BiwvmytJ.js";import{$ as br,A as xr,B as U,C as Sr,D as Cr,E as wr,F as Tr,G as Er,H as Dr,I as Or,J as kr,K as Ar,L as jr,M as Mr,N as Nr,O as Pr,P as Fr,Q as iee,R as Ir,S as aee,T as Lr,U as oee,V as Rr,W as zr,X as Br,Y as Vr,Z as Hr,_ as Ur,a as Wr,at as Gr,b as Kr,c as qr,ct as Jr,d as Yr,et as Xr,f as Zr,g as see,h as Qr,i as $r,it as ei,j as ti,k as ni,l as ri,lt as ii,m as ai,n as oi,nt as si,o as ci,ot as li,p as ui,q as di,r as fi,rt as pi,s as mi,st as hi,t as gi,tt as _i,u as vi,ut as yi,v as bi,w as xi,x as Si,y as Ci,z as wi}from"./vendor-codemirror-B461LMkB.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Ti=$n(),W=e(ht(),1),G=xn(),Ei=(0,W.createContext)({theme:`system`,setTheme:()=>null});function Di({children:e,defaultTheme:t=`system`,storageKey:n=`vite-ui-theme`}){let[r,i]=(0,W.useState)(()=>localStorage.getItem(n)||t);(0,W.useEffect)(()=>{let e=window.document.documentElement,t=()=>{if(e.classList.remove(`light`,`dark`),r===`system`){let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`;e.classList.add(t);return}e.classList.add(r)};if(t(),r===`system`){let e=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>t();return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)}},[r]);let a=(0,W.useCallback)(e=>{localStorage.setItem(n,e),i(e)},[n]),o=(0,W.useMemo)(()=>({theme:r,setTheme:a}),[r,a]);return(0,G.jsx)(Ei.Provider,{value:o,children:e})}var Oi=()=>{let e=(0,W.useContext)(Ei);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e};function K(...e){return D(ut(e))}function ki(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t)}var Ai=R(`inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,outline:`border border-input bg-background hover:bg-accent hover:text-accent-foreground`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-10 px-4 py-2`,sm:`h-9 rounded-md px-3`,lg:`h-11 rounded-md px-8`,icon:`h-11 w-11 min-h-11 min-w-11`}},defaultVariants:{variant:`default`,size:`default`}}),q=W.memo(W.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},a)=>{let o=r?ce:`button`;return(0,G.jsx)(Jt,{as:o,className:K(Ai({variant:t,size:n,className:e})),ref:a,...i})}));q.displayName=`Button`;var ji=[`parser`,`dialect`,`user-plan`,`runtime`,`user-entry`],Mi={parser:`parser`,compiler:`dialect`,dialect:`dialect`,hinted:`dialect`,"user-plan":`user-plan`,runtime:`runtime`,tracked:`runtime`,analyzed:`runtime`,"analyzed-estimated":`runtime`,execution:`runtime`,user:`user-entry`,collected:`user-entry`,diagnostic:`runtime`};function Ni(e){return Mi[e??`parser`]??`parser`}var J=function(e){return e.Duration=`duration`,e.Spans=`spans`,e.SystemTime=`system-time`,e.Time=`time`,e.Elapsed=`elapsed`,e.Total=`total`,e.Rep=`rep`,e.Effort=`effort`,e.Equipment=`equipment`,e.Distance=`distance`,e.Rounds=`rounds`,e.CurrentRound=`current-round`,e.Action=`action`,e.Increment=`increment`,e.Group=`group`,e.Text=`text`,e.Resistance=`resistance`,e.Sound=`sound`,e.System=`system`,e.Label=`label`,e.Lap=`lap`,e.Metric=`metric`,e.Hint=`hint`,e.Custom=`custom`,e.Volume=`volume`,e.Intensity=`intensity`,e.Grade=`grade`,e.Load=`load`,e.Work=`work`,e.RIR=`rir`,e.SessionRPE=`session-rpe`,e.SessionLoad=`session-load`,e.METScore=`met-score`,e.TIS=`tis`,e.Calculated=`calculated`,e.Diagnostic=`diagnostic`,e.Choice=`choice`,e}({}),Pi={parser:0,dialect:1,"user-plan":2,runtime:3,"user-entry":4};function Fi(e){return e.ownershipLayer??Ni(e.origin)}function Ii(e){return Pi[Fi(e)]??0}function Li(e){return e.map((e,t)=>{let n=Fi(e);return{metric:e,type:e.type,layer:n,layerRank:Pi[n]??0,index:t,isSuppressor:e.action===`suppress`}})}function Ri(e,t){return t?e.filter(e=>!(t.types&&!t.types.includes(e.type)||t.layers&&!t.layers.includes(e.layer))):[...e]}function zi(e){let t=new Map;for(let n of e){let e=t.get(n.type);if(e){e.push(n);continue}t.set(n.type,[n])}return t}function Bi(e){let t;for(let n of e)n.isSuppressor||(t==null||n.layerRank>t)&&(t=n.layerRank);return t}function Vi(e,t){return{metric:e.metric,type:e.type,layer:e.layer,outcome:t}}function Hi(e,t){return e.index-t.index}function Ui(e){let t=Li(e);return{raw(e){return Ri(t,e).map(e=>e.metric)},visible(e){let n=zi(Ri(t,e)),r=[];for(let e of n.values()){if(e.some(e=>e.isSuppressor))continue;let t=Bi(e);if(t!=null)for(let n of e)!n.isSuppressor&&n.layerRank===t&&r.push(n)}return r.sort(Hi),r.map(e=>e.metric)},byLayer(e){let n=Ri(t,e),r={};for(let e of ji)r[e]=[];for(let e of n)r[e.layer].push(e.metric);for(let e of ji)r[e]?.length===0&&delete r[e];return r},promotionCandidates(e){let n=zi(Ri(t,e)),r=[];for(let e of n.values()){let t=e.filter(e=>e.isSuppressor),n=e.filter(e=>!e.isSuppressor);if(n.length===0)continue;if(t.length>0){let e=Math.max(...n.map(e=>e.layerRank)),i=Math.max(...t.map(e=>e.layerRank));for(let t of n)t.layerRank===e&&r.push({metric:t.metric,type:t.type,layer:t.layer,reason:`suppressed`,blockedByLayer:ji[i]});continue}let i=Bi(n);if(i==null)continue;let a=n.filter(e=>e.layerRank<i);if(a.length===0)continue;let o=Math.max(...a.map(e=>e.layerRank));for(let e of a)e.layerRank===o&&r.push({metric:e.metric,type:e.type,layer:e.layer,reason:`shadowed-by-higher-layer`,blockedByLayer:ji[i]})}return r.sort((e,t)=>{let n=(Pi[t.layer]??0)-(Pi[e.layer]??0);return n===0?0:n}),r},explain(e){let n=zi(Ri(t,e)),r=[];for(let[e,t]of n.entries()){let n=t.some(e=>e.isSuppressor),i=n?void 0:Bi(t),a=t.map(e=>e.isSuppressor?Vi(e,`suppressor`):n?Vi(e,`hidden-by-suppressor`):i!=null&&e.layerRank===i?Vi(e,`visible`):Vi(e,`hidden-by-layer`));r.push({type:e,winnerLayer:i==null?void 0:ji[i],suppressed:n,entries:a})}return r}}}function Wi(e,t){let n=[...e];return(t?.types?.includes(J.Hint)??!1)||(n=n.filter(e=>e.type!==J.Hint)),t?(t.origins&&(n=n.filter(e=>t.origins.includes(e.origin??`parser`))),t.types&&(n=n.filter(e=>t.types.includes(e.type))),t.excludeTypes&&(n=n.filter(e=>!t.excludeTypes.includes(e.type))),n):n}var Gi=class{resolve(e,t){return Ui(Wi(e,t)).visible()}resolveOne(e,t){return this.resolve(e,{types:[t]})[0]}resolveAll(e,t){let n=e.filter(e=>e.type===t);return n.length<=1?n:[...n].sort((e,t)=>Ii(t)-Ii(e))}};function Ki(e){let t=e.split(/[\s_\-\u2010-\u2015]+/).filter(Boolean),n=[];for(let e of t){let t=e.replace(/([\p{Ll}\p{Nd}])(\p{Lu})/gu,`$1\0$2`).replace(/(\p{Lu})(\p{Lu}\p{Ll})/gu,`$1\0$2`);for(let e of t.split(`\0`))e&&n.push(e)}return n}function qi(e){let t=Ki(e);return t.length===0?``:t.map((e,t)=>{let n=e.toLowerCase();return t===0?n:n.charAt(0).toUpperCase()+n.slice(1)}).join(``)}function Ji(e){return e.split(`.`).map(qi).filter(e=>e.length>0).join(`.`)}function Yi(e){if(e===null)return`null`;if(e===void 0)return`undefined`;if(Array.isArray(e))return`array`;switch(typeof e){case`number`:return`number`;case`string`:return`string`;case`boolean`:return`boolean`;case`object`:return`object`;default:return`undefined`}}function Xi(e){return JSON.stringify([e.path,e.kind,e.dimension??null])}var Zi=class extends Error{code;constructor(e,t){super(t),this.name=`UnitConversionError`,this.code=e}},Qi=[{canonical:`m`,dimension:`distance`,factor:1,aliases:[`meter`,`meters`,`metre`,`metres`]},{canonical:`km`,dimension:`distance`,factor:1e3,aliases:[`kilometer`,`kilometers`,`kilometre`,`kilometres`]},{canonical:`cm`,dimension:`distance`,factor:.01,aliases:[`centimeter`,`centimeters`]},{canonical:`mm`,dimension:`distance`,factor:.001,aliases:[`millimeter`,`millimeters`]},{canonical:`ft`,dimension:`distance`,factor:.3048,aliases:[`foot`,`feet`]},{canonical:`in`,dimension:`distance`,factor:.0254,aliases:[`inch`,`inches`]},{canonical:`yd`,dimension:`distance`,factor:.9144,aliases:[`yard`,`yards`]},{canonical:`mi`,dimension:`distance`,factor:1609.344,aliases:[`mile`,`miles`]},{canonical:`kg`,dimension:`mass`,factor:1,aliases:[`kilogram`,`kilograms`,`kilo`,`kilos`]},{canonical:`g`,dimension:`mass`,factor:.001,aliases:[`gram`,`grams`]},{canonical:`lb`,dimension:`mass`,factor:.45359237,aliases:[`lbs`,`pound`,`pounds`]},{canonical:`ms`,dimension:`duration`,factor:.001,aliases:[`millisecond`,`milliseconds`]},{canonical:`s`,dimension:`duration`,factor:1,aliases:[`sec`,`secs`,`second`,`seconds`]},{canonical:`min`,dimension:`duration`,factor:60,aliases:[`mins`,`minute`,`minutes`]},{canonical:`h`,dimension:`duration`,factor:3600,aliases:[`hr`,`hrs`,`hour`,`hours`]},{canonical:`count`,dimension:`count`,factor:1},{canonical:`rep`,dimension:`count`,factor:1,aliases:[`reps`]},{canonical:`pull-up`,dimension:`count`,factor:1},{canonical:`thruster`,dimension:`count`,factor:1},{canonical:`problem`,dimension:`count`,factor:1},{canonical:`count/s`,dimension:`count-rate`,factor:1},{canonical:`bpm`,dimension:`count-rate`,factor:1/60},{canonical:`cal`,dimension:`energy`,factor:1,aliases:[`calorie`,`calories`]},{canonical:`kcal`,dimension:`energy`,factor:1e3,aliases:[`kilocalorie`,`kilocalories`]},{canonical:`m/s`,dimension:`speed`,factor:1},{canonical:`km/h`,dimension:`speed`,factor:1e3/3600,aliases:[`kmh`,`kph`]},{canonical:`mph`,dimension:`speed`,factor:1609.344/3600},{canonical:`min/km`,dimension:`pace`,factor:1},{canonical:`min/mi`,dimension:`pace`,factor:1e3/1609.344},{canonical:`s/m`,dimension:`pace`,factor:1/60},{canonical:`ratio`,dimension:`ratio`,factor:1,aliases:[`x`]},{canonical:`%`,dimension:`ratio`,factor:.01,aliases:[`pct`,`percent`]},{canonical:`au`,dimension:`ratio`,factor:1,aliases:[`AU`]},{canonical:`pts`,dimension:`ratio`,factor:1,aliases:[`point`,`points`]},{canonical:`rating`,dimension:`ratio`,factor:1,aliases:[`ratings`]}],$i=(()=>{let e=new Map;for(let t of Qi){e.set(t.canonical.toLowerCase(),t);for(let n of t.aliases??[])e.has(n.toLowerCase())||e.set(n.toLowerCase(),t)}return e})();function ea(e){if(typeof e==`string`)return $i.get(e.trim().toLowerCase())}function ta(e){return ea(e)?.dimension}var na=Object.freeze({mass:`kg`,distance:`m`,duration:`s`,count:`count`,"count-rate":`count/s`,energy:`cal`,speed:`m/s`,pace:`min/km`,ratio:void 0});function ra(e){return na[e]}function ia(e,t,n){let r=ea(t);if(!r)throw new Zi(`unknown-unit`,`Unknown unit "${t}"`);let i=ea(n);if(!i)throw new Zi(`unknown-unit`,`Unknown unit "${n}"`);if(r.dimension!==i.dimension)throw new Zi(`dimension-mismatch`,`Cannot convert ${t} (${r.dimension}) to ${n} (${i.dimension})`);if(r.dimension===`ratio`&&r.canonical!==i.canonical&&r.canonical!==`ratio`&&i.canonical!==`ratio`)throw new Zi(`scale-mismatch`,`Named scales ${t} and ${n} are not interchangeable`);if(!Number.isFinite(e))throw new Zi(`non-finite`,`Non-finite value cannot be converted`);return e*r.factor/i.factor}var aa=`references`,cee=[`explicit`,`split`,`whole`,`default`,`none`];function lee(e){if(!e||typeof e!=`object`)return!1;let t=e;return(t.kind===`effort`||t.kind===`equipment`)&&typeof t.slug==`string`&&!!t.slug&&typeof t.label==`string`}function uee(e){return!e||typeof e!=`object`?!1:typeof e.reason==`string`}function oa(e){let t=e?.[aa];if(!t||typeof t!=`object`)return;let n=t;if(!(typeof n.matched!=`string`||!cee.includes(n.matched))&&typeof n.source==`string`&&!(n.refs!==void 0&&(!Array.isArray(n.refs)||!n.refs.every(lee)))&&!(n.diagnostics!==void 0&&(!Array.isArray(n.diagnostics)||!n.diagnostics.every(uee))))return t}var sa=class{line;startOffset;endOffset;length;columnStart;columnEnd;raw;constructor(e,t,n,r,i=0,a=0,o=``){this.line=e,this.startOffset=t,this.endOffset=n,this.length=r,this.columnStart=i,this.columnEnd=a,this.raw=o}},ca=class e{_metrics;_indexedLength=0;_resolver=new Gi;id;constructor(t,n=`metrics`){if(this.id=n,t instanceof e){this._metrics=t.toArray(),this.syncIndexProperties();return}this._metrics=Array.isArray(t)?[...t]:[],this.syncIndexProperties()}static from(t,n=`metrics`){if(t instanceof e)return t.clone(n);if(Array.isArray(t))return new e(t,n);if(typeof t==`object`&&t&&`_metrics`in t){let r=t._metrics;if(Array.isArray(r))return new e(r,n)}return e.empty(n)}static empty(t=`metrics`){return new e(void 0,t)}clone(t=this.id){return new e(this._metrics,t)}get all(){return[...this._metrics]}get length(){return this._metrics.length}get size(){return this._metrics.length}get isEmpty(){return this._metrics.length===0}getByType(e){let t=this._metrics.filter(t=>t.type===e||t.name===e);return t.length<=1?t:[...t].sort((e,t)=>Ii(t)-Ii(e))}getFirst(e){let t=this.getByType(e);return t.length>0?t[0]:void 0}get(e){return this.getFirst(e)}has(e){return this._metrics.some(t=>t.type===e||t.name===e)}hasMetric(e){return this.has(e)}getDisplayMetrics(e){return this.resolve(e)}getMetric(e){return this._resolver.resolveOne(this._metrics,e)}getAllMetricsByType(e){return this.getByType(e)}get rawMetrics(){return this.toArray()}getAll(){return this.toArray()}getByOrigin(e){return this._metrics.filter(t=>(t.origin??`parser`)===e)}resolve(e){return this._resolver.resolve(this._metrics,e)}add(...e){return this._metrics.push(...e),this.syncIndexProperties(),this}remove(e){let t=[];return this._metrics=this._metrics.filter(n=>!e(n)||(t.push(n),!1)),this.syncIndexProperties(),t}removeByType(e){return this.remove(t=>t.type===e||t.name===e)}clear(){return this._metrics=[],this.syncIndexProperties(),this}replaceByType(e,...t){let n=this.removeByType(e);return this._metrics.push(...t),this.syncIndexProperties(),n}merge(t){let n=t instanceof e?t._metrics:Array.isArray(t)?t:t.metrics.toArray(),r=new Map;for(let e of n){let t=r.get(e.type)??[];t.push(e),r.set(e.type,t)}for(let[e,t]of r){let n=this._metrics.filter(t=>t.type===e);if(n.length===0){this._metrics.push(...t);continue}let r=Math.max(...n.map(e=>Ii(e))),i=Math.max(...t.map(e=>Ii(e)));i>r?(this._metrics=this._metrics.filter(t=>t.type!==e),this._metrics.push(...t)):i===r&&this._metrics.push(...t)}return this.syncIndexProperties(),this}[Symbol.iterator](){return this._metrics[Symbol.iterator]()}filter(e){return this._metrics.filter(e)}map(e){return this._metrics.map(e)}flatMap(e){return this._metrics.flatMap(e)}find(e){return this._metrics.find(e)}some(e){return this._metrics.some(e)}every(e){return this._metrics.every(e)}toArray(){return[...this._metrics]}get raw(){return this._metrics}syncIndexProperties(){for(let e=0;e<this._indexedLength;e++)delete this[e];for(let e=0;e<this._metrics.length;e++)this[e]=this._metrics[e];this._indexedLength=this._metrics.length}toString(){return`MetricContainer(${this._metrics.length})[${this._metrics.map(e=>e.type).join(`, `)}]`}},la=class{exerciseId;line;text;raw;dialect;hasMetric(e){return this.metricContainer.hasMetric(e)}getDisplayMetrics(e){return this.metricContainer.getDisplayMetrics(e)}getMetric(e){return this.metricContainer.getMetric(e)}getAllMetricsByType(e){return this.metricContainer.getAllMetricsByType(e)}get rawMetrics(){return this.metricContainer.rawMetrics}get metricContainer(){return this.metrics instanceof ca?this.metrics:ca.from(this.metrics,this.id)}},dee=class extends la{id=0;parent;children=[];meta=new sa(0,0,0,0);_metrics=ca.empty();metricMeta=new Map;isLeaf;get metrics(){return this._metrics}set metrics(e){this._metrics=ca.from(e,this.id)}constructor(e){super(),e&&(Object.assign(this,e),e.metrics&&(this.metrics=ca.from(e.metrics,this.id)),this.metricMeta||=new Map)}},ua=class e extends la{static nextId=1e6;id;outputType;timeSpan;sourceStatementId;sourceBlockKey;stackLevel;metrics;metricMeta;completionReason;parent;children;isLeaf;meta;statement;timestamp;constructor(t,n,r){if(super(),t&&`outputType`in t&&`timeSpan`in t){let n=t;this.id=e.nextId++,this.outputType=n.outputType,this.timeSpan=n.timeSpan,this.sourceBlockKey=n.sourceBlockKey??``,this.sourceStatementId=n.sourceStatementId,this.line=n.line,this.text=n.text,this.dialect=n.dialect,this.stackLevel=n.stackLevel??0,this.metrics=ca.from(n.metrics,this.id),this.metricMeta=n.metricMeta??new Map,this.completionReason=n.completionReason,this.parent=n.parent,this.children=n.children??[],this.isLeaf=this.children.length===0,this.meta=new sa(0,0,0,0)}else{let i=t;this.id=e.nextId++,this.statement=i,this.outputType=`segment`,this.timeSpan={started:r??Date.now()},this.sourceBlockKey=``,this.sourceStatementId=typeof i?.id==`number`?i.id:void 0,this.stackLevel=0,this.metrics=ca.from(n,this.id),this.metricMeta=new Map,this.children=[],this.isLeaf=!0,this.meta=i?.meta??new sa(0,0,0,0),this.line=i?.line,this.text=i?.text,this.dialect=i?.dialect,this.timestamp=r??Date.now()}}static resetIdCounter(t=1e6){e.nextId=t}},da=class{value;constructor(e){this.value=e??(typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():Math.random().toString(36).slice(2))}toString(){return this.value}valueOf(){return this.value}equals(e){return this.value===e?.value}};function fa(e){let t=new Map;for(let n of e)t.set(n.slug,n);return{resolve:e=>t.get(e),list:()=>[...t.values()]}}var pa=`tagReference`;function ma(e){let t=e?.[pa];if(!t||typeof t!=`object`)return;let n=t;if(!(typeof n.slug!=`string`||!n.slug)&&typeof n.label==`string`&&!(n.functions!==void 0&&!Array.isArray(n.functions))&&(n.soundProfileId===void 0||typeof n.soundProfileId==`string`))return t}function ha(e){let t=e.trim(),n=2166136261;for(let e=0;e<t.length;e++)n^=t.charCodeAt(e),n=Math.imul(n,16777619);return`bc-${(n>>>0).toString(16).padStart(8,`0`)}`}function ga(e,t){let n=e.position??1/0,r=t.position??1/0;return n===r?e.createdAt===t.createdAt?e.id<t.id?-1:+(e.id>t.id):e.createdAt-t.createdAt:n-r}function _a(e){return[...e].sort(ga)}function va(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of _a(e)){let e=n.get(t.pageId);e&&r.push({pageId:e.id,noteId:t.noteId,position:t.position,createdAt:t.createdAt,date:e.date,slug:e.slug,title:e.title})}return r}function ya(e){let t={};for(let n of e)t.pageId===void 0&&(t.pageId=n.pageId),t.journalDate===void 0&&n.date&&(t.journalDate=n.date),t.pageSlug===void 0&&n.slug&&!n.date&&(t.pageSlug=n.slug);return t}var ba=[`segment`,`system`,`load`,`event`,`compiler`,`completion`,`analytics`,`wellness`];function xa(e){return e===`time`?`run`:e===`log`?`log`:null}function Sa(e){let t=e.trim();return t.startsWith(`notebook/`)||t.startsWith(`notebook:`)?t.slice(9):t}function Ca(e){return`notebook/${Sa(e)}`}function wa(e,t){return t?t!==`feed`:e.seedOrigin!==`seed`&&e.feedOrigin!==`feed`}var Ta=[{slug:`journal`,notebookId:`notebook/journal`,name:`Journal`,description:`Dated training log and scheduled workouts.`,icon:`📅`,href:`/journal`},{slug:`playground`,notebookId:`notebook/playground`,name:`Playground`,description:`Scratchpad workouts and timer experiments.`,icon:`🧪`,href:`/playgrounds`},{slug:`defaults`,notebookId:`notebook/defaults`,name:`Defaults`,description:`Starter notes — clone any of them into your own notebooks.`,icon:`📝`,href:`/notebook/defaults`},{slug:`guides`,notebookId:`notebook/guides`,name:`Guides`,description:`Built-in Whiteboard Language and WQL guides.`,icon:`📖`,href:`/notebook/guides`,feedEntryId:`core`,seedChunkId:`canvas`},{slug:`efforts`,notebookId:`notebook/efforts`,name:`Efforts`,description:`The effort library — every effort the parser and analytics resolve, across the canonical disciplines.`,icon:`🏋️`,href:`/efforts`,feedEntryId:`core`,seedChunkId:`efforts`},{slug:`equipment`,notebookId:`notebook/equipment`,name:`Equipment`,description:`The equipment library — gear definitions the language resolves.`,icon:`🔧`,href:`/equipment`,feedEntryId:`core`,seedChunkId:`equipment`},{slug:`dashboards`,notebookId:`notebook/dashboards`,name:`Dashboards`,description:`Prebuilt WQL dashboards — query compositions ready to open.`,icon:`📊`,href:`/dashboards`,feedEntryId:`core`,seedChunkId:`dashboards`}],Ea=[`playground-run-tip`,`attention`,`code-example`,`syntax-group`],Da={table:!0,list:!0,value:!0,timeseries:!0,bar:!0,donut:!0,toplist:!0,"stacked-bar":!0,"goal-rings":!0,"zone-distribution":!0};function Oa(e){let t=e.match(/^`{3,}(time|log)(?::([\w-]+))?\s*$/i);return t?{dialect:t[1].toLowerCase()===`time`?`time`:`log`,...t[2]?{sport:t[2]}:{}}:null}function ka(e){let t=e.type?.toLowerCase();if(t===`youtube`||t===`strava`||t===`amazon`||t===`file`||t===`effort`||t===`equipment`)return t;let n=(e.url||e.link||``).replace(/^[a-z][a-z0-9+.-]*:\/\//i,``).split(/[/?#:]/,1)[0].toLowerCase();return n===`youtu.be`||n===`youtube.com`||n.endsWith(`.youtube.com`)?`youtube`:n===`strava.com`||n.endsWith(`.strava.com`)?`strava`:n===`amzn.to`||n===`amazon.com`||n.endsWith(`.amazon.com`)?`amazon`:[`baseAttributes`,`metrics.met`,`discipline`,`effortType`,`targetRPE`,`equipment`,`aliases`,`derivation`].some(t=>t in e)?`effort`:[`slug`,`label`,`registrySource`,`ownerNoteId`,`sourcePath`].some(t=>t in e)?`equipment`:`default`}function Aa(e){return/^#{1,6}\s/.test(e)?`heading`:/^[-*+]\s|^\d+\.\s/.test(e)?`list`:/^>\s?/.test(e)?`blockquote`:e.startsWith(`|`)&&/^\|[\s:]*-+/m.test(e)?`table`:`paragraph`}function ja(e,t={}){if(!e)return[];let n=e.split(/\r\n|\n|\r/),r=[],i=[],a=0;for(let t of n){r.push(a),a+=t.length;let n=e.startsWith(`\r
3
3
  `,a)?`\r
4
4
  `:/[\r\n]/.test(e[a]??``)?e[a]:``;i.push(n),a+=n.length}let o=[],s=Date.now(),c=!0,l=0;function u(t,a,o){let c=r[a],l=r[o]+n[o].length;return{id:crypto.randomUUID(),type:t,from:c,to:l,rawContent:e.slice(c,l),displayContent:e.slice(c,l),startLine:a,endLine:o,lineCount:o-a+1,version:1,createdAt:s,separatorAfter:i[o]}}for(;l<n.length;){let a=n[l].trim(),d=a.match(/^(`{3,}|~{3,})(.*)$/);if(d){let a=d[1],c=l+1,f=RegExp(`^${a[0]}{${a.length},}\\s*$`);for(;c<n.length&&!f.test(n[c].trim());)c++;let p=c<n.length,m=p?c:n.length-1,h=d[2].trim(),g=a[0]==="`"?Oa(`\`\`\`${h}`):null,_=a[0]==="`"?h.match(/^widget:([\w-]+)$/):null,v=t.registeredWidgets??Ea,y=_&&(`has`in v?v.has(_[1]):v.includes(_[1])),b=a[0]==="`"&&!y?h.match(/^widget:([a-zA-Z-]+)(?:-(?:full|\d+))?(?:\s+.*)?$/i):null,x=!!(b&&Da[b[1].toLowerCase()]),S=a[0]==="`"?h.match(/^query(?:[:\s](.*))?$/i)??(x?h.match(/^widget:?(.*)$/i):null):null,C=p&&g?g.dialect:p&&y?`widget`:p&&S?`query`:`code`,w=u(C,l,m);w.contentFrom=r[l]+n[l].length+i[l].length,w.contentTo=p?r[c]:w.to,w.displayContent=e.slice(w.contentFrom,w.contentTo),g&&p&&(w.sport=g.sport,w.contentId=ha(w.displayContent),w.scriptBlock={id:w.id,contentId:w.contentId,dialect:g.dialect,sport:g.sport,startLine:l,endLine:m,content:w.displayContent,state:`idle`,version:1,createdAt:s}),C===`widget`&&_&&(w.widgetName=_[1]),C===`query`&&S&&(w.querySuffix=(S[1]??``).trim()),o.push(w),l=m+1;continue}if(a===`---`&&n[l+1]?.trim()){let t=l+1;for(;t<n.length&&n[t].trim()!==`---`&&!/^(`{3,}|~{3,})/.test(n[t].trim());)t++;let i=n.slice(l+1,t);if(n[t]?.trim()===`---`&&i.some(e=>/^[A-Za-z_][\w.-]*\s*:/.test(e.trim()))){let n=u(`frontmatter`,l,t);n.contentFrom=r[l+1],n.contentTo=r[t],n.displayContent=e.slice(n.contentFrom,n.contentTo),n.properties={};for(let e of i){let t=e.match(/^([^:]+):\s*(.*)$/);t&&(n.properties[t[1].trim()]=t[2].trim())}n.frontmatterType=ka(n.properties),o.push(n),l=t+1;continue}}let f=a.match(/^(!)?\[([^\]]*)\]\((https?:\/\/[^)\s]+|\/[^)\s]+)\)$/);if(f){let e=u(`embed`,l,l),t=!!f[1];e.embed={type:t?`image`:/(?:youtube\.com|youtu\.be)/i.test(f[3])?`youtube`:`link`,label:f[2],url:f[3],isImage:t},o.push(e),l++;continue}let p=l;if(a)for(;p+1<n.length&&n[p+1].trim()&&!/^(?:`{3,}|~{3,}|---\s*$|!?\[[^\]]*\]\()/.test(n[p+1].trim());)p++;let m=u(a&&c?`title`:`markdown`,l,p);m.subtype=Aa(m.displayContent.trim()),a&&(c=!1),o.push(m),l=p+1}return o}function Ma(e){return e.type===`time`||e.type===`log`?`wod`:e.type===`query`||e.type===`widget`||e.type===`embed`?e.type:null}function Na(e,t){if(!Number.isSafeInteger(t.sourceRevision)||t.sourceRevision<1)throw Error(`Invalid source revision`);let n=Object.create(null),r=Object.values(t.blocks??{}).filter(e=>e&&typeof e==`object`),i=t.createId??(()=>crypto.randomUUID());for(let a of ja(e,t)){let e=Ma(a);if(!e)continue;let o=r.filter(t=>t.from===a.from&&t.to===a.to&&t.kind===e),s=o.length===1?o[0]:void 0,c=s?.id??i();if(!c||Object.hasOwn(n,c))throw Error(`Duplicate block occurrence ID`);n[c]={id:c,kind:e,from:a.from,to:a.to,sourceRevision:t.sourceRevision,version:s?.version??1,...e===`wod`&&(a.type===`time`||a.type===`log`)?{dialect:a.type,...a.sport?{sport:a.sport}:{}}:{}}}return n}function Pa(e,t,n,r={}){if(typeof e!=`string`||!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid Note source or blocks`);for(let[e,r]of Object.entries(t))if(!r||r.id!==e||!e||!Number.isSafeInteger(r.version)||r.version<1||r.sourceRevision!==n||!Number.isSafeInteger(r.from)||!Number.isSafeInteger(r.to))throw Error(`Invalid block identity, version or source revision`);let i=Na(e,{...r,sourceRevision:n,blocks:t});if(Object.keys(i).length!==Object.keys(t).length)throw Error(`Incomplete actionable block map`);for(let[e,n]of Object.entries(t)){let t=i[e];if(!t||t.from!==n.from||t.to!==n.to||t.kind!==n.kind||t.dialect!==n.dialect||t.sport!==n.sport)throw Error(`Block does not match authored source`)}}function Fa(e,t){let n=0;for(let e of t){if(!Number.isSafeInteger(e.from)||!Number.isSafeInteger(e.to)||e.from<n||e.to<e.from||typeof e.insert!=`string`)throw Error(`Invalid source changes`);n=e.to}let r={};for(let n of Object.values(e)){let e=n.from,i=n.to,a=!1;for(let r of t){let t=r.insert.length-(r.to-r.from);if(r.from<=n.from&&r.to>=n.to||r.from<n.from&&r.to>n.from||r.from<n.to&&r.to>n.to){a=!0;break}r.to<=n.from?(e+=t,i+=t):r.from<n.to&&(i+=t)}a||(r[n.id]={...n,from:e,to:i})}return r}var Ia=/^[A-Za-z][\w.-]*$/,La=/^---\r?\n([\s\S]*?)\r?\n---/;function Ra(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function za(e){let t=e.trim();return t===``||t.startsWith(`#`)}function Ba(e){return Array.isArray(e)}function Va(e){if(e===``)return`""`;let t=!isNaN(Number(e)),n=/^(true|false|null|yes|no|on|off)$/i.test(e);return/[:"'\n#{}[\],&*?|<>=%!@`]/.test(e)||e!==e.trim()||e.startsWith(`-`)||t||n?`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\n/g,`\\n`).replace(/\r/g,`\\r`).replace(/\t/g,`\\t`)}"`:e}function Ha(e,t,n){let r=` `.repeat(e);return Ba(n)?n.length===0?[`${r}${t}: []`]:[`${r}${t}:`,...n.map(e=>`${r} - ${typeof e==`number`?String(e):Va(e)}`)]:[`${r}${t}: ${typeof n==`number`?String(n):Va(n)}`]}function Ua(e,t,n,r){let i=[],a=r;for(let r=t;r<e.length;r++)r===e.length-1?i.push(...Ha(a,e[r],n)):i.push(`${` `.repeat(a)}${e[r]}:`),a+=2;return i}function Wa(e){let t=!1,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){i===`\\`?r++:i===`"`&&(n=!1);continue}if(t){i===`'`&&(t=!1);continue}if(i===`"`)n=!0;else if(i===`'`)t=!0;else if(i===`#`&&(r===0||/\s/.test(e[r-1])))return r}return-1}function Ga(e,t,n){let r=[t],i=[];for(let a=t+1;a<e.length;a++){let t=e[a];if(za(t)){i.push(a);continue}if(t.length-t.trimStart().length>n)r.push(...i,a),i=[];else break}return r}function Ka(e,t,n,r,i){let a=RegExp(`^ {${n}}${Ra(t)}\\s*:`);for(let t=r;t<i;t++)if(a.test(e[t]))return t;return-1}function qa(e,t,n){if(t.length===0||!t.every(e=>typeof e==`string`&&Ia.test(e)))return e;let r=e.includes(`\r
@@ -106,7 +106,7 @@ sum:$metric{} by {week}
106
106
 
107
107
  `,i=n?.from??e.rawContent.length,a=n?.to??i,o=r+t.rawContent,s=o.length-(a-i),c={};for(let[n,r]of Object.entries(e.blocks))n!==t.blockId&&(c[n]=r.from>=a?{...r,from:r.from+s,to:r.to+s}:r);return c[t.blockId]={id:t.blockId,kind:t.kind,version:n?.version??t.version,sourceRevision:e.sourceRevision,from:i+r.length,to:i+o.length,...t.dialect?{dialect:t.dialect}:{},...t.sport?{sport:t.sport}:{}},{...e,rawContent:e.rawContent.slice(0,i)+o+e.rawContent.slice(a),blocks:c}}function Nz({noteId:e,sourceRevision:t,blocks:n={},persistence:r=YA,onRevert:i}){let[a,o]=(0,W.useState)([]),[s,c]=(0,W.useState)(``),[l,u]=(0,W.useState)(0),[d,f]=(0,W.useState)(0),[p,m]=(0,W.useState)(null),[h,g]=(0,W.useState)(!1);(0,W.useEffect)(()=>{let t=!1;return m(null),r.getNoteBlockHistory(e).then(e=>{t||o(e.toSorted((e,t)=>e.savedAt-t.savedAt||e.version-t.version))}).catch(e=>{t||m(e instanceof Error?e.message:String(e))}),()=>{t=!0}},[e,t,r]);let _=Array.from(new Set(a.map(e=>e.blockId))),v=_.includes(s)?s:_[0]??``,y=a.filter(e=>e.blockId===v).toSorted((e,t)=>e.version-t.version),b=y.find(e=>e.version===l)??y[0],x=y.find(e=>e.version===d)??y.at(-1),S=async()=>{if(!(!b||!i)){g(!0),m(null);try{await i(b),o(await r.getNoteBlockHistory(e))}catch(e){m(e instanceof Error?e.message:String(e))}finally{g(!1)}}};return(0,G.jsxs)(`details`,{className:`rounded-lg border border-border p-3`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer font-medium focus-visible:ring-2`,children:`Saved block history`}),(0,G.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[p&&(0,G.jsx)(`p`,{role:`alert`,children:p}),_.length===0?(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No saved actionable blocks.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`block text-sm`,children:[`Block occurrence`,(0,G.jsx)(`select`,{className:`mt-1 block max-w-full rounded border bg-background p-2 text-foreground focus-visible:ring-2`,value:v,onChange:e=>{c(e.target.value),u(0),f(0)},children:_.map((e,t)=>(0,G.jsxs)(`option`,{value:e,children:[`Block `,t+1,` · `,e,n[e]?``:` · removed`]},e))})]}),(0,G.jsx)(`ol`,{"aria-label":`Saved versions`,className:`space-y-1 text-sm`,style:{contentVisibility:`auto`},children:y.map(e=>(0,G.jsxs)(`li`,{children:[`v`,e.version,` · `,(0,G.jsx)(`time`,{dateTime:new Date(e.savedAt).toISOString(),children:Bb(new Date(e.savedAt))}),` · `,e.kind,e.dialect?` · ${e.dialect}`:``,e.sport?` · ${e.sport}`:``]},e.version))}),(0,G.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[{label:`Compare saved version`,row:b,set:u},{label:`With saved version`,row:x,set:f}].map(({label:e,row:t,set:n})=>(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`label`,{className:`block text-sm`,children:[e,(0,G.jsx)(`select`,{className:`ml-2 rounded border bg-background p-1 text-foreground focus-visible:ring-2`,value:t?.version??0,onChange:e=>n(Number(e.target.value)),children:y.map(e=>(0,G.jsxs)(`option`,{value:e.version,children:[`v`,e.version]},e.version))})]}),(0,G.jsx)(`pre`,{"aria-label":`${e} source`,className:`mt-2 max-h-80 overflow-auto whitespace-pre-wrap break-words rounded bg-muted p-3 text-xs`,children:t?.rawContent})]},e))}),(0,G.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:`text-sm`,children:b?.rawContent===x?.rawContent&&b?.kind===x?.kind&&b?.dialect===x?.dialect&&b?.sport===x?.sport?`Saved states are identical.`:`Saved states differ.`}),i&&b&&(0,G.jsx)(`button`,{type:`button`,disabled:h,className:`rounded border px-3 py-2 hover:bg-accent focus-visible:ring-2 disabled:opacity-50`,onClick:()=>void S(),children:h?`Saving…`:`Restore v${b.version} as a new saved version`})]})]})]})}async function Pz(e){let t=await tk(),n=[`markdown/notebooks/${e}.md`,`markdown/canvas/${e}.md`];for(let e of n)if(t[e])return t[e];let r=`/${e}.md`.toLowerCase(),i=Object.entries(t).find(([e])=>e.toLowerCase().endsWith(r));return i?i[1]:void 0}async function Fz(e){return await Pz(e)??null}var Iz=class{transport;handlers=new Set;transportUnsub=null;disposed=!1;constructor(e){this.transport=e,this.transportUnsub=this.transport.onMessage(e=>{if(e.type===`rpc-event`){let t={name:e.name,timestamp:new Date(e.timestamp),data:e.data};for(let e of this.handlers)e(t)}})}dispatch(e){this.disposed||!this.transport.connected||this.transport.send({type:`rpc-event`,name:e.name,timestamp:e.timestamp.getTime(),data:e.data})}onEvent(e){return this.disposed?()=>{}:(this.handlers.add(e),()=>this.handlers.delete(e))}dispose(){this.disposed||(this.disposed=!0,this.transportUnsub?.(),this.transportUnsub=null,this.handlers.clear())}};function Lz(e){let t=e.getMemoryByTag(`time`);if(t.length===0)return null;let n=t[0].metrics;if(n.length===0)return null;let r=n[0]?.value;if(!r||!Array.isArray(r.spans))return null;let i=r.spans.map(e=>({started:e.started,ended:e.ended})),a=r.direction??`up`,o=r.role,s=o===`hidden`?`auto`:o;return{label:r.label,format:a,durationMs:r.durationMs,direction:a,spans:i,isRunning:i.some(e=>e.ended===void 0),role:s}}function Rz(e){let t=e.getMetricMemoryByVisibility(`display`).map(e=>e.metrics.toArray()),n=e.getMetricMemoryByVisibility(`promote`).map(e=>e.metrics.toArray()),r=e.getMetricMemoryByVisibility(`result`).map(e=>e.metrics.toArray()),i=e.getMetricMemoryByVisibility(`private`),a={};for(let e of i)a[e.tag]||(a[e.tag]=[]),a[e.tag].push(e.metrics.toArray());let o=e.getMemoryByTag(`metric:next`).flatMap(e=>e.metrics.toArray()),s;try{e.behaviors&&e.behaviors.length>0&&(s=e.behaviors.map(e=>({name:e.constructor.name})))}catch{}return{key:e.key.toString(),blockType:e.blockType??`Block`,label:e.label,sourceIds:[...e.sourceIds],isComplete:e.isComplete,completionReason:e.completionReason,displayFragments:t,promoteFragments:n.length>0?n:void 0,resultFragments:r.length>0?r:void 0,privateFragments:Object.keys(a).length>0?a:void 0,timer:Lz(e),nextFragments:o,behaviorsMetadata:s}}function zz(e){return{type:`rpc-stack-update`,snapshotType:e.type,blocks:e.blocks.map(Rz),affectedBlockKey:e.affectedBlock?.key.toString(),depth:e.depth,clockTime:e.clockTime.getTime()}}function Bz(e){let t=e.timeSpan.started,n=e.timeSpan.ended,r=n===void 0?0:n-t;return{type:`rpc-output`,outputType:e.outputType,sourceBlockKey:e.sourceBlockKey,stackLevel:e.stackLevel,metrics:Array.isArray(e.metrics)?e.metrics:e.metrics.toArray(),completionReason:e.completionReason,timeSpan:{started:t,ended:n},elapsed:r}}function Vz(e,t,n){return{type:`rpc-analytics-summary`,totalDurationMs:t,completedSegments:n,projections:e}}function Hz(e){return(e??[]).map(e=>e.map(e=>`${e?.type??``}:${e?.value==null||typeof e.value==`object`?``:String(e.value)}:${e?.image??``}:${e?.unit??``}`).join(`,`)).join(`;`)}var Uz=class{transport;id;lastFingerprint=``;constructor(e,t){this.transport=e,this.id=t?.id??`chromecast`}onStackSnapshot(e){if(!this.transport.connected)return;let t=zz(e),n=this.computeFingerprint(t);n!==this.lastFingerprint&&(this.lastFingerprint=n,this.transport.send(t))}onOutput(e){this.transport.connected&&this.transport.send(Bz(e))}sendAnalyticsSummary(e,t,n){this.transport.connected&&this.transport.send(Vz(e,t,n))}dispose(){this.lastFingerprint=``}computeFingerprint(e){let t=[e.snapshotType,String(e.depth)];for(let n of e.blocks){t.push(`${n.key}:${n.blockType}:${n.label}:${n.isComplete}`),n.timer&&t.push(`timer:${n.timer.isRunning}:${n.timer.spans.length}:${n.timer.durationMs}:${n.timer.spans[0]?.started??``}:${n.timer.role??``}`),t.push(`frags:${Hz(n.displayFragments)}`),t.push(`promote:${Hz(n.promoteFragments)}`),t.push(`result:${Hz(n.resultFragments)}`);let e=Object.keys(n.privateFragments??{}).sort().join(`,`);t.push(`private:${e}`);let r=n.nextFragments?.map(e=>`${e.type??``}:${e.image??(e.value==null?``:String(e.value))}`).join(`,`)??``;t.push(`next:${r}`);let i=n.behaviorsMetadata?.map(e=>e.name).join(`,`)??``;t.push(`behaviors:${i}`)}return t.join(`|`)}},Wz=class{transport;options;disposed=!1;syncSamples=[];constructor(e,t={}){this.transport=e,this.options=t}async sync(){let e=this.options.samples??3,t=this.options.maxRttMs??500;console.log(`[ClockSyncService] Starting sync (${e} samples, max RTT: ${t}ms)`),this.syncSamples.length=0;for(let n=0;n<e;n++){if(this.disposed)throw Error(`ClockSyncService was disposed during sync`);let r=await this.performSyncSample(t);r===null?console.warn(`[ClockSyncService] Sample ${n+1} failed (RTT exceeded ${t}ms)`):(this.syncSamples.push(r),console.log(`[ClockSyncService] Sample ${n+1}/${e}: offset=${r.offsetMs.toFixed(2)}ms, RTT=${r.rttMs.toFixed(2)}ms`)),n<e-1&&await new Promise(e=>setTimeout(e,100))}if(this.syncSamples.length===0)throw Error(`Clock sync failed: all samples exceeded max RTT`);let n=[...this.syncSamples].map(e=>e.offsetMs).sort((e,t)=>e-t),r=n.length%2==0?(n[n.length/2-1]+n[n.length/2])/2:n[Math.floor(n.length/2)],i=this.syncSamples.reduce((e,t)=>e+t.rttMs,0)/this.syncSamples.length,a={offsetMs:r,avgRttMs:i};return console.log(`[ClockSyncService] Sync complete: offset=${r.toFixed(2)}ms (median), avg RTT=${i.toFixed(2)}ms`),this.sendResult(a),a}sendResult(e){if(this.disposed||!this.transport.connected)return;let t={type:`rpc-clock-sync-result`,offsetMs:e.offsetMs,rttMs:e.avgRttMs};this.transport.send(t)}async performSyncSample(e){let t=Date.now(),n={type:`rpc-clock-sync-request`,timestamp:t};this.transport.send(n);let r=await this.waitForResponse(e=>e.type===`rpc-clock-sync-response`&&e.requestTimestamp===t,2e3),i=Date.now()-t;if(i>e)return null;let a=i/2;return{offsetMs:r.receiverTimestamp-(t+a),rttMs:i}}waitForResponse(e,t){return new Promise((n,r)=>{let i=setTimeout(()=>{a(),r(Error(`Clock sync response timeout after ${t}ms`))},t),a=this.transport.onMessage(t=>{e(t)&&(clearTimeout(i),a(),n(t))})})}dispose(){this.disposed=!0,this.syncSamples.length=0}};function Gz(e,...t){console.warn(`[${e}]`,...t)}function Kz(e,...t){console.error(`[${e}]`,...t)}var qz={createSubscription:(e,t)=>new Uz(e,{id:t}),createEventProvider:e=>new Iz(e),createClockSync:e=>new Wz(e)},Jz=new class{deps;activeHandle=null;activeMeta=null;constructor(e=qz){this.deps=e}get isConnected(){return this.activeHandle!==null}getActiveHandle(){return this.activeHandle}setSubscriptionRegistry(e){!this.activeHandle||!this.activeMeta||this.activeMeta.registry!==e&&(this.activeMeta.registry&&this.activeMeta.registry.remove(this.activeMeta.subscriptionId),this.activeMeta.registry=e,e&&e.add(this.activeHandle.subscription))}connect(e,t=null,n={}){this.dispose();let r=n.subscriptionId??`chromecast`,i=this.deps.createSubscription(e,r),a=this.deps.createEventProvider(e),o=e.needsClockSync?this.deps.createClockSync(e):null;t?.add(i),o&&o.sync().catch(e=>{Kz(`CastSessionManager`,`Clock sync failed`,e)});let s=e.onDisconnected(()=>this.dispose());return this.activeHandle={transport:e,eventProvider:a,subscription:i,pushInitialWorkbench:t=>{try{e.send(t)}catch{}},dispose:()=>this.dispose()},this.activeMeta={registry:t,subscriptionId:r,unsubDisconnected:s,clockSync:o},this.activeHandle}sendDisposeSignal(){this.activeHandle?.transport.connected&&this.activeHandle.transport.send({type:`rpc-dispose`})}pushInitialWorkbench(e){if(!this.activeHandle)return!1;try{return this.activeHandle.transport.send(e),!0}catch{return!1}}dispose(e=!1){if(!this.activeHandle)return;let t=this.activeHandle,n=this.activeMeta;if(this.activeHandle=null,this.activeMeta=null,n?.unsubDisconnected(),e&&t.transport.connected)try{t.transport.send({type:`rpc-dispose`})}catch{}n?.registry&&n.registry.remove(n.subscriptionId),t.subscription.dispose(),t.eventProvider.dispose(),n?.clockSync?.dispose()}};function Yz(){return(0,W.useSyncExternalStore)(Pj,Aj,Aj)}function Xz(e,t){if(!e||e.trim().length===0)return{statements:[],errors:[],success:!0};try{let n=e.endsWith(`
108
108
  `)?e:e+`
109
- `;return{statements:dc(ei.create({doc:n,extensions:[zc]}),t),errors:[],success:!0}}catch(e){return{statements:[],errors:[{message:e instanceof Error?e.message:`Unknown parse error`,severity:`error`}],success:!1}}}function Zz(e,t={}){let n=t.sourceRevision??1,r=Na(e,{...t,blocks:t.noteBlocks,sourceRevision:n}),i=ja(e,t),a=[];for(let e of i){if(!Ma(e))continue;let t=Object.values(r).find(t=>t.from===e.from&&t.to===e.to);t&&(e.id=t.id,e.version=t.version,e.scriptBlock&&(e.scriptBlock=Qz({...e.scriptBlock,id:t.id,version:t.version}),a.push(e.scriptBlock)))}return{sections:i,blocks:a,noteBlocks:r,rawContent:e,sourceRevision:n}}function Qz(e){try{let t=Xz(e.content,e.sport);return{...e,statements:t.statements,errors:t.errors,state:t.success?`parsed`:`error`}}catch(t){return zj(`WorkbenchDocumentModel`,`Block parse error:`,t),e}}var $z={content:``,sections:null,noteBlocks:{},sourceRevision:0,capturedRun:null,saveError:null,blocks:[],activeBlockId:null,saveState:`idle`,lastSavedContent:``,loadedRouteId:null,results:[],currentEntry:null,historyEntries:[],panelLayouts:{},attachments:[],runtime:null,execution:{status:`idle`,elapsedTime:0,stepCount:0,startTime:null,start:()=>{},pause:()=>{},stop:()=>{},reset:()=>{},step:()=>{}},handles:{handleStart:()=>{},handlePause:()=>{},handleStop:()=>{},handleNext:()=>{},handleStartWorkoutAction:()=>{}},activeSegmentIds:new Set,activeStatementIds:new Set,analyticsSegments:[],analyticsGroups:[],selectedAnalyticsIds:new Set,lastSelectedAnalyticsId:null,outputStatementList:[],logOutputList:[],userOutputOverrides:new Map,gridViewPreset:`default`,hoveredBlockKey:null,documentItems:[],selectedBlock:null,selectedBlockId:null,cursorLine:1,highlightedLine:null,subscriptionManager:null,viewMode:`plan`},eB=5e3;function tB(e={}){let t=e.listeners??[],n=e.nowProvider??Hl,r=e.notePersistence,i=e.setTimeout??((e,t)=>window.setTimeout(e,t)),a=e.clearTimeout??(e=>{typeof e==`number`&&window.clearTimeout(e)}),o=null,s=[],c=Tn()((t,n)=>{let c=Promise.resolve(),l=async i=>{let a=n(),o=a.currentEntry?.id??a.loadedRouteId;if(!(!o||!r||!e.provider?.capabilities.canWrite)&&(i.rawContent!==a.lastSavedContent||JSON.stringify(Object.values(i.blocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))!==JSON.stringify(Object.values(a.currentEntry?.blocks??{}).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport])))){t({saveState:`saving`,saveError:null});try{let e=await r.saveNote({noteId:o,rawContent:i.rawContent,blocks:i.blocks,expectedSourceRevision:a.sourceRevision,metadata:{title:i.rawContent.match(/^#\s+(.+)$/m)?.[1]?.trim()??`Untitled Session`},noteType:`playground`}),s=n();t({currentEntry:e,...s.content===i.rawContent&&JSON.stringify(Object.values(s.noteBlocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))===JSON.stringify(Object.values(i.blocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))?{noteBlocks:e.blocks}:{},sourceRevision:e.sourceRevision??a.sourceRevision,lastSavedContent:i.rawContent,saveState:`saved`})}catch(e){throw t({saveState:`error`,saveError:e instanceof Error?e.message:String(e)}),e}}},u=()=>{o=null;let e=n(),t={rawContent:e.content,blocks:e.noteBlocks,sourceRevision:e.sourceRevision},r=c.catch(()=>{}).then(()=>l(t));return c=r,r};return{...$z,setContent:r=>{let s=Zz(r,{noteBlocks:n().noteBlocks,sourceRevision:Math.max(1,n().sourceRevision)}),c=n(),l={content:r,sections:s.sections,blocks:s.blocks,noteBlocks:s.noteBlocks};r!==c.lastSavedContent&&(c.saveState===`idle`&&(l.saveState=`changed`),o!==null&&a(o),e.provider&&e.provider.capabilities.canWrite&&(o=i(()=>{u().catch(()=>{})},eB))),t(l)},setBlocks:e=>t({blocks:e}),setEditorIdentity:r=>{let s=JSON.stringify(Object.values(n().noteBlocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))!==JSON.stringify(Object.values(r.blocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]));t({content:r.rawContent,noteBlocks:r.blocks}),s&&e.provider?.capabilities.canWrite&&(o!==null&&a(o),o=i(()=>{u().catch(()=>{})},eB))},acceptSaved:e=>t(t=>({...t.content===e.rawContent&&JSON.stringify(Object.values(t.noteBlocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))===JSON.stringify(Object.values(e.blocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))?{noteBlocks:e.blocks}:{},sourceRevision:e.sourceRevision,lastSavedContent:e.rawContent})),restoreBlock:async e=>{if(!r)throw Error(`Note persistence is unavailable.`);await u();let i=n(),a=Mz({rawContent:i.content,blocks:i.noteBlocks,sourceRevision:i.sourceRevision},e),o=await r.saveNote({noteId:e.noteId,rawContent:a.rawContent,blocks:a.blocks,expectedSourceRevision:i.sourceRevision}),s=Zz(o.rawContent,{noteBlocks:o.blocks,sourceRevision:o.sourceRevision});t({content:o.rawContent,noteBlocks:o.blocks,sourceRevision:o.sourceRevision,lastSavedContent:o.rawContent,currentEntry:o,sections:s.sections,blocks:s.blocks})},startPinnedRun:async e=>{await c.catch(()=>{});let i=n(),a=i.currentEntry?.id??i.loadedRouteId;if(!a||!r)throw Error(`Save the note before starting a workout.`);try{let n=await Ij({noteId:a,rawContent:i.content,blocks:i.noteBlocks,expectedSourceRevision:i.sourceRevision},e,en(),void 0,r);return t({capturedRun:n,noteBlocks:n.note.blocks,sourceRevision:n.note.sourceRevision,currentEntry:{...i.currentEntry,...n.note,updatedAt:Date.now(),targetDate:i.currentEntry?.targetDate??Date.now(),schemaVersion:1},lastSavedContent:n.note.rawContent,saveError:null}),n.block}catch(e){throw t({saveState:`error`,saveError:e instanceof Error?e.message:String(e)}),e}},setActiveBlockId:e=>t({activeBlockId:e}),setSaveState:e=>t({saveState:e}),flushSave:async()=>{o!==null&&a(o),o=null,await u()},markSaved:e=>t({lastSavedContent:e,saveState:`saved`}),setResults:e=>t({results:e}),resetResults:()=>t({results:[]}),setCurrentEntry:e=>{if(e&&e.id!==n().currentEntry?.id){let n=Zz(e.rawContent,{noteBlocks:e.blocks,sourceRevision:Math.max(1,e.sourceRevision??0)});t({currentEntry:e,content:e.rawContent,noteBlocks:n.noteBlocks,sections:n.sections,blocks:n.blocks,sourceRevision:e.sourceRevision??0,lastSavedContent:e.rawContent})}else t({currentEntry:e})},setHistoryEntries:e=>t({historyEntries:e}),setPanelLayouts:e=>t({panelLayouts:e}),expandPanel:(e,n)=>t(t=>{let r=t.panelLayouts[e]??{viewId:e,panelSpans:{},expandedPanelId:null},i=r.expandedPanelId?r.panelSpans:{...r.panelSpans};return{panelLayouts:{...t.panelLayouts,[e]:{...r,panelSpans:{...i,[n]:3},expandedPanelId:n}}}}),collapsePanel:e=>t(t=>{let n=t.panelLayouts[e];return n?{panelLayouts:{...t.panelLayouts,[e]:{...n,expandedPanelId:null}}}:t}),setAttachments:e=>t({attachments:e}),addAttachment:async r=>{let i=e.notePersistence,a=e.provider,o=n().currentEntry?.id;if(!o||!a?.capabilities.canWrite||!i)return;console.log(`[WorkbenchSession] Processing attachment: ${r.name}`);let s=await Fb.process(r),{v7:c}=await at(async()=>{let{v7:e}=await import(`./vendor-BiwvmytJ.js`).then(e=>e.At);return{v7:e}},__vite__mapDeps([0,1,2]));console.log(`[WorkbenchSession] Saving attachment to entry ${o}`),await i.mutateNote(o,{attachments:{add:[{id:c(),label:s.label,mimeType:s.mimeType,data:s.data,timeSpan:s.timeSpan??{start:Date.now(),end:Date.now()}}]}}),t({attachments:(await i.getNote(o,{projection:`workbench`,includeAttachments:!0})).attachments??[]}),console.log(`[WorkbenchSession] Attachment saved successfully`)},deleteAttachment:async r=>{let i=e.notePersistence,a=n().currentEntry?.id;!a||!i||(await i.mutateNote(a,{attachments:{remove:[r]}}),t({attachments:(await i.getNote(a,{projection:`workbench`,includeAttachments:!0})).attachments??[]}))},patchCurrentEntryResults:e=>t(t=>t.currentEntry?{currentEntry:{...t.currentEntry,results:e}}:t),completeWorkout:async(e,i)=>{let a=n().capturedRun,o=i??a?.session.id;if(!o||!r?.finishSession)throw Error(`The saved run pin is unavailable.`);let s=await r.finishSession(o,e,e.endTime);return t(t=>({results:[...t.results,e]})),s.id},loadEntry:async r=>{let i=e.notePersistence,a=e.provider;if(!i||!a)return null;let{routeId:o,routeView:s,routeSectionId:c,routeResultId:l,resultFromLocationState:u,initialActiveEntryId:d,propInitialContent:f}=r;if(n().setContent(``),n().setBlocks([]),t({currentEntry:null,loadedRouteId:o??null}),o){if(a.mode===`history`||a.mode===`static`)try{let e=l?{mode:`by-result-id`,resultId:l}:c&&s===`review`?{mode:`latest-for-section`,blockId:c}:{mode:`latest`},d=await i.getNote(o,{projection:s===`review`?`review`:`workbench`,includeAttachments:!0,includeSections:!0,resultSelection:e}).catch(async t=>(console.warn(`[WorkbenchSession] Note persistence projection failed, falling back to provider entry:`,{routeId:o,projection:s===`review`?`review`:`workbench`,resultSelectionMode:e.mode,err:t}),a.getRecord(o)));if(d){let e=Zz(d.rawContent,{noteBlocks:d.blocks,sourceRevision:Math.max(1,d.sourceRevision??0)});return t({currentEntry:d,content:d.rawContent,sections:e.sections,blocks:e.blocks,noteBlocks:e.noteBlocks,sourceRevision:d.sourceRevision??0,lastSavedContent:d.rawContent,saveState:`saved`}),s===`review`&&u&&t(e=>e.currentEntry?{currentEntry:{...e.currentEntry,results:u}}:e),r.onLoaded?.(d),d}if(a.mode===`static`){let e=await Fz(o);if(e)return n().setContent(e),null}}catch(e){console.error(`[WorkbenchSession] Failed to load entry for ID:`,o,e)}}else d&&e.navigate?.({type:`goToPlan`,noteId:d});return n().setContent(f??``),null},setActiveSegmentIds:e=>t({activeSegmentIds:e}),setActiveStatementIds:e=>t({activeStatementIds:e}),setAnalytics:(e,n)=>t({analyticsSegments:e,analyticsGroups:n}),appendOutputStatement:e=>t(t=>{let n=[...t.outputStatementList,e],{segments:r,groups:i}=Az(t.runtime);return t.runtime?{outputStatementList:n,analyticsSegments:r,analyticsGroups:i}:{outputStatementList:n}}),clearOutputStatementList:()=>t({outputStatementList:[]}),feedLogOutputs:(e,n)=>{let{segments:r,groups:i}=jz(e,n);t({logOutputList:e,analyticsSegments:r,analyticsGroups:i})},toggleAnalyticsSegment:(e,n,r)=>t(t=>{let i=new Set(t.selectedAnalyticsIds);if(n?.shiftKey&&t.lastSelectedAnalyticsId!==null&&r){let n=r.indexOf(t.lastSelectedAnalyticsId),a=r.indexOf(e);if(n!==-1&&a!==-1){let e=Math.min(n,a),t=Math.max(n,a);r.slice(e,t+1).forEach(e=>i.add(e))}}else n?.ctrlKey?i.has(e)?i.delete(e):i.add(e):(i.clear(),i.add(e));return{selectedAnalyticsIds:i,lastSelectedAnalyticsId:e}}),setUserOverride:(e,n)=>t(t=>{let r=new Map(t.userOutputOverrides);return r.set(e,ca.from(n,e)),{userOutputOverrides:r}}),clearUserOverride:e=>t(t=>{let n=new Map(t.userOutputOverrides);return n.delete(e),{userOutputOverrides:n}}),setGridViewPreset:e=>t({gridViewPreset:e}),setHoveredBlockKey:e=>t({hoveredBlockKey:e}),setDocumentItems:e=>t({documentItems:e}),setSelectedBlock:e=>t({selectedBlock:e,selectedBlockId:e?.id??null}),setSelectedBlockId:e=>t({selectedBlockId:e}),setCursorLine:e=>t({cursorLine:e}),setHighlightedLine:e=>t({highlightedLine:e}),setSubscriptionManager:e=>{t({subscriptionManager:e}),Jz.setSubscriptionRegistry(e)},setViewMode:e=>t({viewMode:e}),setRuntime:e=>{for(let e of s)e();if(s=[],e){let r=Az(e);t({runtime:e,outputStatementList:[],analyticsSegments:r.segments,analyticsGroups:r.groups}),s.push(e.subscribeToOutput(()=>{n().appendOutputStatement({})})),s.push(e.subscribeToStack(e=>{let n=e.blocks[0],r=new Set;for(let t of e.blocks)r.add(ki(t.key.toString()));let i=new Set;if(n&&Array.isArray(n.sourceIds))for(let e of n.sourceIds)i.add(e);t({activeSegmentIds:r,activeStatementIds:i})}));let i=cM();if(i?.connected){let t=new Uz(i);s.push(e.subscribeToStack(e=>t.onStackSnapshot(e)),e.subscribeToOutput(e=>t.onOutput(e)),()=>t.dispose());try{t.onStackSnapshot(e.getStackSnapshot())}catch{}}}else t({runtime:null,outputStatementList:[]})},setExecution:e=>t({execution:e}),setHandles:e=>t({handles:e}),getNote:async(e,t)=>{if(!r)throw Error(`[WorkbenchSession] getNote called without a notePersistence port`);return r.getNote(e,t)},resetStore:()=>{o!==null&&(a(o),o=null);for(let e of s)e();s=[],t({...$z})}}});return t.length>0&&c.subscribe(e=>{for(let n of t)n(e)}),Object.assign(c,{__nowProvider:n})}var nB=tB();function rB(e){let t=nB;return nB=e,t}function iB(){return nB}var aB=e=>Nt(nB,e),oB=({nowProvider:e,notePersistence:t,provider:n,navigate:r,children:i})=>{let a=(0,W.useMemo)(()=>tB({nowProvider:e,notePersistence:t,provider:n,navigate:r}),[e,t,n,r]);return(0,W.useEffect)(()=>{let e=rB(a);return()=>{rB(e),a.getState().resetStore()}},[a]),W.createElement(W.Fragment,null,i)},sB={getEventsByTimeRange:(e,t)=>Z.getEventsByTimeRange(e,t),getEventsByMetricDates:e=>Z.getEventsByMetricDates(e),getEventsByResult:e=>Z.getEventsByResult(e),getEventsForNote:e=>Z.getEventsForNote(e),getEventsByContent:e=>Z.getEventsByContent(e),scanAll:()=>Z.scanAll(),appendEvents:e=>Z.appendEvents(e),finalizeSummaries:(e,t)=>Z.finalizeSummaries(e,t),deleteEvents:e=>Z.deleteEvents(e)},cB={getAllNotes:()=>Z.getAllNotes(),getNotesByIds:async e=>[...(await Z.getDetailBatches(e)).values()].map(e=>e.note),getNoteIdsForTag:async e=>new Set((await Z.getNotesForTag(e)).map(e=>e.id)),getNoteTagLabels:async e=>(await Z.getTagsForNote(e)).map(e=>e.label),queryDomain:async e=>{if(!Z.queryDomain)return;let t=await Z.queryDomain({...e,plan:`notes`});return t&&t.plan===`notes`?t:void 0}},lB={getAllBlocks:()=>Z.getAllBlockIndex(),queryDomain:async e=>{if(!Z.queryDomain)return;let t=await Z.queryDomain({...e,plan:`blocks`});return t&&t.plan===`blocks`?t:void 0}},uB=class{async getAllEfforts(){let e=jO();return e.isInitialized()||await EO(e),[...e.list()]}},dB=new m_,fB={events:[],notes:[]},pB={events:[],notes:[]};dB.set(`@session`,fB),dB.set(`@today`,pB);function mB(){let e=iB().getState(),t=e.runtime?.getOutputStatements()??[],n=e.currentEntry;return fB.notes=n?[{id:n.id,title:n.title,createdAt:n.createdAt,date:n.targetDate,rawContent:n.rawContent,sourceRevision:n.sourceRevision??1,blocks:n.blocks??{}}]:[],t.length===0?(fB.events=[],fB):(fB.events=T_(t.map(vm),{noteId:n?.id??``,resultId:`live:${n?.id??`session`}`,origin:`playground`,workoutTimestamp:n?.targetDate}),fB)}function hB(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 Qg(e.date??e.createdAt,r)}async function gB(e,t){let n=Qg(e.instant,e.timeZone),r=r_(n,e.timeZone),i=r_($g(n,1),e.timeZone),[a,o,s,c]=await Promise.all([Z.getEventsByTimeRange(r,i),Z.getAllNotes(),Z.getAllPageNotes(),Z.getAllPages()]),l=a.filter(e=>e.timestamp>=r&&e.timestamp<i),u=new Map(c.map(e=>[e.id,e])),d=new Map;for(let e of s){let t=d.get(e.noteId);t?t.push(e):d.set(e.noteId,[e])}let f=[];for(let t of o)hB(t,d.get(t.id)??[],u,e.timeZone)===n&&f.push(t);t===yB&&(pB.events=l,pB.notes=f,mB())}var _B=null,vB=null,yB=0,bB=!1,xB=new Set;function SB(){for(let e of xB)e()}function CB(e,t){vB=t;let n=++yB;return _B=gB(e,n),_B.then(()=>{n===yB&&wB()},()=>{n===yB&&wB()}),_B}function wB(){bB=!0,SB()}function TB(){let e=Kg(),t=Qg(e.instant,e.timeZone);return!_B||vB!==t?CB(e,t):_B}function EB(){bB=!1;let e=Kg();return CB(e,Qg(e.instant,e.timeZone))}function DB(){return bB}function OB(e){return xB.add(e),()=>{xB.delete(e)}}var kB=class extends pv{async runQuery(e,t){return await TB(),super.runQuery(e,t)}async runPipeline(e,t){return await TB(),super.runPipeline(e,t)}async runFind(e,t){return await TB(),super.runFind(e,t)}async runRows(e,t){return await TB(),super.runRows(e,t)}async run(e,t){return await TB(),super.run(e,t)}};function AB(){return new kB({eventStore:sB,noteStore:cB,blockStore:lB,effortStore:new uB,blockEffortsStore:{getAllFromIndex:(e,t)=>Z.getAllFromIndex(`block_efforts`,e,t)},tagsStore:{getAllFromIndex:(e,t)=>Z.getAllFromIndex(`tags`,e,t),getAll:()=>Z.getAllTags()},noteTagsStore:{getAllFromIndex:(e,t)=>Z.getAllFromIndex(`note_tags`,e,t)},pageStore:{getNotePages:e=>Z.getNotePages(e),getPage:e=>Z.getPage(e),getAllPages:()=>Z.getAllPages(),getAllLinks:()=>Z.getAllPageNotes()},relationStore:{getBatches:e=>Z.getDetailBatches(e)},datasetStore:{getDataset:e=>e===`@session`?mB():dB.getDataset(e)}})}var jB=AB();function MB(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?hL(a):`${t===`segment`?`Segment`:`Event`} ${n+1}`,date:typeof e.date==`string`?e.date:null,subtitle:o.length>0?o.join(` • `):void 0}}function NB(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 PB(e,t,n){e&&e({selected:Math.max(t?.selected??0,n.length),matched:n.length})}function FB(e){return typeof e==`object`&&!!e&&`runFind`in e}var IB=new class e{customService;noteTitleResolver;noteTagsResolver;noteBlockInfo;constructor(e){FB(e)?this.customService=e:(this.customService=e?.service,this.noteTitleResolver=e?.noteTitleResolver,this.noteBlockInfo=e?.noteBlockInfo??!1,this.noteTagsResolver=e?.noteTagsResolver)}get service(){return this.customService??jB}withNoteBlockInfo(){let t=new e({service:this.service,noteTitleResolver:this.noteTitleResolver,noteTagsResolver:this.noteTagsResolver,noteBlockInfo:!0});return Object.prototype.hasOwnProperty.call(this,`query`)&&(t.query=this.query),t}async hydrateEntries(e,t){let n=new Set;for(let r of e)r.sourceNotebook===`journal`&&n.add(r.id),t&&(!r.title||!r.tags||r.tags.length===0)&&n.add(r.id);if(n.size===0)return;let r=await Z.getDetailBatches([...n]);for(let t of e){if(t.sourceNotebook!==`journal`)continue;let e=r.get(t.id),n=va(e?.links??[],e?.pages??[]);t.placements=n;let i=ya(n);t.pageId??=i.pageId,i.pageSlug&&(t.pageSlug=i.pageSlug)}if(t)for(let t of e){let e=r.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){let n=typeof e==`string`?X(e):e;if(!n||n.error)return[];if(_h(n)){if(n.target===`effort`){let e=this.service.runFindEffort?await this.service.runFindEffort(n):await this.service.runFind(n),r=new Map(e.notes.map(e=>[e.id,e])),i=(e.efforts??[]).map(e=>e.ownerNoteId&&r.has(e.ownerNoteId)?cL(r.get(e.ownerNoteId)):vL(e));return PB(t,e.stages,i),i}if(n.target===`block`){let e=await this.service.runFind(n),r=e.blocks.map(mL);return await this.hydrateEntries(r,!0),PB(t,e.stages,r),r}if(n.target===`session`){let e=await this.service.runFind(n);t?.(e.stages);let r;if(this.noteTitleResolver&&e.runs){r=new Map;for(let t of e.runs)if(!r.has(t.noteId)){let e=await this.noteTitleResolver(t.noteId);e&&r.set(t.noteId,e)}}let i=CL(e,{noteTitles:r});return PB(t,e.stages,i),i}if(n.target===`segment`||n.target===`event`){let e=n.target,r=await this.service.runFind(n),i=(r.table?.rows??[]).map((t,n)=>MB(t,e,n));return PB(t,r.stages,i),i}let e=await this.service.runFind(n),r=e.notes.map(cL);if(this.noteTagsResolver?(await this.hydrateEntries(r,!1),await Promise.all(r.map(async e=>{if(!e.tags||e.tags.length===0){let t=await this.noteTagsResolver(e.id);t&&t.length>0&&(e.tags=t)}}))):await this.hydrateEntries(r,!0),PB(t,e.stages,r),this.noteBlockInfo)for(let t=0;t<r.length;t++){let n=r[t],i=e.notes[t];n.excerpt=pL(i.rawContent);try{Pa(i.rawContent,i.blocks,i.sourceRevision)}catch{continue}let a=Object.values(i.blocks).sort((e,t)=>e.from-t.from).find(e=>e.kind===`wod`),o=a&&ja(i.rawContent).find(e=>e.from===a.from&&e.scriptBlock);if(a&&o?.scriptBlock){let e=o.scriptBlock.content,t=ha(e);n.wodBlock={blockId:a.id,blockVersion:a.version,blockContentId:t,content:e},n.blockContentId=t}}return r}if(n.family===`aggregate`){if(!this.service.runQuery)return[];let e=await this.service.runQuery(n.raw),r=NB(e);return t?.({selected:e.stages?.selected??r.length,matched:r.length}),r}return[]}};async function LB(e,t=IB,n){return t.query(e,n)}function RB(e){return e?e.map(e=>e.kind===`wql`?`${e.id}|${e.query}|${e.limit??``}`:`s:${e.id}`).join(`;`):``}async function zB(e){try{let t=(await LB(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 BB(e){let t=RB(e),n=(0,W.useRef)(e);n.current=e;let[r,i]=(0,W.useState)(()=>e&&!e.some(e=>e.kind===`wql`)?e:[]);return(0,W.useEffect)(()=>{let e=n.current;if(!e){i([]);return}if(!e.some(e=>e.kind===`wql`)){i(e);return}let t=!1;return Promise.all(e.map(e=>e.kind===`wql`?zB(e):Promise.resolve(e))).then(e=>{t||i(e)}),()=>{t=!0}},[t]),r}function VB(){let[e]=un(`h`,{shallow:!0}),[t]=un(`s`,{shallow:!0}),{navState:n}=aP(),r=n.activeL3Id??``;return e||t||r||``}function HB({entry:e,active:t,onActivate:n}){let r=e.onRun;return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:K(`group flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors`,e.muted?`text-[11.5px]`:`text-[13px]`,t?`bg-primary/10 font-semibold text-primary`:K(`hover:bg-muted/60 hover:text-foreground`,e.muted?`text-muted-foreground/70`:`text-muted-foreground`)),children:[e.icon&&(0,G.jsx)(e.icon,{className:`size-4 shrink-0`}),e.timestamp&&(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/60`,children:e.timestamp}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 line-clamp-2 break-words`,title:e.label,children:e.label}),e.badge&&(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/50`,children:e.badge}),r&&(0,G.jsx)(`span`,{role:`button`,tabIndex:-1,title:e.runIcon===`link`?`View workout`:e.runIcon===`stop`?`Stop workout`:e.runIcon===`edit`?`Edit note`:`Start workout`,onClick:t=>{t.stopPropagation(),e.onRun?.()},className:`flex size-5 shrink-0 items-center justify-center rounded text-primary opacity-0 transition-all group-hover:opacity-100 hover:bg-primary/10`,children:e.runIcon===`link`?(0,G.jsx)(re,{className:`size-3.5`}):e.runIcon===`stop`?(0,G.jsx)(_,{className:`size-3.5`}):e.runIcon===`edit`?(0,G.jsx)(fe,{className:`size-3.5`}):(0,G.jsx)(V,{className:`size-3.5`})})]})}function UB({entries:e,activeId:t,onSection:n}){let r=dn(),{scrollToSection:i}=aP(),a=EF(),o=e=>{if(a(),n)return n(e);if(e.onRun)return e.onRun();if(e.to)return r(e.to);if(e.sectionId)return i(e.sectionId)};return(0,G.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.map(e=>e.kind===`section`?e.entries.length===0?null:(0,G.jsxs)(`div`,{className:`mt-1 flex flex-col gap-0.5 first:mt-0`,children:[(0,G.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,G.jsx)(UB,{entries:e.entries,activeId:t,onSection:n})]},e.id):e.kind===`wql`?null:e.kind===`widget`?(0,G.jsx)(`div`,{className:`px-1 py-1`,children:e.render()},e.id):(0,G.jsx)(HB,{entry:e,active:t!=null&&e.sectionId===t,onActivate:o},e.id))})}function WB(){let e=dn(),{scrollToSection:t}=aP();return{navigate:(t,n)=>e(t,{replace:n?.replace}),setQueryParam:(e,t)=>{},scrollToSection:t}}function GB(){let e=WB(),t=EF();return n=>{t(),AL(n.action,e)}}function KB(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 qB({items:e}){let{navState:t}=aP(),n=En(),r=GB();return(0,G.jsx)(FF,{children:e.map(e=>{let i=KB(e,t,n);return e.children&&e.children.length>0?(0,G.jsx)(FL,{title:e.label,count:e.children.length,defaultOpen:e.children.some(e=>KB(e,t,n)),collapsible:e.id!==`syntax-group`,children:e.children.map(e=>{let i=KB(e,t,n);return(0,G.jsxs)(LF,{onClick:()=>r(e),current:i,children:[e.icon&&(0,G.jsx)(e.icon,{"data-slot":`icon`}),(0,G.jsx)(RF,{children:e.label})]},e.id)})},e.id):(0,G.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,G.jsxs)(LF,{onClick:e.disabled?void 0:()=>r(e),current:i,disabled:e.disabled,"aria-label":e.disabled?`${e.label} (coming soon)`:void 0,className:K(`flex-1`,e.disabled&&`opacity-60`),children:[e.icon&&(0,G.jsx)(e.icon,{"data-slot":`icon`}),(0,G.jsx)(RF,{children:e.disabled?`+`:e.label})]}),e.onTogglePin&&(0,G.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 text-muted-foreground hover:text-foreground transition-opacity`,children:(0,G.jsx)(gt,{className:`size-3.5`})})]},e.id)})})}function JB({navSpec:e}){let{tree:t,navState:n,dispatch:r,contextNav:i}=aP(),a=En(),o=BB(e),s=(t??[]).find(e=>e?.id===n.activeL1Id)??null,c=i?.pathname===a.pathname?i:null;return(0,G.jsxs)(MF,{children:[(0,G.jsx)(NF,{children:(0,G.jsx)(`div`,{className:`px-2 pt-3 pb-1 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s?.label??`Wod Wiki`})}),(0,G.jsxs)(PF,{children:[(()=>{if(c||!s)return null;if(s.panel){let e=s.panel;return(0,G.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,G.jsx)(e,{item:s,navState:n,dispatch:r})})}return s.children&&s.children.length>0?(0,G.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,G.jsx)(qB,{items:s.children})}):null})(),c?(0,G.jsx)(`div`,{className:`pt-1`,children:(0,G.jsx)(UB,{entries:c.spec})}):o.length>0&&(0,G.jsx)(`div`,{className:`pt-1`,children:(0,G.jsx)(UB,{entries:o})})]})]})}var YB=`0.50.2190`,XB=`https://github.com/bitcobblers/wod-wiki/releases`;function ZB(e){return/-pr\.\d+$/.test(e)?XB:`${XB}/tag/v${e}`}function QB({onSearch:e,onCreate:t}){let{tree:n,navState:r,dispatch:i}=aP(),a=dn(),o=En(),s=EF(),c={navigate:(e,t)=>a(e,{replace:t?.replace}),setQueryParam:()=>{},scrollToSection:()=>{}},l=(n??[]).filter(e=>e!=null&&e.icon!=null&&e.id!==`settings`&&e.id!==`buy-me-a-coffee`),u=o.pathname.startsWith(`/settings`);o.pathname===`/`||o.pathname;let d=`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`;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{onClick:()=>{s(),a(`/`)},title:`Wod Wiki home`,"aria-label":`Wod Wiki home`,className:`group relative mb-3 grid size-8 shrink-0 place-items-center rounded-xl bg-primary text-primary-foreground shadow-md shadow-primary/20 rotate-3`,children:[(0,G.jsx)(be,{size:17}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Wod Wiki home`}),(0,G.jsx)(`span`,{role:`tooltip`,className:d,children:`Wod Wiki home`})]}),(0,G.jsx)(`nav`,{"aria-label":`Primary`,className:`flex flex-col items-center gap-1.5`,children:l.map(e=>{let t=e.icon,n=KB(e,r,o);return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{s(),i({type:`SET_ACTIVE_L1`,id:e.id}),AL(e.action,c)},title:e.label,"aria-label":e.label,"aria-current":n?`page`:void 0,className:K(`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:[n&&(0,G.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,G.jsx)(t,{className:`size-5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:e.label}),(0,G.jsx)(`span`,{role:`tooltip`,className:d,children:e.label})]},e.id)})}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsxs)(`button`,{type:`button`,onClick:e,title:`Search (⌘/)`,"aria-label":`Search`,className:`group relative grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,G.jsx)(ge,{className:`size-5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Search`}),(0,G.jsx)(`span`,{role:`tooltip`,className:d,children:`Search (⌘/)`})]}),(0,G.jsxs)(`a`,{href:IR,target:`_blank`,rel:`noopener noreferrer`,title:`Buy Me a Coffee`,"aria-label":`Buy Me a Coffee`,className:`group relative grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,G.jsx)(LR,{className:`size-5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Buy Me a Coffee`}),(0,G.jsx)(`span`,{role:`tooltip`,className:d,children:`Buy Me a Coffee`})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{s(),a(`/settings/profile`)},title:`Profile`,"aria-label":`Profile`,"aria-current":o.pathname.startsWith(`/settings/profile`)?`page`:void 0,"data-testid":`nav-profile`,className:K(`group relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,o.pathname.startsWith(`/settings/profile`)?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[o.pathname.startsWith(`/settings/profile`)&&(0,G.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,G.jsx)(Le,{className:`size-5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Profile`}),(0,G.jsx)(`span`,{role:`tooltip`,className:d,children:`Profile`})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{s(),a(`/settings/appearance`)},title:`Settings`,"aria-label":`Settings`,"aria-current":u?`page`:void 0,"data-testid":`nav-settings`,className:K(`group relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,u?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[u&&(0,G.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,G.jsx)(Yn,{className:`size-5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Settings`}),(0,G.jsxs)(`span`,{role:`tooltip`,className:`pointer-events-none absolute bottom-0 left-full z-50 ml-2 w-max rounded-md border border-border bg-popover px-2 py-1 text-xs text-popover-foreground opacity-0 shadow-md transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[`Settings (v`,YB,`)`]})]})]})}function $B({activations:e,activeSection:t,variant:n,deps:r,className:i}){return(0,G.jsx)(`nav`,{className:K(`lg:sticky z-20 flex items-center gap-1 px-4 py-2 bg-background/95 backdrop-blur-sm border-b border-border/50 overflow-x-auto`,n===`top-fixed`?`lg:top-0`:`lg:top-[104px]`,i),children:e.map(e=>(0,G.jsx)(`button`,{onClick:()=>AL(e.action,r),className:K(`px-3 py-1.5 rounded-full text-[10px] font-black uppercase tracking-[0.12em] whitespace-nowrap transition-all ring-1`,t===e.id?`bg-primary text-primary-foreground ring-primary/30 shadow-md`:`bg-muted/50 text-muted-foreground ring-transparent hover:bg-muted hover:ring-border`),children:e.label},e.id))})}var eV=class e{now;name=`tick`;timestamp;data;static _counter=0;constructor(t,n=Hl){this.now=n;let r=this.now.nowMs();e._counter++,this.timestamp=new Date(r+e._counter),this.data=t}},tV=20,nV=e=>{let[t,n]=(0,W.useState)(`idle`),[r,i]=(0,W.useState)(0),[a,o]=(0,W.useState)(0),[s,c]=(0,W.useState)(null),l=(0,W.useRef)(null),u=(0,W.useRef)(null),d=(0,W.useCallback)(()=>{l.current&&=(clearInterval(l.current),null),n(`idle`)},[]),f=(0,W.useCallback)(()=>{if(e)try{let t=new eV(void 0,e.nowProvider);e.handle(t),o(e=>e+1)}catch{d(),n(`error`)}},[e,d]);(0,W.useEffect)(()=>{if(e)return e.subscribeToStack(e=>{e.blocks.length===0&&t!==`completed`&&(l.current&&=(clearInterval(l.current),null),n(`completed`))})},[e,t]),(0,W.useEffect)(()=>()=>{l.current&&=(clearInterval(l.current),null)},[]);let p=(0,W.useCallback)(()=>{if(!e){console.warn(`useRuntimeExecution: Cannot start execution without a runtime`);return}if(t===`running`){console.warn(`useRuntimeExecution: Runtime is already running`);return}t===`paused`&&e.handle({name:`timer:resume`,timestamp:new Date,data:{}}),n(`running`);let i=e?.nowProvider?.nowMs()??Hl.nowMs();u.current=i-r,r===0&&c(i),l.current=setInterval(f,tV)},[e,t,r,f]),m=(0,W.useCallback)(()=>{l.current&&=(clearInterval(l.current),null),e&&e.handle({name:`timer:pause`,timestamp:new Date,data:{}}),n(`paused`)},[e]),h=(0,W.useCallback)(()=>{l.current&&=(clearInterval(l.current),null),i(0),o(0),n(`idle`),c(null),u.current=null},[e]),g=(0,W.useCallback)(()=>{!e||t===`running`||(n(`paused`),f())},[e,t,f]);return(0,W.useEffect)(()=>{if(t!==`running`||!u.current)return;let n=setInterval(()=>{i((e?.nowProvider?.nowMs()??Hl.nowMs())-u.current)},100);return()=>clearInterval(n)},[t,e?.nowProvider]),(0,W.useEffect)(()=>()=>{l.current&&=(clearInterval(l.current),null)},[]),(0,W.useEffect)(()=>{h()},[e,h]),(0,W.useMemo)(()=>({status:t,elapsedTime:r,stepCount:a,startTime:s,start:p,pause:m,stop:d,reset:h,step:g}),[t,r,a,s,p,m,d,h,g])},rV=(e,t)=>!e||!Array.isArray(e)?0:e.reduce((e,n)=>{if(`started`in n){let r=n.started,i=n.ended??t;return e+Math.max(0,i-r)}let r=n.start instanceof Date?n.start.getTime():n.start||0,i=n.stop?n.stop instanceof Date?n.stop.getTime():n.stop:t;return e+Math.max(0,i-r)},0);function iV(e,t){let n=t,r=()=>{let t=e?.getMemoryByTag(n)[0];if(t)return n===`round`?t.metrics[0]:t.metrics[0]?.value},[i,a]=(0,W.useState)(r);return(0,W.useEffect)(()=>{if(!e){a(void 0);return}a(r());let t=e.getMemoryByTag(n)[0];if(t)return t.subscribe(e=>{a(n===`round`?e[0]:e[0]?.value)})},[e,t]),i}function aV(e){return iV(e,`round`)}function oV(e){return iV(e,`display`)}function sV(e){let t=aV(e),n=oV(e);return(0,W.useMemo)(()=>{if(!t)return null;let e=n?.roundDisplay??(t.total===void 0?`Round ${t.current}`:`Round ${t.current} of ${t.total}`),r=t.total===void 0?void 0:Math.min(1,(t.current-1)/t.total);return{current:t.current,total:t.total,label:e,progress:r}},[t,n?.roundDisplay])}var cV=(0,W.createContext)(void 0),lV=({runtime:e,children:t})=>(0,G.jsx)(cV.Provider,{value:e,children:t});function uV(){let e=(0,W.useContext)(cV);if(!e)throw Error(`useScriptRuntime must be used within ScriptRuntimeProvider`);return e}function dV(e){let t=uV(),n=e===void 0?t:e,[r,i]=(0,W.useState)(()=>n?.getOutputStatements?.()??[]);return(0,W.useEffect)(()=>{if(!n){i([]);return}return i(n.getOutputStatements()),n.subscribeToOutput?.(()=>{i(n.getOutputStatements())})},[n]),(0,W.useMemo)(()=>{let e=new Map,t=new Map,n=[],i=[];for(let a of r){e.set(a.id,a);let r=t.get(a.sourceBlockKey)??[];switch(r.push(a),t.set(a.sourceBlockKey,r),a.outputType){case`segment`:n.push(a);break;case`metric`:i.push(a)}}let a=n.filter(e=>e.completionReason!==void 0);return{outputs:r,byId:e,byBlockKey:t,segments:n,completions:a,metrics:i}},[r])}function fV(e){let t=uV(),n=e===void 0?t:e,[r,i]=(0,W.useState)(()=>n?.getLiveAnalytics?.()??[]);return(0,W.useEffect)(()=>{if(!n){i([]);return}return i(n.getLiveAnalytics?.()??[]),n.subscribeToOutput?.(()=>{i(n.getLiveAnalytics?.()??[])})},[n]),r}function pV(){let e=uV(),[t,n]=(0,W.useState)({type:`initial`,blocks:e.stack.blocks,depth:e.stack.count,clockTime:e.clock.currentDate});return(0,W.useEffect)(()=>e.subscribeToStack(e=>{n(e)}),[e]),t}function mV(){return pV().blocks}function hV(){let e=mV(),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`metric:next`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,W.useMemo)(()=>{for(let t of e){let e=t.getMemoryByTag(`metric:next`);if(e.length===0)continue;let n=ca.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 gV(){let e=mV(),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`time`)[0];if(e){let r=e.subscribe(()=>{n(e=>e+1)});t.push(r)}}return()=>{t.forEach(e=>e())}},[e]),(0,W.useMemo)(()=>{let t=[];for(let n of e){let e=n.getMemoryByTag(`time`)[0];if(!e)continue;let r=e.metrics[0]?.value;r&&t.push({block:n,timer:r,isPinned:r.role===`primary`})}return t},[e,t])}function _V(){let e=gV();return(0,W.useMemo)(()=>{if(e.length===0)return;let t=e[0];return t.block.blockType===`Rest`?t:[...e].reverse().find(e=>e.isPinned)||t},[e])}function vV(){let e=gV(),t=_V();return(0,W.useMemo)(()=>t?e.filter(e=>e.block!==t.block):[],[e,t])}function yV(){let e=mV(),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`controls`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,W.useMemo)(()=>{let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r].getMemoryByTag(`controls`);if(i.length===0)continue;let a=i[0].metrics.map(e=>e.value).filter(Boolean),o=r===e.length-1;for(let e of a)e.isPinned?t.push(e):o&&n.push(e)}let r=new Set,i=[];for(let e of t)r.has(e.id)||(r.add(e.id),i.push(e));for(let e of n)r.has(e.id)||(r.add(e.id),i.push(e));return i},[e,t])}function bV(){let e=mV(),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`metric:display`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,W.useMemo)(()=>{if(e.length===0)return;let t=[],n=[...e].reverse();return n.forEach((e,r)=>{if(e.blockType===`Root`&&!e.label)return;let i=e.getMemoryByTag(`metric:display`),a=i.map(e=>e.metrics);if(a.length===0&&!e.label)return;let o=r===n.length-1,s=i.length>1?i.map(e=>e.metrics):void 0;t.push({block:e,displayRows:a,label:e.label,depth:r,isLeaf:o,metricGroups:s})}),t.length>0?t:void 0},[e,t])}function xV(e){let t=uV(),n=(0,W.useMemo)(()=>t.stack.blocks.find(t=>t.key.toString()===e),[t,e]),[r,i]=(0,W.useState)(()=>n?.getMemoryByTag(`time`)[0]?.metrics[0]?.value);(0,W.useEffect)(()=>t.stack.subscribe(()=>{let n=t.stack.blocks.find(t=>t.key.toString()===e);if(n){let e=n.getMemoryByTag(`time`)[0];i(e?.metrics[0]?.value)}else i(void 0)}),[t,e]),(0,W.useEffect)(()=>{if(!n){i(void 0);return}let e=n.getMemoryByTag(`time`)[0];if(i(e?.metrics[0]?.value),e)return e.subscribe(e=>{i(e[0]?.value)})},[n]);let a=(0,W.useMemo)(()=>r?.spans??[],[r]),o=a.length>0&&a[a.length-1].ended===void 0,[s,c]=(0,W.useState)(Au()),l=(0,W.useMemo)(()=>a.length===0?0:rV(a,s),[a,s]);return(0,W.useEffect)(()=>{if(!o)return;let e,t=()=>{c(Au()),e=requestAnimationFrame(t)};return t(),()=>cancelAnimationFrame(e)},[o]),{elapsed:l,isRunning:o,timeSpans:a}}var SV=(0,W.createContext)(void 0),CV=(0,W.createContext)(null),wV={getState:()=>iB().getState(),setState:(e,t)=>{let n=iB();typeof e==`function`?n.setState(e(n.getState()),t):n.setState(e,t)},subscribe:e=>iB().subscribe(e)},TV=({factory:e,children:t})=>{let[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),u=(0,W.useRef)(e);u.current=e;let d=(0,W.useRef)(null),f=(0,W.useRef)(null),p=(0,W.useRef)(!1),m=(0,W.useCallback)(()=>{f.current&&=(f.current.dispose(),null),a(null),wV.getState().setSubscriptionManager(null);let e=d.current;if(d.current=null,e)try{u.current.disposeRuntime(e)}catch(e){console.error(`[RuntimeProvider] Error disposing runtime:`,e)}r(null),l(null)},[]),h=(0,W.useCallback)((e,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 _m(i);e.add(new gm({id:`local`})),f.current=e,a(e),wV.getState().setSubscriptionManager(e)}else f.current=null,a(null),wV.getState().setSubscriptionManager(null)}catch(e){console.error(`[RuntimeProvider] Error creating runtime:`,e),l(e instanceof Error?e:Error(String(e))),d.current=null}finally{p.current=!1,s(!1)}}},[]);(0,W.useEffect)(()=>()=>{if(f.current&&f.current.dispose(),d.current)try{u.current.disposeRuntime(d.current)}catch(e){console.error(`[RuntimeProvider] Error disposing runtime on unmount:`,e)}},[]);let g={runtime:n,isInitializing:o,error:c,initializeRuntime:h,disposeRuntime:m};return(0,G.jsx)(SV.Provider,{value:g,children:(0,G.jsx)(CV.Provider,{value:i,children:t})})};function EV({factory:e,children:t}){return(0,G.jsx)(TV,{factory:e,children:t})}var DV=`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`,OV=`flex flex-col flex-1 min-w-0 xl:max-w-[984px] 2xl:max-w-none min-h-screen lg:rounded-[2.5rem]`;function kV({id:e,title:t,subtitle:n,titleAccessory:r,actions:i,queryBar:a,subheader:o,titleTestId:s,className:c}){return(0,G.jsxs)(`div`,{id:e,"data-page-sticky-boundary":`true`,className:K(`max-lg:hidden lg:sticky lg:top-0 z-30 border-b border-border/50 bg-background/95 backdrop-blur-md transition-colors`,c),children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-4 sm:px-6 lg:px-8 py-2 sm:py-2.5`,children:[t&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 sm:gap-3 min-w-0`,children:[(0,G.jsx)(`div`,{className:`h-5 w-1.5 shrink-0 rounded-full bg-primary`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h1`,{"data-testid":s,className:`text-base sm:text-lg font-black tracking-tight text-foreground leading-none truncate`,children:t}),n&&(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground truncate`,children:n})]}),r]})]}),a&&(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:a}),i&&(0,G.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0 ml-auto`,children:i})]}),o&&(0,G.jsx)(`div`,{className:`bg-background/40`,children:o})]})}function AV({ids:e,enabled:t=!0,rootMargin:n=`-10% 0px -40% 0px`,threshold:r=[0,.3,1],onChange:i,shouldAcceptChange:a,scrollDirection:o=`ratio`,dataAttribute:s,debounceMs:c=0}){let l=(0,W.useRef)(``),u=(0,W.useRef)(i),d=(0,W.useRef)(a),f=(0,W.useRef)(null),p=(0,W.useRef)(1);(0,W.useEffect)(()=>{u.current=i},[i]),(0,W.useEffect)(()=>{d.current=a},[a]);let m=e.filter(Boolean).join(`\0`),h=r.join(`,`),g=(0,W.useMemo)(()=>m?m.split(`\0`):[],[m]),_=(0,W.useMemo)(()=>h.split(`,`).map(Number),[h]),v=(0,W.useCallback)(()=>{f.current&&=(clearTimeout(f.current),null)},[]);(0,W.useEffect)(()=>{if(!t||g.length===0||typeof IntersectionObserver>`u`)return;let e=new Map,r=e=>s?e.getAttribute(s):e.id||null,i;if(o===`topmost-when-up`){let e=window.scrollY,t=()=>{let t=window.scrollY;t!==e&&(p.current=t>e?1:-1),e=t};window.addEventListener(`scroll`,t,{passive:!0}),i=()=>window.removeEventListener(`scroll`,t)}let a=new IntersectionObserver(t=>{if(t.forEach(t=>{let n=r(t.target);n&&(t.isIntersecting?e.set(n,t.intersectionRatio):e.delete(n))}),e.size===0)return;let n=``;if(o===`topmost-when-up`&&p.current===-1){let t=1/0;e.forEach((e,r)=>{let i=g.indexOf(r);i>=0&&i<t&&(t=i,n=r)})}else{let t=-1;e.forEach((e,r)=>{e>t&&(t=e,n=r)})}!n||n===l.current||d.current&&!d.current(n)||(l.current=n,c>0?(v(),f.current=setTimeout(()=>{u.current(n),f.current=null},c)):u.current(n))},{rootMargin:n,threshold:_});return g.forEach(e=>{let t=s?document.querySelector(`[${s}="${e}"]`):document.getElementById(e);t&&a.observe(t)}),()=>{a.disconnect(),v(),i?.()}},[t,g,_,n,o,s,c,v])}function jV({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]=un(`s`,{defaultValue:o??a[0]?.id??``,shallow:!0,history:`replace`}),[f,p]=(0,W.useState)(c?.[0]?.id??``);if(AV({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}),AV({ids:c?.map(e=>e.id)??[],enabled:u,rootMargin:`-20% 0px -50% 0px`,threshold:[0,.25,.5,.75],onChange:p}),u){let e=c.map(e=>({id:e.id,label:e.label,action:{type:`scroll`,sectionId:e.id}}));return(0,G.jsxs)(`div`,{className:K(`flex flex-col min-h-screen bg-background`,l),children:[s,(0,G.jsx)($B,{activations:e,activeSection:f,variant:`top-fixed`,deps:{navigate:()=>{},setQueryParam:()=>{},scrollToSection:e=>{let t=document.getElementById(e);if(t){let e=t.getBoundingClientRect().top+window.scrollY-64;window.scrollTo({top:e,behavior:`smooth`})}}}}),(0,G.jsx)(`div`,{className:`flex-1`,children:c.map(e=>{let t=(0,G.jsx)(`div`,{id:e.id,"data-section-id":e.id,className:`py-12 lg:py-16 px-6 lg:px-10 border-b border-border/30`,children:e.content},e.id);return e.runtimeFactory?(0,G.jsx)(EV,{factory:e.runtimeFactory,children:t},e.id):t})})]})}return(0,G.jsx)(`div`,{className:K(`relative flex w-full min-h-screen justify-start items-start`,l),children:(0,G.jsxs)(`div`,{className:K(OV,DV),children:[(0,G.jsx)(kV,{title:e,titleAccessory:t,actions:n,subheader:r}),(0,G.jsx)(`div`,{className:`flex-1`,children:i})]})})}var MV=`[data-page-sticky-boundary="true"]`,NV=0;function PV(e,t=NV){if(typeof document>`u`)return e;let n=Array.from(document.querySelectorAll(MV)).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 FV(e,t=NV){let[n,r]=(0,W.useState)(e);return(0,W.useEffect)(()=>{let n=0,i=()=>r(PV(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(MV).forEach(e=>o?.observe(e));let s=typeof MutationObserver>`u`?void 0:new MutationObserver(()=>{document.querySelectorAll(MV).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 IV({top:e,label:t,icon:n,badge:r,meta:i,testId:a,className:o}){return(0,G.jsxs)(`div`,{"data-testid":a,className:K(`sticky z-10 flex items-center gap-2 border-y border-border/60 bg-card/95 px-6 py-2 shadow-[0_1px_2px_rgba(0,0,0,0.03)] backdrop-blur`,o),style:{top:`${e}px`},children:[n,(0,G.jsx)(`span`,{className:`min-w-0 truncate text-xs font-bold text-foreground`,children:t}),r,i&&(0,G.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[10px] text-muted-foreground`,children:i})]})}var LV=(0,W.createContext)(null),RV=(0,W.createContext)(null);function zV({children:e}){let[t,n]=(0,W.useState)(null);return(0,G.jsx)(RV.Provider,{value:n,children:(0,G.jsx)(LV.Provider,{value:t,children:e})})}function BV({className:e}){let t=(0,W.useContext)(RV);return(0,G.jsx)(`div`,{ref:t,className:e,"data-testid":`mobile-query-slot`})}function VV(){return(0,W.useContext)(LV)}function HV({editor:e,title:t,subtitle:n,titleTestId:r,actions:i,timerOverlay:a,reviewOverlay:o,isTimerOpen:s=!1,isReviewOpen:c=!1,onCloseTimer:l,onCloseReview:u,className:d}){return(0,G.jsxs)(`div`,{className:K(`relative flex w-full min-h-screen justify-start items-start`,d),children:[(0,G.jsxs)(`div`,{className:K(OV,DV),children:[(0,G.jsx)(kV,{title:t,subtitle:n,titleTestId:r,actions:i}),(0,G.jsx)(`main`,{className:`flex-1 min-w-0 max-w-full`,children:e})]}),s&&a&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,G.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,G.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,G.jsx)(`button`,{onClick:l,className:`px-3 py-1.5 rounded-md text-sm font-bold text-muted-foreground hover:text-foreground bg-muted/60 hover:bg-muted transition-colors`,children:`Close`})}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:a})]})}),c&&o&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,G.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,G.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,G.jsx)(`button`,{onClick:u,className:`px-3 py-1.5 rounded-md text-sm font-bold text-muted-foreground hover:text-foreground bg-muted/60 hover:bg-muted transition-colors`,children:`Close`})}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:o})]})})]})}function UV(e){return e.map(e=>{if(e.panel){let t=e.panel;return{kind:`widget`,id:e.id,render:()=>(0,W.createElement)(`div`,{className:`flex flex-col gap-1`},(0,W.createElement)(`span`,{className:`px-1 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`},e.label),(0,W.createElement)(t,{currentPath:``,location:null}))}}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})}var WV=W.createContext(null);function GV(){let e=W.useContext(WV);if(!e)throw Error(`DropdownMenu components must be used inside a DropdownMenu`);return e}function KV(){let e=W.useContext(WV);return W.useCallback(()=>{e?.setIsOpen(!1)},[e])}var qV=({children:e,open:t,onOpenChange:n})=>{let r=W.useContext(WV),i=W.useId(),a=r?`${r.portalChain}/${i}`:i,[o,s]=W.useState(t??!1),c=W.useRef(null),[l,u]=W.useState(-1),d=W.useRef(new Map),[,f]=W.useReducer(e=>e+1,0);W.useEffect(()=>{t!==void 0&&s(t)},[t]);let p=W.useCallback(e=>{s(e),u(-1),n?.(e)},[n]),m=W.useCallback((e,t)=>{d.current.set(e,t),f()},[]),h=W.useCallback(e=>{d.current.delete(e),f()},[]),g=W.useCallback(e=>Array.from(d.current.keys()).indexOf(e),[]),_=d.current.size,v=W.useMemo(()=>({isOpen:o,setIsOpen:p,triggerRef:c,registerItem:m,unregisterItem:h,getItemIndex:g,activeIndex:l,setActiveIndex:u,itemCount:_,menuId:i,portalChain:a}),[o,p,m,h,g,l,_,i,a]);return(0,G.jsx)(WV.Provider,{value:v,children:(0,G.jsx)(`div`,{ref:c,className:`relative inline-block`,children:e})})},JV=W.forwardRef(({className:e,children:t,asChild:n,...r},i)=>{let{isOpen:a,setIsOpen:o}=GV(),s=e=>{e.stopPropagation(),o(!a)};return n&&W.isValidElement(t)?W.cloneElement(t,{...r,onClick:s}):(0,G.jsx)(`button`,{ref:i,className:e,onClick:s,...r,children:t})});JV.displayName=`DropdownMenuTrigger`;var YV=W.forwardRef(({className:e,children:t,align:n=`center`,side:r=`bottom`,...i},a)=>{let{isOpen:o,setIsOpen:s,triggerRef:c,setActiveIndex:l,itemCount:u,menuId:d,portalChain:f}=GV(),p=W.useRef(null),m=a||p,[h,g]=W.useState({top:0,bottom:0,left:0,width:0}),_=r===`bottom`,[v,y]=W.useState(!1);W.useEffect(()=>{if(!o||!c.current)return;let e=c.current.getBoundingClientRect();g({top:e.bottom+8,bottom:window.innerHeight-e.top+8,left:e.left,width:e.width}),y(!1)},[o,c]),W.useLayoutEffect(()=>{if(!o||!_||!m.current)return;let e=m.current.getBoundingClientRect();y(h.top+e.height>window.innerHeight)},[o,_,h.top,m]),W.useEffect(()=>{if(!o||u===0)return;let e=setTimeout(()=>{l(0)},0);return()=>clearTimeout(e)},[o,u,l]),W.useEffect(()=>{if(!o)return;let e=e=>{let t=e.target;if(m.current&&m.current.contains(t)||c.current&&c.current.contains(t))return;let n=t.closest?.(`[data-dropdown-chain]`)?.getAttribute(`data-dropdown-chain`);n&&n.split(`/`).includes(d)||s(!1)},t=setTimeout(()=>{document.addEventListener(`mousedown`,e)},0);return()=>{clearTimeout(t),document.removeEventListener(`mousedown`,e)}},[o,s,m,c,d]);let b=e=>{if(u!==0)switch(e.key){case`ArrowDown`:e.preventDefault(),l(e=>e<u-1?e+1:0);break;case`ArrowUp`:e.preventDefault(),l(e=>e>0?e-1:u-1);break;case`Home`:e.preventDefault(),l(0);break;case`End`:e.preventDefault(),l(u-1);break;case`Escape`:e.preventDefault(),s(!1),c.current?.querySelector(`button`)?.focus();break;case`Tab`:s(!1)}};if(!o)return null;let x={position:`fixed`,zIndex:9999};return r===`top`||v?x.bottom=h.bottom:x.top=h.top,n===`end`?x.right=window.innerWidth-h.left-h.width:n===`start`?x.left=h.left:(x.left=h.left+h.width/2,x.transform=`translateX(-50%)`),NC.createPortal((0,G.jsx)(`div`,{ref:m,role:`menu`,"data-dropdown-chain":f,className:K(`min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95`,e),style:x,onKeyDown:b,...i,children:t}),document.body)});YV.displayName=`DropdownMenuContent`;var XV=W.forwardRef(({className:e,disabled:t,inset:n,onClick:r,onKeyDown:i,...a},o)=>{let{setIsOpen:s,registerItem:c,unregisterItem:l,getItemIndex:u,activeIndex:d}=GV(),f=W.useId(),p=W.useRef(null),m=W.useCallback(e=>{p.current=e,typeof o==`function`?o(e):o&&(o.current=e)},[o]);W.useEffect(()=>(c(f,p),()=>l(f)),[f,c,l]);let h=u(f)===d;return W.useEffect(()=>{h&&p.current?.focus()},[h]),(0,G.jsx)(`div`,{ref:m,role:`menuitem`,tabIndex:t?-1:h?0:-1,"aria-disabled":t,"data-active":h?`true`:void 0,className:K(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors`,`focus:bg-accent focus:text-accent-foreground`,`data-[active]:bg-accent data-[active]:text-accent-foreground`,n&&`pl-8`,t&&`pointer-events-none opacity-50`,e),onClick:e=>{t||(r?.(e),s(!1))},onKeyDown:e=>{t||(i?.(e),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r?.(e),s(!1)))},...a})});XV.displayName=`DropdownMenuItem`;var ZV=W.forwardRef(({className:e,inset:t,...n},r)=>(0,G.jsx)(`div`,{ref:r,className:K(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));ZV.displayName=`DropdownMenuLabel`;var QV=W.forwardRef(({className:e,...t},n)=>(0,G.jsx)(`div`,{ref:n,className:K(`-mx-1 my-1 h-px bg-muted`,e),...t}));QV.displayName=`DropdownMenuSeparator`;function $V({className:e,children:t,...n}){return(0,G.jsx)(`div`,{className:K(`px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,e),...n,children:t})}var eH=[{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`}],tH=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function nH(e,t){return new Date(e,t+1,0).getDate()}function rH(e,t){let n=new Date(e,t,1).getDay();return n===0?6:n-1}function iH(e,t){let n=X(e);if(n.error)return e;if(!t||t===`all`)return ug({...n,window:void 0});let r=X(`:note ${t}`);return r.error||r.family!==`find`||!r.window?e:ug({...n,window:r.window})}function aH(e){let t=X(e);return t.error||t.family===`pipeline`?null:`window`in t?t.window??null:null}function oH({query:e,onQueryChange:t,highlightDates:n=new Set,className:r}){let i=(0,W.useMemo)(()=>aH(e),[e]),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(()=>new Date),l=s.getFullYear(),u=s.getMonth(),d=(0,W.useMemo)(()=>i?i.kind===`relative`?`last ${i.size}${i.unit}`:i.end?`from ${i.start} to ${i.end}`:`from ${i.start}`:`All time`,[i]),f=(0,W.useMemo)(()=>{if(!i)return null;if(i.kind===`range`)return{start:i.start,end:i.end??i.start};let e=new Date,t=new Date;return i.unit===`d`?t.setDate(e.getDate()-i.size):t.setDate(e.getDate()-i.size*7),{start:pF(t),end:pF(e)}},[i]),p=(0,W.useMemo)(()=>{let e=nH(l,u),t=rH(l,u),n=[];for(let e=0;e<t;e++)n.push(null);for(let t=1;t<=e;t++)n.push(t);return n},[l,u]),m=n=>{if(!a)o(n),t(iH(e,`from ${n} to ${n}`));else{let[r,i]=a<=n?[a,n]:[n,a];o(null),t(iH(e,`from ${r} to ${i}`))}},h=e=>{e.stopPropagation(),c(new Date(l,u-1,1))},g=e=>{e.stopPropagation(),c(new Date(l,u+1,1))},_=s.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`}),v=pF(new Date);return(0,G.jsxs)(`div`,{className:K(`relative inline-flex items-center`,r),children:[(0,G.jsxs)(qV,{children:[(0,G.jsx)(JV,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,"data-testid":`wql-window-picker-trigger`,className:`flex h-9 items-center gap-1.5 rounded-lg border border-border bg-background px-2.5 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,G.jsx)(lr,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`font-mono text-xs`,children:d}),(0,G.jsx)(Gt,{className:`size-3 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,G.jsxs)(YV,{align:`end`,className:`w-72 p-3`,children:[(0,G.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1 border-b border-border/60 pb-2`,children:eH.map(n=>{let r=n.value===`all`?!i:i?.kind===`relative`&&`last ${i.size}${i.unit}`===n.value;return(0,G.jsx)(`button`,{type:`button`,"data-testid":`wql-window-preset-${n.value}`,onClick:()=>{o(null),t(iH(e,n.value))},className:K(`rounded-md px-2 py-1 text-[11px] font-medium transition-colors`,r?`bg-primary text-primary-foreground`:`bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground`),children:n.label},n.value)})}),(0,G.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:h,"data-testid":`wql-calendar-prev-month`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":`Previous month`,children:(0,G.jsx)(pn,{className:`size-4`})}),(0,G.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:_}),(0,G.jsx)(`button`,{type:`button`,onClick:g,"data-testid":`wql-calendar-next-month`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":`Next month`,children:(0,G.jsx)(On,{className:`size-4`})})]}),(0,G.jsx)(`div`,{className:`mb-1 grid grid-cols-7 gap-1`,children:tH.map(e=>(0,G.jsx)(`div`,{className:`text-center text-[10px] font-medium text-muted-foreground`,children:e},e))}),(0,G.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,"data-testid":`wql-calendar-grid`,children:p.map((e,t)=>{if(e===null)return(0,G.jsx)(`div`,{className:`size-8`},`empty-${t}`);let r=`${l}-${String(u+1).padStart(2,`0`)}-${String(e).padStart(2,`0`)}`,i=f&&r>=f.start&&r<=f.end,o=f&&r===f.start||a===r,s=f&&r===f.end,c=r===v,d=n.has(r);return(0,G.jsxs)(`button`,{type:`button`,"data-testid":`wql-calendar-day-${r}`,onClick:()=>m(r),className:K(`relative flex size-8 items-center justify-center rounded-md text-xs transition-colors`,o||s?`bg-primary font-bold text-primary-foreground`:i?`bg-primary/15 font-semibold text-primary`:c?`border border-primary font-semibold text-primary`:`text-foreground hover:bg-muted`),children:[(0,G.jsx)(`span`,{children:e}),d&&!o&&!s&&(0,G.jsx)(`span`,{className:`absolute bottom-0.5 size-1 rounded-full bg-primary`})]},r)})}),a&&(0,G.jsxs)(`div`,{className:`mt-2 text-center text-[10px] text-muted-foreground`,children:[`Select second date to complete range (starting from `,a,`)`]})]})]}),i&&(0,G.jsx)(`button`,{type:`button`,"data-testid":`wql-window-picker-clear`,onClick:()=>{o(null),t(iH(e,null))},title:`Clear time window`,"aria-label":`Clear time window`,className:`ml-1 grid size-7 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,G.jsx)(yr,{className:`size-3.5`})})]})}function sH({onOpen:e}){let t=KV();return(0,G.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{t(),e()},"data-testid":`query-settings-trigger`,className:`w-full justify-start gap-2 rounded-lg text-xs`,children:[(0,G.jsx)(zn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`truncate`,children:`Query settings`})]})}function cH(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 lH=[{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??``)}],uH={note:lH,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?``:gL(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`sessionLoad`,label:`Session Load`,level:`session`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``}],result:[{id:`title`,label:`Title`,level:`result`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`elapsedTime`,label:`Elapsed Time`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:gL(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`totalTonnage`,label:`Total Tonnage`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``},{id:`tis`,label:`TIS Score`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.tis,formatValue:e=>typeof e==`number`?e.toFixed(1):``},{id:`prBadges`,label:`PR Badges`,level:`result`,defaultVisible:!0,align:`center`,getValue:e=>e.detail&&/\bPR\b/.test(e.detail)?`PR`:``,formatValue:e=>String(e??``)}],segment:[{id:`splitDuration`,label:`Split Duration`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:gL(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`roundIndex`,label:`Round/Lap Index`,level:`segment`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`reps`,label:`Reps`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.reps,formatValue:e=>e==null?``:String(e)},{id:`load`,label:`Load`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``},{id:`pacingTier`,label:`Pacing / HR Tier`,level:`segment`,defaultVisible:!0,align:`center`,getValue:e=>e.effort?.intensityTier||e.execution?.effortSlug||``,formatValue:e=>String(e??``)}],effort:[{id:`label`,label:`Label`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.label||e.title,formatValue:e=>String(e??``)},{id:`canonicalSlug`,label:`Canonical Slug`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.slug||e.id,formatValue:e=>String(e??``)},{id:`discipline`,label:`Discipline`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.discipline??``,formatValue:e=>String(e??``)},{id:`met`,label:`MET Score`,level:`effort`,defaultVisible:!0,align:`right`,getValue:e=>e.effort?.met,formatValue:e=>typeof e==`number`?e.toFixed(1):``},{id:`intensityTier`,label:`Intensity Tier`,level:`effort`,defaultVisible:!0,align:`center`,getValue:e=>e.effort?.intensityTier??``,formatValue:e=>String(e??``)},{id:`aliases`,label:`Aliases`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.aliases??[],formatValue:e=>Array.isArray(e)?e.join(`, `):String(e??``)}]};function dH(e){return uH[e]??lH}function fH(e){return dH(e).filter(e=>e.defaultVisible).map(e=>e.id)}var pH=1023;function mH(e){return e===`/`?`canvas:home`:`canvas:${e.replace(/^\//,``)}`}function hH(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}=Za(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=e;if(e.startsWith(`wods/examples/`))i=`markdown/canvas/`+e.replace(/^wods\/examples\//,``);else if(e.startsWith(`wods/`))i=`markdown/canvas/`+e.replace(/^wods\//,``);else if(e.startsWith(`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 gH(e){return(e.examples??[]).length>0||e.commands.some(e=>e.pipeline.length>0)}function _H(e){let t=new Map,n=null;for(let r of e)gH(r)&&(n=r),t.set(r.id,n);return t}function vH(){let[e,t]=(0,W.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: ${pH}px)`).matches);return(0,W.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(max-width: ${pH}px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var yH=[{id:`cards`,label:`Cards`,icon:_e},{id:`rows`,label:`Rows`,icon:rt},{id:`feed`,label:`Feed`,icon:Wt},{id:`agenda`,label:`Agenda`,icon:h},{id:`planner`,label:`Planner`,icon:vn}];function bH({streamControls:e}){let t=e.availableLayouts;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,"data-testid":`l3-stream-controls`,children:[e.onOpenQuerySettings&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`This page`}),(0,G.jsx)(sH,{onOpen:e.onOpenQuerySettings})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Date window`}),(0,G.jsx)(oH,{query:e.query,onQueryChange:e.onQueryChange,className:`w-full justify-between`})]}),e.availableGroupDims.length>0&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Group by`}),(0,G.jsx)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":`l3-groupby-options`,children:e.availableGroupDims.map(t=>{let n=e.groupDims.some(e=>e.toLowerCase()===t.id.toLowerCase());return(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-xs text-foreground/80 hover:bg-muted/60 transition-colors`,"data-testid":`l3-groupby-${t.id}`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>e.onToggleGroupDim(t.id),className:`size-3.5 rounded border-border accent-primary cursor-pointer`}),(0,G.jsx)(`span`,{children:t.label})]},t.id)})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Layout`}),(0,G.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,"data-testid":`l3-layout-options`,children:yH.filter(e=>!t||t.includes(e.id)).map(t=>{let n=t.icon,r=e.settings.layout===t.id;return(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>e.onLayoutChange(t.id),"data-testid":`l3-layout-${t.id}`,className:`flex min-h-8 items-center justify-center gap-1 rounded-md border px-1.5 py-1 text-[11px] font-medium transition-colors ${r?`border-border/80 bg-card text-foreground shadow-sm`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:[(0,G.jsx)(n,{"aria-hidden":!0,className:`size-3`}),t.label]},t.id)})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Fields`}),(0,G.jsx)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":`l3-field-options`,children:dH(e.level).map(t=>{let n=e.settings.visibleFields.includes(t.id);return(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-xs text-foreground/80 hover:bg-muted/60 transition-colors`,"data-testid":`l3-field-${t.id}`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>e.onToggleField(t.id),className:`size-3.5 rounded border-border accent-primary cursor-pointer`}),(0,G.jsx)(`span`,{children:t.label})]},t.id)})})]}),(0,G.jsx)(dR,{})]})}function xH(){let e=vH(),{streamControls:t}=aP();return!e||!t?null:(0,G.jsx)(bH,{streamControls:t})}function SH({spec:e,pageAction:t}){let{l3Items:n,streamControls:r}=aP(),i=BB(e),a=(0,W.useMemo)(()=>UV(n),[n]),o=VB();return i.length===0&&a.length===0&&!r&&!t?null:(0,G.jsxs)(`div`,{className:`flex flex-col px-3 py-4 gap-4`,children:[r&&(0,G.jsx)(`div`,{className:`pb-3 border-b border-border/50`,children:(0,G.jsx)(bH,{streamControls:r})}),i.length>0&&(0,G.jsx)(UB,{entries:i,activeId:o}),a.length>0&&(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(`div`,{className:`px-2 pb-1 pt-1 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`On this page`}),(0,G.jsx)(UB,{entries:a,activeId:o})]}),t&&(0,G.jsx)(`div`,{className:`pt-2 border-t border-border/50`,children:t})]})}var CH=`wodwiki:fabAlignment`,wH=[{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 TH(){try{return EH(localStorage.getItem(CH))}catch{return}}function EH(e){return e===`right`||e===`left`?e:void 0}var DH=typeof window>`u`?void 0:TH();typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===CH&&(DH=EH(e.newValue))});function OH(e){DH=e;try{e===`right`?localStorage.removeItem(CH):localStorage.setItem(CH,e)}catch{}window.dispatchEvent(new StorageEvent(`storage`,{key:CH,newValue:e}))}function kH(){let[e,t]=(0,W.useState)(()=>DH??`right`);return(0,W.useEffect)(()=>{let e=e=>{e.key===CH&&t(EH(e.newValue)??`right`)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),[e,OH]}function AH({onOpen:e}){return(0,G.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":`Search`,title:`Search`,"data-testid":`search-fab`,className:K(`size-14 rounded-full flex items-center justify-center`,`bg-primary text-primary-foreground shadow-lg`,`hover:bg-primary/90 active:scale-95 transition-all`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`),children:[(0,G.jsx)(ge,{className:`size-6`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Search`})]})}var jH=(0,W.createContext)(null),MH=(0,W.createContext)(!1),NH=(0,W.createContext)(null);function PH(){return(0,W.useContext)(jH)!==null}function FH({primary:e,navbar:t,children:n,label:r,fallback:i=!1}){let a=(0,W.useContext)(jH),o=(0,W.useContext)(MH),s=vH(),c=(0,W.useId)(),l=a!==null&&!o&&s&&!i,u=a!==null&&i,d=n!=null&&n!==!1,f=(0,W.useMemo)(()=>(0,G.jsx)(MH.Provider,{value:!0,children:n}),[n]),p=l||u,m=(0,W.useRef)(null);return m.current={id:c,primary:e,navbar:t,children:f,hasContent:d,label:r??`Page options`,fallback:i},(0,W.useEffect)(()=>{if(p)return a.register(m.current),()=>a.unregister(c)},[p,a,c]),(0,W.useEffect)(()=>{p&&a.register(m.current)},[p,a,e,t,f,d,r,i]),i||a&&s&&!o?null:(0,G.jsx)(MH.Provider,{value:!0,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t,e,n]})})}function IH({onSearch:e,children:t}){let[n,r]=(0,W.useState)([]),i=(0,W.useCallback)(e=>r(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}),[]),a=(0,W.useCallback)(e=>r(t=>t.filter(t=>t.id!==e)),[]),o=(0,W.useMemo)(()=>({register:i,unregister:a}),[i,a]),s=(0,W.useMemo)(()=>{for(let e=n.length-1;e>=0;--e)if(!n[e].fallback)return n[e].navbar??null;return null},[n]);return(0,G.jsx)(jH.Provider,{value:o,children:(0,G.jsxs)(NH.Provider,{value:s,children:[t,(0,G.jsx)(RH,{registrations:n,onSearch:e})]})})}function LH(){let e=(0,W.useContext)(NH);return e?(0,G.jsx)(G.Fragment,{children:e}):null}function RH({registrations:e,onSearch:t}){let n=vH(),[r]=kH(),i=FC(),[a,o]=(0,W.useState)(!1),s=(0,W.useCallback)(()=>o(!1),[]),c=(0,W.useRef)(null),l=(0,W.useRef)(null),u=(0,W.useRef)(null),d=(0,W.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(!e[t].fallback)return e[t]},[e]),f=(0,W.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(e[t].fallback)return e[t]},[e]);(0,W.useLayoutEffect)(()=>{a&&c.current?.focus({preventScroll:!0})},[a]);let p=!!(d?.hasContent||f?.hasContent);return!n||!t&&!d&&!f?null:(0,G.jsxs)(`div`,{"data-testid":`actions-dock`,className:K(`lg:hidden relative z-40 mt-4 flex flex-col items-center gap-2`,`transition-[transform,visibility] duration-200 ease-out`,r===`left`?`self-start items-start`:`self-end items-end`),children:[(0,G.jsxs)(`div`,{className:`relative z-40 flex flex-col items-center gap-2`,children:[t&&(0,G.jsx)(AH,{onOpen:()=>{o(!1),t()}}),d?.primary&&(0,G.jsx)(`div`,{className:`[&_button]:min-h-11 [&_button]:min-w-11`,children:d.primary})]}),a&&p&&(0,G.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-hidden":`true`,className:`fixed inset-0 z-30 cursor-default`,onClick:()=>o(!1)}),(0,G.jsx)(`div`,{ref:c,role:`dialog`,"aria-label":d?.label??f?.label??`Page options`,tabIndex:-1,hidden:!a||!p,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),o(!1))},className:K(a&&p?`flex`:`hidden`,`relative z-40 w-60 max-w-[calc(100vw-2rem)] flex-col gap-3 overflow-y-auto rounded-2xl bg-card p-3 shadow-xl ring-1 ring-foreground/5 outline-none`,`[&_button]:min-h-11 [&_button]:min-w-11`),style:{maxHeight:`calc(${i.height===null?`100dvh`:`${i.height}px`} - 6rem - env(safe-area-inset-bottom))`},children:(0,G.jsxs)(TF,{close:s,children:[(0,G.jsx)(`div`,{ref:l,className:`contents`,children:d?.children}),d?.children&&f?.children&&(0,G.jsx)(`div`,{className:`my-1 border-t border-border/60`,"aria-hidden":`true`}),(0,G.jsx)(`div`,{ref:u,className:`contents`,children:f?.children})]})}),p&&(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-label":d?.label??f?.label??`Page options`,title:d?.label??f?.label??`Page options`,"aria-expanded":a,"data-testid":`actions-overflow`,className:K(`relative z-40 flex size-12 items-center justify-center rounded-full`,`bg-card text-foreground shadow-lg ring-1 ring-foreground/10`,`hover:bg-muted active:scale-95 transition-all`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`),children:[a?(0,G.jsx)(rr,{className:`size-6`}):(0,G.jsx)(I,{className:`size-6`}),(0,G.jsx)(`span`,{className:`sr-only`,children:d?.label??f?.label??`Page options`})]})]})}function zH(){return(0,G.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,G.jsx)(`path`,{d:`M2 6.75C2 6.33579 2.33579 6 2.75 6H17.25C17.6642 6 18 6.33579 18 6.75C18 7.16421 17.6642 7.5 17.25 7.5H2.75C2.33579 7.5 2 7.16421 2 6.75ZM2 13.25C2 12.8358 2.33579 12.5 2.75 12.5H17.25C17.6642 12.5 18 12.8358 18 13.25C18 13.6642 17.6642 14 17.25 14H2.75C2.33579 14 2 13.6642 2 13.25Z`})})}function BH(){return(0,G.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,G.jsx)(`path`,{d:`M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z`})})}function VH(){let{tree:e,navState:t,contextNav:n}=aP(),r=En(),i=EF();return!e.find(e=>e.id===t.activeL1Id)?.applyFooter||n?.pathname===r.pathname?null:(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border/50 bg-card p-3`,children:(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`h-11 w-full rounded-lg bg-primary text-sm font-medium text-primary-foreground`,children:`Apply`})})}function HH({open:e,close:t,onSearch:n,children:r}){return(0,G.jsxs)(nt,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,G.jsx)(Qe,{transition:!0,className:`fixed inset-0 bg-black/30 dark:bg-black/30 transition data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in`}),(0,G.jsx)(i,{transition:!0,className:`fixed inset-y-0 left-0 w-full transition duration-300 ease-out data-closed:-translate-x-full`,children:(0,G.jsx)(TF,{close:t,children:(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 bg-card`,children:[(0,G.jsx)(`div`,{className:`flex h-full w-14 shrink-0 flex-col items-center border-r border-zinc-950/5 bg-background/72 py-3 dark:border-white/5 [&_a]:size-11 [&_button]:size-11`,children:(0,G.jsx)(QB,{onSearch:()=>{t(),n?.()}})}),(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,G.jsx)(`div`,{className:`flex items-center px-4 pt-3`,children:(0,G.jsxs)(Fn,{as:Tz,"aria-label":`Close navigation`,title:`Close navigation`,children:[(0,G.jsx)(BH,{}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Close navigation`})]})}),(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:r}),(0,G.jsx)(VH,{})]})]})})})]})}function UH({open:e,close:t,children:n}){return(0,G.jsxs)(nt,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,G.jsx)(Qe,{transition:!0,className:`fixed inset-0 bg-black/30 dark:bg-black/30 transition data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in`}),(0,G.jsx)(i,{transition:!0,className:`fixed inset-y-0 right-0 w-full transition duration-300 ease-out data-closed:translate-x-full`,children:(0,G.jsx)(TF,{close:t,children:(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-card`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-end px-4 pt-3`,children:(0,G.jsxs)(Fn,{as:Tz,"aria-label":`Close page options`,title:`Close page options`,children:[(0,G.jsx)(BH,{}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Close page options`})]})}),(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:n}),(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border/50 bg-card p-3`,children:(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`h-11 w-full rounded-lg bg-primary text-sm font-medium text-primary-foreground`,children:`Apply`})})]})})})]})}function WH({navbar:e,sidebar:t,onSearch:n,secondary:r,pageAction:i,hideDesktopSidebar:a,children:o}){let[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(!1),{streamControls:d,l3Items:f}=aP(),p=!!(r&&r.length>0||f&&f.length>0||d||i),m=(0,W.useMemo)(()=>{let e=X(d?.query??``);return!e.error&&_h(e)&&e.filters.length>0},[d?.query]);return(0,W.useEffect)(()=>{if(!s&&!l)return;let e=()=>{c(!1),u(!1)};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[s,l]),(0,G.jsx)(zV,{children:(0,G.jsx)(IH,{onSearch:n,children:(0,G.jsx)(`div`,{className:`relative isolate flex min-h-svh w-full bg-background max-lg:flex-col lg:flex-row`,children:(0,G.jsxs)(`div`,{className:`flex flex-1 w-full max-lg:flex-col lg:flex-row`,children:[(0,G.jsxs)(`nav`,{"aria-label":`Main`,className:`hidden lg:flex`,children:[(0,G.jsx)(`div`,{className:`w-14 shrink-0 sticky top-0 h-svh flex flex-col items-center border-r border-zinc-950/5 dark:border-white/5 bg-background/72 backdrop-blur-sm z-40 py-3`,children:(0,G.jsx)(QB,{onSearch:n??(()=>{})})}),(0,G.jsx)(`div`,{className:K(`w-60 shrink-0 sticky top-0 self-start h-svh min-h-0 overflow-hidden border-r border-zinc-950/5 dark:border-white/5 bg-background/72 backdrop-blur-sm flex flex-col`,a&&`lg:hidden`),children:t})]}),(0,G.jsx)(HH,{open:s,close:()=>c(!1),onSearch:n,children:t}),(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col min-w-0 xl:max-w-[984px] 2xl:max-w-none`,children:[(0,G.jsxs)(`header`,{"data-page-sticky-boundary":`true`,className:`lg:hidden sticky top-0 z-20 flex items-center px-2 sm:px-4 bg-card`,children:[(0,G.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,G.jsxs)(Tz,{onClick:()=>c(!0),"aria-label":`Open navigation`,title:`Open navigation`,children:[(0,G.jsx)(zH,{}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Open navigation`})]})}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),p&&(0,G.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,G.jsxs)(Tz,{onClick:()=>u(!0),"aria-label":`Open page options`,title:`Open page options`,children:[(0,G.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,G.jsx)(zn,{className:`size-5`}),m&&(0,G.jsx)(`span`,{"data-testid":`drawer-filters-active`,className:`absolute -top-1 -right-1 size-2 rounded-full bg-amber-500`,"aria-hidden":`true`})]}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Open page options`})]})})]}),(0,G.jsxs)(`main`,{className:`flex flex-1 flex-col lg:min-w-0`,children:[(0,G.jsx)(`div`,{className:`grow w-full max-lg:pb-48 lg:overflow-visible`,children:o}),(0,G.jsx)(GH,{})]})]}),(0,G.jsx)(`aside`,{className:`hidden 2xl:flex w-60 shrink-0 sticky top-0 h-svh flex-col overflow-y-auto bg-background/72 backdrop-blur-sm`,children:(0,G.jsx)(SH,{spec:r,pageAction:i})}),(0,G.jsx)(UH,{open:l,close:()=>u(!1),children:(0,G.jsx)(SH,{spec:r,pageAction:i})})]})})})})}function GH(){let e=(0,W.useRef)(null),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(e=>{let t=Math.round(e[0]?.contentRect.height??0);n(e=>e===t?e:t)});r.observe(t,{box:`content-box`});let i=Math.round(t.getBoundingClientRect().height);return n(e=>e===i?e:i),()=>r.disconnect()},[]),(0,W.useEffect)(()=>(document.documentElement.style.setProperty(`--thumb-dock-lift`,`${t}px`),()=>document.documentElement.style.setProperty(`--thumb-dock-lift`,`0px`)),[t]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:K(`lg:hidden fixed inset-x-0 bottom-0 z-30`,t>0&&`bg-card border-t border-border/50 px-3 py-2`),children:(0,G.jsx)(`div`,{ref:e,className:`w-full min-w-0`,children:(0,G.jsx)(BV,{className:`flex w-full min-w-0`})})}),(0,G.jsx)(`div`,{className:`lg:hidden`,"aria-hidden":`true`,style:{height:t}})]})}function KH(e){let t=e.indexOf(`markdown`);return t!==-1&&e.length>t+2?e[t+2]:`General`}function qH(e){return String(to(Za(e).meta,`search`)??``).toLowerCase()===`hidden`}function JH(e){let t=to(Za(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 YH(e){return Object.entries(e).map(([e,t])=>{let n=e.split(`/`),r=n[n.length-1].replace(`.md`,``),i=t,a=to(Za(i).meta,`title`);return{id:e,name:r,displayName:typeof a==`string`&&a.trim()?a.trim():IO(r),category:KH(n),content:i,date:JH(i),searchHidden:qH(i)}})}function XH(){let e=ak();return(0,W.useMemo)(()=>e?YH(e):[],[e])}var ZH={};function QH(e){if(!(`payload`in e))return;let t=e.payload;if(!t||typeof t!=`object`)return;let n=t;return n.targetDate??n.updatedAt}function $H(e,t){let{canvasPage:n,workoutItems:r,recentResults:i,selectWorkout:a}=t;if(e===`/`)return[];if(n){let t=/^\/notebook\//.test(e),i=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=qR(e).split(`
109
+ `;return{statements:dc(ei.create({doc:n,extensions:[zc]}),t),errors:[],success:!0}}catch(e){return{statements:[],errors:[{message:e instanceof Error?e.message:`Unknown parse error`,severity:`error`}],success:!1}}}function Zz(e,t={}){let n=t.sourceRevision??1,r=Na(e,{...t,blocks:t.noteBlocks,sourceRevision:n}),i=ja(e,t),a=[];for(let e of i){if(!Ma(e))continue;let t=Object.values(r).find(t=>t.from===e.from&&t.to===e.to);t&&(e.id=t.id,e.version=t.version,e.scriptBlock&&(e.scriptBlock=Qz({...e.scriptBlock,id:t.id,version:t.version}),a.push(e.scriptBlock)))}return{sections:i,blocks:a,noteBlocks:r,rawContent:e,sourceRevision:n}}function Qz(e){try{let t=Xz(e.content,e.sport);return{...e,statements:t.statements,errors:t.errors,state:t.success?`parsed`:`error`}}catch(t){return zj(`WorkbenchDocumentModel`,`Block parse error:`,t),e}}var $z={content:``,sections:null,noteBlocks:{},sourceRevision:0,capturedRun:null,saveError:null,blocks:[],activeBlockId:null,saveState:`idle`,lastSavedContent:``,loadedRouteId:null,results:[],currentEntry:null,historyEntries:[],panelLayouts:{},attachments:[],runtime:null,execution:{status:`idle`,elapsedTime:0,stepCount:0,startTime:null,start:()=>{},pause:()=>{},stop:()=>{},reset:()=>{},step:()=>{}},handles:{handleStart:()=>{},handlePause:()=>{},handleStop:()=>{},handleNext:()=>{},handleStartWorkoutAction:()=>{}},activeSegmentIds:new Set,activeStatementIds:new Set,analyticsSegments:[],analyticsGroups:[],selectedAnalyticsIds:new Set,lastSelectedAnalyticsId:null,outputStatementList:[],logOutputList:[],userOutputOverrides:new Map,gridViewPreset:`default`,hoveredBlockKey:null,documentItems:[],selectedBlock:null,selectedBlockId:null,cursorLine:1,highlightedLine:null,subscriptionManager:null,viewMode:`plan`},eB=5e3;function tB(e={}){let t=e.listeners??[],n=e.nowProvider??Hl,r=e.notePersistence,i=e.setTimeout??((e,t)=>window.setTimeout(e,t)),a=e.clearTimeout??(e=>{typeof e==`number`&&window.clearTimeout(e)}),o=null,s=[],c=Tn()((t,n)=>{let c=Promise.resolve(),l=async i=>{let a=n(),o=a.currentEntry?.id??a.loadedRouteId;if(!(!o||!r||!e.provider?.capabilities.canWrite)&&(i.rawContent!==a.lastSavedContent||JSON.stringify(Object.values(i.blocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))!==JSON.stringify(Object.values(a.currentEntry?.blocks??{}).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport])))){t({saveState:`saving`,saveError:null});try{let e=await r.saveNote({noteId:o,rawContent:i.rawContent,blocks:i.blocks,expectedSourceRevision:a.sourceRevision,metadata:{title:i.rawContent.match(/^#\s+(.+)$/m)?.[1]?.trim()??`Untitled Session`},noteType:`playground`}),s=n();t({currentEntry:e,...s.content===i.rawContent&&JSON.stringify(Object.values(s.noteBlocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))===JSON.stringify(Object.values(i.blocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))?{noteBlocks:e.blocks}:{},sourceRevision:e.sourceRevision??a.sourceRevision,lastSavedContent:i.rawContent,saveState:`saved`})}catch(e){throw t({saveState:`error`,saveError:e instanceof Error?e.message:String(e)}),e}}},u=()=>{o=null;let e=n(),t={rawContent:e.content,blocks:e.noteBlocks,sourceRevision:e.sourceRevision},r=c.catch(()=>{}).then(()=>l(t));return c=r,r};return{...$z,setContent:r=>{let s=Zz(r,{noteBlocks:n().noteBlocks,sourceRevision:Math.max(1,n().sourceRevision)}),c=n(),l={content:r,sections:s.sections,blocks:s.blocks,noteBlocks:s.noteBlocks};r!==c.lastSavedContent&&(c.saveState===`idle`&&(l.saveState=`changed`),o!==null&&a(o),e.provider&&e.provider.capabilities.canWrite&&(o=i(()=>{u().catch(()=>{})},eB))),t(l)},setBlocks:e=>t({blocks:e}),setEditorIdentity:r=>{let s=JSON.stringify(Object.values(n().noteBlocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))!==JSON.stringify(Object.values(r.blocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]));t({content:r.rawContent,noteBlocks:r.blocks}),s&&e.provider?.capabilities.canWrite&&(o!==null&&a(o),o=i(()=>{u().catch(()=>{})},eB))},acceptSaved:e=>t(t=>({...t.content===e.rawContent&&JSON.stringify(Object.values(t.noteBlocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))===JSON.stringify(Object.values(e.blocks).map(e=>[e.id,e.from,e.to,e.kind,e.dialect,e.sport]))?{noteBlocks:e.blocks}:{},sourceRevision:e.sourceRevision,lastSavedContent:e.rawContent})),restoreBlock:async e=>{if(!r)throw Error(`Note persistence is unavailable.`);await u();let i=n(),a=Mz({rawContent:i.content,blocks:i.noteBlocks,sourceRevision:i.sourceRevision},e),o=await r.saveNote({noteId:e.noteId,rawContent:a.rawContent,blocks:a.blocks,expectedSourceRevision:i.sourceRevision}),s=Zz(o.rawContent,{noteBlocks:o.blocks,sourceRevision:o.sourceRevision});t({content:o.rawContent,noteBlocks:o.blocks,sourceRevision:o.sourceRevision,lastSavedContent:o.rawContent,currentEntry:o,sections:s.sections,blocks:s.blocks})},startPinnedRun:async e=>{await c.catch(()=>{});let i=n(),a=i.currentEntry?.id??i.loadedRouteId;if(!a||!r)throw Error(`Save the note before starting a workout.`);try{let n=await Ij({noteId:a,rawContent:i.content,blocks:i.noteBlocks,expectedSourceRevision:i.sourceRevision},e,en(),void 0,r);return t({capturedRun:n,noteBlocks:n.note.blocks,sourceRevision:n.note.sourceRevision,currentEntry:{...i.currentEntry,...n.note,updatedAt:Date.now(),targetDate:i.currentEntry?.targetDate??Date.now(),schemaVersion:1},lastSavedContent:n.note.rawContent,saveError:null}),n.block}catch(e){throw t({saveState:`error`,saveError:e instanceof Error?e.message:String(e)}),e}},setActiveBlockId:e=>t({activeBlockId:e}),setSaveState:e=>t({saveState:e}),flushSave:async()=>{o!==null&&a(o),o=null,await u()},markSaved:e=>t({lastSavedContent:e,saveState:`saved`}),setResults:e=>t({results:e}),resetResults:()=>t({results:[]}),setCurrentEntry:e=>{if(e&&e.id!==n().currentEntry?.id){let n=Zz(e.rawContent,{noteBlocks:e.blocks,sourceRevision:Math.max(1,e.sourceRevision??0)});t({currentEntry:e,content:e.rawContent,noteBlocks:n.noteBlocks,sections:n.sections,blocks:n.blocks,sourceRevision:e.sourceRevision??0,lastSavedContent:e.rawContent})}else t({currentEntry:e})},setHistoryEntries:e=>t({historyEntries:e}),setPanelLayouts:e=>t({panelLayouts:e}),expandPanel:(e,n)=>t(t=>{let r=t.panelLayouts[e]??{viewId:e,panelSpans:{},expandedPanelId:null},i=r.expandedPanelId?r.panelSpans:{...r.panelSpans};return{panelLayouts:{...t.panelLayouts,[e]:{...r,panelSpans:{...i,[n]:3},expandedPanelId:n}}}}),collapsePanel:e=>t(t=>{let n=t.panelLayouts[e];return n?{panelLayouts:{...t.panelLayouts,[e]:{...n,expandedPanelId:null}}}:t}),setAttachments:e=>t({attachments:e}),addAttachment:async r=>{let i=e.notePersistence,a=e.provider,o=n().currentEntry?.id;if(!o||!a?.capabilities.canWrite||!i)return;console.log(`[WorkbenchSession] Processing attachment: ${r.name}`);let s=await Fb.process(r),{v7:c}=await at(async()=>{let{v7:e}=await import(`./vendor-BiwvmytJ.js`).then(e=>e.At);return{v7:e}},__vite__mapDeps([0,1,2]));console.log(`[WorkbenchSession] Saving attachment to entry ${o}`),await i.mutateNote(o,{attachments:{add:[{id:c(),label:s.label,mimeType:s.mimeType,data:s.data,timeSpan:s.timeSpan??{start:Date.now(),end:Date.now()}}]}}),t({attachments:(await i.getNote(o,{projection:`workbench`,includeAttachments:!0})).attachments??[]}),console.log(`[WorkbenchSession] Attachment saved successfully`)},deleteAttachment:async r=>{let i=e.notePersistence,a=n().currentEntry?.id;!a||!i||(await i.mutateNote(a,{attachments:{remove:[r]}}),t({attachments:(await i.getNote(a,{projection:`workbench`,includeAttachments:!0})).attachments??[]}))},patchCurrentEntryResults:e=>t(t=>t.currentEntry?{currentEntry:{...t.currentEntry,results:e}}:t),completeWorkout:async(e,i)=>{let a=n().capturedRun,o=i??a?.session.id;if(!o||!r?.finishSession)throw Error(`The saved run pin is unavailable.`);let s=await r.finishSession(o,e,e.endTime);return t(t=>({results:[...t.results,e]})),s.id},loadEntry:async r=>{let i=e.notePersistence,a=e.provider;if(!i||!a)return null;let{routeId:o,routeView:s,routeSectionId:c,routeResultId:l,resultFromLocationState:u,initialActiveEntryId:d,propInitialContent:f}=r;if(n().setContent(``),n().setBlocks([]),t({currentEntry:null,loadedRouteId:o??null}),o){if(a.mode===`history`||a.mode===`static`)try{let e=l?{mode:`by-result-id`,resultId:l}:c&&s===`review`?{mode:`latest-for-section`,blockId:c}:{mode:`latest`},d=await i.getNote(o,{projection:s===`review`?`review`:`workbench`,includeAttachments:!0,includeSections:!0,resultSelection:e}).catch(async t=>(console.warn(`[WorkbenchSession] Note persistence projection failed, falling back to provider entry:`,{routeId:o,projection:s===`review`?`review`:`workbench`,resultSelectionMode:e.mode,err:t}),a.getRecord(o)));if(d){let e=Zz(d.rawContent,{noteBlocks:d.blocks,sourceRevision:Math.max(1,d.sourceRevision??0)});return t({currentEntry:d,content:d.rawContent,sections:e.sections,blocks:e.blocks,noteBlocks:e.noteBlocks,sourceRevision:d.sourceRevision??0,lastSavedContent:d.rawContent,saveState:`saved`}),s===`review`&&u&&t(e=>e.currentEntry?{currentEntry:{...e.currentEntry,results:u}}:e),r.onLoaded?.(d),d}if(a.mode===`static`){let e=await Fz(o);if(e)return n().setContent(e),null}}catch(e){console.error(`[WorkbenchSession] Failed to load entry for ID:`,o,e)}}else d&&e.navigate?.({type:`goToPlan`,noteId:d});return n().setContent(f??``),null},setActiveSegmentIds:e=>t({activeSegmentIds:e}),setActiveStatementIds:e=>t({activeStatementIds:e}),setAnalytics:(e,n)=>t({analyticsSegments:e,analyticsGroups:n}),appendOutputStatement:e=>t(t=>{let n=[...t.outputStatementList,e],{segments:r,groups:i}=Az(t.runtime);return t.runtime?{outputStatementList:n,analyticsSegments:r,analyticsGroups:i}:{outputStatementList:n}}),clearOutputStatementList:()=>t({outputStatementList:[]}),feedLogOutputs:(e,n)=>{let{segments:r,groups:i}=jz(e,n);t({logOutputList:e,analyticsSegments:r,analyticsGroups:i})},toggleAnalyticsSegment:(e,n,r)=>t(t=>{let i=new Set(t.selectedAnalyticsIds);if(n?.shiftKey&&t.lastSelectedAnalyticsId!==null&&r){let n=r.indexOf(t.lastSelectedAnalyticsId),a=r.indexOf(e);if(n!==-1&&a!==-1){let e=Math.min(n,a),t=Math.max(n,a);r.slice(e,t+1).forEach(e=>i.add(e))}}else n?.ctrlKey?i.has(e)?i.delete(e):i.add(e):(i.clear(),i.add(e));return{selectedAnalyticsIds:i,lastSelectedAnalyticsId:e}}),setUserOverride:(e,n)=>t(t=>{let r=new Map(t.userOutputOverrides);return r.set(e,ca.from(n,e)),{userOutputOverrides:r}}),clearUserOverride:e=>t(t=>{let n=new Map(t.userOutputOverrides);return n.delete(e),{userOutputOverrides:n}}),setGridViewPreset:e=>t({gridViewPreset:e}),setHoveredBlockKey:e=>t({hoveredBlockKey:e}),setDocumentItems:e=>t({documentItems:e}),setSelectedBlock:e=>t({selectedBlock:e,selectedBlockId:e?.id??null}),setSelectedBlockId:e=>t({selectedBlockId:e}),setCursorLine:e=>t({cursorLine:e}),setHighlightedLine:e=>t({highlightedLine:e}),setSubscriptionManager:e=>{t({subscriptionManager:e}),Jz.setSubscriptionRegistry(e)},setViewMode:e=>t({viewMode:e}),setRuntime:e=>{for(let e of s)e();if(s=[],e){let r=Az(e);t({runtime:e,outputStatementList:[],analyticsSegments:r.segments,analyticsGroups:r.groups}),s.push(e.subscribeToOutput(()=>{n().appendOutputStatement({})})),s.push(e.subscribeToStack(e=>{let n=e.blocks[0],r=new Set;for(let t of e.blocks)r.add(ki(t.key.toString()));let i=new Set;if(n&&Array.isArray(n.sourceIds))for(let e of n.sourceIds)i.add(e);t({activeSegmentIds:r,activeStatementIds:i})}));let i=cM();if(i?.connected){let t=new Uz(i);s.push(e.subscribeToStack(e=>t.onStackSnapshot(e)),e.subscribeToOutput(e=>t.onOutput(e)),()=>t.dispose());try{t.onStackSnapshot(e.getStackSnapshot())}catch{}}}else t({runtime:null,outputStatementList:[]})},setExecution:e=>t({execution:e}),setHandles:e=>t({handles:e}),getNote:async(e,t)=>{if(!r)throw Error(`[WorkbenchSession] getNote called without a notePersistence port`);return r.getNote(e,t)},resetStore:()=>{o!==null&&(a(o),o=null);for(let e of s)e();s=[],t({...$z})}}});return t.length>0&&c.subscribe(e=>{for(let n of t)n(e)}),Object.assign(c,{__nowProvider:n})}var nB=tB();function rB(e){let t=nB;return nB=e,t}function iB(){return nB}var aB=e=>Nt(nB,e),oB=({nowProvider:e,notePersistence:t,provider:n,navigate:r,children:i})=>{let a=(0,W.useMemo)(()=>tB({nowProvider:e,notePersistence:t,provider:n,navigate:r}),[e,t,n,r]);return(0,W.useEffect)(()=>{let e=rB(a);return()=>{rB(e),a.getState().resetStore()}},[a]),W.createElement(W.Fragment,null,i)},sB={getEventsByTimeRange:(e,t)=>Z.getEventsByTimeRange(e,t),getEventsByMetricDates:e=>Z.getEventsByMetricDates(e),getEventsByResult:e=>Z.getEventsByResult(e),getEventsForNote:e=>Z.getEventsForNote(e),getEventsByContent:e=>Z.getEventsByContent(e),scanAll:()=>Z.scanAll(),appendEvents:e=>Z.appendEvents(e),finalizeSummaries:(e,t)=>Z.finalizeSummaries(e,t),deleteEvents:e=>Z.deleteEvents(e)},cB={getAllNotes:()=>Z.getAllNotes(),getNotesByIds:async e=>[...(await Z.getDetailBatches(e)).values()].map(e=>e.note),getNoteIdsForTag:async e=>new Set((await Z.getNotesForTag(e)).map(e=>e.id)),getNoteTagLabels:async e=>(await Z.getTagsForNote(e)).map(e=>e.label),queryDomain:async e=>{if(!Z.queryDomain)return;let t=await Z.queryDomain({...e,plan:`notes`});return t&&t.plan===`notes`?t:void 0}},lB={getAllBlocks:()=>Z.getAllBlockIndex(),queryDomain:async e=>{if(!Z.queryDomain)return;let t=await Z.queryDomain({...e,plan:`blocks`});return t&&t.plan===`blocks`?t:void 0}},uB=class{async getAllEfforts(){let e=jO();return e.isInitialized()||await EO(e),[...e.list()]}},dB=new m_,fB={events:[],notes:[]},pB={events:[],notes:[]};dB.set(`@session`,fB),dB.set(`@today`,pB);function mB(){let e=iB().getState(),t=e.runtime?.getOutputStatements()??[],n=e.currentEntry;return fB.notes=n?[{id:n.id,title:n.title,createdAt:n.createdAt,date:n.targetDate,rawContent:n.rawContent,sourceRevision:n.sourceRevision??1,blocks:n.blocks??{}}]:[],t.length===0?(fB.events=[],fB):(fB.events=T_(t.map(vm),{noteId:n?.id??``,resultId:`live:${n?.id??`session`}`,origin:`playground`,workoutTimestamp:n?.targetDate}),fB)}function hB(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 Qg(e.date??e.createdAt,r)}async function gB(e,t){let n=Qg(e.instant,e.timeZone),r=r_(n,e.timeZone),i=r_($g(n,1),e.timeZone),[a,o,s,c]=await Promise.all([Z.getEventsByTimeRange(r,i),Z.getAllNotes(),Z.getAllPageNotes(),Z.getAllPages()]),l=a.filter(e=>e.timestamp>=r&&e.timestamp<i),u=new Map(c.map(e=>[e.id,e])),d=new Map;for(let e of s){let t=d.get(e.noteId);t?t.push(e):d.set(e.noteId,[e])}let f=[];for(let t of o)hB(t,d.get(t.id)??[],u,e.timeZone)===n&&f.push(t);t===yB&&(pB.events=l,pB.notes=f,mB())}var _B=null,vB=null,yB=0,bB=!1,xB=new Set;function SB(){for(let e of xB)e()}function CB(e,t){vB=t;let n=++yB;return _B=gB(e,n),_B.then(()=>{n===yB&&wB()},()=>{n===yB&&wB()}),_B}function wB(){bB=!0,SB()}function TB(){let e=Kg(),t=Qg(e.instant,e.timeZone);return!_B||vB!==t?CB(e,t):_B}function EB(){bB=!1;let e=Kg();return CB(e,Qg(e.instant,e.timeZone))}function DB(){return bB}function OB(e){return xB.add(e),()=>{xB.delete(e)}}var kB=class extends pv{async runQuery(e,t){return await TB(),super.runQuery(e,t)}async runPipeline(e,t){return await TB(),super.runPipeline(e,t)}async runFind(e,t){return await TB(),super.runFind(e,t)}async runRows(e,t){return await TB(),super.runRows(e,t)}async run(e,t){return await TB(),super.run(e,t)}};function AB(){return new kB({eventStore:sB,noteStore:cB,blockStore:lB,effortStore:new uB,blockEffortsStore:{getAllFromIndex:(e,t)=>Z.getAllFromIndex(`block_efforts`,e,t)},tagsStore:{getAllFromIndex:(e,t)=>Z.getAllFromIndex(`tags`,e,t),getAll:()=>Z.getAllTags()},noteTagsStore:{getAllFromIndex:(e,t)=>Z.getAllFromIndex(`note_tags`,e,t)},pageStore:{getNotePages:e=>Z.getNotePages(e),getPage:e=>Z.getPage(e),getAllPages:()=>Z.getAllPages(),getAllLinks:()=>Z.getAllPageNotes()},relationStore:{getBatches:e=>Z.getDetailBatches(e)},datasetStore:{getDataset:e=>e===`@session`?mB():dB.getDataset(e)}})}var jB=AB();function MB(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?hL(a):`${t===`segment`?`Segment`:`Event`} ${n+1}`,date:typeof e.date==`string`?e.date:null,subtitle:o.length>0?o.join(` • `):void 0}}function NB(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 PB(e,t,n){e&&e({selected:Math.max(t?.selected??0,n.length),matched:n.length})}function FB(e){return typeof e==`object`&&!!e&&`runFind`in e}var IB=new class e{customService;noteTitleResolver;noteTagsResolver;noteBlockInfo;constructor(e){FB(e)?this.customService=e:(this.customService=e?.service,this.noteTitleResolver=e?.noteTitleResolver,this.noteBlockInfo=e?.noteBlockInfo??!1,this.noteTagsResolver=e?.noteTagsResolver)}get service(){return this.customService??jB}withNoteBlockInfo(){let t=new e({service:this.service,noteTitleResolver:this.noteTitleResolver,noteTagsResolver:this.noteTagsResolver,noteBlockInfo:!0});return Object.prototype.hasOwnProperty.call(this,`query`)&&(t.query=this.query),t}async hydrateEntries(e,t){let n=new Set;for(let r of e)r.sourceNotebook===`journal`&&n.add(r.id),t&&(!r.title||!r.tags||r.tags.length===0)&&n.add(r.id);if(n.size===0)return;let r=await Z.getDetailBatches([...n]);for(let t of e){if(t.sourceNotebook!==`journal`)continue;let e=r.get(t.id),n=va(e?.links??[],e?.pages??[]);t.placements=n;let i=ya(n);t.pageId??=i.pageId,i.pageSlug&&(t.pageSlug=i.pageSlug)}if(t)for(let t of e){let e=r.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){let n=typeof e==`string`?X(e):e;if(!n||n.error)return[];if(_h(n)){if(n.target===`effort`){let e=this.service.runFindEffort?await this.service.runFindEffort(n):await this.service.runFind(n),r=new Map(e.notes.map(e=>[e.id,e])),i=(e.efforts??[]).map(e=>e.ownerNoteId&&r.has(e.ownerNoteId)?cL(r.get(e.ownerNoteId)):vL(e));return PB(t,e.stages,i),i}if(n.target===`block`){let e=await this.service.runFind(n),r=e.blocks.map(mL);return await this.hydrateEntries(r,!0),PB(t,e.stages,r),r}if(n.target===`session`){let e=await this.service.runFind(n);t?.(e.stages);let r;if(this.noteTitleResolver&&e.runs){r=new Map;for(let t of e.runs)if(!r.has(t.noteId)){let e=await this.noteTitleResolver(t.noteId);e&&r.set(t.noteId,e)}}let i=CL(e,{noteTitles:r});return PB(t,e.stages,i),i}if(n.target===`segment`||n.target===`event`){let e=n.target,r=await this.service.runFind(n),i=(r.table?.rows??[]).map((t,n)=>MB(t,e,n));return PB(t,r.stages,i),i}let e=await this.service.runFind(n),r=e.notes.map(cL);if(this.noteTagsResolver?(await this.hydrateEntries(r,!1),await Promise.all(r.map(async e=>{if(!e.tags||e.tags.length===0){let t=await this.noteTagsResolver(e.id);t&&t.length>0&&(e.tags=t)}}))):await this.hydrateEntries(r,!0),PB(t,e.stages,r),this.noteBlockInfo)for(let t=0;t<r.length;t++){let n=r[t],i=e.notes[t];n.excerpt=pL(i.rawContent);try{Pa(i.rawContent,i.blocks,i.sourceRevision)}catch{continue}let a=Object.values(i.blocks).sort((e,t)=>e.from-t.from).find(e=>e.kind===`wod`),o=a&&ja(i.rawContent).find(e=>e.from===a.from&&e.scriptBlock);if(a&&o?.scriptBlock){let e=o.scriptBlock.content,t=ha(e);n.wodBlock={blockId:a.id,blockVersion:a.version,blockContentId:t,content:e},n.blockContentId=t}}return r}if(n.family===`aggregate`){if(!this.service.runQuery)return[];let e=await this.service.runQuery(n.raw),r=NB(e);return t?.({selected:e.stages?.selected??r.length,matched:r.length}),r}return[]}};async function LB(e,t=IB,n){return t.query(e,n)}function RB(e){return e?e.map(e=>e.kind===`wql`?`${e.id}|${e.query}|${e.limit??``}`:`s:${e.id}`).join(`;`):``}async function zB(e){try{let t=(await LB(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 BB(e){let t=RB(e),n=(0,W.useRef)(e);n.current=e;let[r,i]=(0,W.useState)(()=>e&&!e.some(e=>e.kind===`wql`)?e:[]);return(0,W.useEffect)(()=>{let e=n.current;if(!e){i([]);return}if(!e.some(e=>e.kind===`wql`)){i(e);return}let t=!1;return Promise.all(e.map(e=>e.kind===`wql`?zB(e):Promise.resolve(e))).then(e=>{t||i(e)}),()=>{t=!0}},[t]),r}function VB(){let[e]=un(`h`,{shallow:!0}),[t]=un(`s`,{shallow:!0}),{navState:n}=aP(),r=n.activeL3Id??``;return e||t||r||``}function HB({entry:e,active:t,onActivate:n}){let r=e.onRun;return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(e),className:K(`group flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left transition-colors`,e.muted?`text-[11.5px]`:`text-[13px]`,t?`bg-primary/10 font-semibold text-primary`:K(`hover:bg-muted/60 hover:text-foreground`,e.muted?`text-muted-foreground/70`:`text-muted-foreground`)),children:[e.icon&&(0,G.jsx)(e.icon,{className:`size-4 shrink-0`}),e.timestamp&&(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground/60`,children:e.timestamp}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 line-clamp-2 break-words`,title:e.label,children:e.label}),e.badge&&(0,G.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-muted-foreground/50`,children:e.badge}),r&&(0,G.jsx)(`span`,{role:`button`,tabIndex:-1,title:e.runIcon===`link`?`View workout`:e.runIcon===`stop`?`Stop workout`:e.runIcon===`edit`?`Edit note`:`Start workout`,onClick:t=>{t.stopPropagation(),e.onRun?.()},className:`flex size-5 shrink-0 items-center justify-center rounded text-primary opacity-0 transition-all group-hover:opacity-100 hover:bg-primary/10`,children:e.runIcon===`link`?(0,G.jsx)(re,{className:`size-3.5`}):e.runIcon===`stop`?(0,G.jsx)(_,{className:`size-3.5`}):e.runIcon===`edit`?(0,G.jsx)(fe,{className:`size-3.5`}):(0,G.jsx)(V,{className:`size-3.5`})})]})}function UB({entries:e,activeId:t,onSection:n}){let r=dn(),{scrollToSection:i}=aP(),a=EF(),o=e=>{if(a(),n)return n(e);if(e.onRun)return e.onRun();if(e.to)return r(e.to);if(e.sectionId)return i(e.sectionId)};return(0,G.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.map(e=>e.kind===`section`?e.entries.length===0?null:(0,G.jsxs)(`div`,{className:`mt-1 flex flex-col gap-0.5 first:mt-0`,children:[(0,G.jsx)(`div`,{className:`px-2 pb-1 pt-3 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:e.label}),(0,G.jsx)(UB,{entries:e.entries,activeId:t,onSection:n})]},e.id):e.kind===`wql`?null:e.kind===`widget`?(0,G.jsx)(`div`,{className:`px-1 py-1`,children:e.render()},e.id):(0,G.jsx)(HB,{entry:e,active:t!=null&&e.sectionId===t,onActivate:o},e.id))})}function WB(){let e=dn(),{scrollToSection:t}=aP();return{navigate:(t,n)=>e(t,{replace:n?.replace}),setQueryParam:(e,t)=>{},scrollToSection:t}}function GB(){let e=WB(),t=EF();return n=>{t(),AL(n.action,e)}}function KB(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 qB({items:e}){let{navState:t}=aP(),n=En(),r=GB();return(0,G.jsx)(FF,{children:e.map(e=>{let i=KB(e,t,n);return e.children&&e.children.length>0?(0,G.jsx)(FL,{title:e.label,count:e.children.length,defaultOpen:e.children.some(e=>KB(e,t,n)),collapsible:e.id!==`syntax-group`,children:e.children.map(e=>{let i=KB(e,t,n);return(0,G.jsxs)(LF,{onClick:()=>r(e),current:i,children:[e.icon&&(0,G.jsx)(e.icon,{"data-slot":`icon`}),(0,G.jsx)(RF,{children:e.label})]},e.id)})},e.id):(0,G.jsxs)(`div`,{className:`group relative flex items-center`,children:[(0,G.jsxs)(LF,{onClick:e.disabled?void 0:()=>r(e),current:i,disabled:e.disabled,"aria-label":e.disabled?`${e.label} (coming soon)`:void 0,className:K(`flex-1`,e.disabled&&`opacity-60`),children:[e.icon&&(0,G.jsx)(e.icon,{"data-slot":`icon`}),(0,G.jsx)(RF,{children:e.disabled?`+`:e.label})]}),e.onTogglePin&&(0,G.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 text-muted-foreground hover:text-foreground transition-opacity`,children:(0,G.jsx)(gt,{className:`size-3.5`})})]},e.id)})})}function JB({navSpec:e}){let{tree:t,navState:n,dispatch:r,contextNav:i}=aP(),a=En(),o=BB(e),s=(t??[]).find(e=>e?.id===n.activeL1Id)??null,c=i?.pathname===a.pathname?i:null;return(0,G.jsxs)(MF,{children:[(0,G.jsx)(NF,{children:(0,G.jsx)(`div`,{className:`px-2 pt-3 pb-1 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:s?.label??`Wod Wiki`})}),(0,G.jsxs)(PF,{children:[(()=>{if(c||!s)return null;if(s.panel){let e=s.panel;return(0,G.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,G.jsx)(e,{item:s,navState:n,dispatch:r})})}return s.children&&s.children.length>0?(0,G.jsx)(`div`,{className:`border-b border-border/40 pb-2 mb-2`,children:(0,G.jsx)(qB,{items:s.children})}):null})(),c?(0,G.jsx)(`div`,{className:`pt-1`,children:(0,G.jsx)(UB,{entries:c.spec})}):o.length>0&&(0,G.jsx)(`div`,{className:`pt-1`,children:(0,G.jsx)(UB,{entries:o})})]})]})}var YB=`0.50.2191`,XB=`https://github.com/bitcobblers/wod-wiki/releases`;function ZB(e){return/-pr\.\d+$/.test(e)?XB:`${XB}/tag/v${e}`}function QB({onSearch:e,onCreate:t}){let{tree:n,navState:r,dispatch:i}=aP(),a=dn(),o=En(),s=EF(),c={navigate:(e,t)=>a(e,{replace:t?.replace}),setQueryParam:()=>{},scrollToSection:()=>{}},l=(n??[]).filter(e=>e!=null&&e.icon!=null&&e.id!==`settings`&&e.id!==`buy-me-a-coffee`),u=o.pathname.startsWith(`/settings`);o.pathname===`/`||o.pathname;let d=`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`;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{onClick:()=>{s(),a(`/`)},title:`Wod Wiki home`,"aria-label":`Wod Wiki home`,className:`group relative mb-3 grid size-8 shrink-0 place-items-center rounded-xl bg-primary text-primary-foreground shadow-md shadow-primary/20 rotate-3`,children:[(0,G.jsx)(be,{size:17}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Wod Wiki home`}),(0,G.jsx)(`span`,{role:`tooltip`,className:d,children:`Wod Wiki home`})]}),(0,G.jsx)(`nav`,{"aria-label":`Primary`,className:`flex flex-col items-center gap-1.5`,children:l.map(e=>{let t=e.icon,n=KB(e,r,o);return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{s(),i({type:`SET_ACTIVE_L1`,id:e.id}),AL(e.action,c)},title:e.label,"aria-label":e.label,"aria-current":n?`page`:void 0,className:K(`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:[n&&(0,G.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,G.jsx)(t,{className:`size-5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:e.label}),(0,G.jsx)(`span`,{role:`tooltip`,className:d,children:e.label})]},e.id)})}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsxs)(`button`,{type:`button`,onClick:e,title:`Search (⌘/)`,"aria-label":`Search`,className:`group relative grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,G.jsx)(ge,{className:`size-5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Search`}),(0,G.jsx)(`span`,{role:`tooltip`,className:d,children:`Search (⌘/)`})]}),(0,G.jsxs)(`a`,{href:IR,target:`_blank`,rel:`noopener noreferrer`,title:`Buy Me a Coffee`,"aria-label":`Buy Me a Coffee`,className:`group relative grid size-9 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground`,children:[(0,G.jsx)(LR,{className:`size-5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Buy Me a Coffee`}),(0,G.jsx)(`span`,{role:`tooltip`,className:d,children:`Buy Me a Coffee`})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{s(),a(`/settings/profile`)},title:`Profile`,"aria-label":`Profile`,"aria-current":o.pathname.startsWith(`/settings/profile`)?`page`:void 0,"data-testid":`nav-profile`,className:K(`group relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,o.pathname.startsWith(`/settings/profile`)?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[o.pathname.startsWith(`/settings/profile`)&&(0,G.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,G.jsx)(Le,{className:`size-5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Profile`}),(0,G.jsx)(`span`,{role:`tooltip`,className:d,children:`Profile`})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{s(),a(`/settings/appearance`)},title:`Settings`,"aria-label":`Settings`,"aria-current":u?`page`:void 0,"data-testid":`nav-settings`,className:K(`group relative grid size-9 place-items-center rounded-lg transition-colors mt-1.5`,u?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),children:[u&&(0,G.jsx)(`span`,{className:`absolute -left-[14px] top-1/2 h-5 w-[3px] -translate-y-1/2 rounded-r-full bg-primary`}),(0,G.jsx)(Yn,{className:`size-5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Settings`}),(0,G.jsxs)(`span`,{role:`tooltip`,className:`pointer-events-none absolute bottom-0 left-full z-50 ml-2 w-max rounded-md border border-border bg-popover px-2 py-1 text-xs text-popover-foreground opacity-0 shadow-md transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[`Settings (v`,YB,`)`]})]})]})}function $B({activations:e,activeSection:t,variant:n,deps:r,className:i}){return(0,G.jsx)(`nav`,{className:K(`lg:sticky z-20 flex items-center gap-1 px-4 py-2 bg-background/95 backdrop-blur-sm border-b border-border/50 overflow-x-auto`,n===`top-fixed`?`lg:top-0`:`lg:top-[104px]`,i),children:e.map(e=>(0,G.jsx)(`button`,{onClick:()=>AL(e.action,r),className:K(`px-3 py-1.5 rounded-full text-[10px] font-black uppercase tracking-[0.12em] whitespace-nowrap transition-all ring-1`,t===e.id?`bg-primary text-primary-foreground ring-primary/30 shadow-md`:`bg-muted/50 text-muted-foreground ring-transparent hover:bg-muted hover:ring-border`),children:e.label},e.id))})}var eV=class e{now;name=`tick`;timestamp;data;static _counter=0;constructor(t,n=Hl){this.now=n;let r=this.now.nowMs();e._counter++,this.timestamp=new Date(r+e._counter),this.data=t}},tV=20,nV=e=>{let[t,n]=(0,W.useState)(`idle`),[r,i]=(0,W.useState)(0),[a,o]=(0,W.useState)(0),[s,c]=(0,W.useState)(null),l=(0,W.useRef)(null),u=(0,W.useRef)(null),d=(0,W.useCallback)(()=>{l.current&&=(clearInterval(l.current),null),n(`idle`)},[]),f=(0,W.useCallback)(()=>{if(e)try{let t=new eV(void 0,e.nowProvider);e.handle(t),o(e=>e+1)}catch{d(),n(`error`)}},[e,d]);(0,W.useEffect)(()=>{if(e)return e.subscribeToStack(e=>{e.blocks.length===0&&t!==`completed`&&(l.current&&=(clearInterval(l.current),null),n(`completed`))})},[e,t]),(0,W.useEffect)(()=>()=>{l.current&&=(clearInterval(l.current),null)},[]);let p=(0,W.useCallback)(()=>{if(!e){console.warn(`useRuntimeExecution: Cannot start execution without a runtime`);return}if(t===`running`){console.warn(`useRuntimeExecution: Runtime is already running`);return}t===`paused`&&e.handle({name:`timer:resume`,timestamp:new Date,data:{}}),n(`running`);let i=e?.nowProvider?.nowMs()??Hl.nowMs();u.current=i-r,r===0&&c(i),l.current=setInterval(f,tV)},[e,t,r,f]),m=(0,W.useCallback)(()=>{l.current&&=(clearInterval(l.current),null),e&&e.handle({name:`timer:pause`,timestamp:new Date,data:{}}),n(`paused`)},[e]),h=(0,W.useCallback)(()=>{l.current&&=(clearInterval(l.current),null),i(0),o(0),n(`idle`),c(null),u.current=null},[e]),g=(0,W.useCallback)(()=>{!e||t===`running`||(n(`paused`),f())},[e,t,f]);return(0,W.useEffect)(()=>{if(t!==`running`||!u.current)return;let n=setInterval(()=>{i((e?.nowProvider?.nowMs()??Hl.nowMs())-u.current)},100);return()=>clearInterval(n)},[t,e?.nowProvider]),(0,W.useEffect)(()=>()=>{l.current&&=(clearInterval(l.current),null)},[]),(0,W.useEffect)(()=>{h()},[e,h]),(0,W.useMemo)(()=>({status:t,elapsedTime:r,stepCount:a,startTime:s,start:p,pause:m,stop:d,reset:h,step:g}),[t,r,a,s,p,m,d,h,g])},rV=(e,t)=>!e||!Array.isArray(e)?0:e.reduce((e,n)=>{if(`started`in n){let r=n.started,i=n.ended??t;return e+Math.max(0,i-r)}let r=n.start instanceof Date?n.start.getTime():n.start||0,i=n.stop?n.stop instanceof Date?n.stop.getTime():n.stop:t;return e+Math.max(0,i-r)},0);function iV(e,t){let n=t,r=()=>{let t=e?.getMemoryByTag(n)[0];if(t)return n===`round`?t.metrics[0]:t.metrics[0]?.value},[i,a]=(0,W.useState)(r);return(0,W.useEffect)(()=>{if(!e){a(void 0);return}a(r());let t=e.getMemoryByTag(n)[0];if(t)return t.subscribe(e=>{a(n===`round`?e[0]:e[0]?.value)})},[e,t]),i}function aV(e){return iV(e,`round`)}function oV(e){return iV(e,`display`)}function sV(e){let t=aV(e),n=oV(e);return(0,W.useMemo)(()=>{if(!t)return null;let e=n?.roundDisplay??(t.total===void 0?`Round ${t.current}`:`Round ${t.current} of ${t.total}`),r=t.total===void 0?void 0:Math.min(1,(t.current-1)/t.total);return{current:t.current,total:t.total,label:e,progress:r}},[t,n?.roundDisplay])}var cV=(0,W.createContext)(void 0),lV=({runtime:e,children:t})=>(0,G.jsx)(cV.Provider,{value:e,children:t});function uV(){let e=(0,W.useContext)(cV);if(!e)throw Error(`useScriptRuntime must be used within ScriptRuntimeProvider`);return e}function dV(e){let t=uV(),n=e===void 0?t:e,[r,i]=(0,W.useState)(()=>n?.getOutputStatements?.()??[]);return(0,W.useEffect)(()=>{if(!n){i([]);return}return i(n.getOutputStatements()),n.subscribeToOutput?.(()=>{i(n.getOutputStatements())})},[n]),(0,W.useMemo)(()=>{let e=new Map,t=new Map,n=[],i=[];for(let a of r){e.set(a.id,a);let r=t.get(a.sourceBlockKey)??[];switch(r.push(a),t.set(a.sourceBlockKey,r),a.outputType){case`segment`:n.push(a);break;case`metric`:i.push(a)}}let a=n.filter(e=>e.completionReason!==void 0);return{outputs:r,byId:e,byBlockKey:t,segments:n,completions:a,metrics:i}},[r])}function fV(e){let t=uV(),n=e===void 0?t:e,[r,i]=(0,W.useState)(()=>n?.getLiveAnalytics?.()??[]);return(0,W.useEffect)(()=>{if(!n){i([]);return}return i(n.getLiveAnalytics?.()??[]),n.subscribeToOutput?.(()=>{i(n.getLiveAnalytics?.()??[])})},[n]),r}function pV(){let e=uV(),[t,n]=(0,W.useState)({type:`initial`,blocks:e.stack.blocks,depth:e.stack.count,clockTime:e.clock.currentDate});return(0,W.useEffect)(()=>e.subscribeToStack(e=>{n(e)}),[e]),t}function mV(){return pV().blocks}function hV(){let e=mV(),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`metric:next`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,W.useMemo)(()=>{for(let t of e){let e=t.getMemoryByTag(`metric:next`);if(e.length===0)continue;let n=ca.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 gV(){let e=mV(),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`time`)[0];if(e){let r=e.subscribe(()=>{n(e=>e+1)});t.push(r)}}return()=>{t.forEach(e=>e())}},[e]),(0,W.useMemo)(()=>{let t=[];for(let n of e){let e=n.getMemoryByTag(`time`)[0];if(!e)continue;let r=e.metrics[0]?.value;r&&t.push({block:n,timer:r,isPinned:r.role===`primary`})}return t},[e,t])}function _V(){let e=gV();return(0,W.useMemo)(()=>{if(e.length===0)return;let t=e[0];return t.block.blockType===`Rest`?t:[...e].reverse().find(e=>e.isPinned)||t},[e])}function vV(){let e=gV(),t=_V();return(0,W.useMemo)(()=>t?e.filter(e=>e.block!==t.block):[],[e,t])}function yV(){let e=mV(),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`controls`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,W.useMemo)(()=>{let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r].getMemoryByTag(`controls`);if(i.length===0)continue;let a=i[0].metrics.map(e=>e.value).filter(Boolean),o=r===e.length-1;for(let e of a)e.isPinned?t.push(e):o&&n.push(e)}let r=new Set,i=[];for(let e of t)r.has(e.id)||(r.add(e.id),i.push(e));for(let e of n)r.has(e.id)||(r.add(e.id),i.push(e));return i},[e,t])}function bV(){let e=mV(),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=[];for(let r of e){let e=r.getMemoryByTag(`metric:display`);for(let r of e){let e=r.subscribe(()=>{n(e=>e+1)});t.push(e)}}return()=>{t.forEach(e=>e())}},[e]),(0,W.useMemo)(()=>{if(e.length===0)return;let t=[],n=[...e].reverse();return n.forEach((e,r)=>{if(e.blockType===`Root`&&!e.label)return;let i=e.getMemoryByTag(`metric:display`),a=i.map(e=>e.metrics);if(a.length===0&&!e.label)return;let o=r===n.length-1,s=i.length>1?i.map(e=>e.metrics):void 0;t.push({block:e,displayRows:a,label:e.label,depth:r,isLeaf:o,metricGroups:s})}),t.length>0?t:void 0},[e,t])}function xV(e){let t=uV(),n=(0,W.useMemo)(()=>t.stack.blocks.find(t=>t.key.toString()===e),[t,e]),[r,i]=(0,W.useState)(()=>n?.getMemoryByTag(`time`)[0]?.metrics[0]?.value);(0,W.useEffect)(()=>t.stack.subscribe(()=>{let n=t.stack.blocks.find(t=>t.key.toString()===e);if(n){let e=n.getMemoryByTag(`time`)[0];i(e?.metrics[0]?.value)}else i(void 0)}),[t,e]),(0,W.useEffect)(()=>{if(!n){i(void 0);return}let e=n.getMemoryByTag(`time`)[0];if(i(e?.metrics[0]?.value),e)return e.subscribe(e=>{i(e[0]?.value)})},[n]);let a=(0,W.useMemo)(()=>r?.spans??[],[r]),o=a.length>0&&a[a.length-1].ended===void 0,[s,c]=(0,W.useState)(Au()),l=(0,W.useMemo)(()=>a.length===0?0:rV(a,s),[a,s]);return(0,W.useEffect)(()=>{if(!o)return;let e,t=()=>{c(Au()),e=requestAnimationFrame(t)};return t(),()=>cancelAnimationFrame(e)},[o]),{elapsed:l,isRunning:o,timeSpans:a}}var SV=(0,W.createContext)(void 0),CV=(0,W.createContext)(null),wV={getState:()=>iB().getState(),setState:(e,t)=>{let n=iB();typeof e==`function`?n.setState(e(n.getState()),t):n.setState(e,t)},subscribe:e=>iB().subscribe(e)},TV=({factory:e,children:t})=>{let[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),u=(0,W.useRef)(e);u.current=e;let d=(0,W.useRef)(null),f=(0,W.useRef)(null),p=(0,W.useRef)(!1),m=(0,W.useCallback)(()=>{f.current&&=(f.current.dispose(),null),a(null),wV.getState().setSubscriptionManager(null);let e=d.current;if(d.current=null,e)try{u.current.disposeRuntime(e)}catch(e){console.error(`[RuntimeProvider] Error disposing runtime:`,e)}r(null),l(null)},[]),h=(0,W.useCallback)((e,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 _m(i);e.add(new gm({id:`local`})),f.current=e,a(e),wV.getState().setSubscriptionManager(e)}else f.current=null,a(null),wV.getState().setSubscriptionManager(null)}catch(e){console.error(`[RuntimeProvider] Error creating runtime:`,e),l(e instanceof Error?e:Error(String(e))),d.current=null}finally{p.current=!1,s(!1)}}},[]);(0,W.useEffect)(()=>()=>{if(f.current&&f.current.dispose(),d.current)try{u.current.disposeRuntime(d.current)}catch(e){console.error(`[RuntimeProvider] Error disposing runtime on unmount:`,e)}},[]);let g={runtime:n,isInitializing:o,error:c,initializeRuntime:h,disposeRuntime:m};return(0,G.jsx)(SV.Provider,{value:g,children:(0,G.jsx)(CV.Provider,{value:i,children:t})})};function EV({factory:e,children:t}){return(0,G.jsx)(TV,{factory:e,children:t})}var DV=`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`,OV=`flex flex-col flex-1 min-w-0 xl:max-w-[984px] 2xl:max-w-none min-h-screen lg:rounded-[2.5rem]`;function kV({id:e,title:t,subtitle:n,titleAccessory:r,actions:i,queryBar:a,subheader:o,titleTestId:s,className:c}){return(0,G.jsxs)(`div`,{id:e,"data-page-sticky-boundary":`true`,className:K(`max-lg:hidden lg:sticky lg:top-0 z-30 border-b border-border/50 bg-background/95 backdrop-blur-md transition-colors`,c),children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-4 sm:px-6 lg:px-8 py-2 sm:py-2.5`,children:[t&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 sm:gap-3 min-w-0`,children:[(0,G.jsx)(`div`,{className:`h-5 w-1.5 shrink-0 rounded-full bg-primary`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h1`,{"data-testid":s,className:`text-base sm:text-lg font-black tracking-tight text-foreground leading-none truncate`,children:t}),n&&(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground truncate`,children:n})]}),r]})]}),a&&(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:a}),i&&(0,G.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0 ml-auto`,children:i})]}),o&&(0,G.jsx)(`div`,{className:`bg-background/40`,children:o})]})}function AV({ids:e,enabled:t=!0,rootMargin:n=`-10% 0px -40% 0px`,threshold:r=[0,.3,1],onChange:i,shouldAcceptChange:a,scrollDirection:o=`ratio`,dataAttribute:s,debounceMs:c=0}){let l=(0,W.useRef)(``),u=(0,W.useRef)(i),d=(0,W.useRef)(a),f=(0,W.useRef)(null),p=(0,W.useRef)(1);(0,W.useEffect)(()=>{u.current=i},[i]),(0,W.useEffect)(()=>{d.current=a},[a]);let m=e.filter(Boolean).join(`\0`),h=r.join(`,`),g=(0,W.useMemo)(()=>m?m.split(`\0`):[],[m]),_=(0,W.useMemo)(()=>h.split(`,`).map(Number),[h]),v=(0,W.useCallback)(()=>{f.current&&=(clearTimeout(f.current),null)},[]);(0,W.useEffect)(()=>{if(!t||g.length===0||typeof IntersectionObserver>`u`)return;let e=new Map,r=e=>s?e.getAttribute(s):e.id||null,i;if(o===`topmost-when-up`){let e=window.scrollY,t=()=>{let t=window.scrollY;t!==e&&(p.current=t>e?1:-1),e=t};window.addEventListener(`scroll`,t,{passive:!0}),i=()=>window.removeEventListener(`scroll`,t)}let a=new IntersectionObserver(t=>{if(t.forEach(t=>{let n=r(t.target);n&&(t.isIntersecting?e.set(n,t.intersectionRatio):e.delete(n))}),e.size===0)return;let n=``;if(o===`topmost-when-up`&&p.current===-1){let t=1/0;e.forEach((e,r)=>{let i=g.indexOf(r);i>=0&&i<t&&(t=i,n=r)})}else{let t=-1;e.forEach((e,r)=>{e>t&&(t=e,n=r)})}!n||n===l.current||d.current&&!d.current(n)||(l.current=n,c>0?(v(),f.current=setTimeout(()=>{u.current(n),f.current=null},c)):u.current(n))},{rootMargin:n,threshold:_});return g.forEach(e=>{let t=s?document.querySelector(`[${s}="${e}"]`):document.getElementById(e);t&&a.observe(t)}),()=>{a.disconnect(),v(),i?.()}},[t,g,_,n,o,s,c,v])}function jV({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]=un(`s`,{defaultValue:o??a[0]?.id??``,shallow:!0,history:`replace`}),[f,p]=(0,W.useState)(c?.[0]?.id??``);if(AV({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}),AV({ids:c?.map(e=>e.id)??[],enabled:u,rootMargin:`-20% 0px -50% 0px`,threshold:[0,.25,.5,.75],onChange:p}),u){let e=c.map(e=>({id:e.id,label:e.label,action:{type:`scroll`,sectionId:e.id}}));return(0,G.jsxs)(`div`,{className:K(`flex flex-col min-h-screen bg-background`,l),children:[s,(0,G.jsx)($B,{activations:e,activeSection:f,variant:`top-fixed`,deps:{navigate:()=>{},setQueryParam:()=>{},scrollToSection:e=>{let t=document.getElementById(e);if(t){let e=t.getBoundingClientRect().top+window.scrollY-64;window.scrollTo({top:e,behavior:`smooth`})}}}}),(0,G.jsx)(`div`,{className:`flex-1`,children:c.map(e=>{let t=(0,G.jsx)(`div`,{id:e.id,"data-section-id":e.id,className:`py-12 lg:py-16 px-6 lg:px-10 border-b border-border/30`,children:e.content},e.id);return e.runtimeFactory?(0,G.jsx)(EV,{factory:e.runtimeFactory,children:t},e.id):t})})]})}return(0,G.jsx)(`div`,{className:K(`relative flex w-full min-h-screen justify-start items-start`,l),children:(0,G.jsxs)(`div`,{className:K(OV,DV),children:[(0,G.jsx)(kV,{title:e,titleAccessory:t,actions:n,subheader:r}),(0,G.jsx)(`div`,{className:`flex-1`,children:i})]})})}var MV=`[data-page-sticky-boundary="true"]`,NV=0;function PV(e,t=NV){if(typeof document>`u`)return e;let n=Array.from(document.querySelectorAll(MV)).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 FV(e,t=NV){let[n,r]=(0,W.useState)(e);return(0,W.useEffect)(()=>{let n=0,i=()=>r(PV(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(MV).forEach(e=>o?.observe(e));let s=typeof MutationObserver>`u`?void 0:new MutationObserver(()=>{document.querySelectorAll(MV).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 IV({top:e,label:t,icon:n,badge:r,meta:i,testId:a,className:o}){return(0,G.jsxs)(`div`,{"data-testid":a,className:K(`sticky z-10 flex items-center gap-2 border-y border-border/60 bg-card/95 px-6 py-2 shadow-[0_1px_2px_rgba(0,0,0,0.03)] backdrop-blur`,o),style:{top:`${e}px`},children:[n,(0,G.jsx)(`span`,{className:`min-w-0 truncate text-xs font-bold text-foreground`,children:t}),r,i&&(0,G.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 font-mono text-[10px] text-muted-foreground`,children:i})]})}var LV=(0,W.createContext)(null),RV=(0,W.createContext)(null);function zV({children:e}){let[t,n]=(0,W.useState)(null);return(0,G.jsx)(RV.Provider,{value:n,children:(0,G.jsx)(LV.Provider,{value:t,children:e})})}function BV({className:e}){let t=(0,W.useContext)(RV);return(0,G.jsx)(`div`,{ref:t,className:e,"data-testid":`mobile-query-slot`})}function VV(){return(0,W.useContext)(LV)}function HV({editor:e,title:t,subtitle:n,titleTestId:r,actions:i,timerOverlay:a,reviewOverlay:o,isTimerOpen:s=!1,isReviewOpen:c=!1,onCloseTimer:l,onCloseReview:u,className:d}){return(0,G.jsxs)(`div`,{className:K(`relative flex w-full min-h-screen justify-start items-start`,d),children:[(0,G.jsxs)(`div`,{className:K(OV,DV),children:[(0,G.jsx)(kV,{title:t,subtitle:n,titleTestId:r,actions:i}),(0,G.jsx)(`main`,{className:`flex-1 min-w-0 max-w-full`,children:e})]}),s&&a&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,G.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,G.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,G.jsx)(`button`,{onClick:l,className:`px-3 py-1.5 rounded-md text-sm font-bold text-muted-foreground hover:text-foreground bg-muted/60 hover:bg-muted transition-colors`,children:`Close`})}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:a})]})}),c&&o&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 bg-background/95 backdrop-blur-sm`,children:(0,G.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,G.jsx)(`div`,{className:`flex justify-end p-4`,children:(0,G.jsx)(`button`,{onClick:u,className:`px-3 py-1.5 rounded-md text-sm font-bold text-muted-foreground hover:text-foreground bg-muted/60 hover:bg-muted transition-colors`,children:`Close`})}),(0,G.jsx)(`div`,{className:`flex-1 min-h-0`,children:o})]})})]})}function UV(e){return e.map(e=>{if(e.panel){let t=e.panel;return{kind:`widget`,id:e.id,render:()=>(0,W.createElement)(`div`,{className:`flex flex-col gap-1`},(0,W.createElement)(`span`,{className:`px-1 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`},e.label),(0,W.createElement)(t,{currentPath:``,location:null}))}}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})}var WV=W.createContext(null);function GV(){let e=W.useContext(WV);if(!e)throw Error(`DropdownMenu components must be used inside a DropdownMenu`);return e}function KV(){let e=W.useContext(WV);return W.useCallback(()=>{e?.setIsOpen(!1)},[e])}var qV=({children:e,open:t,onOpenChange:n})=>{let r=W.useContext(WV),i=W.useId(),a=r?`${r.portalChain}/${i}`:i,[o,s]=W.useState(t??!1),c=W.useRef(null),[l,u]=W.useState(-1),d=W.useRef(new Map),[,f]=W.useReducer(e=>e+1,0);W.useEffect(()=>{t!==void 0&&s(t)},[t]);let p=W.useCallback(e=>{s(e),u(-1),n?.(e)},[n]),m=W.useCallback((e,t)=>{d.current.set(e,t),f()},[]),h=W.useCallback(e=>{d.current.delete(e),f()},[]),g=W.useCallback(e=>Array.from(d.current.keys()).indexOf(e),[]),_=d.current.size,v=W.useMemo(()=>({isOpen:o,setIsOpen:p,triggerRef:c,registerItem:m,unregisterItem:h,getItemIndex:g,activeIndex:l,setActiveIndex:u,itemCount:_,menuId:i,portalChain:a}),[o,p,m,h,g,l,_,i,a]);return(0,G.jsx)(WV.Provider,{value:v,children:(0,G.jsx)(`div`,{ref:c,className:`relative inline-block`,children:e})})},JV=W.forwardRef(({className:e,children:t,asChild:n,...r},i)=>{let{isOpen:a,setIsOpen:o}=GV(),s=e=>{e.stopPropagation(),o(!a)};return n&&W.isValidElement(t)?W.cloneElement(t,{...r,onClick:s}):(0,G.jsx)(`button`,{ref:i,className:e,onClick:s,...r,children:t})});JV.displayName=`DropdownMenuTrigger`;var YV=W.forwardRef(({className:e,children:t,align:n=`center`,side:r=`bottom`,...i},a)=>{let{isOpen:o,setIsOpen:s,triggerRef:c,setActiveIndex:l,itemCount:u,menuId:d,portalChain:f}=GV(),p=W.useRef(null),m=a||p,[h,g]=W.useState({top:0,bottom:0,left:0,width:0}),_=r===`bottom`,[v,y]=W.useState(!1);W.useEffect(()=>{if(!o||!c.current)return;let e=c.current.getBoundingClientRect();g({top:e.bottom+8,bottom:window.innerHeight-e.top+8,left:e.left,width:e.width}),y(!1)},[o,c]),W.useLayoutEffect(()=>{if(!o||!_||!m.current)return;let e=m.current.getBoundingClientRect();y(h.top+e.height>window.innerHeight)},[o,_,h.top,m]),W.useEffect(()=>{if(!o||u===0)return;let e=setTimeout(()=>{l(0)},0);return()=>clearTimeout(e)},[o,u,l]),W.useEffect(()=>{if(!o)return;let e=e=>{let t=e.target;if(m.current&&m.current.contains(t)||c.current&&c.current.contains(t))return;let n=t.closest?.(`[data-dropdown-chain]`)?.getAttribute(`data-dropdown-chain`);n&&n.split(`/`).includes(d)||s(!1)},t=setTimeout(()=>{document.addEventListener(`mousedown`,e)},0);return()=>{clearTimeout(t),document.removeEventListener(`mousedown`,e)}},[o,s,m,c,d]);let b=e=>{if(u!==0)switch(e.key){case`ArrowDown`:e.preventDefault(),l(e=>e<u-1?e+1:0);break;case`ArrowUp`:e.preventDefault(),l(e=>e>0?e-1:u-1);break;case`Home`:e.preventDefault(),l(0);break;case`End`:e.preventDefault(),l(u-1);break;case`Escape`:e.preventDefault(),s(!1),c.current?.querySelector(`button`)?.focus();break;case`Tab`:s(!1)}};if(!o)return null;let x={position:`fixed`,zIndex:9999};return r===`top`||v?x.bottom=h.bottom:x.top=h.top,n===`end`?x.right=window.innerWidth-h.left-h.width:n===`start`?x.left=h.left:(x.left=h.left+h.width/2,x.transform=`translateX(-50%)`),NC.createPortal((0,G.jsx)(`div`,{ref:m,role:`menu`,"data-dropdown-chain":f,className:K(`min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95`,e),style:x,onKeyDown:b,...i,children:t}),document.body)});YV.displayName=`DropdownMenuContent`;var XV=W.forwardRef(({className:e,disabled:t,inset:n,onClick:r,onKeyDown:i,...a},o)=>{let{setIsOpen:s,registerItem:c,unregisterItem:l,getItemIndex:u,activeIndex:d}=GV(),f=W.useId(),p=W.useRef(null),m=W.useCallback(e=>{p.current=e,typeof o==`function`?o(e):o&&(o.current=e)},[o]);W.useEffect(()=>(c(f,p),()=>l(f)),[f,c,l]);let h=u(f)===d;return W.useEffect(()=>{h&&p.current?.focus()},[h]),(0,G.jsx)(`div`,{ref:m,role:`menuitem`,tabIndex:t?-1:h?0:-1,"aria-disabled":t,"data-active":h?`true`:void 0,className:K(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors`,`focus:bg-accent focus:text-accent-foreground`,`data-[active]:bg-accent data-[active]:text-accent-foreground`,n&&`pl-8`,t&&`pointer-events-none opacity-50`,e),onClick:e=>{t||(r?.(e),s(!1))},onKeyDown:e=>{t||(i?.(e),(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r?.(e),s(!1)))},...a})});XV.displayName=`DropdownMenuItem`;var ZV=W.forwardRef(({className:e,inset:t,...n},r)=>(0,G.jsx)(`div`,{ref:r,className:K(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));ZV.displayName=`DropdownMenuLabel`;var QV=W.forwardRef(({className:e,...t},n)=>(0,G.jsx)(`div`,{ref:n,className:K(`-mx-1 my-1 h-px bg-muted`,e),...t}));QV.displayName=`DropdownMenuSeparator`;function $V({className:e,children:t,...n}){return(0,G.jsx)(`div`,{className:K(`px-2 py-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,e),...n,children:t})}var eH=[{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`}],tH=[`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`,`Su`];function nH(e,t){return new Date(e,t+1,0).getDate()}function rH(e,t){let n=new Date(e,t,1).getDay();return n===0?6:n-1}function iH(e,t){let n=X(e);if(n.error)return e;if(!t||t===`all`)return ug({...n,window:void 0});let r=X(`:note ${t}`);return r.error||r.family!==`find`||!r.window?e:ug({...n,window:r.window})}function aH(e){let t=X(e);return t.error||t.family===`pipeline`?null:`window`in t?t.window??null:null}function oH({query:e,onQueryChange:t,highlightDates:n=new Set,className:r}){let i=(0,W.useMemo)(()=>aH(e),[e]),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(()=>new Date),l=s.getFullYear(),u=s.getMonth(),d=(0,W.useMemo)(()=>i?i.kind===`relative`?`last ${i.size}${i.unit}`:i.end?`from ${i.start} to ${i.end}`:`from ${i.start}`:`All time`,[i]),f=(0,W.useMemo)(()=>{if(!i)return null;if(i.kind===`range`)return{start:i.start,end:i.end??i.start};let e=new Date,t=new Date;return i.unit===`d`?t.setDate(e.getDate()-i.size):t.setDate(e.getDate()-i.size*7),{start:pF(t),end:pF(e)}},[i]),p=(0,W.useMemo)(()=>{let e=nH(l,u),t=rH(l,u),n=[];for(let e=0;e<t;e++)n.push(null);for(let t=1;t<=e;t++)n.push(t);return n},[l,u]),m=n=>{if(!a)o(n),t(iH(e,`from ${n} to ${n}`));else{let[r,i]=a<=n?[a,n]:[n,a];o(null),t(iH(e,`from ${r} to ${i}`))}},h=e=>{e.stopPropagation(),c(new Date(l,u-1,1))},g=e=>{e.stopPropagation(),c(new Date(l,u+1,1))},_=s.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`}),v=pF(new Date);return(0,G.jsxs)(`div`,{className:K(`relative inline-flex items-center`,r),children:[(0,G.jsxs)(qV,{children:[(0,G.jsx)(JV,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,"data-testid":`wql-window-picker-trigger`,className:`flex h-9 items-center gap-1.5 rounded-lg border border-border bg-background px-2.5 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[(0,G.jsx)(lr,{className:`size-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`font-mono text-xs`,children:d}),(0,G.jsx)(Gt,{className:`size-3 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,G.jsxs)(YV,{align:`end`,className:`w-72 p-3`,children:[(0,G.jsx)(`div`,{className:`mb-3 flex flex-wrap gap-1 border-b border-border/60 pb-2`,children:eH.map(n=>{let r=n.value===`all`?!i:i?.kind===`relative`&&`last ${i.size}${i.unit}`===n.value;return(0,G.jsx)(`button`,{type:`button`,"data-testid":`wql-window-preset-${n.value}`,onClick:()=>{o(null),t(iH(e,n.value))},className:K(`rounded-md px-2 py-1 text-[11px] font-medium transition-colors`,r?`bg-primary text-primary-foreground`:`bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground`),children:n.label},n.value)})}),(0,G.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:h,"data-testid":`wql-calendar-prev-month`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":`Previous month`,children:(0,G.jsx)(pn,{className:`size-4`})}),(0,G.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:_}),(0,G.jsx)(`button`,{type:`button`,onClick:g,"data-testid":`wql-calendar-next-month`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,"aria-label":`Next month`,children:(0,G.jsx)(On,{className:`size-4`})})]}),(0,G.jsx)(`div`,{className:`mb-1 grid grid-cols-7 gap-1`,children:tH.map(e=>(0,G.jsx)(`div`,{className:`text-center text-[10px] font-medium text-muted-foreground`,children:e},e))}),(0,G.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,"data-testid":`wql-calendar-grid`,children:p.map((e,t)=>{if(e===null)return(0,G.jsx)(`div`,{className:`size-8`},`empty-${t}`);let r=`${l}-${String(u+1).padStart(2,`0`)}-${String(e).padStart(2,`0`)}`,i=f&&r>=f.start&&r<=f.end,o=f&&r===f.start||a===r,s=f&&r===f.end,c=r===v,d=n.has(r);return(0,G.jsxs)(`button`,{type:`button`,"data-testid":`wql-calendar-day-${r}`,onClick:()=>m(r),className:K(`relative flex size-8 items-center justify-center rounded-md text-xs transition-colors`,o||s?`bg-primary font-bold text-primary-foreground`:i?`bg-primary/15 font-semibold text-primary`:c?`border border-primary font-semibold text-primary`:`text-foreground hover:bg-muted`),children:[(0,G.jsx)(`span`,{children:e}),d&&!o&&!s&&(0,G.jsx)(`span`,{className:`absolute bottom-0.5 size-1 rounded-full bg-primary`})]},r)})}),a&&(0,G.jsxs)(`div`,{className:`mt-2 text-center text-[10px] text-muted-foreground`,children:[`Select second date to complete range (starting from `,a,`)`]})]})]}),i&&(0,G.jsx)(`button`,{type:`button`,"data-testid":`wql-window-picker-clear`,onClick:()=>{o(null),t(iH(e,null))},title:`Clear time window`,"aria-label":`Clear time window`,className:`ml-1 grid size-7 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,G.jsx)(yr,{className:`size-3.5`})})]})}function sH({onOpen:e}){let t=KV();return(0,G.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{t(),e()},"data-testid":`query-settings-trigger`,className:`w-full justify-start gap-2 rounded-lg text-xs`,children:[(0,G.jsx)(zn,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`truncate`,children:`Query settings`})]})}function cH(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 lH=[{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??``)}],uH={note:lH,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?``:gL(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`sessionLoad`,label:`Session Load`,level:`session`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``}],result:[{id:`title`,label:`Title`,level:`result`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`elapsedTime`,label:`Elapsed Time`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:gL(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`totalTonnage`,label:`Total Tonnage`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``},{id:`tis`,label:`TIS Score`,level:`result`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.tis,formatValue:e=>typeof e==`number`?e.toFixed(1):``},{id:`prBadges`,label:`PR Badges`,level:`result`,defaultVisible:!0,align:`center`,getValue:e=>e.detail&&/\bPR\b/.test(e.detail)?`PR`:``,formatValue:e=>String(e??``)}],segment:[{id:`splitDuration`,label:`Split Duration`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.elapsedMs==null?``:gL(e.execution.elapsedMs),formatValue:e=>String(e??``)},{id:`roundIndex`,label:`Round/Lap Index`,level:`segment`,defaultVisible:!0,align:`left`,getValue:e=>e.title,formatValue:e=>String(e??``)},{id:`reps`,label:`Reps`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.reps,formatValue:e=>e==null?``:String(e)},{id:`load`,label:`Load`,level:`segment`,defaultVisible:!0,align:`right`,getValue:e=>e.execution?.loadLbs,formatValue:e=>typeof e==`number`?`${e.toLocaleString()} lbs`:``},{id:`pacingTier`,label:`Pacing / HR Tier`,level:`segment`,defaultVisible:!0,align:`center`,getValue:e=>e.effort?.intensityTier||e.execution?.effortSlug||``,formatValue:e=>String(e??``)}],effort:[{id:`label`,label:`Label`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.label||e.title,formatValue:e=>String(e??``)},{id:`canonicalSlug`,label:`Canonical Slug`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.slug||e.id,formatValue:e=>String(e??``)},{id:`discipline`,label:`Discipline`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.discipline??``,formatValue:e=>String(e??``)},{id:`met`,label:`MET Score`,level:`effort`,defaultVisible:!0,align:`right`,getValue:e=>e.effort?.met,formatValue:e=>typeof e==`number`?e.toFixed(1):``},{id:`intensityTier`,label:`Intensity Tier`,level:`effort`,defaultVisible:!0,align:`center`,getValue:e=>e.effort?.intensityTier??``,formatValue:e=>String(e??``)},{id:`aliases`,label:`Aliases`,level:`effort`,defaultVisible:!0,align:`left`,getValue:e=>e.effort?.aliases??[],formatValue:e=>Array.isArray(e)?e.join(`, `):String(e??``)}]};function dH(e){return uH[e]??lH}function fH(e){return dH(e).filter(e=>e.defaultVisible).map(e=>e.id)}var pH=1023;function mH(e){return e===`/`?`canvas:home`:`canvas:${e.replace(/^\//,``)}`}function hH(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}=Za(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=e;if(e.startsWith(`wods/examples/`))i=`markdown/canvas/`+e.replace(/^wods\/examples\//,``);else if(e.startsWith(`wods/`))i=`markdown/canvas/`+e.replace(/^wods\//,``);else if(e.startsWith(`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 gH(e){return(e.examples??[]).length>0||e.commands.some(e=>e.pipeline.length>0)}function _H(e){let t=new Map,n=null;for(let r of e)gH(r)&&(n=r),t.set(r.id,n);return t}function vH(){let[e,t]=(0,W.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: ${pH}px)`).matches);return(0,W.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(max-width: ${pH}px)`),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var yH=[{id:`cards`,label:`Cards`,icon:_e},{id:`rows`,label:`Rows`,icon:rt},{id:`feed`,label:`Feed`,icon:Wt},{id:`agenda`,label:`Agenda`,icon:h},{id:`planner`,label:`Planner`,icon:vn}];function bH({streamControls:e}){let t=e.availableLayouts;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,"data-testid":`l3-stream-controls`,children:[e.onOpenQuerySettings&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`This page`}),(0,G.jsx)(sH,{onOpen:e.onOpenQuerySettings})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Date window`}),(0,G.jsx)(oH,{query:e.query,onQueryChange:e.onQueryChange,className:`w-full justify-between`})]}),e.availableGroupDims.length>0&&(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Group by`}),(0,G.jsx)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":`l3-groupby-options`,children:e.availableGroupDims.map(t=>{let n=e.groupDims.some(e=>e.toLowerCase()===t.id.toLowerCase());return(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-xs text-foreground/80 hover:bg-muted/60 transition-colors`,"data-testid":`l3-groupby-${t.id}`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>e.onToggleGroupDim(t.id),className:`size-3.5 rounded border-border accent-primary cursor-pointer`}),(0,G.jsx)(`span`,{children:t.label})]},t.id)})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Layout`}),(0,G.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,"data-testid":`l3-layout-options`,children:yH.filter(e=>!t||t.includes(e.id)).map(t=>{let n=t.icon,r=e.settings.layout===t.id;return(0,G.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>e.onLayoutChange(t.id),"data-testid":`l3-layout-${t.id}`,className:`flex min-h-8 items-center justify-center gap-1 rounded-md border px-1.5 py-1 text-[11px] font-medium transition-colors ${r?`border-border/80 bg-card text-foreground shadow-sm`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:[(0,G.jsx)(n,{"aria-hidden":!0,className:`size-3`}),t.label]},t.id)})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`Fields`}),(0,G.jsx)(`div`,{className:`flex flex-col gap-0.5`,"data-testid":`l3-field-options`,children:dH(e.level).map(t=>{let n=e.settings.visibleFields.includes(t.id);return(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-xs text-foreground/80 hover:bg-muted/60 transition-colors`,"data-testid":`l3-field-${t.id}`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>e.onToggleField(t.id),className:`size-3.5 rounded border-border accent-primary cursor-pointer`}),(0,G.jsx)(`span`,{children:t.label})]},t.id)})})]}),(0,G.jsx)(dR,{})]})}function xH(){let e=vH(),{streamControls:t}=aP();return!e||!t?null:(0,G.jsx)(bH,{streamControls:t})}function SH({spec:e,pageAction:t}){let{l3Items:n,streamControls:r}=aP(),i=BB(e),a=(0,W.useMemo)(()=>UV(n),[n]),o=VB();return i.length===0&&a.length===0&&!r&&!t?null:(0,G.jsxs)(`div`,{className:`flex flex-col px-3 py-4 gap-4`,children:[r&&(0,G.jsx)(`div`,{className:`pb-3 border-b border-border/50`,children:(0,G.jsx)(bH,{streamControls:r})}),i.length>0&&(0,G.jsx)(UB,{entries:i,activeId:o}),a.length>0&&(0,G.jsxs)(`div`,{className:`flex flex-col`,children:[(0,G.jsx)(`div`,{className:`px-2 pb-1 pt-1 text-[10px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:`On this page`}),(0,G.jsx)(UB,{entries:a,activeId:o})]}),t&&(0,G.jsx)(`div`,{className:`pt-2 border-t border-border/50`,children:t})]})}var CH=`wodwiki:fabAlignment`,wH=[{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 TH(){try{return EH(localStorage.getItem(CH))}catch{return}}function EH(e){return e===`right`||e===`left`?e:void 0}var DH=typeof window>`u`?void 0:TH();typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===CH&&(DH=EH(e.newValue))});function OH(e){DH=e;try{e===`right`?localStorage.removeItem(CH):localStorage.setItem(CH,e)}catch{}window.dispatchEvent(new StorageEvent(`storage`,{key:CH,newValue:e}))}function kH(){let[e,t]=(0,W.useState)(()=>DH??`right`);return(0,W.useEffect)(()=>{let e=e=>{e.key===CH&&t(EH(e.newValue)??`right`)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),[e,OH]}function AH({onOpen:e}){return(0,G.jsxs)(`button`,{type:`button`,onClick:e,"aria-label":`Search`,title:`Search`,"data-testid":`search-fab`,className:K(`size-14 rounded-full flex items-center justify-center`,`bg-primary text-primary-foreground shadow-lg`,`hover:bg-primary/90 active:scale-95 transition-all`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`),children:[(0,G.jsx)(ge,{className:`size-6`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Search`})]})}var jH=(0,W.createContext)(null),MH=(0,W.createContext)(!1),NH=(0,W.createContext)(null);function PH(){return(0,W.useContext)(jH)!==null}function FH({primary:e,navbar:t,children:n,label:r,fallback:i=!1}){let a=(0,W.useContext)(jH),o=(0,W.useContext)(MH),s=vH(),c=(0,W.useId)(),l=a!==null&&!o&&s&&!i,u=a!==null&&i,d=n!=null&&n!==!1,f=(0,W.useMemo)(()=>(0,G.jsx)(MH.Provider,{value:!0,children:n}),[n]),p=l||u,m=(0,W.useRef)(null);return m.current={id:c,primary:e,navbar:t,children:f,hasContent:d,label:r??`Page options`,fallback:i},(0,W.useEffect)(()=>{if(p)return a.register(m.current),()=>a.unregister(c)},[p,a,c]),(0,W.useEffect)(()=>{p&&a.register(m.current)},[p,a,e,t,f,d,r,i]),i||a&&s&&!o?null:(0,G.jsx)(MH.Provider,{value:!0,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t,e,n]})})}function IH({onSearch:e,children:t}){let[n,r]=(0,W.useState)([]),i=(0,W.useCallback)(e=>r(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}),[]),a=(0,W.useCallback)(e=>r(t=>t.filter(t=>t.id!==e)),[]),o=(0,W.useMemo)(()=>({register:i,unregister:a}),[i,a]),s=(0,W.useMemo)(()=>{for(let e=n.length-1;e>=0;--e)if(!n[e].fallback)return n[e].navbar??null;return null},[n]);return(0,G.jsx)(jH.Provider,{value:o,children:(0,G.jsxs)(NH.Provider,{value:s,children:[t,(0,G.jsx)(RH,{registrations:n,onSearch:e})]})})}function LH(){let e=(0,W.useContext)(NH);return e?(0,G.jsx)(G.Fragment,{children:e}):null}function RH({registrations:e,onSearch:t}){let n=vH(),[r]=kH(),i=FC(),[a,o]=(0,W.useState)(!1),s=(0,W.useCallback)(()=>o(!1),[]),c=(0,W.useRef)(null),l=(0,W.useRef)(null),u=(0,W.useRef)(null),d=(0,W.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(!e[t].fallback)return e[t]},[e]),f=(0,W.useMemo)(()=>{for(let t=e.length-1;t>=0;--t)if(e[t].fallback)return e[t]},[e]);(0,W.useLayoutEffect)(()=>{a&&c.current?.focus({preventScroll:!0})},[a]);let p=!!(d?.hasContent||f?.hasContent);return!n||!t&&!d&&!f?null:(0,G.jsxs)(`div`,{"data-testid":`actions-dock`,className:K(`lg:hidden relative z-40 mt-4 flex flex-col items-center gap-2`,`transition-[transform,visibility] duration-200 ease-out`,r===`left`?`self-start items-start`:`self-end items-end`),children:[(0,G.jsxs)(`div`,{className:`relative z-40 flex flex-col items-center gap-2`,children:[t&&(0,G.jsx)(AH,{onOpen:()=>{o(!1),t()}}),d?.primary&&(0,G.jsx)(`div`,{className:`[&_button]:min-h-11 [&_button]:min-w-11`,children:d.primary})]}),a&&p&&(0,G.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-hidden":`true`,className:`fixed inset-0 z-30 cursor-default`,onClick:()=>o(!1)}),(0,G.jsx)(`div`,{ref:c,role:`dialog`,"aria-label":d?.label??f?.label??`Page options`,tabIndex:-1,hidden:!a||!p,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),o(!1))},className:K(a&&p?`flex`:`hidden`,`relative z-40 w-60 max-w-[calc(100vw-2rem)] flex-col gap-3 overflow-y-auto rounded-2xl bg-card p-3 shadow-xl ring-1 ring-foreground/5 outline-none`,`[&_button]:min-h-11 [&_button]:min-w-11`),style:{maxHeight:`calc(${i.height===null?`100dvh`:`${i.height}px`} - 6rem - env(safe-area-inset-bottom))`},children:(0,G.jsxs)(TF,{close:s,children:[(0,G.jsx)(`div`,{ref:l,className:`contents`,children:d?.children}),d?.children&&f?.children&&(0,G.jsx)(`div`,{className:`my-1 border-t border-border/60`,"aria-hidden":`true`}),(0,G.jsx)(`div`,{ref:u,className:`contents`,children:f?.children})]})}),p&&(0,G.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-label":d?.label??f?.label??`Page options`,title:d?.label??f?.label??`Page options`,"aria-expanded":a,"data-testid":`actions-overflow`,className:K(`relative z-40 flex size-12 items-center justify-center rounded-full`,`bg-card text-foreground shadow-lg ring-1 ring-foreground/10`,`hover:bg-muted active:scale-95 transition-all`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`),children:[a?(0,G.jsx)(rr,{className:`size-6`}):(0,G.jsx)(I,{className:`size-6`}),(0,G.jsx)(`span`,{className:`sr-only`,children:d?.label??f?.label??`Page options`})]})]})}function zH(){return(0,G.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,G.jsx)(`path`,{d:`M2 6.75C2 6.33579 2.33579 6 2.75 6H17.25C17.6642 6 18 6.33579 18 6.75C18 7.16421 17.6642 7.5 17.25 7.5H2.75C2.33579 7.5 2 7.16421 2 6.75ZM2 13.25C2 12.8358 2.33579 12.5 2.75 12.5H17.25C17.6642 12.5 18 12.8358 18 13.25C18 13.6642 17.6642 14 17.25 14H2.75C2.33579 14 2 13.6642 2 13.25Z`})})}function BH(){return(0,G.jsx)(`svg`,{"data-slot":`icon`,viewBox:`0 0 20 20`,"aria-hidden":`true`,className:`[&>[data-slot=icon]]:size-5`,children:(0,G.jsx)(`path`,{d:`M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z`})})}function VH(){let{tree:e,navState:t,contextNav:n}=aP(),r=En(),i=EF();return!e.find(e=>e.id===t.activeL1Id)?.applyFooter||n?.pathname===r.pathname?null:(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border/50 bg-card p-3`,children:(0,G.jsx)(`button`,{type:`button`,onClick:i,className:`h-11 w-full rounded-lg bg-primary text-sm font-medium text-primary-foreground`,children:`Apply`})})}function HH({open:e,close:t,onSearch:n,children:r}){return(0,G.jsxs)(nt,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,G.jsx)(Qe,{transition:!0,className:`fixed inset-0 bg-black/30 dark:bg-black/30 transition data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in`}),(0,G.jsx)(i,{transition:!0,className:`fixed inset-y-0 left-0 w-full transition duration-300 ease-out data-closed:-translate-x-full`,children:(0,G.jsx)(TF,{close:t,children:(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 bg-card`,children:[(0,G.jsx)(`div`,{className:`flex h-full w-14 shrink-0 flex-col items-center border-r border-zinc-950/5 bg-background/72 py-3 dark:border-white/5 [&_a]:size-11 [&_button]:size-11`,children:(0,G.jsx)(QB,{onSearch:()=>{t(),n?.()}})}),(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,G.jsx)(`div`,{className:`flex items-center px-4 pt-3`,children:(0,G.jsxs)(Fn,{as:Tz,"aria-label":`Close navigation`,title:`Close navigation`,children:[(0,G.jsx)(BH,{}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Close navigation`})]})}),(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:r}),(0,G.jsx)(VH,{})]})]})})})]})}function UH({open:e,close:t,children:n}){return(0,G.jsxs)(nt,{open:e,onClose:t,className:`relative z-50 lg:hidden`,children:[(0,G.jsx)(Qe,{transition:!0,className:`fixed inset-0 bg-black/30 dark:bg-black/30 transition data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in`}),(0,G.jsx)(i,{transition:!0,className:`fixed inset-y-0 right-0 w-full transition duration-300 ease-out data-closed:translate-x-full`,children:(0,G.jsx)(TF,{close:t,children:(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-card`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-end px-4 pt-3`,children:(0,G.jsxs)(Fn,{as:Tz,"aria-label":`Close page options`,title:`Close page options`,children:[(0,G.jsx)(BH,{}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Close page options`})]})}),(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:n}),(0,G.jsx)(`div`,{className:`shrink-0 border-t border-border/50 bg-card p-3`,children:(0,G.jsx)(`button`,{type:`button`,onClick:t,className:`h-11 w-full rounded-lg bg-primary text-sm font-medium text-primary-foreground`,children:`Apply`})})]})})})]})}function WH({navbar:e,sidebar:t,onSearch:n,secondary:r,pageAction:i,hideDesktopSidebar:a,children:o}){let[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(!1),{streamControls:d,l3Items:f}=aP(),p=!!(r&&r.length>0||f&&f.length>0||d||i),m=(0,W.useMemo)(()=>{let e=X(d?.query??``);return!e.error&&_h(e)&&e.filters.length>0},[d?.query]);return(0,W.useEffect)(()=>{if(!s&&!l)return;let e=()=>{c(!1),u(!1)};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[s,l]),(0,G.jsx)(zV,{children:(0,G.jsx)(IH,{onSearch:n,children:(0,G.jsx)(`div`,{className:`relative isolate flex min-h-svh w-full bg-background max-lg:flex-col lg:flex-row`,children:(0,G.jsxs)(`div`,{className:`flex flex-1 w-full max-lg:flex-col lg:flex-row`,children:[(0,G.jsxs)(`nav`,{"aria-label":`Main`,className:`hidden lg:flex`,children:[(0,G.jsx)(`div`,{className:`w-14 shrink-0 sticky top-0 h-svh flex flex-col items-center border-r border-zinc-950/5 dark:border-white/5 bg-background/72 backdrop-blur-sm z-40 py-3`,children:(0,G.jsx)(QB,{onSearch:n??(()=>{})})}),(0,G.jsx)(`div`,{className:K(`w-60 shrink-0 sticky top-0 self-start h-svh min-h-0 overflow-hidden border-r border-zinc-950/5 dark:border-white/5 bg-background/72 backdrop-blur-sm flex flex-col`,a&&`lg:hidden`),children:t})]}),(0,G.jsx)(HH,{open:s,close:()=>c(!1),onSearch:n,children:t}),(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col min-w-0 xl:max-w-[984px] 2xl:max-w-none`,children:[(0,G.jsxs)(`header`,{"data-page-sticky-boundary":`true`,className:`lg:hidden sticky top-0 z-20 flex items-center px-2 sm:px-4 bg-card`,children:[(0,G.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,G.jsxs)(Tz,{onClick:()=>c(!0),"aria-label":`Open navigation`,title:`Open navigation`,children:[(0,G.jsx)(zH,{}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Open navigation`})]})}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),p&&(0,G.jsx)(`div`,{className:`py-2.5 shrink-0`,children:(0,G.jsxs)(Tz,{onClick:()=>u(!0),"aria-label":`Open page options`,title:`Open page options`,children:[(0,G.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,G.jsx)(zn,{className:`size-5`}),m&&(0,G.jsx)(`span`,{"data-testid":`drawer-filters-active`,className:`absolute -top-1 -right-1 size-2 rounded-full bg-amber-500`,"aria-hidden":`true`})]}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Open page options`})]})})]}),(0,G.jsxs)(`main`,{className:`flex flex-1 flex-col lg:min-w-0`,children:[(0,G.jsx)(`div`,{className:`grow w-full max-lg:pb-48 lg:overflow-visible`,children:o}),(0,G.jsx)(GH,{})]})]}),(0,G.jsx)(`aside`,{className:`hidden 2xl:flex w-60 shrink-0 sticky top-0 h-svh flex-col overflow-y-auto bg-background/72 backdrop-blur-sm`,children:(0,G.jsx)(SH,{spec:r,pageAction:i})}),(0,G.jsx)(UH,{open:l,close:()=>u(!1),children:(0,G.jsx)(SH,{spec:r,pageAction:i})})]})})})})}function GH(){let e=(0,W.useRef)(null),[t,n]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(e=>{let t=Math.round(e[0]?.contentRect.height??0);n(e=>e===t?e:t)});r.observe(t,{box:`content-box`});let i=Math.round(t.getBoundingClientRect().height);return n(e=>e===i?e:i),()=>r.disconnect()},[]),(0,W.useEffect)(()=>(document.documentElement.style.setProperty(`--thumb-dock-lift`,`${t}px`),()=>document.documentElement.style.setProperty(`--thumb-dock-lift`,`0px`)),[t]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:K(`lg:hidden fixed inset-x-0 bottom-0 z-30`,t>0&&`bg-card border-t border-border/50 px-3 py-2`),children:(0,G.jsx)(`div`,{ref:e,className:`w-full min-w-0`,children:(0,G.jsx)(BV,{className:`flex w-full min-w-0`})})}),(0,G.jsx)(`div`,{className:`lg:hidden`,"aria-hidden":`true`,style:{height:t}})]})}function KH(e){let t=e.indexOf(`markdown`);return t!==-1&&e.length>t+2?e[t+2]:`General`}function qH(e){return String(to(Za(e).meta,`search`)??``).toLowerCase()===`hidden`}function JH(e){let t=to(Za(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 YH(e){return Object.entries(e).map(([e,t])=>{let n=e.split(`/`),r=n[n.length-1].replace(`.md`,``),i=t,a=to(Za(i).meta,`title`);return{id:e,name:r,displayName:typeof a==`string`&&a.trim()?a.trim():IO(r),category:KH(n),content:i,date:JH(i),searchHidden:qH(i)}})}function XH(){let e=ak();return(0,W.useMemo)(()=>e?YH(e):[],[e])}var ZH={};function QH(e){if(!(`payload`in e))return;let t=e.payload;if(!t||typeof t!=`object`)return;let n=t;return n.targetDate??n.updatedAt}function $H(e,t){let{canvasPage:n,workoutItems:r,recentResults:i,selectWorkout:a}=t;if(e===`/`)return[];if(n){let t=/^\/notebook\//.test(e),i=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=qR(e).split(`
110
110
  `),n=0;t.forEach((t,r)=>{let i=t.trim().match(/^```(time|log)(:\w+)?\s*$/);if(i){let t=i[1];n++,o.push({id:`${e.id}-${t}-${r+1}`,label:`Workout ${n}`,type:t})}})}}),t&&i&&(o.push({id:`notebook-workouts`,label:`Explore`,type:`heading`}),r.filter(e=>e.category===i&&e.name.toLowerCase()!==`readme`).forEach(e=>{o.push({id:`workout-${e.id}`,label:e.name,type:`time`,onRun:()=>a(e),runIcon:`link`})})),o}if(e===`/journal`){let e=new Set;return i.forEach(t=>{let n=new Date(t.createdAt).getTime();Number.isFinite(n)&&e.add(pF(new Date(n)))}),r.forEach(t=>{let n=QH(t);n&&Number.isFinite(new Date(n).getTime())&&e.add(pF(new Date(n)))}),Array.from(e).sort().reverse().slice(0,10).map(e=>({id:e,label:Rb(new Date(e+`T00:00:00`)),type:`heading`}))}return[]}var eU=/^[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 tU(e){return eU.test(e)}function nU(e){try{return decodeURIComponent(e)}catch{return null}}function rU(e){if(!gF(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 iU(e){let t=(e.length>1?e.replace(/\/+$/,``):e).match(/^\/day\/([^/]+)$/);if(!t)return{kind:`invalid`};let n=nU(t[1]);return n!=null&&rU(n)?{kind:`date`,date:n}:{kind:`invalid`}}var aU=`# My Workout Notebook
111
111
 
112
112
  Welcome to the **WOD.WIKI** playground.
@@ -169,7 +169,7 @@ Timer 12:00
169
169
  border border-border/80 shadow-xl rounded-lg overflow-hidden pointer-events-auto`,style:{top:k,maxHeight:200},children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 bg-muted/40 border-b border-border/50 shrink-0`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-mono px-2 py-0.5 rounded bg-metric-time/10 text-metric-time uppercase tracking-wider font-semibold`,children:h.type}),(0,G.jsxs)(`div`,{className:`flex items-center min-w-0 gap-2`,children:[(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground/60`,children:[`L`,D]}),(0,G.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}),(0,G.jsx)(`span`,{className:`text-xs font-mono text-foreground/90 truncate font-medium`,title:E,children:E||(0,G.jsx)(`span`,{className:`italic text-muted-foreground`,children:`—`})})]})]}),(0,G.jsx)(`div`,{className:`px-3 py-2.5 min-h-0 overflow-auto`,children:w.length>0?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:w.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 rounded-md text-sm font-semibold ${e.color}`,title:e.label,children:[(0,G.jsx)(`span`,{className:`text-base leading-none`,children:e.icon}),(0,G.jsx)(`span`,{className:`font-mono tracking-tight`,children:e.value})]},t))}):(0,G.jsx)(`span`,{className:`text-xs italic text-muted-foreground`,children:`No metrics on this line`})}),T&&(0,G.jsx)(WY,{summary:T}),(0,G.jsx)(`div`,{className:`border-t border-border/40 shrink-0`,children:(0,G.jsx)(JY,{commands:f,section:h,view:n})})]})]})},XY=({sectionId:e,widgetName:t,view:n,registry:r,docVersion:i})=>{let{rawContent:a,config:o}=(0,W.useMemo)(()=>{let t=n.state.field(ST).sections.find(t=>t.id===e),r=t?.contentFrom!==void 0&&t?.contentTo!==void 0?n.state.doc.sliceString(t.contentFrom,t.contentTo).trim():``,i={};if(r)try{i=JSON.parse(r)}catch{}return{rawContent:r,config:i}},[n,e,i]),s=r.get(t);return s?(0,G.jsx)(`div`,{className:`h-full w-full overflow-hidden rounded-l-md border-l border-border bg-background shadow-sm`,children:(0,G.jsx)(s,{config:o,rawContent:a,sectionId:e})}):(0,G.jsxs)(`div`,{className:`flex h-full w-full items-center justify-center rounded-l-md border-l border-border bg-muted/60 p-4 text-xs text-muted-foreground`,children:[(0,G.jsxs)(`span`,{className:`font-mono`,children:[`widget:`,t]}),(0,G.jsx)(`span`,{className:`ml-2 opacity-60`,children:`— not registered`})]})};function ZY(e,t,n,r,i){switch(t.type){case`fixed-field`:return QY(e,t);case`metric-type`:return $Y(e,t);case`derived`:return eX(e,t,n,r,i);case`fallback`:return tX(e,t,n,r,i);default:return}}function QY(e,t){return e[t.field]}function $Y(e,t){return e.cells.get(t.metricType)}function eX(e,t,n,r,i){let a=new Map;if(t.dependencies&&r)for(let o of t.dependencies){if(i?.includes(o))throw Error(`Circular dependency detected in column '${o}': ${(i??[]).join(` -> `)} -> ${o}`);let t=r.get(o);if(t){let s=ZY(e,t.source,n,r,[...i??[],o]);a.set(o,s)}}let o={...n,allRows:n?.allRows??[e],rowIndex:n?.rowIndex??0,columnDef:n?.columnDef??{id:`unknown`,label:``,source:t,format:{type:`text`}},dependencies:a,...t.context};return t.compute(e,o)}function tX(e,t,n,r,i){return nX(e,t,n,r,i)}function nX(e,t,n,r,i){if(!(!t.sources||t.sources.length===0))switch(t.semantics){case`first-present`:return rX(e,t.sources,n,r,i);case`all-present-joined`:return iX(e,t.sources,t.joinString,n,r,i);case`all-present-combined`:return aX(e,t.sources,n,r,i);default:return}}function rX(e,t,n,r,i){for(let a of t){let t=ZY(e,a,n,r,i);if(t!=null)return t}}function iX(e,t,n,r,i,a){let o=[];for(let n of t){let t=ZY(e,n,r,i,a);if(t==null)return;o.push(t)}let s=n??` `;return o.map(e=>sX(e)).join(s)}function aX(e,t,n,r,i){let a=[];for(let o of t){let t=ZY(e,o,n,r,i);if(t==null)return;a.push(t)}return a}function oX(e){if(e==null)return``;let t=Array.isArray(e)?e:e instanceof ca?e.toArray():[];if(t.length===0)return``;let n=t[0];if(typeof n==`object`&&n){if(`image`in n&&typeof n.image==`string`)return n.image;if(`value`in n&&n.value!==void 0)return String(n.value)}return String(n)}function sX(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(typeof e==`object`&&`metrics`in e){let t=oX(e.metrics);if(t.length>0)return t}return String(e)}function cX(e,t,n,r){if(!t.sort)return``;let i=ZY(e,t.source,n,r);return(t.sort.type===`custom`?typeof i==`number`||typeof i==`string`?i:String(i??``):t.sort.extractor(i))??``}function lX(e,t){if(typeof e==`number`&&typeof t==`number`)return Number.isNaN(e)&&Number.isNaN(t)?0:Number.isNaN(e)?1:Number.isNaN(t)?-1:e-t;let n=String(e??``),r=String(t??``),i=parseFloat(n),a=parseFloat(r);return!Number.isNaN(i)&&!Number.isNaN(a)&&n===String(i)&&r===String(a)?i-a:n.localeCompare(r)}function uX(e,t,n,r){if(!t.graph)return;let i=ZY(e,t.source,n,r);return t.graph.extractor(i)}function dX(e,t,n,r){if(!t.filter)return``;let i=ZY(e,t.source,n,r);return t.filter.extractor(i)??``}function fX(e,t,n,r,i){if(!n||n.trim().length===0||!t.filter)return!0;let a=dX(e,t,r,i),o=t.filter.caseInsensitive===!1?n.trim():n.trim().toLowerCase(),s=t.filter.caseInsensitive===!1?a:a.toLowerCase();return t.filter.matcher?t.filter.matcher(s,o):s.includes(o)}var pX=({metric:e})=>{let t=e.origin===`hinted`||e.image===`?`,n=(0,W.useMemo)(()=>jG(Ko.present(e,`review-grid-cell`)),[e]);return(0,G.jsxs)(`span`,{className:[`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded text-xs font-medium border transition-all`,t?`bg-warning/10 border-warning/40 text-warning animate-pulse-opacity`:`${n.colorClasses} ${n.originClasses}`].join(` `),title:t?`Missing value - click to fill`:n.tooltip,children:[t&&(0,G.jsx)(`span`,{className:`mr-0.5 text-[10px]`,children:`◉`}),n.label,n.userEntered&&!t&&(0,G.jsx)(`span`,{className:`text-[10px] opacity-70 ml-0.5`,children:`👤`})]})},mX=({columnDef:e,row:t,allRows:n,rowIndex:r,indent:i=0,onDoubleClick:a,className:o,style:s,definitionMap:c})=>{let l=(0,W.useRef)(null),u=(0,W.useMemo)(()=>{if(!(!n||r===void 0))return{allRows:n,rowIndex:r,columnDef:e,dependencies:new Map}},[n,r,e]),d=(0,W.useMemo)(()=>ZY(t,e.source,u,c),[t,e.source,u,c]),f=e.source.type===`metric-type`,p=(0,W.useCallback)(n=>{if(n.stopPropagation(),f&&a&&l.current){let n=l.current.getBoundingClientRect();a(t.sourceBlockKey,e.source.metricType,n)}},[f,e.source,t.sourceBlockKey,a]),m=(0,W.useMemo)(()=>hX(d,e.format,i,t),[d,e.format,i,t]);return(0,G.jsx)(`td`,{ref:l,className:K(`py-1 px-2`,f&&`cursor-cell`,o),style:s,onDoubleClick:p,children:m})};function hX(e,t,n,r){if(e==null)return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[OX(n),(0,G.jsx)(`span`,{className:`text-muted-foreground opacity-40`,children:`—`})]});switch(t.type){case`text`:return gX(e,t,n);case`time`:return _X(e,t);case`number`:return vX(e,t);case`badge`:return yX(e,t);case`pill`:return bX(e,t);case`combined`:return SX(e,t,n);case`custom`:return wX(e,t,r);default:return EX(e,n)}}function gX(e,t,n){let r=t.transform?t.transform(e):kX(e);return(0,G.jsxs)(`span`,{className:K(`inline-flex items-center gap-1`,t.className),children:[OX(n),r]})}function _X(e,t){let n=AX(e);if(n==null||!Number.isFinite(n))return(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r;switch(t.style){case`long`:r=JW(n);break;case`precise`:r=`${n.toFixed(2)}s`;break;default:r=qW(n)}return t.transform&&(r=t.transform(r)),(0,G.jsx)(`span`,{className:`font-mono text-xs whitespace-nowrap`,children:r})}function vX(e,t){let n=AX(e);if(n==null||!Number.isFinite(n))return(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t.decimals??0,i=n.toFixed(r)+(t.unit??``);return t.transform?(0,G.jsx)(`span`,{children:t.transform(i)}):(0,G.jsx)(`span`,{children:i})}function yX(e,t){let n=t.styleResolver(e),r=t.textResolver(e);return(0,G.jsxs)(`span`,{className:K(`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium`,n.className),title:n.title,children:[n.icon&&(0,G.jsx)(`span`,{className:`mr-0.5`,children:n.icon}),r]})}function bX(e,t){let n=t.transform?t.transform(e):kX(e),r=t.backgroundColor??`bg-muted`,i=t.borderRadius??`rounded`;return(0,G.jsx)(`span`,{className:K(`inline-block px-1.5 py-0.5 text-xs font-medium`,r,i),children:n})}var xX={primary:`text-sm font-semibold text-foreground`,secondary:`text-xs text-muted-foreground`,tertiary:`text-[11px] text-muted-foreground opacity-80`};function SX(e,t,n,r){let[i,a,o]=Array.isArray(e)?e:[e],s=i===void 0?null:CX(i,t.primaryFormat??{type:`text`},r,`primary`),c=a===void 0?null:CX(a,t.secondaryFormat??{type:`text`},r,`secondary`),l=o===void 0?null:CX(o,t.tertiaryFormat??{type:`text`},r,`tertiary`),u=t.layout===`horizontal`;return(0,G.jsxs)(`div`,{className:K(`inline-flex`,u?`flex-row items-center gap-1`:`flex-col items-start gap-0.5`,t.containerClassName),children:[OX(n),s,c&&(0,G.jsxs)(G.Fragment,{children:[u&&t.separator&&(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:t.separator}),c]}),l&&(0,G.jsxs)(G.Fragment,{children:[u&&t.separator&&(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:t.separator}),l]})]})}function CX(e,t,n,r){let i=hX(e,t,0,n);return r?(0,G.jsx)(`span`,{className:K(`inline-flex items-center`,xX[r]),children:i}):i}function wX(e,t,n){let r=n?{...t.context,row:n}:t.context;return t.render(e,r)}function TX(e){let t=e?.metrics;if(!t)return[];if(Array.isArray(t))return t;if(typeof t==`object`&&t&&`toArray`in t){let e=t;if(typeof e.toArray==`function`)return e.toArray()}return[]}function EX(e,t){return e?.metrics?DX(e,t):(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[OX(t),kX(e)]})}function DX(e,t){let n=TX(e);return n.length===0?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[OX(t),(0,G.jsx)(`span`,{className:`text-muted-foreground opacity-40`,children:`—`})]}):(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-1 items-center`,children:[OX(t),n.map((e,t)=>(0,G.jsx)(pX,{metric:e},t))]})}function OX(e){return e<=0?null:(0,G.jsx)(`div`,{className:`flex-shrink-0 mr-1 border-l-2 border-muted h-4`,style:{width:`${e*1.25}rem`,marginLeft:`2px`}})}function kX(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);let t=TX(e);if(t.length>0){let e=t[0];if(e?.image)return e.image;if(e?.value!==void 0)return String(e.value)}return String(e)}function AX(e){if(e==null)return;if(typeof e==`number`)return e;if(typeof e==`string`){let t=parseFloat(e);if(!Number.isNaN(t))return t}let t=TX(e);if(t.length>0&&typeof t[0]?.value==`number`)return t[0].value}var jX=e=>e;function MX(e){let t=e?.metrics;if(!t)return[];if(Array.isArray(t))return t;if(typeof t==`object`&&t&&`toArray`in t){let e=t;if(typeof e.toArray==`function`)return e.toArray()}return[]}function NX(e){let t=MX(e);if(t.length===0)return;let n=t[0];return typeof n?.value==`number`?n.value:n?.image?n.image:String(n?.value??``)}function PX(e){let t=MX(e);for(let e of t)if(typeof e?.value==`number`)return e.value}function FX(e){return MX(e).map(e=>e.image??String(e.value??``)).join(`, `)}function IX(e){return e==null?``:Array.isArray(e)?e.map(e=>IX(e)).filter(Boolean).join(` — `):typeof e==`string`?e:typeof e==`number`?String(e):FX(e)}function LX(e){switch(e){case J.Duration:case J.Rep:case J.Distance:case J.Rounds:case J.Resistance:case J.Increment:case J.Metric:case J.Volume:case J.Intensity:case J.Load:case J.Work:case J.CurrentRound:case J.Calculated:return!0;default:return!1}}function RX(e){switch(e){case J.Duration:return`s`;case J.Rep:return`reps`;case J.Distance:return`m`;case J.Rounds:return`rounds`;case J.Resistance:return`kg`;case J.Increment:return`Δ`;case J.Calculated:case J.Custom:return``;default:return``}}function zX(e,t){let n=Ao(e),r=pG(e)??void 0,i=t?.graphable??LX(e);return{id:e,label:n,icon:r,source:{type:`metric-type`,metricType:e},format:{type:`custom`,render:e=>DX(e,0)},sort:LX(e)?{type:`numeric`,extractor:e=>PX(e)}:{type:`text`,extractor:e=>{let t=NX(e);return t===void 0?void 0:String(t)}},graph:i?{extractor:e=>PX(e),axisLabel:n,unit:RX(e)}:void 0,filter:{extractor:e=>FX(e),caseInsensitive:!0},meta:{defaultVisible:t?.defaultVisible??!0,debugOnly:t?.debugOnly,tags:[e]}}}function BX(e){switch(e){case`segment`:return`bg-blue-100 text-blue-800 dark:bg-blue-900/50 dark:text-blue-200`;case`milestone`:return`bg-yellow-100 text-yellow-800 dark:bg-yellow-900/50 dark:text-yellow-200`;case`system`:return`bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400`;case`event`:return`bg-purple-100 text-purple-800 dark:bg-purple-900/50 dark:text-purple-200`;case`group`:return`bg-indigo-100 text-indigo-800 dark:bg-indigo-900/50 dark:text-indigo-200`;case`load`:return`bg-green-100 text-green-800 dark:bg-green-900/50 dark:text-green-200`;case`compiler`:return`bg-pink-100 text-pink-800 dark:bg-pink-900/50 dark:text-pink-200`;default:return`bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300`}}function VX(e,t){if(!e||e.length===0)return``;let n=e=>qW(e);if(t===0)return n(e[0].started);let r=n(e[0].started),i=e[e.length-1];if(i.ended===void 0)return r;let a=n(i.ended);return r===a?r:`${r} — ${a}`}function HX(e,t=!0){if(e===void 0||e===0)return``;let n=new Date(e),r=n.getHours().toString().padStart(2,`0`),i=n.getMinutes().toString().padStart(2,`0`),a=n.getSeconds().toString().padStart(2,`0`);return t?`${r}:${i}:${a}.${n.getMilliseconds().toString().padStart(3,`0`)}`:`${r}:${i}:${a}`}function UX({value:e}){let t=e.match(/^(-?)(\d+)(:\d{2})(?::\d{2})?(\.\d+)?$/);if(!t)return(0,G.jsx)(`span`,{className:`font-mono text-xs whitespace-nowrap`,children:e});let[,n,r,i,a,o]=t,s=i.slice(1);return(0,G.jsxs)(`span`,{className:`font-mono text-xs whitespace-nowrap inline-flex items-baseline`,children:[n&&(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:n}),(0,G.jsx)(`span`,{className:`font-semibold text-foreground`,children:r}),(0,G.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`:`,s]}),a&&(0,G.jsx)(`span`,{className:`text-muted-foreground/40`,children:a}),o&&(0,G.jsx)(`span`,{className:`text-muted-foreground/30 text-[10px]`,children:o})]})}function WX({elapsed:e,duration:t}){let n=qW(e);return(0,G.jsxs)(`span`,{className:`inline-flex items-baseline gap-0.5`,children:[(0,G.jsx)(UX,{value:n}),t!==void 0&&t>0&&t!==e&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-muted-foreground/40 mx-0.5`,children:`/`}),(0,G.jsx)(`span`,{className:`opacity-60`,children:(0,G.jsx)(UX,{value:qW(t)})})]})]})}var GX={id:`#`,label:`#`,source:{type:`derived`,compute:e=>({index:e.index,outputType:e.outputType,sourceBlockKey:e.sourceBlockKey})},format:{type:`custom`,render:e=>{let{index:t,outputType:n,sourceBlockKey:r}=e??{};return(0,G.jsx)(`span`,{className:K(`font-mono text-[11px] w-8 text-right inline-block`,BX(n)),title:`Type: ${n}\nBlock: ${r}`,children:t})}},sort:{type:`numeric`,extractor:e=>jX(e)?.index||0},meta:{tags:[`layout`],defaultVisible:!0,width:`40px`,resizable:!1}},KX={id:`timestamp`,label:`Timestamp`,source:{type:`fixed-field`,field:`absoluteStartTime`},format:{type:`custom`,render:(e,t)=>{let n=e,r=jX(t)?.hideMs!==!1;return(0,G.jsx)(`span`,{className:`text-muted-foreground font-mono text-[10px] text-center w-24 whitespace-nowrap`,children:HX(n,r)})},context:{hideMs:!1}},sort:{type:`numeric`,extractor:e=>jX(e)?.absoluteStartTime??0},meta:{tags:[`timing`,`layout`],defaultVisible:!0}},qX={id:`spans`,label:`Time`,source:{type:`derived`,compute:e=>({spans:e.spans,duration:e.duration})},format:{type:`custom`,render:e=>{let{spans:t,duration:n}=e??{};return(0,G.jsx)(`span`,{className:`text-muted-foreground font-mono text-[10px] text-center w-40 whitespace-nowrap`,children:VX(t,n)})}},sort:{type:`numeric`,extractor:e=>(jX(e)?.spans)?.[0]?.started??0},meta:{tags:[`timing`,`layout`],defaultVisible:!0}},JX={id:`timeSpan`,label:`Time`,source:{type:`derived`,compute:e=>({timestamp:e.absoluteStartTime,elapsed:e.elapsed,duration:e.duration})},format:{type:`custom`,render:e=>{let{timestamp:t,elapsed:n,duration:r}=e??{};return n===void 0?(0,G.jsx)(`span`,{className:`text-muted-foreground opacity-40`,children:`—`}):(0,G.jsxs)(`div`,{className:`flex flex-col items-start gap-0 leading-tight`,children:[t!==void 0&&t>0&&(0,G.jsx)(`span`,{className:`text-muted-foreground/50 font-mono text-[10px] whitespace-nowrap`,children:HX(t,!1)}),(0,G.jsx)(WX,{elapsed:n,duration:r})]})}},sort:{type:`numeric`,extractor:e=>jX(e)?.elapsed??0},graph:{extractor:e=>jX(e)?.elapsed,axisLabel:`Elapsed`,unit:`s`},filter:{extractor:e=>{let{timestamp:t,elapsed:n,duration:r}=e??{},i=[];return t!==void 0&&t>0&&i.push(HX(t,!1)),n!==void 0&&i.push(qW(n)),r!==void 0&&r>0&&r!==n&&i.push(qW(r)),i.join(` `)},caseInsensitive:!0},meta:{tags:[`timing`,`compound`],defaultVisible:!0,width:`100px`,subsumes:[`duration`,`elapsedTotal`]}},YX={id:`blockKey`,label:`Block`,source:{type:`fixed-field`,field:`sourceBlockKey`},format:{type:`text`,className:`truncate max-w-[160px] text-sm`},sort:{type:`text`,extractor:e=>jX(e)?.sourceBlockKey??``},filter:{extractor:e=>jX(e)?.sourceBlockKey??``,caseInsensitive:!0},meta:{tags:[`layout`],defaultVisible:!1}},XX={id:`outputType`,label:`Type`,source:{type:`fixed-field`,field:`outputType`},format:{type:`custom`,render:e=>{let t=String(e??``);return(0,G.jsx)(`span`,{className:K(`text-xs px-1.5 py-0.5 rounded font-medium`,BX(t)),children:t})}},sort:{type:`text`,extractor:e=>jX(e)?.outputType??``},filter:{extractor:e=>jX(e)?.outputType??``,caseInsensitive:!0},meta:{tags:[`debug`],defaultVisible:!1}},ZX={id:`stackLevel`,label:`Depth`,source:{type:`fixed-field`,field:`stackLevel`},format:{type:`text`,className:`text-muted-foreground font-mono text-xs text-center w-12`},sort:{type:`numeric`,extractor:e=>jX(e)?.stackLevel??0},meta:{tags:[`debug`],defaultVisible:!1,debugOnly:!0}},QX={id:`elapsedTotal`,label:`Elapsed`,source:{type:`derived`,compute:e=>({elapsed:e.elapsed,total:e.total})},format:{type:`custom`,render:e=>{let{elapsed:t,total:n}=e??{};if(t===void 0||n===void 0)return``;let r=t===n?qW(t):`${qW(t)} / ${qW(n)}`;return(0,G.jsx)(`span`,{className:`text-foreground font-mono text-xs text-right w-32 whitespace-nowrap`,children:r})}},sort:{type:`numeric`,extractor:e=>jX(e)?.elapsed??0},graph:{extractor:e=>jX(e)?.elapsed,axisLabel:`Elapsed`,unit:`s`,color:`#14b8a6`},meta:{tags:[`timing`],defaultVisible:!1}},$X={id:`completionReason`,label:`Reason`,source:{type:`fixed-field`,field:`completionReason`},format:{type:`text`,className:`text-muted-foreground text-xs truncate max-w-[120px]`},sort:{type:`text`,extractor:e=>jX(e)?.completionReason??``},filter:{extractor:e=>jX(e)?.completionReason??``,caseInsensitive:!0},meta:{tags:[`debug`],defaultVisible:!1,debugOnly:!0}},eZ=zX(J.Effort,{defaultVisible:!1}),tZ=zX(J.Duration,{debugOnly:!0}),nZ=zX(J.Rep),rZ=zX(J.Rounds,{defaultVisible:!1}),iZ=zX(J.Distance),aZ=zX(J.Resistance),oZ=zX(J.Action),sZ=zX(J.Increment),cZ=zX(J.Metric),lZ=zX(J.Calculated),uZ=zX(J.Custom,{defaultVisible:!1}),dZ=zX(J.Group,{defaultVisible:!1}),fZ=zX(J.System,{defaultVisible:!1}),pZ=zX(J.Label,{defaultVisible:!1}),mZ=zX(J.Text),hZ=zX(J.CurrentRound,{defaultVisible:!1}),gZ=zX(J.Volume),_Z=zX(J.Intensity),vZ=zX(J.Load),yZ=zX(J.Work),bZ=zX(J.Diagnostic),xZ=[GX,JX,KX,qX,YX,XX,ZX,QX,$X,{id:`exercise`,label:`Exercise`,icon:pG(J.Effort)??void 0,source:{type:`fallback`,semantics:`first-present`,sources:[{type:`fallback`,semantics:`all-present-combined`,sources:[{type:`metric-type`,metricType:J.Effort},{type:`metric-type`,metricType:J.Text}]},{type:`metric-type`,metricType:J.Text},{type:`metric-type`,metricType:J.Label},{type:`metric-type`,metricType:J.Effort}]},format:{type:`combined`,layout:`vertical`,primaryFormat:{type:`text`,className:`font-medium text-foreground`},secondaryFormat:{type:`text`,className:`text-muted-foreground text-xs`},containerClassName:`items-start`},sort:{type:`text`,extractor:e=>IX(e)},filter:{extractor:e=>IX(e),caseInsensitive:!0},meta:{defaultVisible:!1,tags:[`grouping`,`fallback`,`descriptor`],subsumes:[`effort`,`text`,`label`]}},{id:`descriptor`,label:`Descriptor`,icon:pG(J.Effort)??void 0,source:{type:`fallback`,semantics:`first-present`,sources:[{type:`metric-type`,metricType:J.Effort},{type:`metric-type`,metricType:J.Label},{type:`metric-type`,metricType:J.Rounds},{type:`metric-type`,metricType:J.CurrentRound}]},format:{type:`custom`,render:e=>DX(e,0)},sort:{type:`text`,extractor:e=>IX(e)},filter:{extractor:e=>IX(e),caseInsensitive:!0},meta:{defaultVisible:!0,subsumes:[`effort`,`label`,`rounds`,`current-round`]}},eZ,mZ,pZ,tZ,{id:`pace`,label:`Pace`,icon:`⏱️`,source:{type:`derived`,dependencies:[`distance`,`duration`],compute:(e,t)=>{let n=PX(t.dependencies.get(`distance`)),r=PX(t.dependencies.get(`duration`));if(!(!n||!r))return n/r}},format:{type:`custom`,render:e=>{if(typeof e!=`number`||!Number.isFinite(e)||e<=0)return(0,G.jsx)(`span`,{className:`text-muted-foreground opacity-40`,children:`—`});let t=1e3/e;return(0,G.jsxs)(`span`,{className:`font-mono text-xs whitespace-nowrap`,children:[qW(t),`/km`]})}},sort:{type:`numeric`,extractor:e=>typeof e==`number`?e:void 0},graph:{extractor:e=>typeof e==`number`?e:void 0,axisLabel:`Pace`,unit:`m/s`},filter:{extractor:e=>typeof e!=`number`||!Number.isFinite(e)||e<=0?``:`${qW(1e3/e)}/km`,caseInsensitive:!0},meta:{defaultVisible:!1,tags:[`endurance`,`derived`]}},nZ,rZ,iZ,aZ,oZ,sZ,cZ,lZ,uZ,hZ,gZ,_Z,{id:`loadFocus`,label:`Load`,icon:pG(J.Load)??pG(J.Resistance)??void 0,source:{type:`fallback`,semantics:`first-present`,sources:[{type:`metric-type`,metricType:J.Load},{type:`metric-type`,metricType:J.Resistance}]},format:{type:`custom`,render:e=>DX(e,0)},sort:{type:`numeric`,extractor:e=>PX(e)},graph:{extractor:e=>PX(e),axisLabel:`Load`,unit:`kg`},filter:{extractor:e=>FX(e),caseInsensitive:!0},meta:{defaultVisible:!1,tags:[`strength`,`fallback`]}},vZ,yZ,bZ,dZ,fZ],SZ={outputTypes:[`segment`,`milestone`,`group`,`analytics`]},CZ={definitions:xZ,presets:{default:{label:`Default`,filters:SZ,visibleColumnIds:[`#`,`timeSpan`,`descriptor`,`rep`,`distance`,`resistance`,`action`,`increment`,`metric`,`calculated`,`custom`,`volume`,`intensity`,`load`,`work`,`diagnostic`]},debug:{label:`Debug`,filters:{},visibleColumnIds:`#.timeSpan.timestamp.spans.blockKey.outputType.stackLevel.descriptor.duration.rep.distance.resistance.action.increment.metric.calculated.custom.volume.intensity.load.work.diagnostic.group.system.elapsedTotal.completionReason`.split(`.`)},strength:{label:`Strength`,filters:SZ,visibleColumnIds:[`#`,`timeSpan`,`exercise`,`rep`,`loadFocus`,`volume`,`intensity`,`load`,`work`,`elapsedTotal`]},endurance:{label:`Endurance`,filters:SZ,visibleColumnIds:[`#`,`timeSpan`,`exercise`,`distance`,`duration`,`pace`,`rounds`,`increment`,`work`,`elapsedTotal`]}},defaultPreset:`default`},wZ=class{config;definitionMap;constructor(e){this.config=e,this.definitionMap=new Map(e.definitions.map(e=>[e.id,e]))}getVisibleColumns(e){return this.getOrderedCandidates(e).filter(t=>this.computeVisibility(t.id,e))}getAvailableColumns(e){let t=new Set(this.getVisibleColumns(e).map(e=>e.id));return this.config.definitions.filter(n=>!t.has(n.id)&&this.isColumnAvailable(n,e))}getGraphableColumns(e){return this.getVisibleColumns(e).filter(e=>e.graph!==void 0)}getGraphTaggedColumns(e){let t=e.graphTaggedColumnIds;return!t||t.size===0?[]:this.getVisibleColumns(e).filter(e=>t.has(e.id))}isColumnVisible(e,t){return this.getDefinition(e)?this.computeVisibility(e,t):!1}getDefinition(e){return this.definitionMap.get(e)}getPreset(e){return this.config.presets[e]??this.config.presets[this.config.defaultPreset]}getAllDefinitions(){return this.config.definitions}get definitions(){return this.definitionMap}resolveColumnValue(e,t,n,r){let i=this.getDefinition(t);if(!i)return;let a={allRows:n,rowIndex:r??n.findIndex(t=>t.id===e.id),columnDef:i,dependencies:new Map};return ZY(e,i.source,a,this.definitionMap)}getOrderedCandidates(e){let t=this.getPreset(e.activePresetId),n=[],r=new Set,i=e=>{if(r.has(e))return;let t=this.getDefinition(e);t&&(n.push(t),r.add(e))};for(let e of t.visibleColumnIds)i(e);for(let e of this.config.definitions)i(e.id);if(e.addedColumnIds)for(let t of e.addedColumnIds)i(t);return n}computeVisibility(e,t,n){if(t.visibilityOverrides&&e in t.visibilityOverrides)return t.visibilityOverrides[e];if(t.addedColumnIds?.has(e))return!0;let r=this.getDefinition(e);if(!r||r.meta?.debugOnly&&!t.isDebugMode||!n&&this.isColumnSubsumed(e,t))return!1;let i=this.getPreset(t.activePresetId).visibleColumnIds.includes(e),a=this.hasDataInRows(r,t.rows);switch(r.source.type){case`fixed-field`:return i;case`derived`:return i;case`metric-type`:return a;case`fallback`:return i&&a;default:return i}}isColumnSubsumed(e,t){for(let n of this.config.definitions)if(n.meta?.subsumes?.length&&this.getPreset(t.activePresetId).visibleColumnIds.includes(n.id)&&n.meta.subsumes.includes(e))return!0;return!1}isColumnAvailable(e,t){return e.meta?.debugOnly&&!t.isDebugMode?!1:this.getPreset(t.activePresetId).visibleColumnIds.includes(e.id)?!this.computeVisibility(e.id,t):e.source.type===`fixed-field`||e.source.type===`derived`||this.hasDataInRows(e,t.rows)}hasDataInRows(e,t){if(t.length===0)return!1;switch(e.source.type){case`fixed-field`:return!0;case`metric-type`:{let{metricType:n}=e.source;return t.some(e=>e.cells.has(n))}case`derived`:return!0;case`fallback`:{let{sources:n}=e.source;return t.some(e=>n.some(t=>this.sourceHasDataInRow(t,e)))}default:return!0}}sourceHasDataInRow(e,t){switch(e.type){case`fixed-field`:return t[e.field]!==void 0&&t[e.field]!==null;case`metric-type`:return t.cells.has(e.metricType);case`derived`:return!0;case`fallback`:return e.sources.some(e=>this.sourceHasDataInRow(e,t));default:return!1}}};function TZ(e){let{segments:t,userOutputOverrides:n,presetId:r,isDebugMode:i,sortConfigs:a,filterOverrides:o,graphTaggedColumns:s,extraMetricTypes:c,columnVisibilityOverrides:l,addedColumnIds:u}=e,d=(0,W.useMemo)(()=>EZ(t,n),[t,n]),f=(0,W.useMemo)(()=>{let e=[...CZ.definitions],t=new Set(e.map(e=>e.id));for(let n of d)for(let r of n.cells.keys())t.has(r)||(e.push(zX(r)),t.add(r));return new wZ({...CZ,definitions:e})},[d]),p=(0,W.useMemo)(()=>{let e=new Set(u??[]);for(let t of c??[])e.add(t);return e},[u,c]),m=(0,W.useMemo)(()=>({rows:d,activePresetId:r,isDebugMode:i,graphTaggedColumnIds:s,visibilityOverrides:l,addedColumnIds:p}),[d,r,i,s,l,p]),h=(0,W.useMemo)(()=>f.getVisibleColumns(m),[f,m]),g=(0,W.useMemo)(()=>f.getAvailableColumns(m),[f,m]),_=(0,W.useMemo)(()=>({...f.getPreset(r).filters??{},...o}),[r,o,f]);return{rows:(0,W.useMemo)(()=>AZ(kZ(d,_,h,f.definitions),a,h,f.definitions),[d,_,a,h,f]),visibleColumns:h,availableColumns:g,graphTaggedColumnIds:(0,W.useMemo)(()=>Array.from(s??[]),[s])}}function EZ(e,t){return e.map((e,n)=>{let r=new Map;if(e.metrics)for(let t of e.metrics)OZ(r,t);let i=DZ(e),a=i?t.get(i):void 0;if(a)for(let e of a)OZ(r,e);for(let[,e]of r)e.hasUserOverride=e.metrics.some(e=>e.origin===`user`);let o=e.context?.outputType??e.type;return{id:e.id,index:n+1,sourceBlockKey:i??`segment-${e.id}`,sourceStatementId:e.context?.sourceStatementId,outputType:o,stackLevel:e.depth,absoluteStartTime:e.absoluteStartTime,duration:e.duration,elapsed:e.elapsed,total:e.total,spans:e.spans?[...e.spans]:[],completionReason:e.context?.completionReason,cells:r}})}function DZ(e){let t=e.context;return t?.sourceBlockKey?t.sourceBlockKey:e.name}function OZ(e,t){let n=t.type;if(n===J.Sound)return;let r=e.get(n);r?e.set(n,{metrics:r.metrics.clone().add(t),hasUserOverride:r.hasUserOverride}):e.set(n,{metrics:ca.empty(n).add(t),hasUserOverride:!1})}function kZ(e,t,n,r){let i=e;if(t.outputTypes&&t.outputTypes.length>0){let e=new Set(t.outputTypes);i=i.filter(t=>e.has(t.outputType))}if(t.origins&&t.origins.length>0){let e=new Set(t.origins);i=i.filter(t=>{for(let[,n]of t.cells)if(n.metrics.some(t=>t.origin&&e.has(t.origin)))return!0;return!1})}if(t.searchText&&t.searchText.trim().length>0){let a=t.searchText.trim().toLowerCase();i=i.filter(t=>{for(let i of n)if(i.filter&&dX(t,i,{allRows:e,rowIndex:e.indexOf(t),columnDef:i,dependencies:new Map},r).toLowerCase().includes(a))return!0;return!1})}if(t.columnFilters)for(let[a,o]of Object.entries(t.columnFilters)){if(!o||o.trim().length===0)continue;let t=n.find(e=>e.id===a);t&&(i=i.filter(n=>{let i={allRows:e,rowIndex:e.indexOf(n),columnDef:t,dependencies:new Map};return fX(n,t,o,i,r)}))}return i}function AZ(e,t,n,r){if(t.length===0)return e;let i=[...e];return i.sort((i,a)=>{for(let o of t){let t=n.find(e=>e.id===o.columnId);if(!t||!t.sort)continue;let s={allRows:e,rowIndex:e.indexOf(i),columnDef:t,dependencies:new Map},c={allRows:e,rowIndex:e.indexOf(a),columnDef:t,dependencies:new Map},l=lX(cX(i,t,s,r),cX(a,t,c,r));if(l!==0)return o.direction===`asc`?l:-l}return i.index-a.index}),i}function jZ(e,t){return{id:e,label:t.label,filters:t.filters??{},visibleColumns:[...t.visibleColumnIds],isDefault:e===CZ.defaultPreset}}var MZ=Object.fromEntries(Object.entries(CZ.presets).map(([e,t])=>[e,jZ(e,t)])),NZ=MZ.default;MZ.debug,MZ.strength,MZ.endurance;function PZ(e){return MZ[e]??NZ}var FZ=({activePreset:e,onPresetChange:t,searchText:n,onSearchChange:r,showFilters:i,onToggleFilters:a,totalRows:o,visibleRows:s})=>(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 py-2 border-b border-border bg-muted/10 dark:bg-muted/5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`label`,{className:`text-xs text-muted-foreground font-medium`,children:`View:`}),(0,G.jsx)(`select`,{className:`text-xs rounded border border-border bg-background text-foreground px-1.5 py-1 focus:outline-none focus:ring-1 focus:ring-primary/40`,value:e.id,onChange:e=>t(e.target.value),children:Object.values(MZ).map(e=>(0,G.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,G.jsx)(`div`,{className:`w-px h-5 bg-border`}),(0,G.jsx)(`div`,{className:`flex items-center flex-1 max-w-md`,children:(0,G.jsxs)(`div`,{className:`flex w-full group`,children:[(0,G.jsx)(`input`,{type:`text`,className:`flex-1 px-2.5 py-1 text-xs rounded-l border border-r-0 border-border bg-background text-foreground placeholder:text-muted-foreground/40 focus:outline-none focus:ring-1 focus:ring-primary/40 focus:z-10`,placeholder:`Filter results…`,value:n,onChange:e=>r(e.target.value)}),(0,G.jsxs)(`button`,{className:`px-2.5 py-1 text-xs rounded-r border border-border bg-muted/30 text-muted-foreground hover:bg-muted/50 hover:text-foreground transition-colors flex items-center gap-1.5 border-l-0`,title:`Filter results`,children:[(0,G.jsx)(`span`,{children:`🔍`}),(0,G.jsx)(`span`,{className:`font-medium`,children:`Search`})]})]})}),(0,G.jsx)(`div`,{className:`w-px h-5 bg-border`}),(0,G.jsx)(`button`,{className:[`text-xs px-2 py-1 rounded border transition-colors`,i?`bg-primary/10 border-primary/30 text-primary`:`bg-muted/30 border-border text-muted-foreground hover:text-foreground`].join(` `),onClick:a,title:i?`Hide column filters`:`Show column filters`,children:`🔽 Filters`}),(0,G.jsx)(`div`,{className:`ml-auto text-xs text-muted-foreground tabular-nums`,children:s===o?`${o} rows`:`${s} / ${o} rows`})]}),IZ={"#":`40px`,exercise:`180px`,text:`160px`,notes:`160px`,completionReason:`160px`,rep:`72px`,rounds:`72px`,"current-round":`72px`,duration:`96px`,distance:`96px`,resistance:`96px`,load:`96px`,volume:`96px`,intensity:`96px`,metric:`96px`,work:`96px`,elapsedTotal:`96px`,action:`96px`,increment:`96px`,timestamp:`96px`,spans:`96px`,blockKey:`180px`,outputType:`96px`,stackLevel:`72px`,elapsed:`96px`},LZ=`48px`;function RZ(e){return e.meta?.width??IZ[e.id]??`96px`}function zZ(){return LZ}var BZ=({columns:e,sortConfigs:t,onSort:n,onToggleGraph:r,showFilters:i,columnFilters:a,onColumnFilterChange:o,availableToAdd:s,onAddColumn:c,graphTaggedColumnIds:l})=>(0,G.jsxs)(`thead`,{className:`bg-muted/50 dark:bg-muted/30 sticky top-0 z-10`,children:[(0,G.jsxs)(`tr`,{className:`border-b border-border`,children:[e.map(e=>(0,G.jsx)(VZ,{column:e,sortConfig:t.find(t=>t.columnId===e.id),onSort:n,onToggleGraph:r,isGraphed:l?.has(e.id)??!1},e.id)),c&&(0,G.jsx)(`th`,{className:`py-2 px-1`,style:{minWidth:zZ()},children:(0,G.jsx)(UZ,{availableToAdd:s??[],onAddColumn:c})})]}),i&&(0,G.jsxs)(`tr`,{className:`border-b border-border/50 bg-muted/20 dark:bg-muted/10`,children:[e.map(e=>(0,G.jsx)(gte,{column:e,value:a[e.id]??``,onChange:o},e.id)),c&&(0,G.jsx)(`th`,{className:`py-1 px-1`,style:{minWidth:zZ()}})]})]}),VZ=({column:e,sortConfig:t,onSort:n,onToggleGraph:r,isGraphed:i})=>{let a=e.sort!==void 0,o=e.graph!==void 0,s=(0,W.useCallback)(t=>{a&&n(e.id,t.shiftKey)},[e.id,a,n]),c=(0,W.useCallback)(t=>{t.stopPropagation(),r(e.id)},[e.id,r]);return(0,G.jsx)(`th`,{className:[`py-1.5 px-2 text-[11px] font-semibold text-muted-foreground uppercase tracking-wider whitespace-nowrap select-none`,a?`cursor-pointer hover:text-foreground transition-colors`:``].join(` `),style:{minWidth:RZ(e)},onClick:s,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[e.icon&&(0,G.jsx)(`span`,{className:`text-sm`,children:e.icon}),(0,G.jsx)(`span`,{children:e.label}),t&&(0,G.jsx)(HZ,{direction:t.direction}),o&&(0,G.jsx)(`button`,{className:[`ml-auto text-sm opacity-40 hover:opacity-100 transition-opacity`,i?`opacity-100 text-primary`:``].join(` `),onClick:c,title:i?`Remove from graph`:`Add to graph`,children:`📊`})]})})},HZ=({direction:e})=>(0,G.jsx)(`span`,{className:`text-primary text-[10px] ml-0.5`,children:e===`asc`?`▲`:`▼`}),gte=({column:e,value:t,onChange:n})=>e.filter?(0,G.jsx)(`th`,{className:`py-1 px-2`,style:{minWidth:RZ(e)},children:(0,G.jsx)(`input`,{type:`text`,className:`w-full px-1.5 py-0.5 text-xs rounded border border-border bg-background text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary/40`,placeholder:`Filter…`,value:t,onChange:t=>n(e.id,t.target.value)})}):(0,G.jsx)(`th`,{className:`py-1 px-2`,style:{minWidth:RZ(e)}}),UZ=({availableToAdd:e,onAddColumn:t})=>{let[n,r]=(0,W.useState)(!1),i=(0,W.useRef)(null),a=(0,W.useRef)(null);return(0,W.useEffect)(()=>{if(!n)return;let e=e=>{i.current&&!i.current.contains(e.target)&&a.current&&!a.current.contains(e.target)&&r(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]),e.length===0?null:(0,G.jsxs)(`div`,{className:`relative flex items-center justify-center`,children:[(0,G.jsx)(`button`,{ref:a,title:`Add metric column`,onClick:e=>{e.stopPropagation(),r(e=>!e)},className:[`flex items-center justify-center w-5 h-5 rounded text-[11px] font-bold transition-all`,`text-muted-foreground hover:text-foreground hover:bg-primary/10 hover:border-primary/40`,`border border-dashed border-muted-foreground/40`,n?`bg-primary/10 border-primary/40 text-foreground`:``].join(` `),children:`+`}),n&&(0,G.jsxs)(`div`,{ref:i,className:`absolute right-0 top-full mt-1 z-50 min-w-[160px] max-h-64 overflow-y-auto
170
170
  bg-popover border border-border rounded-md shadow-xl py-1`,onClick:e=>e.stopPropagation(),children:[(0,G.jsx)(`div`,{className:`px-3 py-1.5 text-[10px] font-semibold text-muted-foreground uppercase tracking-wider border-b border-border/50 mb-1`,children:`Add metric column`}),e.map(e=>{let n=pG(e)??`•`,i=Ko.columnLabel(e);return(0,G.jsxs)(`button`,{onClick:()=>{t(e),r(!1)},className:`w-full flex items-center gap-2 px-3 py-1.5 text-xs hover:bg-muted text-foreground transition-colors`,children:[(0,G.jsx)(`span`,{className:`text-sm w-4 text-center`,children:n}),(0,G.jsx)(`span`,{children:i})]},e)})]})]})},WZ=({row:e,allRows:t,rowIndex:n,columns:r,isSelected:i,onSelect:a,isHovered:o,onHover:s,onCellDoubleClick:c})=>{let l=t=>{a(e.id,{ctrlKey:t.ctrlKey||t.metaKey,shiftKey:t.shiftKey})},u=e.outputType===`group`;return(0,G.jsx)(`tr`,{className:K(`border-b border-border transition-colors cursor-pointer`,u?`bg-muted/50 font-bold`:``,i?`bg-accent dark:bg-accent/20`:o?`bg-muted/50 dark:bg-muted/40`:`hover:bg-muted/30 dark:hover:bg-muted/20`),onClick:l,onMouseEnter:()=>s(e.sourceBlockKey),onMouseLeave:()=>s(null),children:r.map(r=>{let i=r.source.type===`metric-type`&&r.source.metricType===J.Effort;return(0,G.jsx)(mX,{columnDef:r,row:e,allRows:t,rowIndex:n,indent:i?e.stackLevel:0,onDoubleClick:c,style:{minWidth:RZ(r)}},r.id)})})};function GZ(e){let{rows:t,columns:n,graphTaggedColumnIds:r,definitionMap:i}=e,a=(0,W.useMemo)(()=>KZ(r,n),[r,n]),o=(0,W.useMemo)(()=>qZ(t,r,n,i),[t,r,n,i]);return{data:o,graphConfigs:a,hasData:a.length>0&&o.length>0}}function KZ(e,t){let n=[];for(let r of e){let e=t.find(e=>e.id===r);e&&n.push({id:r,label:e.label,unit:ZZ(e),color:JZ(e),dataKey:r,icon:e.icon})}return n}function qZ(e,t,n,r){return t.length===0?[]:e.map((i,a)=>{let o={index:i.index,label:i.sourceBlockKey};for(let s of t){let t=n.find(e=>e.id===s);if(!t||!t.graph){o[s]=0;continue}o[s]=uX(i,t,{allRows:e,rowIndex:a,columnDef:t,dependencies:new Map},r)??0}return o})}function JZ(e){if(e.graph?.color)return e.graph.color;let t=YZ(e);return t?XZ[t]??`#888888`:`#888888`}function YZ(e){if(e.source.type===`metric-type`)return e.source.metricType}var XZ={[J.Time]:`#3b82f6`,[J.Rep]:`#22c55e`,[J.Effort]:`#eab308`,[J.Distance]:`#14b8a6`,[J.Rounds]:`#a855f7`,[J.Resistance]:`#ef4444`,[J.Increment]:`#6366f1`,[J.Action]:`#ec4899`};function ZZ(e){if(e.graph?.unit)return e.graph.unit;let t=YZ(e);if(!t)return``;switch(t){case J.Time:return`ms`;case J.Rep:return`reps`;case J.Distance:return`m`;case J.Rounds:return`rounds`;case J.Resistance:return`kg`;case J.Increment:return`Δ`;default:return``}}var QZ=({rows:e,columns:t,graphTaggedColumnIds:r,selectedIds:i,onSelectRow:a})=>{let[o,s]=(0,W.useState)(!1),{data:c,graphConfigs:l,hasData:u}=GZ({rows:e,columns:t,graphTaggedColumnIds:r,selectedIds:i}),d=(0,W.useCallback)(t=>{if(!t?.activePayload?.[0])return;let n=t.activePayload[0].payload,r=e.find(e=>e.index===n.index);r&&a&&a(r.id)},[e,a]);return r.length===0?null:(0,G.jsxs)(`div`,{className:`border-b border-border bg-background`,children:[(0,G.jsxs)(`button`,{className:`w-full flex items-center justify-between px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted/20 transition-colors`,onClick:()=>s(e=>!e),children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{children:`📊`}),(0,G.jsxs)(`span`,{children:[`Graph — `,l.map(e=>e.label).join(`, `)]})]}),(0,G.jsx)(`span`,{className:`text-[10px]`,children:o?`▼`:`▲`})]}),!o&&(0,G.jsx)(`div`,{className:`px-3 pb-3`,children:u?(0,G.jsx)(`div`,{className:`w-full bg-muted/30 rounded-lg border border-border p-2`,style:{height:220},children:(0,G.jsx)(Vn,{width:`100%`,height:`100%`,children:(0,G.jsxs)(et,{data:c,onClick:d,children:[(0,G.jsx)(yn,{strokeDasharray:`3 3`,stroke:`hsl(var(--border))`,vertical:!1}),(0,G.jsx)(n,{dataKey:`index`,stroke:`hsl(var(--muted-foreground))`,tick:{fontSize:10},label:{value:`Row #`,position:`insideBottom`,offset:-5,fill:`hsl(var(--muted-foreground))`,fontSize:10}}),(0,G.jsx)(ye,{stroke:`hsl(var(--muted-foreground))`,tick:{fontSize:10},domain:[`auto`,`auto`]}),(0,G.jsx)(pt,{contentStyle:{backgroundColor:`hsl(var(--popover))`,borderColor:`hsl(var(--border))`,fontSize:`12px`,color:`hsl(var(--popover-foreground))`},labelFormatter:e=>`Row ${e}`,formatter:(e,t)=>{let n=l.find(e=>e.dataKey===t);return[`${typeof e==`number`?e.toLocaleString():e}${n?.unit?` ${n.unit}`:``}`,n?.label??t]}}),(0,G.jsx)(wn,{verticalAlign:`top`,height:24,wrapperStyle:{fontSize:`11px`}}),l.map(e=>(0,G.jsx)(Kn,{type:`monotone`,dataKey:e.dataKey,name:e.label,stroke:e.color,strokeWidth:2,dot:{r:3,fill:e.color},activeDot:{r:5,stroke:e.color,strokeWidth:2}},e.id))]})})}):(0,G.jsx)(`div`,{className:`h-32 flex items-center justify-center text-sm text-muted-foreground`,children:`No numeric data available for the tagged columns.`})})]})},$Z=({isOpen:e,blockKey:t,metricType:n,existingFragments:r,existingUserValue:i,anchorRect:a,onSave:o,onRemove:s,onClose:c})=>{let[l,u]=(0,W.useState)(``),d=(0,W.useRef)(null),f=(0,W.useRef)(null);(0,W.useEffect)(()=>{e&&(u(i===void 0?``:String(i)),setTimeout(()=>d.current?.focus(),0))},[e,i]),(0,W.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&c()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,c]),(0,W.useEffect)(()=>{if(!e)return;let t=e=>{f.current&&!f.current.contains(e.target)&&c()},n=setTimeout(()=>{document.addEventListener(`mousedown`,t)},100);return()=>{clearTimeout(n),document.removeEventListener(`mousedown`,t)}},[e,c]);let p=(0,W.useCallback)(()=>{if(l.trim()===``)return;let e=Number(l.trim()),r=!isNaN(e)&&l.trim()!==``?e:l.trim();o(t,n,r,String(r)),c()},[l,t,n,o,c]),m=(0,W.useCallback)(()=>{s(t,n),c()},[t,n,s,c]),h=(0,W.useCallback)(e=>{e.key===`Enter`&&(e.preventDefault(),p())},[p]);if(!e)return null;let g=pG(n),_=dG(n),v=i!==void 0,y=r.filter(e=>e.origin!==`user`),b=a?{position:`fixed`,top:a.bottom+4,left:Math.max(8,Math.min(a.left,window.innerWidth-280)),zIndex:50}:{position:`fixed`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,zIndex:50};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`fixed inset-0 bg-black/20 dark:bg-black/40 z-40`}),(0,G.jsxs)(`div`,{ref:f,className:`w-64 rounded-lg border border-border bg-popover text-popover-foreground shadow-lg`,style:b,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border`,children:[g&&(0,G.jsx)(`span`,{className:`text-sm`,children:g}),(0,G.jsx)(`span`,{className:`text-sm font-medium capitalize`,children:n}),(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground ml-auto truncate max-w-[100px]`,title:t,children:t})]}),y.length>0&&(0,G.jsxs)(`div`,{className:`px-3 py-1.5 border-b border-border/50 bg-muted/10`,children:[(0,G.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-1 uppercase tracking-wider`,children:`Current`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:y.map((e,t)=>(0,G.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs border ${_}`,children:e.image??String(e.value??e.type)},t))})]}),(0,G.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,G.jsx)(`label`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider mb-1 block`,children:v?`Update override`:`Enter value`}),(0,G.jsx)(`input`,{ref:d,type:`text`,className:`w-full px-2 py-1.5 text-sm rounded border border-border bg-background text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-2 focus:ring-primary/40`,placeholder:`Enter ${n} value…`,value:l,onChange:e=>u(e.target.value),onKeyDown:h})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-t border-border/50`,children:[(0,G.jsx)(`button`,{className:`flex-1 px-2 py-1 text-xs rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted/30 transition-colors`,onClick:c,children:`Cancel`}),v&&(0,G.jsx)(`button`,{className:`px-2 py-1 text-xs rounded border border-destructive/30 text-destructive hover:bg-destructive/10 transition-colors`,onClick:m,title:`Remove user override`,children:`Clear`}),(0,G.jsx)(`button`,{className:`flex-1 px-2 py-1 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,onClick:p,disabled:l.trim()===``,children:`Save`})]})]})]})},eQ=({segments:e,selectedSegmentIds:t,onSelectSegment:n,userOutputOverrides:r=new Map,gridViewPreset:i=`default`,onPresetChange:a,hoveredBlockKey:o,onHoverBlockKey:s})=>{let{isDebugMode:c}=jb(),[l,u]=(0,W.useState)([]),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)({}),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(new Set),[y,b]=(0,W.useState)({}),[x,S]=(0,W.useState)(new Set),{overrides:C,setOverride:w,removeOverride:T}=Sq(!0),[E,D]=(0,W.useState)({isOpen:!1,blockKey:``,type:`Time`,anchorRect:null,existingFragments:[]}),O=(0,W.useMemo)(()=>{let e=new Map;for(let[t,n]of r)e.set(t,n instanceof ca?n:ca.from(n,t));for(let[t,n]of C)e.set(t,n);return e},[r,C]),k=c?`debug`:i,A=(0,W.useMemo)(()=>PZ(k),[k]),{rows:j,visibleColumns:M,availableColumns:N,graphTaggedColumnIds:P}=TZ({segments:e,userOutputOverrides:O,presetId:k,isDebugMode:c,sortConfigs:l,filterOverrides:(0,W.useMemo)(()=>({searchText:d||void 0,columnFilters:Object.keys(p).length>0?p:void 0}),[d,p]),graphTaggedColumns:_,extraMetricTypes:x,columnVisibilityOverrides:y,addedColumnIds:x}),F=M,I=e.length,L=(0,W.useMemo)(()=>j.map(e=>e.id),[j]),R=(0,W.useCallback)((e,t)=>{u(n=>{let r=n.find(t=>t.columnId===e);return t?r?r.direction===`asc`?n.map(t=>t.columnId===e?{...t,direction:`desc`}:t):n.filter(t=>t.columnId!==e):[...n,{columnId:e,direction:`asc`}]:r?r.direction===`asc`?[{columnId:e,direction:`desc`}]:[]:[{columnId:e,direction:`asc`}]})},[]),z=(0,W.useCallback)(e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ee=(0,W.useCallback)((e,t)=>{m(n=>{if(!t){let t={...n};return delete t[e],t}return{...n,[e]:t}})},[]),te=(0,W.useCallback)(e=>{b({}),m({}),f(``),a?.(e)},[a]),ne=(0,W.useCallback)(e=>{S(t=>{let n=new Set(t);return n.add(e),n})},[]),re=(0,W.useMemo)(()=>N.filter(e=>e.source.type===`metric-type`).map(e=>e.source.metricType),[N]),B=(0,W.useCallback)((e,t)=>{n(e,t,L)},[n,L]),ie=(0,W.useCallback)(e=>{s?.(e)},[s]),ae=(0,W.useCallback)(e=>{n(e,{ctrlKey:!1,shiftKey:!1},L)},[n,L]),oe=(0,W.useCallback)((e,t,n)=>{let r=(j.find(t=>t.sourceBlockKey===e)?.cells.get(t))?.metrics.toArray()??[],i=r.find(e=>e.origin===`user`),a=i?.value==null?void 0:String(i.value);D({isOpen:!0,blockKey:e,type:t,anchorRect:n,existingFragments:r,existingUserValue:a})},[j]),se=(0,W.useCallback)((e,t,n,r)=>{w(e,t,n,r),D(e=>({...e,isOpen:!1}))},[w]),ce=(0,W.useCallback)(()=>{T(E.blockKey,E.type),D(e=>({...e,isOpen:!1}))},[E.blockKey,E.type,T]),V=(0,W.useCallback)(()=>{D(e=>({...e,isOpen:!1}))},[]);return(0,G.jsxs)(`div`,{className:`h-full flex flex-col bg-background`,children:[(0,G.jsx)(FZ,{activePreset:A,onPresetChange:te,searchText:d,onSearchChange:f,showFilters:h,onToggleFilters:()=>g(e=>!e),totalRows:I,visibleRows:j.length}),(0,G.jsx)(QZ,{rows:j,columns:M,graphTaggedColumnIds:P,selectedIds:t,onSelectRow:ae}),(0,G.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,G.jsxs)(`table`,{className:`text-left text-sm border-collapse min-w-[700px]`,children:[(0,G.jsx)(BZ,{columns:F,sortConfigs:l,onSort:R,onToggleGraph:z,showFilters:h,columnFilters:p,onColumnFilterChange:ee,availableToAdd:re,onAddColumn:ne,graphTaggedColumnIds:_}),(0,G.jsx)(`tbody`,{className:`divide-y divide-border`,children:j.length===0?(0,G.jsx)(`tr`,{children:(0,G.jsx)(`td`,{colSpan:F.length,className:`py-8 text-center text-muted-foreground text-sm`,children:e.length===0?`Finish or stop the timer — results land here`:`No rows match the current filters.`})}):j.map((e,n)=>(0,G.jsx)(WZ,{row:e,allRows:j,rowIndex:n,columns:F,isSelected:t.has(e.id),onSelect:B,isHovered:o===e.sourceBlockKey,onHover:ie,onCellDoubleClick:oe},e.id))})]})}),(0,G.jsx)($Z,{isOpen:E.isOpen,blockKey:E.blockKey,metricType:E.type,existingFragments:E.existingFragments,existingUserValue:E.existingUserValue,anchorRect:E.anchorRect??void 0,onSave:se,onRemove:ce,onClose:V}),(0,G.jsxs)(`div`,{className:`px-3 py-1.5 border-t border-border bg-muted/10 text-xs text-muted-foreground flex items-center justify-between`,children:[(0,G.jsx)(`span`,{children:t.size>0?`${t.size} selected`:`Click a row to select`}),(0,G.jsxs)(`span`,{className:`tabular-nums`,children:[j.length,` / `,I,` rows`]})]})]})};qt();var tQ=({title:e,onClose:t,children:n,closeButtonClassName:r,floatingClose:i=!1,variant:a=`default`,actions:o,closeLabel:s})=>{(0,W.useEffect)(()=>(document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=``}),[]);let c=W.useRef(null);(0,W.useEffect)(()=>{let e=document.activeElement;return c.current?.focus({preventScroll:!0}),()=>e?.focus({preventScroll:!0})},[]);let l=e=>{if(e.key!==`Tab`||!c.current)return;let t=Array.from(c.current.querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>e.offsetParent!==null);if(t.length===0){e.preventDefault();return}let n=document.activeElement,r=t[0],i=t[t.length-1];e.shiftKey&&(n===r||n===c.current||!c.current.contains(n))?(e.preventDefault(),i.focus()):!e.shiftKey&&n===i&&(e.preventDefault(),r.focus())},u=a===`minimal`,d=(0,G.jsx)(`button`,{onClick:t,className:r??`rounded-pill transition-colors shadow-[rgba(0,0,0,0.06)_0px_1px_2px] ${u?`bg-muted hover:bg-muted/80 text-muted-foreground hover:text-foreground`:`bg-muted/50 hover:bg-muted text-muted-foreground hover:text-foreground`} ${s?`flex h-11 min-w-[44px] items-center justify-center px-4 text-sm font-medium hover:text-foreground`:`p-2`}`,title:s??`Close`,"data-testid":iG.FOCUSED_DIALOG_CLOSE,children:s??(0,G.jsx)(yr,{className:`h-5 w-5`})});return NC.createPortal((0,G.jsxs)(`div`,{ref:c,onKeyDown:l,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":e??`Workout`,className:`fixed inset-0 z-[100] flex flex-col bg-background text-foreground outline-none animate-in fade-in duration-200`,children:[i||u&&!e?(0,G.jsxs)(`div`,{className:`absolute top-4 right-4 z-[110] flex items-center gap-2`,children:[o,d]}):e?(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-border ${u?`bg-muted/10`:`bg-muted/30`} shrink-0`,children:[(0,G.jsx)(`h2`,{className:`text-lg ${u?`font-black tracking-tight uppercase text-[11px] text-muted-foreground`:`font-semibold`}`,children:e}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o,d]})]}):null,(0,G.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden flex flex-col`,children:n})]}),document.body)},nQ=(0,W.createContext)({updateFromSegments:()=>{},clear:()=>{}}),rQ=({children:e,chromecastSubscription:t=null})=>(0,G.jsx)(nQ.Provider,{value:{updateFromSegments:(e,n,r)=>{t&&t.sendAnalyticsSummary([],n,r)},clear:()=>{}},children:e}),iQ=new class{resolve(e){let t=this.resolveMode(e);return t===`active`?{type:`rpc-workbench-update`,mode:`active`}:t===`review`?vq(e.analyticsSegments):bq(e.selectedBlock,e.documentItems)}resolveMode(e){return e.viewMode===`track`?e.runtime&&(e.executionStatus===`running`||e.executionStatus===`paused`)?`active`:e.analyticsSegments.length>0?`review`:e.runtime?`active`:`preview`:e.viewMode===`review`&&e.analyticsSegments.length>0?`review`:`preview`}};function aQ(){if(!(`wakeLock`in navigator))return;let e=navigator.wakeLock;if(!(typeof e!=`object`||!e||!(`request`in e)))return e}function oQ(e){let t=(0,W.useRef)(null);(0,W.useEffect)(()=>{let n=aQ();if(!n||!e)return;let r=!1,i=async()=>{if(document.visibilityState===`visible`)try{let e=await n.request(`screen`);if(r){e.release();return}t.current=e,e.addEventListener(`release`,()=>{t.current===e&&(t.current=null)})}catch{}},a=()=>{document.visibilityState===`visible`&&!t.current&&i()};return i(),document.addEventListener(`visibilitychange`,a),()=>{r=!0,document.removeEventListener(`visibilitychange`,a);let e=t.current;t.current=null,e&&!e.released&&e.release()}},[e])}function sQ(e){if(e instanceof Error)return e.message;if(typeof e==`object`&&e){let{code:t,description:n}=e;if(t!==void 0||n!==void 0)return[t===void 0?null:String(t),n?String(n):null].filter(e=>e!==null).join(`: `)||`unknown`;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}var cQ=``,lQ=null,uQ=()=>{let e=yK(),[t,n]=(0,W.useState)(e.state),[r,i]=(0,W.useState)(!1);oQ(r);let[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(null),d=(0,W.useRef)(null),f=Jz,p=(0,W.useRef)(f.getActiveHandle()),m=(0,W.useRef)(!1),h=(0,W.useCallback)(e=>{let t=p.current;p.current=null,t&&f.dispose(e),sM(null),u(null),c(null),i(!1)},[f]),g=(0,W.useCallback)(async e=>{if(!m.current){m.current=!0;try{let t=wV.getState().subscriptionManager,n=f.connect(e,t);p.current=n,u(n),c(n.subscription),i(!0),sM(n.transport),n.eventProvider.onEvent(e=>{if(e.name===`clock-command`){let t=gq(e.data);if(!t){console.warn(`[CastButtonRpc] Dropped malformed clock-command payload`);return}LK(t.runId,t.command)||console.warn(`[CastButtonRpc] Clock command rejected by authority:`,t.command.kind);return}let t=FK(),n=_q(e.name,t);n&&t&&!LK(t.runId,n)&&console.warn(`[CastButtonRpc] Legacy receiver event rejected by authority:`,e.name)});let r=wV.getState(),a=iQ.resolve({viewMode:r.viewMode,executionStatus:r.execution.status,runtime:r.runtime,analyticsSegments:r.analyticsSegments,selectedBlock:r.selectedBlock,documentItems:r.documentItems});n.pushInitialWorkbench(a)}finally{m.current=!1}}},[f]),_=(0,W.useRef)(!1),v=(0,W.useCallback)(async()=>{if(f.isConnected&&f.getActiveHandle()){let e=f.getActiveHandle();p.current=e,u(e),c(e.subscription),i(!0);return}if(!(p.current||_.current)&&typeof e.resumeSession==`function`){_.current=!0;try{let t=await e.resumeSession();await g(t)}catch(t){console.warn(`[CastButtonRpc] Session resume failed:`,sQ(t)),h(!1),e.endSession()}finally{_.current=!1}}},[e,g,h,f]);(0,W.useEffect)(()=>e.onStateChanged(e=>{n(e),e===`session-active`?(i(!0),v()):e===`ready`||e===`unavailable`?i(!1):e===`session-ended`&&h(!1)}),[e,h,v]),(0,W.useEffect)(()=>{if(f.isConnected&&f.getActiveHandle()){let e=f.getActiveHandle();p.current=e,u(e),c(e.subscription),i(!0)}else e.state===`session-active`&&v()},[e,f]),(0,W.useEffect)(()=>{let e=l?.transport;if(!e)return;let t=()=>{let t=FK(),n=JSON.stringify(t);if(n!==cQ||e!==lQ){cQ=n,lQ=e;try{e.send({type:`rpc-clock-snapshot`,snapshot:t})}catch{}}};return t(),IK(t)},[l]),(0,W.useEffect)(()=>{let e=()=>{f.sendDisposeSignal()};return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[f]),(0,W.useEffect)(()=>{let t=d.current;if(!t)return;let n=async()=>{if(y.current===`session-active`){if(b.current)return;o(!0);try{h(!0),e.endSession()}finally{setTimeout(()=>o(!1),2e3)}return}try{let t=await e.startSession();i(!0),await g(t)}catch(e){let t=sQ(e);t===`cancel`||t.includes(`cancel`)?console.log(`[CastButtonRpc] Cast request canceled or gesture expired`):console.error(`[CastButtonRpc] Cast failed:`,t),h(!1)}};return t.addEventListener(`click`,n),()=>t.removeEventListener(`click`,n)},[e,g,h]);let y=(0,W.useRef)(t);y.current=t;let b=(0,W.useRef)(a);b.current=a;let x=t===`unavailable`,S=t===`ready`,C=t===`session-active`,w=t===`connecting`,T=r&&C,E=w,D=E||a,O=S||C;return x?(0,G.jsxs)(q,{variant:`ghost`,size:`icon`,disabled:!0,className:`opacity-20 cursor-not-allowed`,"aria-label":`Cast to TV (unavailable)`,title:`Cast to TV (unavailable)`,children:[(0,G.jsx)(mr,{className:`h-5 w-5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Cast to TV (unavailable)`})]}):(0,G.jsx)(lte,{transport:l?.transport??null,children:(0,G.jsx)(rQ,{chromecastSubscription:s,children:(0,G.jsxs)(q,{ref:d,variant:`ghost`,size:`icon`,disabled:D,onClick:()=>{},className:K(`transition-all`,T&&`text-signal-positive ring-2 ring-signal-positive/30`,E&&`animate-pulse text-signal-caution`,!O&&`opacity-50`),"aria-label":T?`Stop casting`:`Cast to TV`,title:T?`Stop casting`:E?`Connecting...`:`Cast to TV`,children:[T?(0,G.jsx)(j,{className:`h-5 w-5`}):(0,G.jsx)(mr,{className:`h-5 w-5`}),(0,G.jsx)(`span`,{className:`sr-only`,children:T?`Stop casting`:`Cast to TV`})]})})})};function dQ(){let{isEnabled:e,toggleAudio:t}=mM();return(0,G.jsxs)(q,{variant:`ghost`,size:`icon`,onClick:t,className:`h-9 w-9 text-muted-foreground hover:text-foreground`,title:e?`Mute audio`:`Enable audio`,children:[e?(0,G.jsx)(F,{className:`h-[1.2rem] w-[1.2rem]`}):(0,G.jsx)(Ve,{className:`h-[1.2rem] w-[1.2rem]`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Toggle audio`})]})}var fQ=new Map,pQ=({block:e,noteContent:t,prepareRun:n,view:r,onClose:i,onCompleteWorkout:a,resultId:o,autoStart:s,onRuntimeReady:c,onRunStarted:l,externalStop:u,adoptRuntime:d,parkOnUnmount:f,onPark:p})=>{let[m,h]=(0,W.useState)(n?null:e),[g,_]=(0,W.useState)(null),v=(0,W.useRef)(!1),y=(0,W.useCallback)(async()=>{if(!(!n||v.current)){v.current=!0,_(null);try{h(await n())}catch(e){_(e instanceof Error?e.message:String(e))}finally{v.current=!1}}},[n]);(0,W.useEffect)(()=>{y()},[y]);let[b,x]=(0,W.useState)(null),[S,C]=(0,W.useState)(new Set),{isDebugMode:w}=jb(),T=(0,W.useRef)(Date.now()),E=(0,W.useRef)(typeof document<`u`?document.title:`Wod.Wiki`),D=(0,W.useRef)(null);(0,W.useEffect)(()=>{let t=e.label||e.id,n=b!==null,r=n?`Wod.Wiki - Workout Complete${t?`: `+t:``}`:`Wod.Wiki - Workout Timer${t?`: `+t:``}`,i=n?`/workout/review`:`/workout/timer`;document.title=r,D.current!==i&&(D.current=i,window.gtag?.(`event`,`page_view`,{page_title:r,page_path:i,page_location:typeof window<`u`?window.location.href:i,engagement_time_msec:pj()}));let a=mj.consent;n?a&&window.gtag?.(`event`,`runtime_dialog_review`,{workout_label:t,block_type:e.blockType}):(mj.record(`runtime:dialog_loaded`,{workout_label:t,block_type:e.blockType}),a&&window.gtag?.(`event`,`runtime_dialog_loaded`,{workout_label:t,block_type:e.blockType}))},[e.id,e.label,e.blockType,b]),(0,W.useEffect)(()=>{let t=E.current,n=T.current,r=e.label||e.id;return()=>{let e=Date.now()-n;e>=1e3&&window.gtag?.(`event`,`runtime_dialog_closed`,{workout_label:r,duration_seconds:Math.round(e/1e3),engagement_time_msec:e}),typeof document<`u`&&(document.title=t)}},[e.id,e.label]);let O=(0,W.useRef)(!1),k=(0,W.useRef)(!1),A=(0,W.useRef)(!1),[j,M]=(0,W.useState)(!1),[N,P]=(0,W.useState)(!1),F=(0,W.useRef)(!1),I=(0,W.useRef)(!1),L=(0,W.useRef)(null),[R,z]=(0,W.useState)(`idle`),[ee,te]=(0,W.useState)(null),[ne,re]=(0,W.useState)(!1),{collectionItems:B}=Yq(b??[],fQ,null),[ie,ae]=(0,W.useState)(new Set),[oe,se]=(0,W.useState)(new Set),[ce,V]=(0,W.useState)(!1),le=(0,W.useMemo)(()=>B.filter(e=>{let t=Fq(e);return!ie.has(t)&&!oe.has(t)}),[B,ie,oe]),ue=b!==null&&!!o&&le.length>0&&!ce,de=(0,W.useCallback)(async(e,t)=>{if(typeof t!=`number`||!Number.isFinite(t))throw Error(`Invalid value`);if(e.kind!==`value`)throw Error(`Unsupported entry`);if(!o)throw Error(`The saved run is unavailable.`);if(await cte({resultId:o,occurrence:{blockKey:e.blockKey,...e.sourceStatementId===void 0?{}:{sourceStatementId:e.sourceStatementId},...e.stackLevel===void 0?{}:{stackLevel:e.stackLevel}},metric:{type:e.metricType,value:t,image:String(t)}})===`not-found`)throw Error(`This result entry could not be found — retry or skip.`);let{segments:n}=jz(O_(await Z.getEventsByResult(o)).map(e=>PA(new ua(e))));x(n),ae(t=>new Set(t).add(Fq(e)))},[o]),fe=(0,W.useCallback)(e=>{se(t=>new Set(t).add(Fq(e)))},[]),pe=(0,W.useMemo)(()=>b===null||ue?null:{runId:o?`result:${o}`:`review`,phase:`review`,status:`idle`,canNext:!1,canStop:!1,stopRequested:!1,reps:[],selectedOccurrenceId:null,entry:null,error:null,saving:!1},[b,ue,o]),me=async()=>{let e=L.current;if(!e||F.current)return;F.current=!0,I.current=!1,z(`saving`),te(null);let t;try{t=a?.(e.blockId,e.results),await t}catch(e){I.current=!0,te(e instanceof Error?e.message:String(e)),z(`error`),F.current=!1;return}F.current=!1,z(`idle`),re(!0);let{results:n}=e;if(n.logs&&n.logs.length>0)try{let{segments:e}=jz(n.logs,n.startTime);x(e)}catch{x([])}else n.completed?x([]):A.current&&i()},H=(0,W.useCallback)(()=>{O.current=!0,l?.()},[l]),he=()=>{if(F.current||I.current){A.current=!0;return}if(b!==null||k.current||!O.current){i();return}if(!j&&!u){P(!0);return}A.current=!0,M(!0)},ge=()=>{P(!1),A.current=!0,M(!0)},_e=(0,W.useRef)(he);_e.current=he,bK(pe,(0,W.useCallback)(e=>e.kind===`dismiss`&&(_e.current(),!0),[]),20,{keyboard:!0});let ve=(e,t)=>{k.current||(k.current=!0,L.current={blockId:e,results:t},me())},ye=(e,t,n)=>{C(r=>{let i=new Set(r);if(t?.ctrlKey)i.has(e)?i.delete(e):i.add(e);else if(t?.shiftKey&&n){let t=Array.from(r).pop();if(t!==void 0){let r=n.indexOf(t),a=n.indexOf(e);if(r!==-1&&a!==-1){let e=Math.min(r,a),t=Math.max(r,a);for(let r=e;r<=t;r++)i.add(n[r])}else i.add(e)}else i.add(e)}else i.clear(),i.add(e);return i})},be=R===`idle`?null:(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-3 border-b border-border bg-muted/20 px-6 py-2 text-sm`,children:[R===`saving`&&(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`Saving…`}),R===`error`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{role:`alert`,className:`text-destructive`,children:[`Save failed`,ee?` — ${ee}`:``]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>void me(),className:`rounded-pill border border-border px-3 py-1 text-xs font-medium text-foreground transition-colors hover:bg-accent`,children:`Retry save`})]})]});return m?b===null?(0,G.jsx)(tQ,{onClose:he,title:`Workout`,closeLabel:`Exit`,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:he,title:`Stop Session`,className:`flex h-11 min-w-[44px] items-center justify-center rounded-pill bg-muted/50 px-4 text-sm font-medium text-muted-foreground shadow-[rgba(0,0,0,0.06)_0px_1px_2px] transition-colors hover:bg-muted hover:text-foreground`,children:`Stop`}),(0,G.jsx)(uQ,{}),(0,G.jsx)(dQ,{})]}),children:(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[be,g?(0,G.jsxs)(`div`,{className:`space-y-2 p-4`,children:[(0,G.jsxs)(`p`,{role:`alert`,children:[`Workout not started. `,g]}),(0,G.jsx)(`button`,{type:`button`,className:`rounded border px-3 py-2 hover:bg-accent focus-visible:ring-2`,onClick:()=>void y(),children:`Retry starting workout`})]}):m?null:(0,G.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:`p-4`,children:`Saving workout before starting…`}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,G.jsx)(yJ,{block:m,noteContent:t,view:r,onClose:he,onComplete:ve,isExpanded:!0,autoStart:s,onRuntimeReady:c,onRunStarted:H,externalStop:u||j,adoptRuntime:d,parkOnUnmount:f,onPark:p})}),N&&(0,G.jsx)(tQ,{title:`Stop workout?`,onClose:()=>P(!1),closeLabel:`Keep going`,actions:void 0,children:(0,G.jsxs)(`div`,{className:`space-y-4 p-6`,children:[(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The run stops now and your partial results are kept.`}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-3`,children:[(0,G.jsx)(`button`,{type:`button`,"data-testid":`stop-cancel`,onClick:()=>P(!1),className:`rounded-lg border border-border px-4 py-2 text-sm font-medium text-foreground transition-colors hover:bg-accent`,children:`Keep going`}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`stop-confirm`,onClick:ge,className:`rounded-lg bg-destructive px-4 py-2 text-sm font-bold text-destructive-foreground transition-colors hover:brightness-110`,children:`Stop — keep partial results`})]})]})})]})}):(0,G.jsx)(tQ,{title:`Workout Complete`,onClose:he,actions:(0,G.jsxs)(G.Fragment,{children:[ne&&(0,G.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Saved ✓`}),(0,G.jsx)(uQ,{}),(0,G.jsx)(dQ,{})]}),children:(0,G.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[be,(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:ue?(0,G.jsx)(eJ,{mode:`post-run`,items:le,onSave:de,onSkip:fe,onClose:()=>V(!0),runId:o?`result:${o}`:void 0,className:`mx-auto max-w-md`}):(0,G.jsx)(eQ,{runtime:null,segments:b,selectedSegmentIds:S,onSelectSegment:ye,groups:[],gridViewPreset:w?`debug`:`default`})})]})}):(0,G.jsx)(tQ,{title:`Starting workout`,onClose:i,children:g?(0,G.jsxs)(`div`,{className:`space-y-3 p-6`,children:[(0,G.jsxs)(`p`,{role:`alert`,children:[`Workout not started. `,g,` Your draft is kept.`]}),(0,G.jsx)(`button`,{type:`button`,className:`rounded border px-3 py-2 focus-visible:ring-2`,onClick:()=>void y(),children:`Retry start`})]}):(0,G.jsx)(`p`,{role:`status`,className:`p-6`,children:`Saving workout before starting…`})})},mQ={play:!0,"add-to-today":!0,schedule:!0},hQ=`log`;function gQ(e,t){return e.filter(e=>e.id===hQ?t===`log`:!mQ[e.id]||t===`run`)}function _Q(e,t){let n=t.contentFrom!==void 0&&t.contentTo!==void 0?e.state.doc.sliceString(t.contentFrom,t.contentTo):``,r=t.type===`time`||t.type===`log`?t.type:`time`;return{id:t.id,contentId:t.contentId,dialect:r,sport:t.sport,startLine:t.startLine-1,endLine:t.endLine-1,content:n,state:`idle`,version:1,createdAt:Date.now(),widgetIds:{}}}function vQ(e){return function({className:t}){return W.isValidElement(e)?W.cloneElement(e,{className:K(e.props.className,t)}):(0,G.jsx)(`span`,{className:K(`flex items-center`,t),children:e})}}var yQ=({cmd:e,block:t})=>{let[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(!1),o=(0,W.useCallback)(async()=>{!e.onSplitClick||n||(await e.onSplitClick(t),r(!0),setTimeout(()=>r(!1),1500))},[e,t,n]),s=(0,W.useCallback)(async()=>{i||(await e.onClick(t),e.successIcon&&(a(!0),setTimeout(()=>a(!1),1500)))},[e,t,i]),c=(0,W.useMemo)(()=>vQ(i?e.successIcon??e.icon:e.icon),[e.icon,e.successIcon,i]),l=(0,W.useMemo)(()=>vQ(n?e.splitSuccessIcon??e.splitIcon:e.splitIcon),[n,e.splitIcon,e.splitSuccessIcon]),u=(0,W.useMemo)(()=>({id:e.id,label:e.label,icon:c,action:{type:`call`,handler:()=>s()}}),[e.id,e.label,c,s]),d=(0,W.useMemo)(()=>({id:`${e.id}-split`,label:`Copy link`,icon:l,action:{type:`call`,handler:o}}),[e.id,l,o]),f=(0,W.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]);if(!e.onSplitClick){let t=i?e.successIcon??e.icon:e.icon;return(0,G.jsxs)(q,{variant:e.primary?`default`:`secondary`,className:K(e.iconOnly?`h-11 w-11 rounded-full p-0 sm:h-auto sm:min-h-[44px] sm:min-w-[44px] sm:w-auto sm:rounded-sm sm:px-1.5 sm:py-0.5 text-[10px] font-medium shadow-sm`:`h-11 w-11 rounded-full p-0 text-[10px] font-medium shadow-sm gap-0 sm:h-auto sm:min-h-[44px] sm:w-auto sm:gap-1 sm:rounded-sm sm:px-2 sm:py-0.5`,!e.primary&&`border border-border/50`,i&&`text-emerald-600 bg-emerald-500/15 dark:text-emerald-400 dark:bg-emerald-500/20 border-emerald-500/30`),title:e.label,"aria-label":e.label,"data-testid":e.id===`run`?iG.EDITOR_START_WORKOUT:void 0,onClick:e=>{f(e),s()},onMouseDown:f,onPointerDown:f,children:[(0,G.jsx)(`span`,{className:`flex items-center justify-center size-4 sm:size-3`,children:t}),!e.iconOnly&&(0,G.jsx)(`span`,{className:`sr-only sm:not-sr-only sm:inline`,children:e.label})]})}return(0,G.jsx)(`div`,{onClick:f,onMouseDown:f,onPointerDown:f,children:(0,G.jsx)(IY,{primary:u,secondary:d,size:`xs`,variant:e.primary?`primary`:`default`,className:`rounded-full sm:rounded-sm`,labelClassName:`sr-only sm:not-sr-only sm:inline`})})},bQ=({view:e,commands:t})=>{let[n,r]=(0,W.useState)(()=>e?.plugin(JT)?.rects??[]),[i,a]=(0,W.useState)(0);(0,W.useEffect)(()=>{if(!e)return;let t=e.plugin(JT);t&&(r([...t.rects]),t.addListener(e=>r([...e])))},[e]),(0,W.useEffect)(()=>{if(!e)return;let t=e.scrollDOM,n=null,r=()=>{n===null&&(n=requestAnimationFrame(()=>{n=null,a(t.scrollTop)}))};return t.addEventListener(`scroll`,r,{passive:!0}),a(t.scrollTop),()=>{n!==null&&cancelAnimationFrame(n),t.removeEventListener(`scroll`,r)}},[e]);let o=e?e.plugin(JT):null,s=(n.length>0?n:o?.rects??[]).filter(e=>e.type===`time`||e.type===`log`);if(s.length===0)return null;let{sections:c}=e.state.field(ST),l=new Map(c.map(e=>[e.id,e]));return(0,G.jsx)(G.Fragment,{children:s.map(n=>{let r=l.get(n.sectionId);if(!r)return null;let a=_Q(e,r),o=gQ(t,xa(r.type));return o.length===0?null:(0,G.jsx)(`div`,{className:`absolute right-1 z-10 flex items-end gap-1 pointer-events-auto`,style:{top:n.top-i,height:n.firstLineHeight},children:o.map(e=>(0,G.jsx)(yQ,{cmd:e,block:a},e.id))},n.sectionId)})})},xQ=({sections:e,isRuntimeActive:t,editorState:n,onSelectBlock:r})=>{let i=dM(),a=(0,W.useRef)(``);return(0,W.useEffect)(()=>{if(!i?.connected||t||!n)return;let r=e.filter(e=>e.type===`time`).map(e=>{let t=e.contentFrom!==void 0&&e.contentTo!==void 0?n.doc.sliceString(e.contentFrom,e.contentTo):``,r=t.split(`
171
171
  `).filter(e=>e.trim().length>0),i=r.slice(0,3).join(`
172
- `),a=t.match(/^(\d{1,2}:\d{2}(?::\d{2})?)/m)?.[1],o=r[0]?.substring(0,60)||`Workout`,s=e.type===`time`||e.type===`log`?e.type:`time`;return{id:e.id,title:o,statementCount:r.length,contentPreview:i,timerHint:a,dialect:s}}),o={type:`rpc-workbench-update`,mode:r.length>0?`preview`:`idle`,previewData:r.length>0?{title:r[0].title,blocks:r}:void 0},s=JSON.stringify(o);if(s!==a.current){a.current=s;try{i.send(o)}catch{}}},[i,e,t,n]),(0,W.useEffect)(()=>{i?.connected||(a.current=``)},[i]),(0,W.useEffect)(()=>{t||(a.current=``)},[t]),(0,W.useEffect)(()=>{if(!(!i?.connected||!r||!n))return i.onMessage(t=>{if(t.type!==`rpc-event`||t.name!==`select-block`)return;let{index:i,blockId:a}=t.data??{},o=e.filter(e=>e.type===`time`),s=a?o.find(e=>e.id===a):o[i??0];if(!s||!n)return;let c=s.contentFrom!==void 0&&s.contentTo!==void 0?n.doc.sliceString(s.contentFrom,s.contentTo):``;r({id:s.id,dialect:s.type===`time`||s.type===`log`?s.type:`time`,sport:s.sport,startLine:s.startLine-1,endLine:s.endLine-1,content:c,state:`idle`,version:1,createdAt:Date.now(),widgetIds:{}})})},[i,e,n,r,t]),null},SQ={[J.Duration]:{label:`Timer`,icon:`⏱`,textClass:`text-metric-time`,bgClass:`bg-metric-time/10`,borderClass:`border-metric-time/30`},[J.Rep]:{label:`Reps`,icon:`✕`,textClass:`text-metric-rep`,bgClass:`bg-metric-rep/10`,borderClass:`border-metric-rep/30`},[J.Effort]:{label:`Exercise`,icon:`🏋`,textClass:`text-metric-effort`,bgClass:`bg-metric-effort/10`,borderClass:`border-metric-effort/30`},[J.Rounds]:{label:`Rounds`,icon:`↻`,textClass:`text-metric-rounds`,bgClass:`bg-metric-rounds/10`,borderClass:`border-metric-rounds/30`},[J.Distance]:{label:`Distance`,icon:`📏`,textClass:`text-metric-distance`,bgClass:`bg-metric-distance/10`,borderClass:`border-metric-distance/30`},[J.Resistance]:{label:`Weight`,icon:`⚖`,textClass:`text-metric-resistance`,bgClass:`bg-metric-resistance/10`,borderClass:`border-metric-resistance/30`},[J.Equipment]:{label:`Equipment`,icon:`🧰`,textClass:`text-metric-equipment`,bgClass:`bg-metric-equipment/10`,borderClass:`border-metric-equipment/30`},[J.Action]:{label:`Action`,icon:`⚡`,textClass:`text-metric-action`,bgClass:`bg-metric-action/10`,borderClass:`border-metric-action/30`},[J.Label]:{label:`Label`,icon:`🏷`,textClass:`text-muted-foreground`,bgClass:`bg-muted/30`,borderClass:`border-border/40`}},CQ={[J.Rep]:`reps`,[J.Effort]:`movement`,[J.Resistance]:`weight`},wQ=({metric:e,tooltip:t,isFocused:n,onClick:r})=>{let i=SQ[e.type],a=e.type===J.Hint,o=e.name??e.image??(e.value===void 0?``:String(e.value)),s=i?.label??String(e.type);return(0,G.jsxs)(`span`,{title:t,onClick:r,className:K(`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full border text-[10px] leading-none font-medium whitespace-nowrap`,`pointer-events-auto transition-opacity hover:opacity-80`,i?.bgClass??`bg-muted/30`,i?.textClass??`text-muted-foreground`,i?.borderClass??`border-border/40`,r&&`cursor-pointer`,n&&`font-bold shadow-xs`),children:[(0,G.jsx)(`span`,{children:a?e.icon:i?.icon??`•`}),!a&&(0,G.jsx)(`span`,{className:`sr-only`,children:s}),!a&&(0,G.jsx)(`span`,{className:`font-semibold`,children:o||s})]})};function TQ(e){let t=oa(e.metadata);return{refs:t?.refs??[],diagnostics:t?.diagnostics??[]}}function EQ(e,t){try{let n=e.coordsAtPos(t.lineFrom);if(!n)return null;let r=typeof t.lineTo==`number`?e.coordsAtPos(t.lineTo)??n:n,i=e.dom?.getBoundingClientRect?.()??{top:0,left:0,width:600},a=e.contentDOM?.getBoundingClientRect?.()??{left:0,width:600},o=Math.max(0,a.left-i.left),s=o+Math.max(240,a.width),c=r.left-i.left+12,l=s-c;if(l>=180){let e=typeof r.top==`number`?r.top:r.bottom-20;return{top:Math.max(0,e-i.top-1),left:c,maxWidth:l-4,belowLine:!1}}return{top:r.bottom-i.top+3,left:o,maxWidth:Math.max(220,a.width),belowLine:!0}}catch{return null}}var DQ=({view:e,cursorVersion:t,getCursorFocusState:n})=>{let[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(null),l=(0,W.useRef)(null),u=(0,W.useCallback)(()=>{if(!e){o(null),i(null);return}let t=(n??mY)(e.state);o(t),i(t?EQ(e,t):null)},[e,n]);(0,W.useEffect)(()=>{u()},[u,t]),(0,W.useEffect)(()=>{if(!e)return;let t=()=>u();return window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t,!0),()=>{window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t,!0)}},[e,u]);let d=e?.state&&typeof e.state.field==`function`?Lr(e.state)===`active`:!1;if(!r||!a?.section||d)return null;let f=a.allStatements?.filter(e=>e.meta?.line===a.cursorLine-a.section.startLine)??(a.statement?[a.statement]:[]),p=f.flatMap(e=>e.metrics.toArray()).filter(e=>{if(e.type===J.Sound||e.type===J.System||e.type===J.Hint&&!e.icon||e.type===J.Custom&&typeof e.value==`string`&&/^#[a-zA-Z0-9][a-zA-Z0-9-]*$/.test(e.value.trim()))return!1;if(e.type===J.Effort||e.type===J.Equipment){let t=TQ(e);if(t.refs.length>0||t.diagnostics.length>0)return!1}return!0}),m=MG(p,`runtime-badge`),h=f.flatMap(e=>e.metrics.toArray()),g=[],_=[],v=[];for(let e of h){let t=TQ(e);for(let e of t.refs){let t=`${e.kind}:${e.slug}`;g.includes(t)||(g.push(t),_.push(e))}v.push(...t.diagnostics)}let y=[],b=[];for(let e of h){let t=ma(e.metadata);if(t){y.some(e=>e.slug===t.slug)||y.push(t);continue}if(e.type===J.Custom&&typeof e.value==`string`&&/^#[a-zA-Z0-9][a-zA-Z0-9-]*$/.test(e.value.trim())){let t=e.value.trim().slice(1);b.includes(t)||b.push(t)}}let x=typeof e?.state?.facet==`function`?e.state.facet(sE)?.()??null:null,S=typeof e?.state?.doc?.sliceString==`function`?nY(e.state.doc.sliceString(a.lineFrom,a.lineTo)):null,C=e=>e.reason===`conflict`||e.reason.endsWith(`equipment`)||e.reason===`invalid-explicit`&&e.token&&S?.equipment.includes(e.token)?`equipment`:`effort`,w=e=>typeof e==`string`&&e.trim()?e:null,T=async t=>{if(!e)return;let n=e.state.doc.sliceString(a.lineFrom,a.lineTo),r=SU.getState();if(t===`effort`){let t=await r.open({placeholder:`Change effort…`,sources:[YJ(`effort`)]});if(t.dismissed)return;let i=w(t.item.payload);if(!i)return;e.dispatch({changes:{from:a.lineFrom,to:a.lineTo,insert:rY(n,{effort:i})}});return}let i=[...S?.equipment??[]];for(;;){let e=await r.open({placeholder:i.length>0?`Add equipment (Esc to finish)…`:`Set equipment…`,sources:[YJ(`equipment`)]});if(e.dismissed)break;let t=w(e.item.payload);t&&!i.includes(t)&&i.push(t)}((S?.jsonFrom??-1)>=0||i.length>0)&&e.dispatch({changes:{from:a.lineFrom,to:a.lineTo,insert:rY(n,{equipment:i})}})},E=async()=>{if(!e)return;let t=e.state.doc.sliceString(a.lineFrom,a.lineTo),n=SU.getState(),r,i=await n.open({placeholder:`Add effort (Esc to skip)…`,sources:[YJ(`effort`)]});i.dismissed||(r=w(i.item.payload)??void 0);let o=[];for(;;){let e=await n.open({placeholder:`Add equipment (Esc to finish)…`,sources:[YJ(`equipment`)]});if(e.dismissed)break;let t=w(e.item.payload);t&&!o.includes(t)&&o.push(t)}!r&&o.length===0||e.dispatch({changes:{from:a.lineFrom,to:a.lineTo,insert:rY(t,{effort:r,equipment:o})}})},D=()=>{e&&typeof e.dispatch==`function`&&e.dispatch({effects:[oY.of(null)]}),u()},O=async t=>{if(!e||!t.token)return;let n=C(t),r=await SU.getState().open({placeholder:`Replace “${t.token}”…`,sources:[YJ(n,t.candidates)]});if(r.dismissed)return;let i=w(r.item.payload);if(!i)return;let o=e.state.doc.sliceString(a.lineFrom,a.lineTo).indexOf(t.token);o<0||e.dispatch({changes:{from:a.lineFrom+o,to:a.lineFrom+o+t.token.length,insert:i}})},k=async(e,t)=>{t.trim()&&(e===`effort`?await ZJ(t):await $J(t),D())},A=async e=>{if(!e.trim())return;let t=await SU.getState().open({placeholder:`Link “${e}” as alias to effort…`,sources:[YJ(`effort`)]});if(t.dismissed)return;let n=w(t.item.payload);n&&(await QJ(n,e),D())},j=async e=>{e.trim()&&(await eY(e),D())},M=t=>{let n=CQ[t.type];if(!n||!e)return;let r=t.type===J.Effort?`effort`:t.type===J.Equipment?`equipment`:null;if(r&&S?.jsonFrom!==void 0&&S.jsonFrom>=0){T(r);return}at(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-DV-yv1de.js`);return{runStatementBuilderFlow:e}},__vite__mapDeps([3,1,0,2])).then(({runStatementBuilderFlow:t})=>{t(a,e,n)})};return(0,G.jsx)(`div`,{ref:l,className:K(`cm-metric-inline-panel`,`absolute z-40 pointer-events-auto`,`inline-flex items-center gap-1 px-1.5 py-0.5 min-h-[22px]`,r.belowLine?`bg-popover/95 backdrop-blur-md border border-border/70 rounded-md shadow-sm`:`bg-transparent`,`transition-opacity duration-100 max-w-full`),style:{top:r.top,left:r.left,maxWidth:r.maxWidth},"aria-live":`polite`,"aria-label":`Metric inline panel`,children:p.length>0||_.length>0||y.length>0||v.length>0||b.length>0?(0,G.jsxs)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:[p.map((e,t)=>(0,G.jsx)(wQ,{metric:e,tooltip:e.type===J.Hint?String(e.value??``):m[t]?.tooltip,isFocused:a.focusedMetric===e,onClick:CQ[e.type]?()=>M(e):void 0},`${e.type}-${t}`)),_.map(e=>{let t=e.kind===`effort`&&a.focusedMetric?.type===J.Effort||e.kind===`equipment`&&a.focusedMetric?.type===J.Equipment;return(0,G.jsxs)(`span`,{title:`${e.kind===`effort`?`Effort`:`Equipment`}: ${e.label} (${e.slug})${e.matchedAlias?` · matched alias "${e.matchedAlias}"`:``} · click to change`,onClick:()=>void T(e.kind),className:K(`pointer-events-auto inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full border text-[10px] leading-none font-medium cursor-pointer hover:opacity-80 whitespace-nowrap`,e.kind===`effort`?`bg-metric-effort/10 text-metric-effort border-metric-effort/30`:`bg-metric-equipment/10 text-metric-equipment border-metric-equipment/30`,t&&`font-bold shadow-xs`),children:[(0,G.jsx)(`span`,{children:e.kind===`effort`?`🏋`:`🧰`}),(0,G.jsx)(`span`,{className:`sr-only`,children:e.kind===`effort`?`Exercise`:`Equipment`}),(0,G.jsx)(`span`,{className:`font-semibold`,children:e.label}),x&&(0,G.jsx)(`a`,{href:x.openHref(e.kind,e.slug),title:`Open ${e.label} page`,"aria-label":`Open ${e.label} page`,className:`opacity-70 hover:opacity-100 ml-0.5`,onClick:e=>e.stopPropagation(),children:`↗`})]},`${e.kind}:${e.slug}`)}),y.map(e=>(0,G.jsxs)(`span`,{title:e.soundProfileId?`Tag ${e.label} · names the ${e.soundProfileId} sound profile`:`Tag ${e.label}`,className:`pointer-events-auto inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full border text-[10px] leading-none font-medium bg-primary/10 text-primary border-primary/30 whitespace-nowrap`,children:[(0,G.jsx)(`span`,{children:`#`}),(0,G.jsx)(`span`,{className:`font-semibold font-mono`,children:e.label}),x&&(0,G.jsx)(`a`,{href:x.openHref(`tag`,e.slug),title:`Open the ${e.label} tag`,"aria-label":`Open the ${e.label} tag`,className:`opacity-70 hover:opacity-100 ml-0.5`,onClick:e=>e.stopPropagation(),children:`↗`})]},`tag:${e.slug}`)),S?.malformed&&(0,G.jsxs)(`span`,{"data-testid":`editor-ref-unknown`,title:`Reference JSON on this line does not parse — fix it in the raw text.`,className:`pointer-events-auto inline-flex items-center gap-1.5 px-2 py-0.5 rounded border text-[11px] font-medium bg-destructive/10 text-destructive border-destructive/30`,children:[(0,G.jsx)(`span`,{children:`⚠`}),(0,G.jsx)(`span`,{children:`Malformed reference JSON`})]}),b.map(e=>(0,G.jsxs)(`span`,{"data-testid":`editor-tag-unknown`,title:`Unknown tag #${e} — click to create`,className:`pointer-events-auto inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full border border-dashed text-[10px] leading-none font-medium bg-warning/10 text-warning border-warning/40 whitespace-nowrap`,children:[(0,G.jsxs)(`span`,{className:`font-mono font-semibold`,children:[`#`,e]}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`editor-create-tag-inline`,className:`underline cursor-pointer hover:text-foreground font-semibold ml-0.5`,onClick:()=>void j(e),children:`+ Tag`})]},`unresolved-tag:${e}`)),v.map((e,t)=>{let n=C(e),r=e.token?.trim()??``,i=e.reason===`unknown-effort`,a=`${e.reason}-${r||t}`,o=s===a||s===`all`;return(0,G.jsxs)(`span`,{"data-testid":`editor-ref-unknown`,title:e.message,onClick:()=>{o||c(a)},className:K(`pointer-events-auto inline-flex flex-wrap items-center gap-1.5 px-1.5 py-0.5 rounded-xl border border-dashed text-[10px] leading-tight font-medium bg-warning/10 text-warning border-warning/40 max-w-full`,!o&&`rounded-full whitespace-nowrap cursor-pointer hover:bg-warning/15`),children:[(0,G.jsx)(`span`,{children:`?`}),(0,G.jsx)(`span`,{className:`font-semibold`,children:e.token??e.reason}),o?(0,G.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1.5 pl-1 border-l border-warning/30`,children:[r&&(0,G.jsxs)(`button`,{type:`button`,"data-testid":`editor-create-${n}-inline`,className:`underline cursor-pointer hover:text-foreground font-semibold`,onClick:e=>{e.stopPropagation(),k(n,r)},children:[`+ `,n===`effort`?`Effort`:`Equipment`]}),r&&i&&(0,G.jsx)(`button`,{type:`button`,"data-testid":`editor-link-alias-inline`,className:`underline cursor-pointer hover:text-foreground font-semibold`,onClick:e=>{e.stopPropagation(),A(r)},children:`+ Alias`}),r&&i&&(0,G.jsx)(`button`,{type:`button`,"data-testid":`editor-create-equipment-from-token`,className:`underline cursor-pointer hover:text-foreground font-semibold`,onClick:e=>{e.stopPropagation(),k(`equipment`,r)},children:`+ Equipment`}),(0,G.jsx)(`button`,{type:`button`,className:`underline cursor-pointer hover:text-foreground`,onClick:t=>{t.stopPropagation(),O(e)},children:`Select existing`}),x&&(0,G.jsx)(`a`,{href:x.createHref(n),className:`underline hover:text-foreground`,onClick:e=>e.stopPropagation(),children:`Create page`})]}):(0,G.jsx)(`button`,{type:`button`,"data-testid":`editor-define-token`,className:`underline cursor-pointer hover:text-foreground font-semibold`,onClick:e=>{e.stopPropagation(),c(a)},children:`Define ▾`})]},a)}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`editor-add-metric-line`,title:`Add effort/equipment reference to this line`,onClick:()=>void E(),className:`pointer-events-auto inline-flex items-center px-1.5 py-0.5 rounded-full border border-dashed border-border/60 text-[10px] leading-none text-muted-foreground hover:text-foreground hover:border-primary/50 cursor-pointer whitespace-nowrap`,children:`+ Metric`})]}):(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60 italic select-none`,children:`No metrics on this line`})})},OQ=new si,kQ=new si,AQ=new si;async function jQ(e){let t=new TextEncoder().encode(e);if(typeof CompressionStream<`u`)try{let e=new CompressionStream(`gzip`),n=e.writable.getWriter(),r=e.readable.getReader();n.write(t),n.close();let i=[];for(;;){let{done:e,value:t}=await r.read();if(e)break;i.push(t)}let a=i.reduce((e,t)=>e+t.length,0),o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return btoa(String.fromCharCode(...o)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}catch{}return btoa(String.fromCharCode(...t)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}async function MQ(e){let t=await jQ(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`);return`${window.location.origin}/load?zip=${t}`}async function NQ(e){let t=await jQ(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`),n=`shared by ${Mx()}`;return`${window.location.origin}/?z=${t}&by=${encodeURIComponent(n)}`}var PQ=({noteId:e,noteBlocks:t,sourceRevision:n=0,onIdentityChange:r,onSaved:i,beforeRun:a,onSaveRequest:o,onCommitChange:s,value:c,onChange:l,onDocUpdate:u,onCursorPositionChange:d,onBlur:f,theme:p=`vs`,readonly:m=!1,className:h=``,ariaLabel:g=`Note editor`,onStartWorkout:_,onCompleteWorkout:v,onBlocksChange:y,onAddToPlan:b,notePersistence:x,onViewCreated:S,mode:C=`edit`,lineWrapping:w=!0,showLineNumbers:T=!0,enablePreview:E=!0,showFrontmatter:D=!0,enableLinting:O=!0,enableOverlay:k=!1,commands:A,hideDefaultCommands:j=!1,enableInlineRuntime:M=!0,extensions:N,widgetComponents:P,activeSectionId:F,scrollToSectionId:I,results:L,placeholder:R})=>{let z=(0,W.useRef)(null),ee=(0,W.useRef)(null),te=(0,W.useRef)(null),ne=(0,W.useRef)(``),re=p===`dark`||p===`vs-dark`,B=iY(te,x),[ie,ae]=(0,W.useState)(null),[oe,se]=(0,W.useState)([]),[ce,V]=(0,W.useState)(1),[le,ue]=(0,W.useState)(0),de=F??ie,fe=TY(oe,de),[pe,me]=(0,W.useState)(null),[H,he]=(0,W.useState)(null),[ge,_e]=(0,W.useState)(null),[ve,ye]=(0,W.useState)(!1),be=(0,W.useRef)(null),xe=(0,W.useRef)(!1),Se=(0,W.useRef)(n??0);(0,W.useEffect)(()=>{Se.current=n??0},[n]);let[Ce,we]=(0,W.useState)(null),Te=(0,W.useRef)(null),Ee=(0,W.useCallback)(async(t,n=!1)=>{let r=ee.current;if(!(!r||xe.current)){xe.current=!0,we(null);try{let o=await a?.();typeof o==`number`&&(Se.current=o);let s=r.state.field(ST),c=await Ij({noteId:e??en(),rawContent:s.rawContent,blocks:s.noteBlocks,expectedSourceRevision:Se.current,...e?{}:{metadata:{title:`Playground workout`},noteType:`playground`}},t,en(),e?void 0:`playground`,B);be.current=c,Te.current=null,Se.current=c.note.sourceRevision,r.dispatch({effects:mT.of({blocks:c.note.blocks,sourceRevision:c.note.sourceRevision})}),i?.({rawContent:c.note.rawContent,blocks:c.note.blocks,sourceRevision:c.note.sourceRevision}),ye(n),he(c.block),_e(c.session.id)}catch(e){we(e instanceof Error?e.message:String(e))}finally{xe.current=!1}}},[e,B,i,a]),De=(0,W.useCallback)(()=>{he(null),_e(null),ye(!1)},[]),Oe=(0,W.useCallback)(e=>{M&&Ee(e,!0)},[M,Ee]),ke=(0,W.useRef)(null),Ae=(0,W.useCallback)((e,t)=>{let n=ke.current,r=n!==null&&n.results===t,i=be.current;if(!i||!t)return Promise.reject(Error(`The saved run pin is unavailable.`));let a=i.session.id;if(Te.current===a)return Promise.resolve();let o={id:i.block.id,contentId:i.session.blockContentId};if(!r&&t&&ee.current){let t=ee.current,n=LD(t.state,e,a);if(n){let e=n.from+n.insert.indexOf("```");t.dispatch({changes:n,effects:[Dr.scrollIntoView(e,{y:`start`,yMargin:96})]}),l?.(t.state.doc.toString())}}r||(ke.current={results:t,resultId:a,runBlock:o});let s;try{s=Uj(B).record({resultId:a,noteId:i.session.noteId,blockId:i.session.blockId,data:t,createdAt:t.endTime}).then(()=>v?.(e,t,a,o))}catch(e){return Promise.reject(e instanceof Error?e:Error(String(e)))}return Promise.resolve(s).then(()=>{ke.current?.results===t&&(ke.current=null),Te.current=a},()=>{}),s},[l,v,B]),je=(0,W.useMemo)(()=>{if(j)return[];if(A&&A.length>0)return A;let e=[];return M?e.push({id:`run`,label:`Run`,icon:(0,G.jsx)(pr,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:Ee}):_&&e.push({id:`run`,label:`Run`,icon:(0,G.jsx)(pr,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:_}),e.push({id:`playground`,label:`Playground`,icon:(0,G.jsx)(tt,{className:`h-3 w-3`}),splitIcon:(0,G.jsx)(Gn,{className:`h-3 w-3`}),splitSuccessIcon:(0,G.jsx)(Bt,{className:`h-3 w-3`}),onClick:e=>{MQ(e.content).then(e=>{let t=window.open(e,`wodwiki-playground`);t&&t.focus()})},onSplitClick:async e=>{let t=await NQ(e.content);await navigator.clipboard.writeText(t)}}),b&&e.push({id:`plan`,label:`Plan`,icon:(0,G.jsx)(er,{className:`h-3 w-3`}),onClick:b}),e},[A,_,b,M,j,Ee]),Me=(0,W.useMemo)(()=>fi({codeLanguages:CO}),[]),Ne=(0,W.useMemo)(()=>{let e=Math.max(1,n),r=P?[...P.keys()]:Ea;if(t&&Object.keys(t).length>0)try{return Pa(c,t,e,{registeredWidgets:r}),t}catch{return Na(c,{sourceRevision:e,blocks:t,registeredWidgets:r})}return Na(c,{sourceRevision:e,registeredWidgets:r})},[c,t,n,P]),Pe=(0,W.useMemo)(()=>[...T?[Xr(),Br()]:[],Hr(),ui(),Ar(),di(),...w?[Dr.lineWrapping]:[],ei.allowMultipleSelections.of(!0),Or(),Si(),Vr(),gi(),li.highest(br.of([{key:`Tab`,run:e=>Lr(e.state)!==null&&(Ci(e),!0)},{key:`Enter`,run:e=>{let t=e.state.selection.main,n=RQ(e.state,t.head),r=e.state.doc.lineAt(t.head);return!t.empty||n?.value.trim()!==``||r.text.slice(t.head-r.from).trim()?!1:(Sr(e),see(e))}}])),br.of([...aee,...Zr,...oi,...ai,...xi,...ci,Qr,{key:`Mod-s`,run:()=>(o?.(),!0)},{key:`Ctrl-.`,run:e=>{let t=mY(e.state);if(!t?.focusedMetric)return!1;let n=t.focusedMetric.type;return!new Set([`duration`,`rep`,`rounds`,`distance`,`resistance`]).has(n)&&(at(()=>Promise.resolve().then(()=>xU).then(()=>{at(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-DV-yv1de.js`);return{runStatementBuilderFlow:e}},__vite__mapDeps([3,1,0,2])).then(({runStatementBuilderFlow:n})=>{n(t,e)}).catch(()=>{SU.getState().open({placeholder:`Modify metric…`,sources:[]})})}),void 0),!0)}}]),UD,ST,dT.of({blocks:Ne,sourceRevision:Math.max(1,n),rawContent:c}),fT.of(P?[...P.keys()]:Ea),CT,lE.of(D),...E||!D?[YE]:[],...E?[$T,nE,LJ(),KJ(),fD,oD(),CD]:[],...O?[OT]:[],KT,Hw,PT,NT,FT.of(FQ),IT.of(IQ),...k?[WD]:[],JT,uT,_Y,...kD,oT,...P&&P.size>0?[SO(P)]:[],QD({executor:jB,onResultSaved:Vj,readOnly:m,noteHref:e=>TL(`blockContentId`in e||`dataType`in e?mL(e):cL(e))}),aY(e,B),Dr.domEventHandlers({blur:()=>(f?.(),!1)}),Dr.updateListener.of(e=>{if(e.docChanged){let t=e.state.field(ST);r?.({rawContent:t.rawContent,blocks:t.noteBlocks,sourceRevision:t.sourceRevision}),l(t.rawContent),u?.(e),BQ(e.state,y,ne),e.transactions.some(e=>e.isUserEvent(`input`)||e.isUserEvent(`delete`)||e.isUserEvent(`paste`)||e.isUserEvent(`drop`))||s?.()}if(e.selectionSet||e.docChanged){ue(e=>e+1),e.transactions.some(e=>e.isUserEvent(`delete.backward`))&&Lr(e.startState)!==null&&Lr(e.state)===null&&RQ(e.state,e.state.selection.main.head)?.value===``&&queueMicrotask(()=>{e.view.state===e.state&&ti(e.view)});let{head:t}=e.state.selection.main,n=e.state.doc.lineAt(t);d?.(n.number,t-n.from+1);let r=TT(e.state);ae(r?.id??null),V(n.number);let{sections:i}=e.state.field(ST);se(i)}}),ei.readOnly.of(m),Dr.editable.of(!m),...R?[_i(R)]:[],Dr.contentAttributes.of({"aria-label":g})],[l,d,f,u,y,r,m,o,s,T,w,E,D,O,k,e,B,P,R,g]);return(0,W.useEffect)(()=>{let e=z.current;if(!e)return;let t;try{t=ei.create({doc:c,extensions:[...Pe,OQ.of(aT(re)),kQ.of(Me),AQ.of([]),...N??[]]})}catch(e){console.error(`NoteEditor: Failed to initialize EditorState, recovering with safe fallback`,e),t=ei.create({doc:c,extensions:[OQ.of(aT(re)),kQ.of(Me)]})}let n=new Dr({state:t,parent:e}),i=window.visualViewport,a=0,o=()=>{cancelAnimationFrame(a),a=requestAnimationFrame(()=>{n.hasFocus&&i?.scale===1&&i.height<window.innerHeight&&n.dispatch({effects:Dr.scrollIntoView(n.state.selection.main.head,{y:`nearest`,yMargin:24})})})};i?.addEventListener(`resize`,o),n.contentDOM.addEventListener(`focus`,o),ee.current=n,me(n),e.__codemirrorView=n,S?.(n);let{sections:s}=n.state.field(ST);se(s);let l=n.state.doc.lineAt(n.state.selection.main.head).number;V(l);let u=TT(n.state);ae(u?.id??null);let d=n.state.field(ST);return r?.({rawContent:d.rawContent,blocks:d.noteBlocks,sourceRevision:d.sourceRevision}),BQ(n.state,y,ne),()=>{cancelAnimationFrame(a),i?.removeEventListener(`resize`,o),n.contentDOM.removeEventListener(`focus`,o),delete e.__codemirrorView,me(null),n.destroy()}},[]),(0,W.useEffect)(()=>{let e=ee.current;if(!e)return;let r=e.state.field(ST);if(c!==r.rawContent){let r=Math.max(1,n),i=t?Na(c,{sourceRevision:r,blocks:t,registeredWidgets:P?[...P.keys()]:Ea}):void 0,a=i&&t&&Object.keys(i).length===Object.keys(t).length&&Object.entries(t).every(([e,t])=>{let n=i[e];return n&&n.from===t.from&&n.to===t.to&&n.kind===t.kind&&n.dialect===t.dialect&&n.sport===t.sport});e.dispatch({changes:{from:0,to:e.state.doc.length,insert:c},...a?{effects:hT.of({rawContent:c,blocks:t,sourceRevision:r})}:{}})}else t&&n!==r.sourceRevision&&e.dispatch({effects:mT.of({blocks:t,sourceRevision:Math.max(1,n)})})},[c,t,n]),(0,W.useEffect)(()=>{ee.current&&ee.current.dispatch({effects:OQ.reconfigure(aT(re))})},[re]),(0,W.useEffect)(()=>{if(ee.current){let e=[];ee.current.dispatch({effects:[Jr.reconfigure.of([...Pe,OQ.of(aT(re)),kQ.of(Me),AQ.of(e),...N??[]])]})}},[Pe,N,C,re,Me]),(0,W.useEffect)(()=>{m||ee.current?.focus()},[m]),(0,W.useEffect)(()=>{if(I&&ee.current){let e=ee.current,t=e.state.doc.toString().split(`
172
+ `),a=t.match(/^(\d{1,2}:\d{2}(?::\d{2})?)/m)?.[1],o=r[0]?.substring(0,60)||`Workout`,s=e.type===`time`||e.type===`log`?e.type:`time`;return{id:e.id,title:o,statementCount:r.length,contentPreview:i,timerHint:a,dialect:s}}),o={type:`rpc-workbench-update`,mode:r.length>0?`preview`:`idle`,previewData:r.length>0?{title:r[0].title,blocks:r}:void 0},s=JSON.stringify(o);if(s!==a.current){a.current=s;try{i.send(o)}catch{}}},[i,e,t,n]),(0,W.useEffect)(()=>{i?.connected||(a.current=``)},[i]),(0,W.useEffect)(()=>{t||(a.current=``)},[t]),(0,W.useEffect)(()=>{if(!(!i?.connected||!r||!n))return i.onMessage(t=>{if(t.type!==`rpc-event`||t.name!==`select-block`)return;let{index:i,blockId:a}=t.data??{},o=e.filter(e=>e.type===`time`),s=a?o.find(e=>e.id===a):o[i??0];if(!s||!n)return;let c=s.contentFrom!==void 0&&s.contentTo!==void 0?n.doc.sliceString(s.contentFrom,s.contentTo):``;r({id:s.id,dialect:s.type===`time`||s.type===`log`?s.type:`time`,sport:s.sport,startLine:s.startLine-1,endLine:s.endLine-1,content:c,state:`idle`,version:1,createdAt:Date.now(),widgetIds:{}})})},[i,e,n,r,t]),null},SQ={[J.Duration]:{label:`Timer`,icon:`⏱`,textClass:`text-metric-time`,bgClass:`bg-metric-time/10`,borderClass:`border-metric-time/30`},[J.Rep]:{label:`Reps`,icon:`✕`,textClass:`text-metric-rep`,bgClass:`bg-metric-rep/10`,borderClass:`border-metric-rep/30`},[J.Effort]:{label:`Exercise`,icon:`🏋`,textClass:`text-metric-effort`,bgClass:`bg-metric-effort/10`,borderClass:`border-metric-effort/30`},[J.Rounds]:{label:`Rounds`,icon:`↻`,textClass:`text-metric-rounds`,bgClass:`bg-metric-rounds/10`,borderClass:`border-metric-rounds/30`},[J.Distance]:{label:`Distance`,icon:`📏`,textClass:`text-metric-distance`,bgClass:`bg-metric-distance/10`,borderClass:`border-metric-distance/30`},[J.Resistance]:{label:`Weight`,icon:`⚖`,textClass:`text-metric-resistance`,bgClass:`bg-metric-resistance/10`,borderClass:`border-metric-resistance/30`},[J.Equipment]:{label:`Equipment`,icon:`🧰`,textClass:`text-metric-equipment`,bgClass:`bg-metric-equipment/10`,borderClass:`border-metric-equipment/30`},[J.Action]:{label:`Action`,icon:`⚡`,textClass:`text-metric-action`,bgClass:`bg-metric-action/10`,borderClass:`border-metric-action/30`},[J.Label]:{label:`Label`,icon:`🏷`,textClass:`text-muted-foreground`,bgClass:`bg-muted/30`,borderClass:`border-border/40`}},CQ={[J.Rep]:`reps`,[J.Effort]:`movement`,[J.Resistance]:`weight`},wQ=({metric:e,tooltip:t,isFocused:n,onClick:r})=>{let i=SQ[e.type],a=e.type===J.Hint,o=e.name??e.image??(e.value===void 0?``:String(e.value)),s=i?.label??String(e.type);return(0,G.jsxs)(`span`,{title:t,onClick:r,className:K(`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full border text-[10px] leading-none font-medium whitespace-nowrap`,`pointer-events-auto transition-opacity hover:opacity-80`,i?.bgClass??`bg-muted/30`,i?.textClass??`text-muted-foreground`,i?.borderClass??`border-border/40`,r&&`cursor-pointer`,n&&`font-bold shadow-xs`),children:[(0,G.jsx)(`span`,{children:a?e.icon:i?.icon??`•`}),!a&&(0,G.jsx)(`span`,{className:`sr-only`,children:s}),!a&&(0,G.jsx)(`span`,{className:`font-semibold`,children:o||s})]})};function TQ(e){let t=oa(e.metadata);return{refs:t?.refs??[],diagnostics:t?.diagnostics??[]}}function EQ(e,t){try{let n=e.coordsAtPos(t.lineFrom);if(!n)return null;let r=typeof t.lineTo==`number`?e.coordsAtPos(t.lineTo)??n:n,i=e.dom?.getBoundingClientRect?.()??{top:0,left:0,width:600},a=e.contentDOM?.getBoundingClientRect?.()??{left:0,width:600},o=Math.max(0,a.left-i.left),s=o+Math.max(240,a.width),c=r.left-i.left+12,l=s-c;if(l>=180){let e=typeof r.top==`number`?r.top:r.bottom-20;return{top:Math.max(0,e-i.top-1),left:c,maxWidth:l-4,belowLine:!1}}return{top:r.bottom-i.top+3,left:o,maxWidth:Math.max(220,a.width),belowLine:!0}}catch{return null}}var DQ=({view:e,cursorVersion:t,getCursorFocusState:n})=>{let[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(null),l=(0,W.useRef)(null),u=(0,W.useCallback)(()=>{if(!e){o(null),i(null);return}let t=(n??mY)(e.state);o(t),i(t?EQ(e,t):null)},[e,n]);(0,W.useEffect)(()=>{u()},[u,t]),(0,W.useEffect)(()=>{if(!e)return;let t=()=>u();return window.addEventListener(`scroll`,t,!0),window.addEventListener(`resize`,t,!0),()=>{window.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t,!0)}},[e,u]);let d=e?.state&&typeof e.state.field==`function`?Lr(e.state)===`active`:!1;if(!r||!a?.section||d)return null;let f=a.allStatements?.filter(e=>e.meta?.line===a.cursorLine-a.section.startLine)??(a.statement?[a.statement]:[]),p=f.flatMap(e=>e.metrics.toArray()).filter(e=>{if(e.type===J.Sound||e.type===J.System||e.type===J.Hint&&!e.icon||e.type===J.Custom&&typeof e.value==`string`&&/^#[a-zA-Z0-9][a-zA-Z0-9-]*$/.test(e.value.trim()))return!1;if(e.type===J.Effort||e.type===J.Equipment){let t=TQ(e);if(t.refs.length>0||t.diagnostics.length>0)return!1}return!0}),m=MG(p,`runtime-badge`),h=f.flatMap(e=>e.metrics.toArray()),g=[],_=[],v=[];for(let e of h){let t=TQ(e);for(let e of t.refs){let t=`${e.kind}:${e.slug}`;g.includes(t)||(g.push(t),_.push(e))}v.push(...t.diagnostics)}let y=[],b=[];for(let e of h){let t=ma(e.metadata);if(t){y.some(e=>e.slug===t.slug)||y.push(t);continue}if(e.type===J.Custom&&typeof e.value==`string`&&/^#[a-zA-Z0-9][a-zA-Z0-9-]*$/.test(e.value.trim())){let t=e.value.trim().slice(1);b.includes(t)||b.push(t)}}let x=typeof e?.state?.facet==`function`?e.state.facet(sE)?.()??null:null,S=typeof e?.state?.doc?.sliceString==`function`?nY(e.state.doc.sliceString(a.lineFrom,a.lineTo)):null,C=e=>e.reason===`conflict`||e.reason.endsWith(`equipment`)||e.reason===`invalid-explicit`&&e.token&&S?.equipment.includes(e.token)?`equipment`:`effort`,w=e=>typeof e==`string`&&e.trim()?e:null,T=async t=>{if(!e)return;let n=e.state.doc.sliceString(a.lineFrom,a.lineTo),r=SU.getState();if(t===`effort`){let t=await r.open({placeholder:`Change effort…`,sources:[YJ(`effort`)]});if(t.dismissed)return;let i=w(t.item.payload);if(!i)return;e.dispatch({changes:{from:a.lineFrom,to:a.lineTo,insert:rY(n,{effort:i})}});return}let i=[...S?.equipment??[]];for(;;){let e=await r.open({placeholder:i.length>0?`Add equipment (Esc to finish)…`:`Set equipment…`,sources:[YJ(`equipment`)]});if(e.dismissed)break;let t=w(e.item.payload);t&&!i.includes(t)&&i.push(t)}((S?.jsonFrom??-1)>=0||i.length>0)&&e.dispatch({changes:{from:a.lineFrom,to:a.lineTo,insert:rY(n,{equipment:i})}})},E=async()=>{if(!e)return;let t=e.state.doc.sliceString(a.lineFrom,a.lineTo),n=SU.getState(),r,i=await n.open({placeholder:`Add effort (Esc to skip)…`,sources:[YJ(`effort`)]});i.dismissed||(r=w(i.item.payload)??void 0);let o=[];for(;;){let e=await n.open({placeholder:`Add equipment (Esc to finish)…`,sources:[YJ(`equipment`)]});if(e.dismissed)break;let t=w(e.item.payload);t&&!o.includes(t)&&o.push(t)}!r&&o.length===0||e.dispatch({changes:{from:a.lineFrom,to:a.lineTo,insert:rY(t,{effort:r,equipment:o})}})},D=()=>{e&&typeof e.dispatch==`function`&&e.dispatch({effects:[oY.of(null)]}),u()},O=async t=>{if(!e||!t.token)return;let n=C(t),r=await SU.getState().open({placeholder:`Replace “${t.token}”…`,sources:[YJ(n,t.candidates)]});if(r.dismissed)return;let i=w(r.item.payload);if(!i)return;let o=e.state.doc.sliceString(a.lineFrom,a.lineTo).indexOf(t.token);o<0||e.dispatch({changes:{from:a.lineFrom+o,to:a.lineFrom+o+t.token.length,insert:i}})},k=async(e,t)=>{t.trim()&&(e===`effort`?await ZJ(t):await $J(t),D())},A=async e=>{if(!e.trim())return;let t=await SU.getState().open({placeholder:`Link “${e}” as alias to effort…`,sources:[YJ(`effort`)]});if(t.dismissed)return;let n=w(t.item.payload);n&&(await QJ(n,e),D())},j=async e=>{e.trim()&&(await eY(e),D())},M=t=>{let n=CQ[t.type];if(!n||!e)return;let r=t.type===J.Effort?`effort`:t.type===J.Equipment?`equipment`:null;if(r&&S?.jsonFrom!==void 0&&S.jsonFrom>=0){T(r);return}at(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-CdnAYXCq.js`);return{runStatementBuilderFlow:e}},__vite__mapDeps([3,1,0,2])).then(({runStatementBuilderFlow:t})=>{t(a,e,n)})};return(0,G.jsx)(`div`,{ref:l,className:K(`cm-metric-inline-panel`,`absolute z-40 pointer-events-auto`,`inline-flex items-center gap-1 px-1.5 py-0.5 min-h-[22px]`,r.belowLine?`bg-popover/95 backdrop-blur-md border border-border/70 rounded-md shadow-sm`:`bg-transparent`,`transition-opacity duration-100 max-w-full`),style:{top:r.top,left:r.left,maxWidth:r.maxWidth},"aria-live":`polite`,"aria-label":`Metric inline panel`,children:p.length>0||_.length>0||y.length>0||v.length>0||b.length>0?(0,G.jsxs)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:[p.map((e,t)=>(0,G.jsx)(wQ,{metric:e,tooltip:e.type===J.Hint?String(e.value??``):m[t]?.tooltip,isFocused:a.focusedMetric===e,onClick:CQ[e.type]?()=>M(e):void 0},`${e.type}-${t}`)),_.map(e=>{let t=e.kind===`effort`&&a.focusedMetric?.type===J.Effort||e.kind===`equipment`&&a.focusedMetric?.type===J.Equipment;return(0,G.jsxs)(`span`,{title:`${e.kind===`effort`?`Effort`:`Equipment`}: ${e.label} (${e.slug})${e.matchedAlias?` · matched alias "${e.matchedAlias}"`:``} · click to change`,onClick:()=>void T(e.kind),className:K(`pointer-events-auto inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full border text-[10px] leading-none font-medium cursor-pointer hover:opacity-80 whitespace-nowrap`,e.kind===`effort`?`bg-metric-effort/10 text-metric-effort border-metric-effort/30`:`bg-metric-equipment/10 text-metric-equipment border-metric-equipment/30`,t&&`font-bold shadow-xs`),children:[(0,G.jsx)(`span`,{children:e.kind===`effort`?`🏋`:`🧰`}),(0,G.jsx)(`span`,{className:`sr-only`,children:e.kind===`effort`?`Exercise`:`Equipment`}),(0,G.jsx)(`span`,{className:`font-semibold`,children:e.label}),x&&(0,G.jsx)(`a`,{href:x.openHref(e.kind,e.slug),title:`Open ${e.label} page`,"aria-label":`Open ${e.label} page`,className:`opacity-70 hover:opacity-100 ml-0.5`,onClick:e=>e.stopPropagation(),children:`↗`})]},`${e.kind}:${e.slug}`)}),y.map(e=>(0,G.jsxs)(`span`,{title:e.soundProfileId?`Tag ${e.label} · names the ${e.soundProfileId} sound profile`:`Tag ${e.label}`,className:`pointer-events-auto inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full border text-[10px] leading-none font-medium bg-primary/10 text-primary border-primary/30 whitespace-nowrap`,children:[(0,G.jsx)(`span`,{children:`#`}),(0,G.jsx)(`span`,{className:`font-semibold font-mono`,children:e.label}),x&&(0,G.jsx)(`a`,{href:x.openHref(`tag`,e.slug),title:`Open the ${e.label} tag`,"aria-label":`Open the ${e.label} tag`,className:`opacity-70 hover:opacity-100 ml-0.5`,onClick:e=>e.stopPropagation(),children:`↗`})]},`tag:${e.slug}`)),S?.malformed&&(0,G.jsxs)(`span`,{"data-testid":`editor-ref-unknown`,title:`Reference JSON on this line does not parse — fix it in the raw text.`,className:`pointer-events-auto inline-flex items-center gap-1.5 px-2 py-0.5 rounded border text-[11px] font-medium bg-destructive/10 text-destructive border-destructive/30`,children:[(0,G.jsx)(`span`,{children:`⚠`}),(0,G.jsx)(`span`,{children:`Malformed reference JSON`})]}),b.map(e=>(0,G.jsxs)(`span`,{"data-testid":`editor-tag-unknown`,title:`Unknown tag #${e} — click to create`,className:`pointer-events-auto inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full border border-dashed text-[10px] leading-none font-medium bg-warning/10 text-warning border-warning/40 whitespace-nowrap`,children:[(0,G.jsxs)(`span`,{className:`font-mono font-semibold`,children:[`#`,e]}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`editor-create-tag-inline`,className:`underline cursor-pointer hover:text-foreground font-semibold ml-0.5`,onClick:()=>void j(e),children:`+ Tag`})]},`unresolved-tag:${e}`)),v.map((e,t)=>{let n=C(e),r=e.token?.trim()??``,i=e.reason===`unknown-effort`,a=`${e.reason}-${r||t}`,o=s===a||s===`all`;return(0,G.jsxs)(`span`,{"data-testid":`editor-ref-unknown`,title:e.message,onClick:()=>{o||c(a)},className:K(`pointer-events-auto inline-flex flex-wrap items-center gap-1.5 px-1.5 py-0.5 rounded-xl border border-dashed text-[10px] leading-tight font-medium bg-warning/10 text-warning border-warning/40 max-w-full`,!o&&`rounded-full whitespace-nowrap cursor-pointer hover:bg-warning/15`),children:[(0,G.jsx)(`span`,{children:`?`}),(0,G.jsx)(`span`,{className:`font-semibold`,children:e.token??e.reason}),o?(0,G.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1.5 pl-1 border-l border-warning/30`,children:[r&&(0,G.jsxs)(`button`,{type:`button`,"data-testid":`editor-create-${n}-inline`,className:`underline cursor-pointer hover:text-foreground font-semibold`,onClick:e=>{e.stopPropagation(),k(n,r)},children:[`+ `,n===`effort`?`Effort`:`Equipment`]}),r&&i&&(0,G.jsx)(`button`,{type:`button`,"data-testid":`editor-link-alias-inline`,className:`underline cursor-pointer hover:text-foreground font-semibold`,onClick:e=>{e.stopPropagation(),A(r)},children:`+ Alias`}),r&&i&&(0,G.jsx)(`button`,{type:`button`,"data-testid":`editor-create-equipment-from-token`,className:`underline cursor-pointer hover:text-foreground font-semibold`,onClick:e=>{e.stopPropagation(),k(`equipment`,r)},children:`+ Equipment`}),(0,G.jsx)(`button`,{type:`button`,className:`underline cursor-pointer hover:text-foreground`,onClick:t=>{t.stopPropagation(),O(e)},children:`Select existing`}),x&&(0,G.jsx)(`a`,{href:x.createHref(n),className:`underline hover:text-foreground`,onClick:e=>e.stopPropagation(),children:`Create page`})]}):(0,G.jsx)(`button`,{type:`button`,"data-testid":`editor-define-token`,className:`underline cursor-pointer hover:text-foreground font-semibold`,onClick:e=>{e.stopPropagation(),c(a)},children:`Define ▾`})]},a)}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`editor-add-metric-line`,title:`Add effort/equipment reference to this line`,onClick:()=>void E(),className:`pointer-events-auto inline-flex items-center px-1.5 py-0.5 rounded-full border border-dashed border-border/60 text-[10px] leading-none text-muted-foreground hover:text-foreground hover:border-primary/50 cursor-pointer whitespace-nowrap`,children:`+ Metric`})]}):(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60 italic select-none`,children:`No metrics on this line`})})},OQ=new si,kQ=new si,AQ=new si;async function jQ(e){let t=new TextEncoder().encode(e);if(typeof CompressionStream<`u`)try{let e=new CompressionStream(`gzip`),n=e.writable.getWriter(),r=e.readable.getReader();n.write(t),n.close();let i=[];for(;;){let{done:e,value:t}=await r.read();if(e)break;i.push(t)}let a=i.reduce((e,t)=>e+t.length,0),o=new Uint8Array(a),s=0;for(let e of i)o.set(e,s),s+=e.length;return btoa(String.fromCharCode(...o)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}catch{}return btoa(String.fromCharCode(...t)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}async function MQ(e){let t=await jQ(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`);return`${window.location.origin}/load?zip=${t}`}async function NQ(e){let t=await jQ(`\`\`\`time\n${e.trimEnd()}\n\`\`\`\n`),n=`shared by ${Mx()}`;return`${window.location.origin}/?z=${t}&by=${encodeURIComponent(n)}`}var PQ=({noteId:e,noteBlocks:t,sourceRevision:n=0,onIdentityChange:r,onSaved:i,beforeRun:a,onSaveRequest:o,onCommitChange:s,value:c,onChange:l,onDocUpdate:u,onCursorPositionChange:d,onBlur:f,theme:p=`vs`,readonly:m=!1,className:h=``,ariaLabel:g=`Note editor`,onStartWorkout:_,onCompleteWorkout:v,onBlocksChange:y,onAddToPlan:b,notePersistence:x,onViewCreated:S,mode:C=`edit`,lineWrapping:w=!0,showLineNumbers:T=!0,enablePreview:E=!0,showFrontmatter:D=!0,enableLinting:O=!0,enableOverlay:k=!1,commands:A,hideDefaultCommands:j=!1,enableInlineRuntime:M=!0,extensions:N,widgetComponents:P,activeSectionId:F,scrollToSectionId:I,results:L,placeholder:R})=>{let z=(0,W.useRef)(null),ee=(0,W.useRef)(null),te=(0,W.useRef)(null),ne=(0,W.useRef)(``),re=p===`dark`||p===`vs-dark`,B=iY(te,x),[ie,ae]=(0,W.useState)(null),[oe,se]=(0,W.useState)([]),[ce,V]=(0,W.useState)(1),[le,ue]=(0,W.useState)(0),de=F??ie,fe=TY(oe,de),[pe,me]=(0,W.useState)(null),[H,he]=(0,W.useState)(null),[ge,_e]=(0,W.useState)(null),[ve,ye]=(0,W.useState)(!1),be=(0,W.useRef)(null),xe=(0,W.useRef)(!1),Se=(0,W.useRef)(n??0);(0,W.useEffect)(()=>{Se.current=n??0},[n]);let[Ce,we]=(0,W.useState)(null),Te=(0,W.useRef)(null),Ee=(0,W.useCallback)(async(t,n=!1)=>{let r=ee.current;if(!(!r||xe.current)){xe.current=!0,we(null);try{let o=await a?.();typeof o==`number`&&(Se.current=o);let s=r.state.field(ST),c=await Ij({noteId:e??en(),rawContent:s.rawContent,blocks:s.noteBlocks,expectedSourceRevision:Se.current,...e?{}:{metadata:{title:`Playground workout`},noteType:`playground`}},t,en(),e?void 0:`playground`,B);be.current=c,Te.current=null,Se.current=c.note.sourceRevision,r.dispatch({effects:mT.of({blocks:c.note.blocks,sourceRevision:c.note.sourceRevision})}),i?.({rawContent:c.note.rawContent,blocks:c.note.blocks,sourceRevision:c.note.sourceRevision}),ye(n),he(c.block),_e(c.session.id)}catch(e){we(e instanceof Error?e.message:String(e))}finally{xe.current=!1}}},[e,B,i,a]),De=(0,W.useCallback)(()=>{he(null),_e(null),ye(!1)},[]),Oe=(0,W.useCallback)(e=>{M&&Ee(e,!0)},[M,Ee]),ke=(0,W.useRef)(null),Ae=(0,W.useCallback)((e,t)=>{let n=ke.current,r=n!==null&&n.results===t,i=be.current;if(!i||!t)return Promise.reject(Error(`The saved run pin is unavailable.`));let a=i.session.id;if(Te.current===a)return Promise.resolve();let o={id:i.block.id,contentId:i.session.blockContentId};if(!r&&t&&ee.current){let t=ee.current,n=LD(t.state,e,a);if(n){let e=n.from+n.insert.indexOf("```");t.dispatch({changes:n,effects:[Dr.scrollIntoView(e,{y:`start`,yMargin:96})]}),l?.(t.state.doc.toString())}}r||(ke.current={results:t,resultId:a,runBlock:o});let s;try{s=Uj(B).record({resultId:a,noteId:i.session.noteId,blockId:i.session.blockId,data:t,createdAt:t.endTime}).then(()=>v?.(e,t,a,o))}catch(e){return Promise.reject(e instanceof Error?e:Error(String(e)))}return Promise.resolve(s).then(()=>{ke.current?.results===t&&(ke.current=null),Te.current=a},()=>{}),s},[l,v,B]),je=(0,W.useMemo)(()=>{if(j)return[];if(A&&A.length>0)return A;let e=[];return M?e.push({id:`run`,label:`Run`,icon:(0,G.jsx)(pr,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:Ee}):_&&e.push({id:`run`,label:`Run`,icon:(0,G.jsx)(pr,{className:`h-3 w-3 fill-current`}),primary:!0,onClick:_}),e.push({id:`playground`,label:`Playground`,icon:(0,G.jsx)(tt,{className:`h-3 w-3`}),splitIcon:(0,G.jsx)(Gn,{className:`h-3 w-3`}),splitSuccessIcon:(0,G.jsx)(Bt,{className:`h-3 w-3`}),onClick:e=>{MQ(e.content).then(e=>{let t=window.open(e,`wodwiki-playground`);t&&t.focus()})},onSplitClick:async e=>{let t=await NQ(e.content);await navigator.clipboard.writeText(t)}}),b&&e.push({id:`plan`,label:`Plan`,icon:(0,G.jsx)(er,{className:`h-3 w-3`}),onClick:b}),e},[A,_,b,M,j,Ee]),Me=(0,W.useMemo)(()=>fi({codeLanguages:CO}),[]),Ne=(0,W.useMemo)(()=>{let e=Math.max(1,n),r=P?[...P.keys()]:Ea;if(t&&Object.keys(t).length>0)try{return Pa(c,t,e,{registeredWidgets:r}),t}catch{return Na(c,{sourceRevision:e,blocks:t,registeredWidgets:r})}return Na(c,{sourceRevision:e,registeredWidgets:r})},[c,t,n,P]),Pe=(0,W.useMemo)(()=>[...T?[Xr(),Br()]:[],Hr(),ui(),Ar(),di(),...w?[Dr.lineWrapping]:[],ei.allowMultipleSelections.of(!0),Or(),Si(),Vr(),gi(),li.highest(br.of([{key:`Tab`,run:e=>Lr(e.state)!==null&&(Ci(e),!0)},{key:`Enter`,run:e=>{let t=e.state.selection.main,n=RQ(e.state,t.head),r=e.state.doc.lineAt(t.head);return!t.empty||n?.value.trim()!==``||r.text.slice(t.head-r.from).trim()?!1:(Sr(e),see(e))}}])),br.of([...aee,...Zr,...oi,...ai,...xi,...ci,Qr,{key:`Mod-s`,run:()=>(o?.(),!0)},{key:`Ctrl-.`,run:e=>{let t=mY(e.state);if(!t?.focusedMetric)return!1;let n=t.focusedMetric.type;return!new Set([`duration`,`rep`,`rounds`,`distance`,`resistance`]).has(n)&&(at(()=>Promise.resolve().then(()=>xU).then(()=>{at(async()=>{let{runStatementBuilderFlow:e}=await import(`./statementBuilderFlow-CdnAYXCq.js`);return{runStatementBuilderFlow:e}},__vite__mapDeps([3,1,0,2])).then(({runStatementBuilderFlow:n})=>{n(t,e)}).catch(()=>{SU.getState().open({placeholder:`Modify metric…`,sources:[]})})}),void 0),!0)}}]),UD,ST,dT.of({blocks:Ne,sourceRevision:Math.max(1,n),rawContent:c}),fT.of(P?[...P.keys()]:Ea),CT,lE.of(D),...E||!D?[YE]:[],...E?[$T,nE,LJ(),KJ(),fD,oD(),CD]:[],...O?[OT]:[],KT,Hw,PT,NT,FT.of(FQ),IT.of(IQ),...k?[WD]:[],JT,uT,_Y,...kD,oT,...P&&P.size>0?[SO(P)]:[],QD({executor:jB,onResultSaved:Vj,readOnly:m,noteHref:e=>TL(`blockContentId`in e||`dataType`in e?mL(e):cL(e))}),aY(e,B),Dr.domEventHandlers({blur:()=>(f?.(),!1)}),Dr.updateListener.of(e=>{if(e.docChanged){let t=e.state.field(ST);r?.({rawContent:t.rawContent,blocks:t.noteBlocks,sourceRevision:t.sourceRevision}),l(t.rawContent),u?.(e),BQ(e.state,y,ne),e.transactions.some(e=>e.isUserEvent(`input`)||e.isUserEvent(`delete`)||e.isUserEvent(`paste`)||e.isUserEvent(`drop`))||s?.()}if(e.selectionSet||e.docChanged){ue(e=>e+1),e.transactions.some(e=>e.isUserEvent(`delete.backward`))&&Lr(e.startState)!==null&&Lr(e.state)===null&&RQ(e.state,e.state.selection.main.head)?.value===``&&queueMicrotask(()=>{e.view.state===e.state&&ti(e.view)});let{head:t}=e.state.selection.main,n=e.state.doc.lineAt(t);d?.(n.number,t-n.from+1);let r=TT(e.state);ae(r?.id??null),V(n.number);let{sections:i}=e.state.field(ST);se(i)}}),ei.readOnly.of(m),Dr.editable.of(!m),...R?[_i(R)]:[],Dr.contentAttributes.of({"aria-label":g})],[l,d,f,u,y,r,m,o,s,T,w,E,D,O,k,e,B,P,R,g]);return(0,W.useEffect)(()=>{let e=z.current;if(!e)return;let t;try{t=ei.create({doc:c,extensions:[...Pe,OQ.of(aT(re)),kQ.of(Me),AQ.of([]),...N??[]]})}catch(e){console.error(`NoteEditor: Failed to initialize EditorState, recovering with safe fallback`,e),t=ei.create({doc:c,extensions:[OQ.of(aT(re)),kQ.of(Me)]})}let n=new Dr({state:t,parent:e}),i=window.visualViewport,a=0,o=()=>{cancelAnimationFrame(a),a=requestAnimationFrame(()=>{n.hasFocus&&i?.scale===1&&i.height<window.innerHeight&&n.dispatch({effects:Dr.scrollIntoView(n.state.selection.main.head,{y:`nearest`,yMargin:24})})})};i?.addEventListener(`resize`,o),n.contentDOM.addEventListener(`focus`,o),ee.current=n,me(n),e.__codemirrorView=n,S?.(n);let{sections:s}=n.state.field(ST);se(s);let l=n.state.doc.lineAt(n.state.selection.main.head).number;V(l);let u=TT(n.state);ae(u?.id??null);let d=n.state.field(ST);return r?.({rawContent:d.rawContent,blocks:d.noteBlocks,sourceRevision:d.sourceRevision}),BQ(n.state,y,ne),()=>{cancelAnimationFrame(a),i?.removeEventListener(`resize`,o),n.contentDOM.removeEventListener(`focus`,o),delete e.__codemirrorView,me(null),n.destroy()}},[]),(0,W.useEffect)(()=>{let e=ee.current;if(!e)return;let r=e.state.field(ST);if(c!==r.rawContent){let r=Math.max(1,n),i=t?Na(c,{sourceRevision:r,blocks:t,registeredWidgets:P?[...P.keys()]:Ea}):void 0,a=i&&t&&Object.keys(i).length===Object.keys(t).length&&Object.entries(t).every(([e,t])=>{let n=i[e];return n&&n.from===t.from&&n.to===t.to&&n.kind===t.kind&&n.dialect===t.dialect&&n.sport===t.sport});e.dispatch({changes:{from:0,to:e.state.doc.length,insert:c},...a?{effects:hT.of({rawContent:c,blocks:t,sourceRevision:r})}:{}})}else t&&n!==r.sourceRevision&&e.dispatch({effects:mT.of({blocks:t,sourceRevision:Math.max(1,n)})})},[c,t,n]),(0,W.useEffect)(()=>{ee.current&&ee.current.dispatch({effects:OQ.reconfigure(aT(re))})},[re]),(0,W.useEffect)(()=>{if(ee.current){let e=[];ee.current.dispatch({effects:[Jr.reconfigure.of([...Pe,OQ.of(aT(re)),kQ.of(Me),AQ.of(e),...N??[]])]})}},[Pe,N,C,re,Me]),(0,W.useEffect)(()=>{m||ee.current?.focus()},[m]),(0,W.useEffect)(()=>{if(I&&ee.current){let e=ee.current,t=e.state.doc.toString().split(`
173
173
  `),n=-1,r=I.match(/-line-(\d+)$/);if(n=r?parseInt(r[1],10)-1:t.findIndex(e=>{let t=e.match(/^(#{1,6})\s+(.*)$/);if(t){let e=t[2].trim(),n=e.match(/(\d{1,2}:\d{2})/);if(n){let t=n[1];e=e.replace(t,``).replace(/\s+/g,` `).trim(),e||=t}return e.toLowerCase().replace(/[^\w]+/g,`-`)===I}return!1}),n>=0&&n<t.length){let t=e.state.doc.line(n+1).from;e.dispatch({selection:{anchor:t,head:t},effects:[Dr.scrollIntoView(t,{y:`start`,yMargin:20})]})}}},[I]),(0,G.jsxs)(`div`,{ref:z,className:`cm-note-editor relative w-full min-w-0 ${h}`,children:[k&&(0,G.jsx)(bY,{view:pe??ee.current,widths:fe.widths,activeSectionId:de,renderSlot:t=>{if(!D&&t.sectionType===`frontmatter`)return null;if(t.sectionType===`time`||t.sectionType===`log`)return(0,G.jsx)(YY,{noteId:e,sectionId:t.sectionId,view:t.view,isActive:t.isActive,widthPercent:t.widthPercent,cursorLine:ce,docVersion:t.docVersion,commands:je,extendedResults:L,hoverLine:t.hoverLine,stickyTopOffset:t.stickyTopOffset,isPanelHovered:t.isPanelHovered,lineDocY:t.lineDocY,rect:t.rect});if(t.sectionType===`frontmatter`||t.sectionType===`embed`){let{sections:e}=t.view.state.field(ST),n=e.find(e=>e.id===t.sectionId);return(0,G.jsx)(kY,{sectionId:t.sectionId,section:n,view:t.view,isActive:t.isActive,widthPercent:t.widthPercent,docVersion:t.docVersion})}return t.sectionType===`widget`&&t.widgetName?(0,G.jsx)(XY,{sectionId:t.sectionId,widgetName:t.widgetName,view:t.view,registry:P??new Map,docVersion:t.docVersion}):(0,G.jsx)(`div`,{className:`h-full w-full bg-popover/80 backdrop-blur-sm border-l border-border rounded-l-md p-2 text-xs text-muted-foreground`,children:(0,G.jsx)(`div`,{className:`font-medium text-foreground`,children:t.sectionType})})},cursorLine:ce}),Ce&&(0,G.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[`Workout not started. `,Ce,` Your draft is kept.`]}),!k&&je.length>0&&(0,G.jsx)(bQ,{view:pe??ee.current,commands:je}),(0,G.jsx)(DQ,{view:pe??ee.current,cursorVersion:le}),H&&ee.current&&(0,G.jsx)(pQ,{block:H,view:pe??ee.current,onClose:De,onCompleteWorkout:Ae,resultId:ge??void 0,autoStart:ve}),(0,G.jsx)(xQ,{sections:oe,isRuntimeActive:H!==null,editorState:(pe??ee.current)?.state??null,onSelectBlock:Oe})]})},FQ=async e=>{if(!LQ(e.state,e.pos))return null;let t=e.state.doc.lineAt(e.pos),n=t.text.slice(0,e.pos-t.from).match(/^([a-zA-Z][\w.-]*)$/),r=RQ(e.state,e.pos);if(!n&&!r)return null;let[i,a]=await Promise.all([Z.getAllTagTypes().catch(()=>[]),Z.getAllTags().catch(()=>[])]);if(n)return{from:t.from,options:i.map(e=>({label:e.name,detail:`Tag Type (${e.label})`,type:`property`,apply:`${e.name}:\n - `})),validFor:(e,t,n,r)=>/^[a-zA-Z][\w.-]*$/.test(e)&&LQ(r,n)};if(!r)return null;let{propertyKey:o,from:s}=r,c={"metrics.effort":`effort`,"metrics.equipment":`equipment`,equipment:`equipment`}[o.toLowerCase()];if(c){let e=await qJ();return{from:s,options:(c===`effort`?e.efforts:e.equipment).map(e=>({label:`${e.label} (${e.slug})`,detail:c===`effort`?`Effort`:`Equipment`,type:`constant`,apply:e.slug})),validFor:(e,t,n,r)=>{let i=RQ(r,n);return/^[\w-]*$/.test(e)&&i?.propertyKey===o&&i.from===t}}}let l=i.find(e=>e.name.toLowerCase()===o.toLowerCase());if(!l)return null;let u=a.filter(e=>e.type?.toLowerCase()===l.name.toLowerCase());return u.length===0?null:{from:s,options:u.map(e=>({label:e.label,detail:l.label,type:`constant`})),validFor:(e,t,n,r)=>{let i=RQ(r,n);return/^[\w-]*$/.test(e)&&i?.propertyKey===o&&i.from===t}}},IQ={wql:{values:async e=>(await hw(e===`tags`?`tag`:e)).map(e=>({label:e.value,detail:e.label,type:`constant`}))},whiteboardScript:{efforts:async()=>(await qJ()).efforts.map(e=>({value:e.slug,label:e.label,detail:e.slug})),equipment:async()=>(await qJ()).equipment.map(e=>({value:e.slug,label:e.label,detail:e.slug})),tags:async()=>Aj().list().map(e=>({value:e.slug})),sounds:()=>Zj().map(e=>({value:e.id,label:e.name}))}};function LQ(e,t){let n=e.doc.lineAt(t);if(n.number===1||e.doc.line(1).text.trim()!==`---`)return!1;for(let t=2;t<=n.number;t++)if(/^(---|\.\.\.)\s*$/.test(e.doc.line(t).text))return!1;return!0}function RQ(e,t){if(!LQ(e,t))return null;let n=e.doc.lineAt(t),r=n.text.slice(0,t-n.from),i=r.match(/^([a-zA-Z][\w.-]*)\s*:\s*(.*)$/);if(i)return{propertyKey:i[1],from:t-i[2].length,value:i[2]};let a=r.match(/^\s*-\s*(.*)$/);if(!a)return null;for(let r=n.number-1;r>1;r--){let n=e.doc.line(r).text.match(/^([a-zA-Z][\w.-]*)\s*:/);if(n)return{propertyKey:n[1],from:t-a[1].length,value:a[1]}}return null}function zQ(e,t){if(e.type!==`time`&&e.type!==`log`)return null;let n=e.contentFrom!==void 0&&e.contentTo!==void 0?t.doc.sliceString(e.contentFrom,e.contentTo):``,r=[];try{n.trim()&&(r=vc({tags:Aj()}).read(n,e.sport).statements??[])}catch{}return{id:e.id,contentId:e.contentId,dialect:e.type,sport:e.sport,startLine:e.startLine-1,endLine:e.endLine-1,content:n,statements:r,state:`idle`,version:t.field(ST).noteBlocks[e.id]?.version??1,createdAt:Date.now(),widgetIds:{}}}function BQ(e,t,n){if(!t)return;let r=e.field(ST).sections.filter(e=>e.type===`time`||e.type===`log`).map(t=>zQ(t,e)).filter(e=>e!==null),i=JSON.stringify(r.map(e=>({id:e.id,startLine:e.startLine,endLine:e.endLine,content:e.content})));i!==n.current&&(n.current=i,t(r))}function VQ({title:e,subtitle:t,doc:n,onDocChange:r,noteId:i,onBlocksChange:a,theme:o,readonly:s=!1,showLineNumbers:c=!1,enableOverlay:l=!1,enableInlineRuntime:u=!1,enablePreview:d=!0,showFrontmatter:f=!1,enableLinting:p=!0,commands:m,hideDefaultCommands:h,onViewCreated:g,onReset:_,run:v,headerActions:y,subheader:b,children:x,className:S,editorClassName:C,bodyRef:w}){let T=(0,W.useRef)([]),E=(0,W.useCallback)(e=>{T.current=e,a?.(e)},[a]),D=(0,W.useCallback)(()=>{v?.onRun(n,T.current[0]??null)},[v,n]),O=(0,G.jsxs)(G.Fragment,{children:[y,v&&(0,G.jsxs)(`button`,{ref:v.ref,type:`button`,title:v.title??`Run the workout`,onClick:D,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-2.5 py-1 text-[11px] font-medium text-primary-foreground transition-colors hover:bg-primary/90`,children:[(0,G.jsx)(pr,{size:11,fill:`currentColor`}),v.label??`Run`]})]});return(0,G.jsx)(IJ,{title:e,subtitle:t,onReset:_,headerActions:O,className:S,children:(0,G.jsxs)(`div`,{className:`flex h-full flex-col min-h-0`,children:[b,(0,G.jsxs)(`div`,{ref:w,className:K(`relative flex-1 min-h-0`,C),children:[(0,G.jsx)(PQ,{noteId:i,value:n,onChange:r,onBlocksChange:E,theme:o,readonly:s,showLineNumbers:c,enableOverlay:l,enableInlineRuntime:u,enablePreview:d,showFrontmatter:f,enableLinting:p,commands:m,hideDefaultCommands:h,onViewCreated:g,className:`h-full`}),x]})]})})}function HQ({editorSource:e,editorOpacity:t,activeOriginalSource:n,handleEditorChange:r,onResetToSource:i,canvasNoteId:a,theme:o,commands:s,onBlocksChange:c,onViewCreated:l,panelTitle:u,panelSubtitle:d,panelThemeClass:f,headerActions:p,onRun:m,readonly:h=!1,showFrontmatter:g}){return(0,G.jsx)(`div`,{className:`h-full`,style:{opacity:t,transition:`opacity 180ms ease`},children:(0,G.jsx)(VQ,{title:u,subtitle:d,doc:e,onDocChange:r,noteId:a,onBlocksChange:c,onViewCreated:l,theme:o,readonly:h,showLineNumbers:!1,showFrontmatter:g,enableOverlay:!1,enableInlineRuntime:!1,commands:s,hideDefaultCommands:!1,headerActions:p,className:f,subheader:(0,G.jsxs)(`div`,{style:{opacity:t,transition:`opacity 180ms ease`},className:`flex items-center justify-between gap-3 border-b border-border/40 bg-primary/5 px-4 py-2 text-[11px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[(0,G.jsx)(`span`,{children:`Try editing this example ↓`}),e===n?null:(0,G.jsx)(`button`,{type:`button`,onClick:()=>{i()},className:`rounded-full border border-primary/30 px-3 py-1 text-[10px] font-black text-primary transition-colors hover:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:`Reset to example`})]}),run:m?{onRun:m}:void 0})})}function UQ(e,t){return e>=t?`split`:`stack`}function WQ(e,t){let n=(0,W.useCallback)(()=>{if(typeof window>`u`)return{width:0,height:0,mode:`stack`};let t=window.innerWidth,n=Math.max(0,window.innerHeight-e);return{width:t,height:n,mode:UQ(t,n)}},[e]),[r,i]=(0,W.useState)(n);return(0,W.useEffect)(()=>{if(t&&typeof ResizeObserver<`u`){let e=new ResizeObserver(([e])=>{let{width:t,height:n}=e.contentRect;i(e=>e.width===t&&e.height===n?e:{width:t,height:n,mode:UQ(t,n)})});return e.observe(t),()=>e.disconnect()}let e=()=>i(e=>{let t=n();return e.width===t.width&&e.height===t.height?e:t});return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[t,n]),r}var GQ=e=>Math.max(0,Math.min(1,e)),KQ=(e,t,n)=>e+(t-e)*n,qQ=e=>1-(1-e)**2;function JQ(e,t){return e===``||t===e}var YQ={id:``,range:[0,1]};function XQ(e,t){if(!t||t.length===0)return{index:-1,stage:YQ,t:0,ring:null};let n=GQ(e),r=t.map(e=>({...e,start:GQ(Math.min(e.range[0],e.range[1])),end:GQ(Math.max(e.range[0],e.range[1]))})),i=r.findIndex(e=>n>=e.start&&n<e.end);i===-1&&(i=n>=1?r.length-1:0);let a=r[i]??YQ,o=(a.end??1)-(a.start??0),s=o>0?GQ((n-(a.start??0))/o):0,c=a.ring?{tag:a.ring===!0?void 0:a.ring.tag,key:a.ring===!0?void 0:a.ring.key,lines:a.ring===!0?void 0:a.ring.lines}:null;return{index:i,stage:a,t:s,ring:c}}function ZQ(e,t,n){let r=t-n;return{progress:r>0?GQ(-e/r):0,reached:e<=0,inView:e<n&&e+t>0}}function QQ(e,t){let n=t/2;for(let t of e)if(t.top<=n&&t.bottom>n)return t.id;return null}var $Q=(0,W.createContext)(null);function e$(){return(0,W.useContext)($Q)}function t$({children:e}){let t=(0,W.useRef)(new Map),n=(0,W.useRef)(new Map),r=(0,W.useRef)(null),i=(0,W.useRef)(0),[a,o]=(0,W.useState)(null),s=(0,W.useRef)(null),c=(0,W.useCallback)(e=>{r.current?.gateId===e&&(r.current=null,o(null))},[]),l=(0,W.useCallback)((e,t)=>{r.current={gateId:e,segmentId:t},o(e)},[]),u=(0,W.useCallback)(()=>{i.current&&cancelAnimationFrame(i.current),i.current=0;let e=window.innerHeight,a=new Map,c=(e,t)=>{let n=t();n&&a.set(e,n.getBoundingClientRect())};t.current.forEach((e,t)=>c(t,e)),n.current.forEach((e,t)=>c(t,e.getEl));let l=[];a.forEach((e,t)=>l.push({id:t,top:e.top,bottom:e.top+e.height}));let u=QQ(l,e);if(u!==s.current){s.current=u;let e=r.current;e&&e.segmentId!==u&&(r.current=null,o(null))}n.current.forEach((t,n)=>{let r=a.get(n);if(!r||r.height-e<=0)return;let i=ZQ(r.top,r.height,e);t.onMeasure({slice:XQ(i.progress,t.getStages()),progress:i.progress,reached:i.reached})})},[]),d=(0,W.useCallback)(()=>{i.current||=requestAnimationFrame(u)},[u]);(0,W.useEffect)(()=>(window.addEventListener(`scroll`,d,{passive:!0,capture:!0}),window.addEventListener(`resize`,d),u(),()=>{window.removeEventListener(`scroll`,d,{capture:!0}),window.removeEventListener(`resize`,d),i.current&&cancelAnimationFrame(i.current)}),[d,u]);let f=(0,W.useCallback)((e,n)=>(t.current.set(e,n),d(),()=>{t.current.delete(e)}),[d]),p=(0,W.useCallback)((e,t)=>(n.current.set(e,t),d(),()=>{n.current.delete(e)}),[d]),m=(0,W.useCallback)(()=>u(),[u]),h=(0,W.useMemo)(()=>({registerAnchor:f,registerDriver:p,resync:m,capturedGateId:a,captureGate:l,releaseGate:c}),[f,p,m,a,l,c]);return(0,G.jsx)($Q.Provider,{value:h,children:e})}function n$(e,t){let n=e$()?.registerAnchor;(0,W.useEffect)(()=>{if(n)return n(e,()=>t.current)},[n,e,t])}function r$({gateId:e,segmentId:t,className:n,children:r}){let i=e$(),a=(0,W.useRef)(null),[o,s]=(0,W.useState)(!1);if((0,W.useEffect)(()=>{let e=a.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>{let t=e.querySelectorAll(`.cm-scroller, [data-scroll-pane], .overflow-auto, .overflow-y-auto`);s(e.scrollHeight>e.clientHeight+1||[...t].some(e=>e.scrollHeight>e.clientHeight+1))},n=new ResizeObserver(t);n.observe(e);let r=0,i=new MutationObserver(()=>{t(),window.clearTimeout(r),r=window.setTimeout(t,400)});i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`]}),window.addEventListener(`resize`,t);let o=window.setTimeout(t,1200);return t(),()=>{window.clearTimeout(r),window.clearTimeout(o),n.disconnect(),i.disconnect(),window.removeEventListener(`resize`,t)}},[]),!i)return(0,G.jsx)(`div`,{className:n,children:r});let c=i.capturedGateId===e?`captured`:`yield`;return(0,G.jsxs)(`div`,{"data-scroll-gate":c,"data-gate-id":e,className:`${n??``} flex flex-col`,onFocus:n=>{let r=n.target;r instanceof HTMLElement&&r.closest(`input:not([readonly]):not([disabled]), textarea:not([readonly]):not([disabled]), select:not([disabled]), [contenteditable="true"]`)&&i.captureGate(e,t??null)},onBlur:t=>{(!(t.relatedTarget instanceof Node)||!t.currentTarget.contains(t.relatedTarget))&&i.releaseGate(e)},children:[(0,G.jsx)(`div`,{ref:a,className:`relative min-h-0 flex-1`,children:r}),(o||c===`captured`)&&(0,G.jsx)(`button`,{type:`button`,className:`min-h-11 self-start rounded px-3 py-2 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-primary`,"aria-label":`${c===`captured`?`Scroll page`:`Scroll panel`}: ${e.replace(/-/g,` `)} content`,"aria-pressed":c===`captured`,onClick:()=>c===`captured`?i.releaseGate(e):i.captureGate(e,t??null),onKeyDown:t=>{t.key===`Escape`&&i.releaseGate(e)},children:c===`captured`?`Scroll page`:`Scroll panel`})]})}function i$({trackRef:e,height:t,stages:n,activeIndex:r,pane:i,captions:a,status:o,segmentId:s,testId:c,className:l}){let[u,d]=(0,W.useState)(null),f=WQ(104,u).mode===`split`,p={status:o,pips:(0,G.jsx)(`div`,{className:`flex items-center gap-1.5`,"aria-hidden":`true`,children:n.map((e,t)=>{let n=r===t;return(0,G.jsx)(`span`,{className:`h-1 rounded-full transition-all duration-300`,style:{width:n?30:10,background:n?e.accent??`hsl(var(--primary))`:r>t?`hsl(var(--foreground))`:`hsl(var(--foreground) / 0.15)`}},e.id)})})};return(0,G.jsx)(`section`,{ref:e,"data-testid":c,className:l?`relative ${l}`:`relative`,style:{height:t},children:(0,G.jsx)(PJ.Provider,{value:p,children:(0,G.jsx)(`div`,{className:`sticky top-[65px] flex h-[calc(100dvh-65px)] flex-col overflow-hidden lg:top-[104px] lg:h-[calc(100dvh-104px)]`,children:(0,G.jsxs)(`div`,{ref:d,className:`mx-auto flex min-h-0 w-full max-w-[1500px] 2xl:max-w-[1720px] flex-1 px-5 pt-2 pb-5 lg:px-10 lg:pt-3 xl:px-16 xl:pb-8 2xl:pb-10 ${f?`flex-row items-stretch gap-[clamp(20px,2.5vw,56px)] xl:gap-12 2xl:gap-16`:`flex-col gap-6 xl:gap-8`}`,children:[(0,G.jsx)(`div`,{className:`relative min-h-0 min-w-0 flex-[3_1_0%]`,children:i}),(0,G.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-[2_1_0%] flex-col`,children:s?(0,G.jsx)(r$,{gateId:`${s}-captions`,segmentId:s,className:`relative min-h-0 flex-1`,children:a}):(0,G.jsx)(`div`,{className:`relative min-h-0 flex-1`,children:a})})]})})})})}function a$(e){let t=e.parentElement;for(;t;){let e=window.getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`)return t;t=t.parentElement}return window}function o$(e,t,n=`smooth`){let r=a$(e),i=e.offsetHeight-window.innerHeight;if(i<=0)return;if(r instanceof HTMLElement){let a=e.offsetTop;r.scrollTo({top:a+t*i,behavior:n});return}let a=e.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:a+t*i,behavior:n})}function s$(e,t,n,r){let[i,a]=(0,W.useState)(()=>XQ(0,n)),[o,s]=(0,W.useState)(!1),c=(0,W.useRef)(0),l=(0,W.useRef)(i),u=(0,W.useRef)(new Set),d=(0,W.useRef)(0),f=(0,W.useRef)(t);f.current=t;let p=e$(),m=p?.registerDriver,h=(0,W.useRef)(p);h.current=p;let g=(0,W.useId)(),_=r??g,v=(0,W.useRef)(n);v.current=n;let y=(0,W.useCallback)((e,t)=>{let n=l.current;l.current=e,c.current=t,(n.index!==e.index||n.ring?.key!==e.ring?.key)&&a(e),u.current.forEach(n=>n(e,t))},[]),b=(0,W.useCallback)(()=>{if(d.current=0,f.current)return;let t=e.current;if(!t)return;let n=t.getBoundingClientRect(),r=n.height-window.innerHeight;if(r<=0)return;let i=Math.max(0,Math.min(1,-n.top/r));s(n.top<=0),y(XQ(i,v.current),i)},[e,y]),x=(0,W.useCallback)(()=>{if(h.current){h.current.resync();return}b()},[b]),S=(0,W.useCallback)(()=>{d.current||=requestAnimationFrame(x)},[x]);(0,W.useEffect)(()=>{if(m)return m(_,{getEl:()=>e.current,getStages:()=>v.current,onMeasure:({slice:e,progress:t,reached:n})=>{f.current||(s(n),y(e,t))}})},[m,_,e,y]),(0,W.useEffect)(()=>{if(!m)return window.addEventListener(`scroll`,S,{passive:!0,capture:!0}),window.addEventListener(`resize`,S),b(),()=>{window.removeEventListener(`scroll`,S,{capture:!0}),window.removeEventListener(`resize`,S),d.current&&cancelAnimationFrame(d.current)}},[m,S,b]);let C=(0,W.useCallback)(e=>(u.current.add(e),e(l.current,c.current),()=>{u.current.delete(e)}),[]),w=(0,W.useCallback)(()=>{x()},[x]);return{slice:i,progress:c.current,runwayReached:o,subscribe:C,resync:w}}var c$={reference:!0},l$={start:[[`fences`,`first-workout`],[`measurements`,`actions-comments`],[`system`,`try-it`]],protocols:[[`countdown-countup`,`required-rest`],[`amrap`,`emom`],[`tabata-intervals`,`caps`,`distance-intervals`,`try-it`]],structure:[[`rounds`,`rep-schemes`,`sets`],[`nesting`,`rep-math`,`named-sections`,`try-it`]],metrics:[[`planned-vs-recorded`,`custom-metrics`],[`capture`,`session-rpe`],[`calculated`,`try-it`]],clock:[[`run-next`,`pause-skip`],[`capture-prompts`,`casting`,`provenance`,`try-it`]],wql:[[`planes`,`aggregate`,`filters`,`sources`],[`windows`,`grouping-rollup`,`joins`],[`content`,`pipes`,`try-it`]],dashboards:[[`note-frontmatter`,`avg-tis`,`weekly-tonnage`,`widgets`],[`composer`,`cookbook`,`seeded-boards`,`try-it`]],sessions:[[`intent`,`full-session`],[`nested`,`partner`,`swimming`],[`barbell-cycling`,`climbing`,`try-it`]],"metrics-summaries":[[`frontmatter-metrics`,`tag-summaries`,`stacking-overrides`],[`querying-summaries`,`dependency-diagnostics`,`try-it`]]};function u$(e,t){let n=e.filter(e=>!c$[e.id]),r=e.filter(e=>c$[e.id]);if(n.length===0)return{groups:[],tail:r};let i=t?l$[t]:void 0;if(i){let e=new Map(n.map(e=>[e.id,e])),t=new Set,a=[];for(let n of i){let r=n.map(t=>e.get(t)).filter(e=>!!e&&!t.has(e.id));for(let e of r)t.add(e.id);r.length>0&&a.push(r)}let o=n.filter(e=>!t.has(e.id));if(o.length>0){let e=a[a.length-1];if(e&&e.length+o.length<=4)e.push(...o);else for(let e=0;e<o.length;e+=4)a.push(o.slice(e,e+4))}if(a.length>0)return{groups:a,tail:r}}let a=Math.max(1,Math.ceil(n.length/4)),o=Math.floor(n.length/a),s=n.length%a,c=[],l=0;for(let e=0;e<a;e++){let t=o+ +(e<s);c.push(n.slice(l,l+t)),l+=t}return{groups:c,tail:r}}function d$(e){let t=Math.max(1,e.length);return e.map((e,n)=>({id:e.id,range:[n/t,(n+1)/t]}))}var f$=[{src:`/images/hero/editing.png`,alt:`WhiteboardScript editor with live syntax highlighting and inline previews`,eyebrow:`Write`,title:`Type your workout in plain Markdown.`,caption:"Movements, reps, time caps, and rounds — fenced in a familiar ```time block. No drag-and-drop. No proprietary DSL."},{src:`/images/hero/timer.png`,alt:`Live runtime timer HUD counting down an interval with active round and rest indicators`,eyebrow:`Run`,title:`Press Run. The compiler takes over.`,caption:`Your Markdown becomes a live wallclock. The JIT engine dispatches rounds, counts reps, and tracks rest — all offline.`},{src:`/images/hero/journal.png`,alt:`Unified Library listing journal notes, notebook workouts, and dated entries`,eyebrow:`Library`,title:`Browse Journal and Notebook notes in one Library.`,caption:`Your dated journal notes and preloaded notebook benchmarks live in one unified surface. Search, filter by source, or clone to today’s note.`},{src:`/images/hero/results.png`,alt:`WQL Metric Explorer displaying volume trends and embedded dashboard blocks`,eyebrow:`Query`,title:`Ask questions with Wod Query Language (WQL).`,caption:`Aggregate volume, track TIS intensity trends, or embed live query and dashboard blocks directly in your Markdown notes.`}];function p$({slides:e=f$,className:t}){let n=(0,W.useRef)(null),[r,i]=(0,W.useState)(0);(0,W.useEffect)(()=>{let t=n.current;if(!t)return;let r=()=>{let n=t.clientWidth,r=Math.round(t.scrollLeft/n);i(Math.min(Math.max(r,0),e.length-1))};return t.addEventListener(`scroll`,r,{passive:!0}),()=>t.removeEventListener(`scroll`,r)},[e.length]);let a=e=>{let t=n.current;t&&t.scrollTo({left:e*t.clientWidth,behavior:`smooth`})};return(0,G.jsxs)(`div`,{className:K(`relative w-full`,t),children:[(0,G.jsx)(`div`,{ref:n,className:`flex w-full snap-x snap-mandatory overflow-x-auto scroll-smooth scrollbar-none`,style:{scrollbarWidth:`none`},children:e.map((t,n)=>(0,G.jsxs)(`article`,{className:`relative flex w-full shrink-0 snap-start flex-col gap-4 sm:flex-row sm:items-center sm:gap-8`,"aria-label":`Slide ${n+1} of ${e.length}: ${t.title}`,children:[(0,G.jsx)(`div`,{className:`relative aspect-[16/10] w-full overflow-hidden rounded-2xl border border-border/60 bg-muted shadow-sm sm:w-1/2`,children:(0,G.jsx)(`img`,{src:t.src,alt:t.alt,loading:n===0?`eager`:`lazy`,className:`h-full w-full object-cover`})}),(0,G.jsxs)(`div`,{className:`flex w-full flex-col gap-2 sm:w-1/2 sm:gap-3`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-black uppercase tracking-[0.24em] text-primary/80`,children:t.eyebrow}),(0,G.jsx)(`h3`,{className:`text-2xl font-black tracking-[-0.04em] text-foreground sm:text-3xl`,children:t.title}),(0,G.jsx)(`p`,{className:`text-sm leading-7 text-muted-foreground sm:text-base`,children:t.caption}),(0,G.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-2 text-[10px] font-black uppercase tracking-[0.2em] text-muted-foreground`,children:[(0,G.jsxs)(`span`,{className:`text-primary`,children:[`Step `,n+1]}),(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`/`}),(0,G.jsx)(`span`,{children:e.length})]})]})]},t.src))}),(0,G.jsx)(`div`,{className:`mt-4 flex items-center justify-center gap-2`,children:e.map((e,t)=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(t),"aria-label":`Go to slide ${t+1}: ${e.title}`,"aria-current":t===r?`true`:`false`,className:K(`h-2 rounded-full transition-all`,t===r?`w-8 bg-primary`:`w-2 bg-border hover:bg-muted-foreground/40`)},e.src))})]})}var m$=`wodwiki:text-filter-navigation`,h$=({paramName:e=`q`,placeholder:t=`Search…`,autoFocus:n=!1,className:r,navigationScope:i,inputTestId:a})=>{let[o,s]=un(e,{defaultValue:``}),c=i??e,l=(0,W.useRef)(null);return(0,W.useEffect)(()=>{let e=e=>{e.key===`/`&&document.activeElement?.tagName!==`INPUT`&&document.activeElement?.tagName!==`TEXTAREA`&&(e.preventDefault(),l.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,G.jsxs)(`div`,{className:K(`flex items-center gap-3 px-6 lg:px-10 pb-3`,r),children:[(0,G.jsx)(ge,{className:`size-5 text-muted-foreground shrink-0`}),(0,G.jsx)(`input`,{ref:l,type:`text`,"data-testid":a,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{if(e.altKey||e.ctrlKey||e.metaKey||![`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Enter`].includes(e.key))return;let t=new CustomEvent(m$,{detail:{key:e.key,scopeId:c},cancelable:!0});window.dispatchEvent(t),t.defaultPrevented&&e.preventDefault()},placeholder:t,autoFocus:n,autoComplete:`off`,spellCheck:!1,className:`flex-1 bg-transparent border-none outline-none text-foreground placeholder:text-muted-foreground text-sm sm:text-base font-medium`}),o&&(0,G.jsx)(`button`,{onClick:()=>s(``),"aria-label":`Clear`,className:`text-muted-foreground hover:text-foreground transition-colors text-lg leading-none`,children:`×`})]})};function g$(e){let t=[],n=!1;for(let r of e){if(r.trim()===`---`){n=!n;continue}n||t.push(r)}return t}function _$(e){let t=e;return t=t.replace(/\*\*([^*]+)\*\*/g,`$1`),t=t.replace(/__([^_]+)__/g,`$1`),t=t.replace(/`([^`]+)`/g,`$1`),t=t.replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`),t=t.replace(/\*\*/g,``),t=t.replace(/__/g,``),t=t.replace(/`/g,``),t.trim()}function v$(e){return new Date(e).toISOString().slice(0,10)}function y$(e,t){let n=t.trim().toLowerCase();return!n||e.name.toLowerCase().includes(n)||e.content.toLowerCase().includes(n)||e.date!==void 0&&v$(e.date).includes(n)}function b$(e){if(!e)return null;let t=g$(eo(e).split(`
174
174
  `)).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`#`)&&!e.startsWith("```"))[0];return t?_$(t):null}var x$=({category:e,workoutItems:t,onSelect:n,showSearch:r=!0,variant:i=`card`,className:a,navigationScope:o=`q`,getItemActions:s})=>{let[c]=un(`q`,{defaultValue:``}),[l,u]=(0,W.useState)(0),[d,f]=(0,W.useState)(0),p=(0,W.useRef)([]),m=(0,W.useMemo)(()=>t.filter(t=>t.category===e&&t.name.toLowerCase()!==`readme`).filter(e=>y$(e,c)),[t,e,c]),h=(0,W.useMemo)(()=>m.map(e=>({item:e,preview:b$(e.content),actions:s?.(e)??[{id:`open`,label:`Open`,onSelect:n}]})),[m,s,n]);return(0,W.useEffect)(()=>{if(h.length===0){u(0),f(0);return}let e=Math.min(l,h.length-1),t=h[e]?.actions.length??1;e!==l&&u(e),d>t-1&&f(t-1)},[h,d,l]),(0,W.useEffect)(()=>{p.current=[]},[h]),(0,W.useEffect)(()=>{u(0),f(0)},[c]),(0,W.useEffect)(()=>{(p.current[l]?.[d])?.scrollIntoView({block:`nearest`,inline:`nearest`})},[d,l]),(0,W.useEffect)(()=>{let e=e=>{let t=e;if(t.detail.scopeId===o&&h.length!==0)switch(t.detail.key){case`ArrowDown`:t.preventDefault(),u(e=>Math.min(e+1,h.length-1)),f(0);break;case`ArrowUp`:t.preventDefault(),u(e=>Math.max(e-1,0)),f(0);break;case`ArrowRight`:{let e=h[l]?.actions.length??1;if(e<=1)return;t.preventDefault(),f(t=>Math.min(t+1,e-1));break}case`ArrowLeft`:if((h[l]?.actions.length??1)<=1)return;t.preventDefault(),f(e=>Math.max(e-1,0));break;case`Enter`:{let e=h[l]?.actions[d],n=h[l]?.item;if(!e||!n)return;t.preventDefault(),e.onSelect(n);break}}};return window.addEventListener(m$,e),()=>{window.removeEventListener(m$,e)}},[h,o,d,l]),(0,G.jsxs)(`div`,{className:K(`flex flex-col`,i===`card`&&`rounded-3xl border border-border bg-card overflow-hidden shadow-2xl shadow-black/5`,a),children:[r?(0,G.jsx)(`div`,{className:`border-b border-border/60 bg-background/95 backdrop-blur-md`,children:(0,G.jsx)(h$,{placeholder:`Filter collection workouts…`,className:`pt-3`,navigationScope:o})}):null,h.length===0?(0,G.jsx)(`div`,{className:`px-6 py-10 text-sm font-medium text-muted-foreground`,children:`No workouts found.`}):(0,G.jsx)(`div`,{className:`divide-y divide-border/60`,role:`listbox`,"aria-label":`Collection workouts`,children:h.map((e,t)=>{let n=t===l;return(0,G.jsx)(`div`,{role:`option`,"aria-selected":n,className:K(`flex items-stretch gap-2 px-3 py-2 transition-colors`,n?`bg-muted/50`:`hover:bg-muted/40`),children:e.actions.map((r,i)=>{let a=i===0;return(0,G.jsx)(`button`,{ref:e=>{p.current[t]||(p.current[t]=[]),p.current[t][i]=e},onClick:()=>r.onSelect(e.item),onMouseEnter:()=>{u(t),f(i)},className:K(`transition-colors text-left`,a?`flex-1 flex items-center gap-4 rounded-2xl px-3 py-2 hover:bg-background/80`:`shrink-0 self-center rounded-full border border-border px-3 py-2 text-[11px] font-black uppercase tracking-[0.18em] text-muted-foreground hover:bg-background/80 hover:text-foreground`,n&&i===d&&`bg-background text-foreground ring-2 ring-primary/40`),children:a?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`flex-shrink-0 size-10 rounded-xl bg-muted flex items-center justify-center transition-colors`,children:(0,G.jsx)(be,{className:`size-4 text-primary`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-bold text-foreground truncate uppercase tracking-tight`,children:e.item.displayName??e.item.name}),e.preview?(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground font-medium truncate mt-1`,children:e.preview}):null]}),e.item.date===void 0?null:(0,G.jsx)(`span`,{className:`shrink-0 self-center text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:Lb(new Date(e.item.date))}),(0,G.jsx)(On,{className:`size-4 text-muted-foreground shrink-0 transition-opacity`})]}):r.label},r.id)})},e.item.id)})})]})};function S$(){return(0,W.useEffect)(()=>{TB().catch(e=>console.warn(`[queryService] page source population failed`,e))},[]),(0,W.useSyncExternalStore)(OB,DB)}function C$(e,t){let n=e.find(e=>e.key===t&&!e.negate);return n&&n.values.length===1?n.values[0].value:null}function w$(e){let t=e.trim();if(!t.startsWith(`:`))return null;let n=iI(t),r=X(n);if(r.error||!_h(r))return null;let i=`?q=${encodeURIComponent(n)}`;switch(r.target){case`effort`:return`/efforts${i}`;case`session`:case`segment`:case`event`:return`/sessions${i}`;case`notebook`:{let e=C$(r.filters,`notebook`);if(e){let t=Sa(e);return`/notebook/${encodeURIComponent(t)}${i}`}return`/notebooks${i}`}case`page`:return`/pages${i}`;case`tag`:return`/tags${i}`;case`equipment`:return`/equipment${i}`;case`note`:case`block`:{let e=C$(r.filters,`notebook`);if(e){let t=Sa(e);return t===`journal`?`/journal${i}`:t===`playground`?`/playgrounds${i}`:`/notebook/${encodeURIComponent(t)}${i}`}let t=C$(r.filters,`source`);return t===`journal`?`/journal${i}`:t===`playground`?`/playgrounds${i}`:t===`feeds`||t===`notebooks`||t===`notebook`||t===`guides`?`/notes${i}`:C$(r.filters,`type`)===`dashboard`?`/dashboards${i}`:`/notes${i}`}default:return null}}function T$(e){let t=e.trim().split(/\s+/).filter(e=>e!==``);if(t.length===0)return;let n={};for(let e of t){let t=e.indexOf(`=`);if(t===-1)continue;let r=e.slice(0,t),i=e.slice(t+1);i.startsWith(`"`)&&i.endsWith(`"`)&&i.length>=2&&(i=i.slice(1,-1)),n[r]=i}return Object.keys(n).length===0?void 0:n}var E$=[{label:`Auto`,spanCols:void 0,spanFull:!1},{label:`1 col`,spanCols:1,spanFull:!1},{label:`2 cols`,spanCols:2,spanFull:!1},{label:`4 cols`,spanCols:4,spanFull:!1},{label:`Full row`,spanCols:void 0,spanFull:!0}],D$=300;function O$({open:e,...t}){return e?(0,G.jsx)(k$,{...t}):null}function k$({onClose:e,mode:t,initialWql:n,initial:r,subsetQuery:i,destination:a,executor:o,rangeStart:s,rangeEnd:c,preferredUnit:l,tokenValues:u,onApply:d,footerExtra:f,applyLabel:p=t===`edit`?`Apply changes`:`Add widget`}){let m=t===`inspect`,[h,g]=(0,W.useState)(n),[_,v]=(0,W.useState)(r?.title??``),[y,b]=(0,W.useState)(r?.question??``),[x,S]=(0,W.useState)(r?.type||`table`),[C,w]=(0,W.useState)({spanCols:r?.spanCols,spanFull:r?.spanFull}),[T,E]=(0,W.useState)(Object.entries(r?.attributes??{}).map(([e,t])=>`${e}=${t}`).join(` `)),[D,O]=(0,W.useState)(!1),[k,A]=(0,W.useState)(()=>!X(n).error),[j,M]=(0,W.useState)(null),N=(0,W.useMemo)(()=>X(h.trim()),[h]),P=x===``?`table`:x,F=!N.error&&h.trim()!==``&&(_h(N)?P===`table`||P===`list`:P!==`list`),[I,L]=(0,W.useState)({status:`idle`}),R=(0,W.useRef)(0);(0,W.useEffect)(()=>{if(!F||!o){L(e=>e.status===`ok`?e:{status:`idle`});return}let e=Lv(h.trim(),u??{});if(e.missing.length>0){L({status:`blocked`,message:Ov(e.missing)});return}let t=++R.current;L({status:`loading`});let n=setTimeout(()=>{new g_(gS(o,{rangeStart:s,rangeEnd:c,preferredUnit:l})).run(e.query).then(n=>{if(R.current!==t)return;let r=n.outputs[0],i=r?.error??n.diagnostics[0];if(!r||i){L({status:`error`,message:i??`widget produced no output`});return}L({status:`ok`,result:vS(X(e.query),r)})}).catch(e=>{R.current===t&&L({status:`error`,message:e instanceof Error?e.message:String(e)})})},D$);return()=>clearTimeout(n)},[h,F,o,s,c,l,u]);let z=!F&&I.status===`ok`,ee=F&&k,te=async()=>{if(!(!ee||!d||D)&&!(X(h.trim()).error||h.trim()===``)){O(!0),M(null);try{await d({title:_.trim()||void 0,question:y.trim()||void 0,type:x===`table`?``:x,spanCols:C.spanFull?void 0:C.spanCols,spanFull:C.spanFull||void 0,wql:h.trim(),attributes:T$(T)}),e()}catch(e){M(e instanceof Error?e.message:String(e))}finally{O(!1)}}};return(0,G.jsx)(IC,{open:!0,onClose:e,presentation:`sheet`,title:t===`inspect`?`Inspect widget`:t===`edit`?`Edit widget`:`Add widget`,description:m?`Read-only — clone the dashboard to edit this widget.`:`Dataset, calculation, visualization, preview — then apply.`,footer:m&&!f?void 0:(0,G.jsxs)(G.Fragment,{children:[f,(0,G.jsx)(`div`,{className:`flex-1`}),!m&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:e,className:`min-h-12 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground rounded-lg border border-border hover:bg-muted transition-colors`,children:`Cancel`}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`widget-composer-apply`,disabled:!ee||D,title:N.error?N.error:void 0,onClick:()=>void te(),className:`min-h-12 px-3 py-1.5 text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed rounded-lg shadow transition-colors`,children:D?`Applying…`:p})]})]}),children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[i!==void 0&&(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`div`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground mb-1.5`,children:`Dataset — the subset`}),i?(0,G.jsx)(`code`,{className:`block rounded-md border border-border bg-muted/40 px-3 py-2 font-mono text-xs text-foreground break-all`,"data-testid":`widget-composer-subset`,children:i}):(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`widget-composer-subset`,children:`No subset — the calculation runs over the whole store.`})]}),a,(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Query & Filter Manipulation`}),!m&&u&&Object.keys(u).length>0&&(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,"data-testid":`widget-composer-token-chips`,children:Object.keys(u).map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{let t=h.trim();e===`scope`?t.includes(`{}`)?g(t.replace(`{}`,`{$scope}`)):t.includes(`$scope`)||g(`${t} where :note{$scope}`):t.includes(`$${e}`)||g(t.replace(/\{([^}]*)\}/,(t,n)=>n.trim()?`{${n},${e}:$${e}}`:`{${e}:$${e}}`))},className:`rounded border border-primary/30 bg-primary/10 px-1.5 py-0.5 font-mono text-[10px] font-semibold text-primary hover:bg-primary/20 transition-colors`,title:`Bind $${e} token into query`,children:[`+$`,e]},e))})]}),m?(0,G.jsx)(`code`,{className:`block rounded-md border border-border bg-muted/40 px-3 py-2 font-mono text-xs text-foreground break-all`,"data-testid":`widget-composer-query`,children:h}):(0,G.jsx)(eT,{query:h,onQueryChange:g,onValidationChange:e=>A(e.valid),showDiagnostics:!0,...o?{execute:e=>o.runQuery(e.raw,{rangeStart:s,rangeEnd:c,preferredUnit:l})}:{}}),!m&&h.trim()!==``&&(0,G.jsx)(`code`,{className:`mt-1.5 block rounded-md border border-primary/30 bg-primary/[0.04] px-3 py-2 font-mono text-xs text-foreground break-all`,"data-testid":`widget-composer-wql`,children:h.trim()}),!m&&(0,G.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Visualization`}),(0,G.jsx)(`select`,{value:x,onChange:e=>S(e.target.value),"data-testid":`widget-composer-type`,"aria-label":`Visualization`,className:`rounded-md border border-border bg-card px-2 py-1 text-xs font-mono text-foreground focus:outline-none focus:border-primary`,children:wv.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-5 gap-1.5`,role:`group`,"aria-label":`Visualization picker`,children:wv.map(e=>{let t=x===e;return(0,G.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>S(e),className:`rounded-lg border px-2 py-1.5 text-[11px] font-semibold truncate transition-colors ${t?`border-primary bg-primary/10 text-primary`:`border-border/70 bg-card text-muted-foreground hover:text-foreground hover:bg-muted/60`}`,children:e},e)})})]})]}),!m&&(0,G.jsxs)(`section`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Title`}),(0,G.jsx)(`input`,{type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:`Weekly volume`,"data-testid":`widget-composer-title`,className:`rounded-lg border border-border bg-card px-3 py-1.5 text-sm text-foreground focus:outline-none focus:border-primary`})]}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,G.jsxs)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:[`Coaching question `,(0,G.jsx)(`span`,{className:`normal-case font-normal`,children:`(optional)`})]}),(0,G.jsx)(`input`,{type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`How much work per week?`,"data-testid":`widget-composer-question`,className:`rounded-lg border border-border bg-card px-3 py-1.5 text-sm text-foreground focus:outline-none focus:border-primary`})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Size`}),(0,G.jsx)(`div`,{className:`inline-flex items-center gap-1 rounded-lg border border-border bg-card p-1 self-start`,children:E$.map(e=>{let t=e.spanFull?C.spanFull===!0:e.spanCols==null?!C.spanFull&&C.spanCols==null:!C.spanFull&&C.spanCols===e.spanCols;return(0,G.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>w(e.spanFull?{spanFull:!0}:{spanCols:e.spanCols}),className:`text-xs px-2.5 py-1 rounded-md transition-colors ${t?`bg-primary text-primary-foreground font-medium`:`text-muted-foreground hover:text-foreground hover:bg-muted`}`,children:e.label},e.label)})})]}),(0,G.jsxs)(`label`,{className:`flex flex-col gap-1 sm:col-span-2`,children:[(0,G.jsxs)(`span`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:[`Parameters `,(0,G.jsx)(`span`,{className:`normal-case font-normal`,children:`(goal targets, space-separated)`})]}),(0,G.jsx)(`input`,{type:`text`,value:T,onChange:e=>E(e.target.value),placeholder:`300 200`,"data-testid":`widget-composer-params`,className:`rounded-lg border border-border bg-card px-3 py-1.5 text-sm font-mono text-foreground focus:outline-none focus:border-primary`})]})]}),m&&(0,G.jsxs)(`section`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 text-xs text-muted-foreground`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`font-bold uppercase tracking-wider text-[10px]`,children:`Title`}),(0,G.jsx)(`div`,{className:`text-foreground`,children:r?.title||`—`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`font-bold uppercase tracking-wider text-[10px]`,children:`Question`}),(0,G.jsx)(`div`,{className:`text-foreground`,children:r?.question||`—`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`font-bold uppercase tracking-wider text-[10px]`,children:`Type`}),(0,G.jsx)(`div`,{className:`font-mono text-foreground`,children:x||`table`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`font-bold uppercase tracking-wider text-[10px]`,children:`Size`}),(0,G.jsx)(`div`,{className:`font-mono text-foreground`,children:r?.spanFull?`full row`:r?.spanCols?`${r.spanCols} cols`:`default`})]})]}),(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground mb-1.5 flex items-center gap-2`,children:[`Preview`,z&&(0,G.jsx)(`span`,{"data-testid":`widget-preview-stale`,className:`font-medium normal-case tracking-normal text-amber-600`,children:`stale — showing the last valid query`})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/50 p-3 h-56 overflow-hidden`,children:[I.status===`idle`&&(F?(0,G.jsx)(`div`,{className:`h-full flex items-center justify-center text-xs text-muted-foreground`,children:`Preview runs as you compose…`}):(0,G.jsx)(`div`,{className:`h-full flex items-center justify-center text-xs text-destructive font-mono px-4 text-center`,children:N.error?N.error:_h(N)?`find: queries return things — use a table or list widget instead`:`Compose a calculation to preview.`})),I.status===`loading`&&(0,G.jsx)(`div`,{className:`h-full flex items-center justify-center text-xs text-muted-foreground`,children:`Running preview…`}),I.status===`blocked`&&(0,G.jsx)(`div`,{className:`h-full flex items-center justify-center text-xs text-destructive font-mono px-4 text-center`,children:I.message}),I.status===`error`&&(0,G.jsx)(`div`,{className:`h-full flex items-center justify-center text-xs text-destructive font-mono px-4 text-center`,children:I.message}),I.status===`ok`&&(0,G.jsx)(LS,{type:x,result:I.result,label:_.trim()||void 0,unit:l,attributes:T$(T)})]})]}),j&&(0,G.jsx)(`p`,{role:`alert`,"data-testid":`widget-composer-error`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive font-mono`,children:j})]})})}var A$=`__new__`;function j$(e){return e.open?(0,G.jsx)(M$,{...e},e.subsetQuery??`(whole-store)`):null}function M$({onOpenChange:e,initialQuery:t,subsetQuery:n,rangeStart:r,rangeEnd:i,preferredUnit:a}){let o=dn(),{items:s,loading:c}=fF(),l=s.filter(e=>e.editable),[u,d]=(0,W.useState)(l[0]?.slug??A$),[f,p]=(0,W.useState)(``),[m,h]=(0,W.useState)(null),g=()=>e(!1);return(0,G.jsx)(O$,{open:!0,onClose:g,mode:`add`,initialWql:t,subsetQuery:n,rangeStart:r,rangeEnd:i,preferredUnit:a,onApply:async e=>{h(null);let t={title:e.title,question:e.question,type:e.type,spanCols:e.spanCols,spanFull:e.spanFull,wql:e.wql,attributes:e.attributes};try{if(u===A$){let e=f.trim()||`New Dashboard`,n=await SF.createDashboard(e);await bF.update(n,Zv(n.rawContent,t)),g(),o(tF(Uv(e)))}else{let e=await bF.resolve(u);await bF.update(e,Zv(e.rawContent,t)),g(),o(tF(u))}}catch(e){let t=e instanceof Error?e.message:String(e);throw h(t),e}},applyLabel:`Add to dashboard`,destination:(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`div`,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground mb-1.5`,children:`Destination`}),c?(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading dashboards…`}):(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[l.map(e=>(0,G.jsx)(`button`,{type:`button`,"aria-pressed":u===e.slug,onClick:()=>d(e.slug),className:`rounded-lg border px-3 py-1.5 text-xs font-medium transition-colors ${u===e.slug?`border-primary/60 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground hover:bg-muted`}`,children:e.title},e.slug)),(0,G.jsxs)(`button`,{type:`button`,"data-testid":`dashboard-dest-new`,"aria-pressed":u===A$,onClick:()=>d(A$),className:`flex items-center gap-1 rounded-lg border px-3 py-1.5 text-xs font-medium transition-colors ${u===A$?`border-primary/60 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground hover:bg-muted`}`,children:[(0,G.jsx)(er,{className:`size-3`}),` New dashboard`]})]}),u===A$&&(0,G.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:`New Dashboard`,"data-testid":`dashboard-new-title`,className:`w-full sm:w-64 rounded-lg border border-border bg-card px-3 py-1.5 text-sm text-foreground focus:outline-none focus:border-primary`})]}),m&&(0,G.jsxs)(`p`,{role:`alert`,"data-testid":`dashboard-save-error`,className:`mt-2 text-xs text-destructive font-mono`,children:[`Could not save: `,m]})]})})}var N$=new Set([`pdf`,`doc`,`docx`,`xls`,`xlsx`,`ppt`,`pptx`,`zip`,`tar`,`gz`,`rar`,`mp4`,`mov`,`avi`,`mkv`,`webm`,`mp3`,`wav`,`flac`,`png`,`jpg`,`jpeg`,`gif`,`svg`,`webp`]);function P$(e){let t=e.split(`.`).pop()?.split(`?`)[0]?.toLowerCase()??``;return N$.has(t)}function F$(e){return/^https?:\/\//.test(e)||e.startsWith(`//`)}function I$({queryText:e,widgetType:t,widgetError:n,attributes:r}){let i=S$(),a=En(),[o,s]=(0,W.useState)(!1),c=/^\/dashboards?(?:\/|$)/.test(a.pathname),l=X(e),u=!l.error&&_h(l)?e:null;return i?(0,G.jsxs)(`div`,{className:`my-5 not-prose`,children:[(0,G.jsx)(nT,{query:e,widgetType:t,widgetError:n,attributes:r,executor:jB,readOnly:!0,onAddToDashboard:c?void 0:()=>s(!0),noteHref:e=>TL(`blockContentId`in e||`dataType`in e?mL(e):cL(e))}),(0,G.jsx)(j$,{open:o,onOpenChange:s,initialQuery:e,subsetQuery:u})]}):(0,G.jsx)(`div`,{className:`my-5 not-prose text-xs text-muted-foreground py-2`,children:`Loading…`})}function L$(e){let{meta:t,body:n}=Za(e);return Object.keys(t).length===0&&n===e?{fields:null,body:e}:{fields:t,body:n.trim()}}var R$={table({children:e}){return(0,G.jsx)(`div`,{className:`my-6 overflow-x-auto rounded-xl border border-border`,children:(0,G.jsx)(`table`,{className:`w-full text-sm border-collapse`,children:e})})},thead({children:e}){return(0,G.jsx)(`thead`,{className:`bg-muted/50 text-left`,children:e})},tbody({children:e}){return(0,G.jsx)(`tbody`,{className:`divide-y divide-border/50`,children:e})},tr({children:e}){return(0,G.jsx)(`tr`,{className:`hover:bg-muted/20 transition-colors`,children:e})},th({children:e}){return(0,G.jsx)(`th`,{className:`px-4 py-2.5 text-[11px] font-black tracking-widest uppercase text-muted-foreground border-b border-border`,children:e})},td({children:e}){return(0,G.jsx)(`td`,{className:`px-4 py-2.5 text-sm text-foreground`,children:e})},img({src:e,alt:t,node:n}){let r=n?.properties??{},i=r.width,a=r.height;return(0,G.jsxs)(`figure`,{className:`my-6`,children:[(0,G.jsx)(`img`,{src:e??``,alt:t??``,loading:`lazy`,width:i,height:a,className:`rounded-xl border border-border max-w-full h-auto`}),t&&(0,G.jsx)(`figcaption`,{className:`mt-2 text-center text-xs text-muted-foreground italic`,children:t})]})},a({href:e,children:t}){let n=e??``;if(n.startsWith(`:`)){let e=n;try{e=decodeURIComponent(n)}catch{}let r=w$(e);if(r)return(0,G.jsx)(on,{to:r,className:`underline underline-offset-2 transition-colors text-primary hover:text-primary/70`,children:t})}let r=F$(n),i=P$(n);return(0,G.jsxs)(`a`,{href:n,rel:r?`noopener noreferrer`:void 0,target:r||i?`_blank`:void 0,className:K(`underline underline-offset-2 transition-colors`,i?`text-primary font-medium`:`text-primary hover:text-primary/70`),children:[t,r&&(0,G.jsx)(`span`,{className:`ml-0.5 text-[10px] align-super opacity-60`,children:`↗`}),i&&!r&&(0,G.jsx)(`span`,{className:`ml-0.5 text-[10px] align-super opacity-60`,children:`⬇`})]})},code({children:e,className:t}){let n=t?.replace(`language-`,``)??``,r=typeof e==`string`?e:Array.isArray(e)?e.join(``):String(e??``);if(!t&&!r.includes(`
175
175
  `))return(0,G.jsx)(`code`,{className:`px-1.5 py-0.5 rounded-md bg-muted font-mono text-[0.85em] text-foreground`,children:e});if(n===`query`||n.startsWith(`query:`)||n.startsWith(`query `)||n.startsWith(`widget:`)){let t=(typeof e==`string`?e:Array.isArray(e)?e.join(``):String(e??``)).trim(),r=n.replace(/^(?:query|widget)[:\s]?/,``).trim(),i=r?Av(r):void 0;return(0,G.jsx)(I$,{queryText:t,widgetType:i?.type,widgetError:i?.error,attributes:i?.attributes})}return(0,G.jsxs)(`div`,{className:`my-5 rounded-xl overflow-hidden border border-border`,children:[n&&(0,G.jsx)(`div`,{className:`flex items-center gap-2 px-4 py-2 bg-muted border-b border-border`,children:(0,G.jsx)(`span`,{className:`text-[10px] font-black tracking-widest uppercase text-muted-foreground`,children:n})}),(0,G.jsx)(`pre`,{className:`overflow-x-auto p-4 bg-muted/30`,children:(0,G.jsx)(`code`,{className:`font-mono text-sm text-foreground`,children:e})})]})},h1({children:e,id:t}){return(0,G.jsx)(`h1`,{id:t,className:`text-2xl lg:text-3xl font-black tracking-tight text-foreground uppercase leading-tight mt-10 mb-4 first:mt-0`,children:e})},h2({children:e,id:t}){return(0,G.jsx)(`h2`,{id:t,className:`text-xl lg:text-2xl font-black tracking-tight text-foreground uppercase leading-tight mt-8 mb-3 first:mt-0`,children:e})},h3({children:e,id:t}){return(0,G.jsx)(`h3`,{id:t,className:`text-base lg:text-lg font-black tracking-wide text-foreground uppercase mt-6 mb-2 first:mt-0`,children:e})},h4({children:e,id:t}){return(0,G.jsx)(`h4`,{id:t,className:`text-sm font-black tracking-widest text-primary uppercase mt-5 mb-2 first:mt-0`,children:e})},p({children:e}){return(0,G.jsx)(`p`,{className:`text-sm lg:text-[15px] font-medium text-muted-foreground leading-relaxed my-4 first:mt-0`,children:e})},ul({children:e}){return(0,G.jsx)(`ul`,{className:`my-4 pl-5 space-y-1.5 list-disc list-outside text-left text-sm text-muted-foreground font-medium leading-relaxed`,children:e})},ol({children:e}){return(0,G.jsx)(`ol`,{className:`my-4 pl-5 space-y-1.5 list-decimal list-outside text-left text-sm text-muted-foreground font-medium leading-relaxed`,children:e})},li({children:e}){return(0,G.jsx)(`li`,{className:`leading-relaxed`,children:e})},blockquote({children:e}){return(0,G.jsx)(`blockquote`,{className:`my-5 pl-4 border-l-2 border-primary/40 text-muted-foreground italic text-sm`,children:e})},hr(){return(0,G.jsx)(`hr`,{className:`my-8 border-border/50`})},strong({children:e}){return(0,G.jsx)(`strong`,{className:`font-black text-foreground`,children:e})},em({children:e}){return(0,G.jsx)(`em`,{className:`italic text-foreground/80`,children:e})}},z$={...R$,p({children:e}){return(0,G.jsx)(`p`,{className:`text-3xl sm:text-4xl lg:text-5xl font-black tracking-tight text-foreground leading-[1.08] my-0`,children:e})},strong({children:e}){let t=W.Children.toArray(e).map(e=>typeof e==`string`||typeof e==`number`?String(e):``).join(``).trim();return t.includes(`Write it in Markdown`)&&t.includes(`Run it as a Timer`)&&t.includes(`Own the Analytics`)?(0,G.jsxs)(`span`,{className:`flex flex-col select-none mt-4 w-full gap-5 sm:gap-7`,children:[(0,G.jsxs)(`span`,{className:`block text-3xl sm:text-4xl lg:text-5xl text-primary font-black text-left pl-[5%] sm:pl-[10%] transform hover:translate-x-1 transition-transform duration-200`,children:[`Write it in `,(0,G.jsx)(`span`,{className:`inline-block border-b-4 border-primary/70 pb-1 hover:scale-105 transition-transform duration-200`,children:`Markdown`}),`.`]}),(0,G.jsxs)(`span`,{className:`block text-3xl sm:text-4xl lg:text-5xl text-primary font-black text-center transform hover:scale-[1.02] transition-transform duration-200`,children:[(0,G.jsx)(`span`,{className:`inline-block border-b-4 border-primary/70 pb-1 hover:scale-105 transition-transform duration-200`,children:`Run`}),` it as a Timer.`]}),(0,G.jsxs)(`span`,{className:`block text-3xl sm:text-4xl lg:text-5xl text-primary font-black text-right pr-[5%] sm:pr-[10%] transform hover:-translate-x-1 transition-transform duration-200`,children:[`Own the `,(0,G.jsx)(`span`,{className:`inline-block border-b-4 border-primary/70 pb-1 hover:scale-105 transition-transform duration-200`,children:`Analytics`}),`.`]})]}):(0,G.jsx)(`strong`,{className:`font-black text-foreground`,children:e})}},B$={...R$,p({children:e}){return(0,G.jsx)(`p`,{className:`text-base lg:text-lg font-medium text-foreground/75 leading-relaxed my-4 first:mt-0`,children:e})}},V$=[Hn];function H$(e){return e.startsWith(`:`)?e:Pn(e)}function U$(e){return e.type===`text`&&typeof e.value==`string`?e.value:(e.children??[]).map(U$).join(``)}function W$(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N} _-]/gu,``).replace(/ /g,`-`).replace(/-+/g,`-`)||`heading`}var G$=()=>e=>{let t=new Map,n=e=>{if(e.tagName&&/^h[1-6]$/.test(e.tagName)){let n=W$(U$(e)),r=t.get(n)??0;t.set(n,r+1),(e.properties??={}).id=r===0?n:`${n}-${r}`}for(let t of e.children??[])n(t)};n(e)};function K$({fields:e}){let t=Object.entries(e);return t.length===0?null:(0,G.jsxs)(`div`,{className:`my-6 rounded-xl border border-border bg-muted/30 overflow-hidden`,children:[(0,G.jsx)(`div`,{className:`px-4 py-2 border-b border-border bg-muted/50`,children:(0,G.jsx)(`span`,{className:`text-[10px] font-black tracking-[0.2em] uppercase text-muted-foreground`,children:`Metadata`})}),(0,G.jsx)(`dl`,{className:`divide-y divide-border/50`,children:t.map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex items-baseline gap-4 px-4 py-2`,children:[(0,G.jsx)(`dt`,{className:`text-[11px] font-semibold text-muted-foreground uppercase tracking-wide min-w-[100px] shrink-0`,children:e}),(0,G.jsx)(`dd`,{className:`text-sm text-foreground break-words`,children:Array.isArray(t)?t.join(`, `):String(t)})]},e))})]})}var q$={default:R$,heroLead:z$,heroBody:B$};function J$({prose:e,className:t,variant:n=`default`}){if(!e)return null;let{fields:r,body:i}=L$(e);return(0,G.jsxs)(`div`,{className:K(`prose-canvas`,t),children:[r&&(0,G.jsx)(K$,{fields:r}),i&&(0,G.jsx)(hn,{remarkPlugins:V$,rehypePlugins:[G$],urlTransform:H$,components:q$[n],children:i})]})}var Y$=({activations:e,fullBleed:t,runState:n,deps:r})=>{if(e.length===0)return null;let i=e[0];if(NL(i)&&n){let a=e.slice(1),o=n.isReconnect?(0,G.jsxs)(`button`,{onClick:n.onReconnect,className:K(`flex items-center gap-2 px-5 py-2 text-[11px] font-black uppercase tracking-widest`,`rounded-full border transition-all active:scale-95`,`border-amber-500/40 bg-amber-500/15 text-amber-600 hover:bg-amber-500/20`,`dark:text-amber-400`,t&&`mx-auto`),children:[(0,G.jsx)(qe,{className:`size-3.5`}),`View`]}):(0,G.jsxs)(`button`,{type:`button`,onClick:n.onRun,className:K(`flex items-center gap-2 transition-all active:scale-95 bg-primary text-primary-foreground hover:bg-primary/90 font-black uppercase tracking-widest rounded-full shadow-lg shadow-primary/25 min-h-[44px] px-6 py-2 text-xs`,t&&`mx-auto`),children:[(()=>{let e=i.icon||pr;return(0,G.jsx)(e,{className:`shrink-0 size-4 fill-current sm:size-3`})})(),(0,G.jsx)(`span`,{children:i.label})]});return(0,G.jsxs)(`div`,{className:K(`flex flex-wrap items-center gap-4 mt-8`,t&&`justify-center`),children:[o,a.map((e,t)=>(0,G.jsx)(`button`,{onClick:()=>AL(e.action,r),className:`flex items-center gap-2 px-6 py-2 text-xs font-black uppercase tracking-widest rounded-full bg-background border border-border text-foreground hover:bg-muted transition-all active:scale-95`,children:e.label},e.id||t))]})}return(0,G.jsx)(`div`,{className:K(`flex flex-wrap gap-4 mt-8`,t&&`justify-center`),children:e.map((e,t)=>(0,G.jsx)(`button`,{onClick:()=>AL(e.action,r),className:K(`flex items-center gap-2 px-8 py-4 text-xs font-black uppercase tracking-widest rounded-full transition-all active:scale-95`,t===0?`bg-primary text-primary-foreground shadow-xl shadow-primary/25 hover:scale-[1.04]`:`bg-background border border-border text-foreground hover:bg-muted`),children:e.label},e.id||t))})},X$=({examples:e,activeIndex:t,onSelect:n})=>e.length===0?null:(0,G.jsx)(`div`,{className:`mt-6 rounded-2xl border border-border/70 bg-card/80 backdrop-blur-sm`,children:(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 py-3`,children:e.map((e,r)=>{let i=r===t,a=e.anchor===!0&&!i,o=!!e.badge&&a;return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(r),"aria-current":i?`true`:void 0,className:K(`relative rounded-full px-4 py-2 text-[11px] font-black uppercase tracking-[0.18em] transition-all active:scale-95`,i?`bg-primary text-primary-foreground shadow-lg shadow-primary/25`:a?`border border-brand bg-brand/5 text-brand-deep hover:bg-brand/10 dark:text-brand-light`:`border border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground`),children:[e.label,o?(0,G.jsx)(`span`,{className:`ml-2 inline-block rounded-pill bg-brand px-1.5 py-0.5 align-middle text-[8px] font-black leading-none tracking-[0.12em] text-background`,children:e.badge}):null]},`${e.label}-${r}`)})})}),Z$=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`struct-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00E676`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#00F2FF`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#struct-grad)`,strokeWidth:`4`}),(0,G.jsx)(`path`,{d:`M35 35 L65 35 L65 45 L45 45 L45 65 L35 65 Z`,fill:`url(#struct-grad)`}),(0,G.jsx)(`path`,{d:`M55 45 L65 45 L65 65 L45 65 L45 55 L55 55 Z`,fill:`url(#struct-grad)`,opacity:`0.7`})]}),Q$=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`proto-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#FFD600`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#FFAB00`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#proto-grad)`,strokeWidth:`4`}),(0,G.jsx)(`circle`,{cx:`50`,cy:`50`,r:`5`,fill:`url(#proto-grad)`}),(0,G.jsx)(`circle`,{cx:`50`,cy:`50`,r:`15`,fill:`none`,stroke:`url(#proto-grad)`,strokeWidth:`2`,strokeDasharray:`4 2`}),(0,G.jsx)(`circle`,{cx:`50`,cy:`50`,r:`25`,fill:`none`,stroke:`url(#proto-grad)`,strokeWidth:`1`,opacity:`0.5`}),(0,G.jsx)(`line`,{x1:`50`,y1:`50`,x2:`50`,y2:`25`,stroke:`url(#proto-grad)`,strokeWidth:`4`,strokeLinecap:`round`})]}),$$=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`complex-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#F50057`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#D500F9`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#complex-grad)`,strokeWidth:`4`}),(0,G.jsx)(`path`,{d:`M40 35 H60 V45 A5 5 0 0 1 60 55 V65 H40 V55 A5 5 0 0 0 40 45 Z`,fill:`url(#complex-grad)`})]}),e1=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsxs)(`defs`,{children:[(0,G.jsxs)(`linearGradient`,{id:`basics-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00F2FF`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#6200EA`,stopOpacity:1}})]}),(0,G.jsxs)(`filter`,{id:`glow`,x:`-20%`,y:`-20%`,width:`140%`,height:`140%`,children:[(0,G.jsx)(`feGaussianBlur`,{stdDeviation:`3`,result:`blur`}),(0,G.jsx)(`feComposite`,{in:`SourceGraphic`,in2:`blur`,operator:`over`})]})]}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#basics-grad)`,strokeWidth:`4`}),(0,G.jsx)(`path`,{d:`M55 20 L30 55 L45 55 L40 85 L70 45 L55 45 Z`,fill:`url(#basics-grad)`,filter:`url(#glow)`})]}),t1=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`basics-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00F2FF`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#6200EA`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#basics-grad)`,strokeWidth:`4`}),(0,G.jsx)(`text`,{x:`50`,y:`65`,fontFamily:`monospace`,fontSize:`40`,fontWeight:`bold`,fill:`url(#basics-grad)`,textAnchor:`middle`,children:`10`})]}),n1=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`basics-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00F2FF`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#6200EA`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#basics-grad)`,strokeWidth:`4`}),(0,G.jsx)(`rect`,{x:`30`,y:`30`,width:`40`,height:`8`,rx:`2`,fill:`url(#basics-grad)`}),(0,G.jsx)(`rect`,{x:`30`,y:`45`,width:`40`,height:`8`,rx:`2`,fill:`url(#basics-grad)`}),(0,G.jsx)(`rect`,{x:`30`,y:`60`,width:`40`,height:`8`,rx:`2`,fill:`url(#basics-grad)`})]}),r1=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`struct-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00E676`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#00F2FF`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#struct-grad)`,strokeWidth:`4`}),(0,G.jsx)(`path`,{d:`M50 30 A20 20 0 1 1 35.8 35.8 L30 30 M35.8 35.8 L42 38`,fill:`none`,stroke:`url(#struct-grad)`,strokeWidth:`6`,strokeLinecap:`round`})]}),i1=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`struct-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00E676`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#00F2FF`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#struct-grad)`,strokeWidth:`4`}),(0,G.jsx)(`path`,{d:`M30 40 L45 40 M30 50 L55 50 M30 60 L70 60`,fill:`none`,stroke:`url(#struct-grad)`,strokeWidth:`6`,strokeLinecap:`round`}),(0,G.jsx)(`text`,{x:`50`,y:`30`,fontFamily:`monospace`,fontSize:`12`,fill:`url(#struct-grad)`,textAnchor:`middle`,children:`21-15-9`})]}),a1=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`proto-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#FFD600`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#FFAB00`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#proto-grad)`,strokeWidth:`4`}),(0,G.jsx)(`path`,{d:`M35 35 H65 V55 L50 70 L35 55 Z`,fill:`url(#proto-grad)`}),(0,G.jsx)(`circle`,{cx:`50`,cy:`45`,r:`4`,fill:`#0b1326`})]}),o1=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`metric-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00E5FF`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#1DE9B6`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#metric-grad)`,strokeWidth:`4`}),(0,G.jsx)(`rect`,{x:`30`,y:`60`,width:`10`,height:`15`,fill:`url(#metric-grad)`}),(0,G.jsx)(`rect`,{x:`45`,y:`40`,width:`10`,height:`35`,fill:`url(#metric-grad)`}),(0,G.jsx)(`rect`,{x:`60`,y:`25`,width:`10`,height:`50`,fill:`url(#metric-grad)`})]}),s1=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`metric-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#00E5FF`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#1DE9B6`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#metric-grad)`,strokeWidth:`4`}),(0,G.jsx)(`path`,{d:`M35 40 L65 60 M65 40 L35 60 M35 30 H65 M35 70 H65`,fill:`none`,stroke:`url(#metric-grad)`,strokeWidth:`4`,strokeLinecap:`round`})]}),c1=e=>(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 100 100`,...e,children:[(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`dialect-grad`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,G.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#76FF03`,stopOpacity:1}}),(0,G.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#00E676`,stopOpacity:1}})]})}),(0,G.jsx)(`path`,{d:`M50 5 L90 27.5 L90 72.5 L50 95 L10 72.5 L10 27.5 Z`,fill:`none`,stroke:`url(#dialect-grad)`,strokeWidth:`4`,strokeLinecap:`round`}),(0,G.jsx)(`path`,{d:`M35 30 H65 M35 45 H65 M35 60 H55 M35 75 H65`,fill:`none`,stroke:`url(#dialect-grad)`,strokeWidth:`4`,strokeLinecap:`round`})]});function l1(e){switch(e){case`trophy`:return e1;case`dumbbell`:return be;case`timer`:return Q$;case`play`:return pr;case`blocks`:return Z$;case`puzzle`:return $$;case`activity`:return o1;case`file-text`:return c1;default:return ae}}function u1(e){switch(e){case`basics-movement`:return e1;case`basics-reps`:return t1;case`basics-load`:return n1;case`structure-rounds`:case`complex-rounds`:case`protocols-rounds`:return r1;case`structure-repscheme`:return i1;case`protocols-timer`:case`complex-time`:return Q$;case`protocols-tag`:return a1;case`metrics-custom`:return o1;case`metrics-calc`:return s1;case`dialects-log`:case`dialects-climb`:return c1;default:return null}}function d1({quest:e,onClick:t,className:n,compact:r=!1,disabled:i=!1}){let a=u1(e.id),o=t?`Select to jump to its section.`:`Open the editor to begin.`,s=e.isCompleted?`Challenge complete.`:e.result?e.result.pass?`Ready — ${e.result.detail??`looks good`}`:e.result.reason??o:o,c={"data-testid":`challenge-row-${e.id}`,"data-completed":e.isCompleted?`true`:`false`,className:K(`w-full text-left flex items-start gap-3 rounded-xl border px-3 py-2 text-sm transition-colors`,e.isCompleted?`border-primary/40 bg-primary/5`:`border-border/50 bg-background/60`,t&&!i&&`cursor-pointer hover:bg-background/80`,i&&`opacity-60 cursor-default`,r&&`px-2.5 py-1.5`,n)},l=(0,G.jsxs)(G.Fragment,{children:[a?(0,G.jsxs)(`span`,{className:K(`relative shrink-0 mt-0.5`,r?`size-5`:`size-6`),children:[(0,G.jsx)(a,{className:`w-full h-full`}),e.isCompleted&&(0,G.jsx)(`span`,{className:`absolute -bottom-1 -right-1 flex size-3.5 items-center justify-center rounded-full bg-emerald-500 text-white border border-background shadow`,children:(0,G.jsx)(Bt,{className:`size-2`,strokeWidth:3})})]}):(0,G.jsx)(`span`,{className:K(`mt-0.5 shrink-0`,e.isCompleted?`text-primary`:`text-muted-foreground/50`),"aria-hidden":`true`,children:e.isCompleted?(0,G.jsx)(cn,{className:r?`size-3.5`:`size-4`}):(0,G.jsx)(St,{className:r?`size-3.5`:`size-4`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:K(`font-semibold`,e.isCompleted?`text-foreground line-through decoration-primary/40`:`text-foreground`,r&&`text-xs`),children:e.label}),e.desc&&!r&&(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e.desc}),(0,G.jsx)(`p`,{"data-testid":`challenge-hint-${e.id}`,className:K(`mt-1 text-xs`,e.isCompleted||e.result?.pass?`text-primary/80`:`text-muted-foreground`),children:s})]})]});return t?(0,G.jsx)(`button`,{type:`button`,onClick:t,disabled:i,...c,children:l}):(0,G.jsx)(`div`,{...c,children:l})}function f1(e){let t=e.replace(/^\s+/,``),n=t.match(/\n\s*\n/);return!n||n.index===void 0?{lead:t,rest:``}:{lead:t.slice(0,n.index),rest:t.slice(n.index).trimStart()}}var p1=({section:e,idx:t,prose:n,blockId:r,keySuffix:i,showHeading:a=!0,showEyebrow:o=!0,renderButtons:s=!0,isActive:c=!1,hasViewDef:l=!1,runState:u,deps:d,onExampleSelect:f,selectedExampleIndex:p,chapters:m=[],challengeQuests:h=[],isCollection:g=!1,notebookSlug:_=null,workoutItems:v=[],handleSelectWorkout:y,onScrollToSection:b,variant:x=`default`})=>{let S=!!e.isFullBleed,C=!!e.isDark&&x!==`caption`,w=e.density,T=KR[e.theme||`slate`]??KR.slate,E=e.examples??[],D=t===-1,O=W.useMemo(()=>{if(!m||!h)return null;for(let t of m){let n=t.sectionIds.indexOf(e.id);if(n>=0&&t.questIds[n]){let e=t.questIds[n],r=h.find(t=>t.id===e);if(r)return{quest:r,chapterTitle:t.title}}}return null},[m,h,e.id]);if(D){let t=e.proseChunks.filter(e=>e.kind===`button`).map(e=>e.button),n=e.proseChunks.findIndex(e=>e.kind===`prose`&&e.text.trim()!==``),a=n>=0?e.proseChunks[n]:null,{lead:o,rest:s}=a&&a.kind===`prose`?f1(a.text.trim()):{lead:``,rest:``},c=e.proseChunks.slice(n+1);return(0,G.jsxs)(`div`,{id:r,"data-section-id":i==="default"?e.id:void 0,className:`group relative flex min-h-[70vh] lg:min-h-[80vh] items-center justify-center overflow-hidden border-b-2 border-primary/10 bg-gradient-to-b from-primary/[0.08] via-muted/30 to-background px-6 py-16 lg:px-10 lg:py-24`,children:[(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_75%_60%_at_50%_0%,_var(--tw-gradient-stops))] from-primary/30 via-primary/5 to-transparent`}),(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 text-primary opacity-[0.15]`,style:{backgroundImage:`radial-gradient(circle, currentColor 1.5px, transparent 1.5px)`,backgroundSize:`24px 24px`,maskImage:`radial-gradient(ellipse 70% 60% at 50% 40%, black 40%, transparent 90%)`,WebkitMaskImage:`radial-gradient(ellipse 70% 60% at 50% 40%, black 40%, transparent 90%)`}}),(0,G.jsxs)(`div`,{className:`relative max-w-2xl w-full text-center`,children:[o&&(0,G.jsx)(J$,{prose:o,variant:`heroLead`,className:`mb-5`}),s&&(0,G.jsx)(J$,{prose:s,variant:`heroBody`,className:`mb-2`}),c.map((e,t)=>{if(e.kind===`prose`){let n=e.text.trim();return n?(0,G.jsx)(J$,{prose:n,className:`mt-6 mb-2`},`hero-prose-${t}`):null}if(e.kind===`challenge`){let n=h.find(t=>t.id===e.id);return n?(0,G.jsx)(`div`,{className:`my-4 flex justify-center`,children:(0,G.jsx)(d1,{quest:n,onClick:()=>b?.(r),compact:!0})},`hero-challenge-${t}`):null}return null}),t.length>0&&(0,G.jsx)(Y$,{activations:t.map((e,t)=>ML(e,t)),fullBleed:!0,runState:l?u:void 0,deps:d})]})]})}let k=n===void 0?e.proseChunks??[]:[{kind:`prose`,text:n}],A=!k.some(e=>e.kind===`button`)&&(e.buttons??[]).length>0;return(0,G.jsxs)(`div`,{id:r,"data-section-id":i==="default"||i===`before-workouts`?e.id:void 0,className:K(`group relative border-b border-border/50 transition-colors duration-300`,x===`caption`?`py-6 pb-10`:l?S?`flex items-center justify-center min-h-[35vh] py-12 lg:py-16 px-6 lg:px-10`:w===`compact`?`py-10 lg:py-12 px-6 lg:px-10`:`py-14 lg:py-20 px-6 lg:px-10`:w===`compact`?`py-10 lg:py-12 px-6 lg:px-12`:`py-16 lg:py-20 px-6 lg:px-12`,!x||x==="default"?C&&`bg-muted/20 overflow-hidden`:void 0,x!==`caption`&&!C&&!S&&(t%2==0?`bg-background`:`bg-muted/[0.18]`)),children:[x!==`caption`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:K(`pointer-events-none absolute inset-y-0 left-0 w-px bg-gradient-to-b opacity-0 transition-opacity duration-300`,T.accent,c&&`opacity-100`)}),(0,G.jsx)(`div`,{className:K(`pointer-events-none absolute left-0 top-0 h-full w-1 origin-top rounded-r-full bg-gradient-to-b transition-all duration-300`,T.progress,c?`scale-y-100 opacity-100`:`scale-y-[0.18] opacity-25`)})]}),C&&(0,G.jsx)(`div`,{className:`pointer-events-none absolute inset-0 opacity-40 bg-[radial-gradient(circle_at_center,_var(--tw-gradient-stops))] from-primary/20 via-transparent to-transparent`}),(0,G.jsxs)(`div`,{className:K(`relative`,x===`caption`?`max-w-none`:l?S?`max-w-md w-full text-center`:`max-w-sm`:`max-w-4xl w-full mx-auto`),children:[o&&(!S||!l)&&O&&(0,G.jsx)(`div`,{className:`mb-4 flex items-center gap-2 select-none min-h-[14px]`,children:O.quest.isCompleted?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[9px] font-black uppercase tracking-wider text-emerald-800 dark:text-emerald-400 bg-emerald-500/10 px-2 py-0.5 rounded-full border border-emerald-500/20`,children:[(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400 animate-pulse`}),`Challenge Complete`]}):(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[9px] font-black uppercase tracking-wider text-muted-foreground bg-muted/60 px-2 py-0.5 rounded-full border border-border/50`,children:[(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-zinc-400 dark:bg-zinc-500`}),O.chapterTitle,`: Challenge Pending`]})}),a?(0,G.jsx)(`h2`,{className:K(`font-bold tracking-tight text-foreground leading-tight`,x===`caption`?`text-xl lg:text-2xl mb-4`:`text-2xl lg:text-3xl font-black uppercase mb-5`),children:e.heading}):null,k.map((e,t)=>{if(e.kind===`prose`){let n=e.text.trim();return n?(0,G.jsx)(J$,{prose:n,className:t===0?`mb-6`:`mt-4 mb-6`},`prose-${t}`):null}if(e.kind===`button`)return(0,G.jsx)(Y$,{activations:[ML(e.button,t)],fullBleed:S,runState:l?u:void 0,deps:d},`button-${t}`);if(e.kind===`widget`){if(e.widget===`hero-carousel`)return(0,G.jsx)(`div`,{className:`my-6`,children:(0,G.jsx)(p$,{})},`hero-carousel-${t}`);if(e.widget===`workouts-list`&&g&&_&&y)return(0,G.jsx)(`div`,{id:`notebook-workouts`,className:`border-b border-border/50 bg-card my-6`,children:(0,G.jsx)(`div`,{className:`w-full mx-auto`,children:(0,G.jsx)(x$,{category:_,workoutItems:v,onSelect:y,showSearch:!1,variant:`flat`})})},`workouts-${t}`)}if(e.kind===`challenge`){let n=h.find(t=>t.id===e.id);return n?(0,G.jsx)(`div`,{className:`my-4`,children:(0,G.jsx)(d1,{quest:n,onClick:()=>b?.(r),compact:!0})},`challenge-${t}`):null}return null}),E.length>0?(0,G.jsx)(X$,{examples:E,activeIndex:Math.min(p,E.length-1),onSelect:t=>f(e,t)}):null,s&&A?(0,G.jsx)(Y$,{activations:e.buttons.map((e,t)=>ML(e,t)),fullBleed:S,runState:l?u:void 0,deps:d}):null]})]},`${e.id}-${i}`)};function m1({sections:e,activeIndex:t,part:n,args:r}){return(0,G.jsx)(`div`,{className:`h-full min-h-0 pr-1`,"data-testid":`guide-captions-${n}`,children:e.map((e,n)=>{let i=n===t;return(0,G.jsx)(`div`,{className:`absolute inset-0 min-h-0 overflow-y-auto transition-opacity duration-300 ${i?`opacity-100`:`pointer-events-none invisible opacity-0`}`,"aria-hidden":!i,children:(0,G.jsx)(p1,{section:e,idx:n,blockId:`guide-caption-${e.id}`,keySuffix:`caption`,variant:`caption`,isActive:i,hasViewDef:r.hasViewDef??!0,runState:r.runState,deps:r.deps,onExampleSelect:r.onExampleSelect,selectedExampleIndex:r.selectedExamples[e.id]??0,chapters:r.chapters,challengeQuests:r.challengeQuests,onScrollToSection:r.onScrollToSection})},e.id)})})}function h1({sections:e,part:t,partCount:n,title:r,pane:i,cardArgs:a,onActivateSection:o}){let s=(0,W.useRef)(null),c=(0,W.useMemo)(()=>d$(e),[e]),{slice:l,subscribe:u}=s$(s,!1,c),d=(0,W.useRef)(e);d.current=e;let[f,p]=(0,W.useState)(!1);(0,W.useEffect)(()=>{let e=s.current;if(!e||typeof IntersectionObserver>`u`){p(!0);return}let t=new IntersectionObserver(([e])=>{e.isIntersecting&&(p(!0),t.disconnect())},{rootMargin:`100px`});return t.observe(e),()=>t.disconnect()},[]);let m=()=>{let e=s.current;if(!e)return!1;let{top:t,bottom:n}=e.getBoundingClientRect();return t<=0&&n>window.innerHeight},[h,g]=(0,W.useState)(!1);(0,W.useEffect)(()=>u(()=>{let e=m();g(t=>t===e?t:e)}),[u]);let _=(0,W.useRef)(!1),v=(0,W.useRef)(-1),y=(0,W.useRef)(o);y.current=o,(0,W.useEffect)(()=>{let e=_.current,t=v.current;if(_.current=h,v.current=l.index,!h||e&&t===l.index)return;let n=d.current[l.index];n&&y.current(n)},[h,l.index]);let b=e[l.index]??null;return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`header`,{"data-testid":`guide-runway-header-${t}`,className:`mx-auto w-full max-w-[1500px] px-6 pt-12 pb-6 lg:px-12`,children:[(0,G.jsxs)(`div`,{className:`font-mono text-[11px] uppercase tracking-[0.22em] text-muted-foreground`,children:[`Part `,t,` / `,n]}),(0,G.jsx)(`h2`,{className:`mt-1 text-xl font-black uppercase tracking-tight text-foreground`,children:r})]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(i$,{trackRef:s,height:`${(e.length+1)*100}vh`,stages:c,activeIndex:l.index,pane:f?i:null,captions:(0,G.jsx)(m1,{sections:e,activeIndex:l.index,part:t,args:a}),status:(0,G.jsxs)(`div`,{className:`truncate font-mono text-[11px] uppercase tracking-[0.22em] text-muted-foreground`,children:[String(l.index+1).padStart(2,`0`),b?` — ${b.heading}`:``]}),testId:`guide-runway-${t}`}),e.map((t,n)=>(0,G.jsx)(`span`,{id:t.id,"data-section-id":t.id,"aria-hidden":`true`,className:`pointer-events-none absolute left-0 h-px w-px`,style:{top:`calc((100% - 100vh) * ${n/e.length} + 160px)`}},t.id))]})]})}function g1({sections:e,groupKey:t,title:n,pane:r,cardArgs:i,onActivateSection:a}){let{groups:o,tail:s}=u$(e,t);return(0,G.jsxs)(G.Fragment,{children:[o.map((e,t)=>(0,G.jsx)(h1,{sections:e,part:t+1,partCount:o.length,title:n,pane:r,cardArgs:i,onActivateSection:a},e[0]?.id??t)),s.length>0&&(0,G.jsx)(`div`,{className:`mx-auto w-full max-w-[1500px] px-6 lg:px-12`,"data-testid":`guide-static-tail`,children:(0,G.jsx)(`div`,{className:`lg:max-w-[50%]`,children:s.map((e,t)=>(0,G.jsx)(p1,{section:e,idx:t,blockId:e.id,keySuffix:`default`,isActive:i.activeSectionId===e.id,hasViewDef:i.hasViewDef??!0,runState:i.runState,deps:i.deps,onExampleSelect:i.onExampleSelect,selectedExampleIndex:i.selectedExamples[e.id]??0,chapters:i.chapters,challengeQuests:i.challengeQuests,onScrollToSection:i.onScrollToSection},`tail-${e.id}`))})})]})}function _1({videoId:e,title:t=`YouTube video`,onClose:n}){return(0,W.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,NC.createPortal)((0,G.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/90 p-4 animate-in fade-in duration-200`,"data-testid":`youtube-lightbox`,onClick:e=>{e.target===e.currentTarget&&n()},children:[(0,G.jsx)(`button`,{type:`button`,onClick:n,title:`Close video`,"data-testid":`youtube-lightbox-close`,className:`absolute right-4 top-4 z-[110] flex size-11 items-center justify-center rounded-full border border-border bg-background/80 text-foreground transition-colors hover:bg-accent`,children:(0,G.jsx)(yr,{className:`size-5`})}),(0,G.jsx)(`div`,{className:`aspect-video w-full max-w-5xl overflow-hidden rounded-lg border border-border bg-black shadow-2xl`,children:(0,G.jsx)(`iframe`,{className:`h-full w-full border-0`,src:`https://www.youtube-nocookie.com/embed/${encodeURIComponent(e)}?autoplay=1&rel=0`,title:t,allow:`accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0})})]}),document.body)}function v1({index:e,before:t,accentText:n,after:r,accent:i,blurb:a}){return(0,G.jsx)(`header`,{className:`flex items-center px-6 py-14 lg:px-12 xl:py-20 2xl:py-24 xl:px-16`,children:(0,G.jsxs)(`div`,{className:`mx-auto w-full max-w-[1500px] 2xl:max-w-[1720px]`,children:[(0,G.jsxs)(`h2`,{className:`flex items-baseline gap-4 xl:gap-6 text-[clamp(26px,3.6vw,52px)] font-extrabold leading-[1.1] tracking-[-0.03em]`,children:[(0,G.jsx)(`span`,{className:`font-mono text-xs font-normal tracking-normal text-muted-foreground`,children:e}),(0,G.jsxs)(`span`,{children:[t,n,r]})]}),(0,G.jsx)(`p`,{className:`mt-3 xl:mt-4 max-w-xl xl:max-w-2xl 2xl:max-w-3xl text-[clamp(14px,1.2vw,18px)] leading-[1.65] text-muted-foreground`,children:a})]})})}var y1=`hsl(var(--primary))`,b1={ink:`hsl(var(--foreground))`,editor:y1,timer:y1,analytics:y1,library:y1,rounds:y1},x1={editor:`WOD Editor & Autocomplete`,timer:`Clock`,analytics:`WQL Analytics`,metrics:`Own the Metrics`,result:`Run Results`},S1={start:`/page/guide-start`,protocols:`/page/guide-protocols`,structure:`/page/guide-structure`,metrics:`/page/guide-metrics`,clock:`/page/guide-clock`,wql:`/page/guide-wql`,dashboards:`/page/guide-dashboards`,sessions:`/page/guide-sessions`,basics:`/page/guide-start`,"custom-metrics":`/page/guide-metrics`,dialects:`/page/guide-sessions#intent`,complex:`/page/guide-sessions#full-session`},C1=`dQw4w9WgXcQ`,w1=`https://i.ytimg.com/vi/${C1}/hqdefault.jpg`;function T1({variant:e=`index`}){let t=Sz(),{pathname:n}=En(),[r,i]=(0,W.useState)(null),a=(0,W.useMemo)(()=>zR(t).flatMap(e=>e.action?.type===`route`?[{id:e.id,label:e.label,to:e.action.to}]:[]),[t]),o=(0,W.useMemo)(()=>{let e=new Map;for(let n of t){if(n.route.startsWith(`/notebook`)||n.page.frontmatter?.type!==`guide`)continue;let t=n.page.frontmatter?.description;t&&e.set(`guide-${n.route}`,String(t))}return e},[t]);if(a.length===0)return null;let s=a.findIndex(e=>e.to===n),c=s>=0,l=c&&a.length>1?(s+1)%a.length:-1,u=r&&(0,G.jsx)(_1,{videoId:C1,title:r.label,onClose:()=>i(null)});return e===`university`?(0,G.jsxs)(`section`,{id:`tour-section-university`,"data-testid":`tour-section-university`,"aria-label":`Wod Wiki University`,children:[(0,G.jsx)(v1,{index:`05`,before:`Wod Wiki `,accentText:`University`,after:``,accent:b1.library,blurb:`Eight short chapters take you from your first workout to querying your training history. Each guide pairs a video walkthrough with a runnable example.`}),(0,G.jsx)(`nav`,{"aria-label":`Wod Wiki University`,className:`px-6 pb-16 lg:px-12 xl:px-16`,children:(0,G.jsx)(`ul`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-5`,children:a.map((e,t)=>(0,G.jsxs)(`li`,{className:K(`flex flex-col gap-5 rounded-lg border border-border p-5 md:flex-row md:items-center md:gap-8 md:p-6`,t%2==1&&`md:flex-row-reverse`),children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i({id:e.id,label:e.label}),title:`Watch: ${e.label}`,"aria-label":`Watch: ${e.label}`,"data-testid":`guide-watch`,className:`group relative block w-full flex-none overflow-hidden rounded-md border border-border md:w-56`,children:[(0,G.jsx)(`img`,{src:w1,alt:``,loading:`lazy`,className:`aspect-video w-full object-cover transition-transform duration-300 group-hover:scale-105`}),(0,G.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/25 transition-colors group-hover:bg-black/40`,children:(0,G.jsx)(pr,{className:`size-9 fill-white text-white`})})]}),(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,G.jsx)(on,{to:e.to,className:`font-semibold hover:underline`,children:e.label}),(0,G.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:o.get(e.id)??e.to})]})]},e.id))})}),u]}):(0,G.jsxs)(`nav`,{"aria-label":c?`What’s Next`:`Syntax & Guides`,"data-testid":`guide-index-footer`,className:`border-t border-border px-6 py-12 xl:py-16`,children:[(0,G.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col rounded-lg border border-border overflow-hidden`,children:[(0,G.jsxs)(`h2`,{className:`px-4 py-2 text-xs font-black uppercase tracking-wider text-muted-foreground bg-muted/40`,children:[c?`What’s Next`:`Syntax & Guides`,` · `,a.length]}),(0,G.jsx)(`ul`,{className:`flex flex-col divide-y divide-border`,children:a.map((e,t)=>(0,G.jsxs)(`li`,{className:`flex items-stretch`,children:[(0,G.jsxs)(on,{to:e.to,"aria-current":t===s?`page`:void 0,className:K(`flex min-w-0 flex-1 flex-col gap-0.5 px-4 py-3 hover:bg-muted/50`,t===s&&`bg-muted/50`),children:[(0,G.jsxs)(`span`,{className:`flex w-full items-baseline justify-between gap-3`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.label}),t===l&&(0,G.jsx)(`span`,{className:`text-xs font-semibold text-primary`,"data-testid":`guide-next-marker`,children:`Next →`})]}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.to})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>i({id:e.id,label:e.label}),title:`Watch: ${e.label}`,"aria-label":`Watch: ${e.label}`,"data-testid":`guide-watch`,className:`flex flex-none items-center gap-1.5 border-l border-border px-4 text-xs font-semibold text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground`,children:[(0,G.jsx)(pr,{className:`size-3.5`}),`Watch`]})]},e.id))})]}),u]})}var E1=`22rem`,D1=`42rem`,O1=`20rem`,k1=`calc(100dvh - var(--canvas-sticky-top) - 2rem)`;function A1(e){return{editorWidth:e||`50%`,editorMinWidth:E1,editorMaxWidth:D1,editorMinHeight:O1,editorMaxHeight:k1}}function j1(e){let t=Math.max(1,e.split(`
@@ -496,4 +496,4 @@ Fran went unbroken until round three. Throat on fire.
496
496
  `,k9]})]})}var kne=`✎`;function Ane({wql:e,setWql:t}){let[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(e);return(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(j9,{wql:e}),!n&&(0,G.jsx)(`button`,{onClick:()=>{a(e),r(!0)},className:`absolute top-2 right-2 text-muted-foreground hover:text-foreground text-xs px-1.5 py-0.5 rounded hover:bg-muted`,children:kne})]}),n&&(0,G.jsxs)(`div`,{className:`rounded-lg border border-sky-500/50 bg-card p-3 space-y-2 shadow-lg shadow-sky-500/5`,children:[(0,G.jsx)(`div`,{className:`text-[10px] text-sky-400 font-mono`,children:`editing query:table — Apply writes the fence`}),(0,G.jsx)(eT,{query:i,onQueryChange:a,autoFocus:!0,placeholder:`:session…`}),(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(`button`,{onClick:()=>r(!1),className:`px-3 py-1 text-xs rounded-md border border-border text-muted-foreground hover:text-foreground`,children:`Cancel`}),(0,G.jsx)(`button`,{onClick:()=>{t(i),r(!1)},className:`px-3 py-1 text-xs rounded-md bg-sky-500 text-zinc-950 font-medium`,children:`Apply to fence`})]})]})]})}function jne({wql:e,setWql:t}){let[n,r]=(0,W.useState)(!1);return(0,G.jsxs)(`div`,{className:`space-y-3 pb-24`,children:[(0,G.jsx)(`button`,{onClick:()=>r(!0),className:`block w-full text-left rounded-lg transition-shadow ${n?`ring-2 ring-sky-500/70`:`hover:ring-1 hover:ring-border`}`,children:(0,G.jsx)(j9,{wql:e})}),(0,G.jsxs)(`div`,{className:`sticky bottom-20 rounded-xl border p-3 space-y-2 shadow-xl backdrop-blur transition-colors ${n?`border-sky-500/60 bg-card/95`:`border-border bg-card/80 opacity-70`}`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-mono ${n?`text-sky-400`:`text-muted-foreground`}`,children:n?`◉ bound: query:table · ${D9.slice(0,8)}…`:`○ click a query block to bind the composer`}),n&&(0,G.jsx)(`button`,{onClick:()=>r(!1),className:`text-[10px] text-muted-foreground hover:text-foreground`,children:`Done`})]}),n&&(0,G.jsx)(eT,{query:e,onQueryChange:t,autoFocus:!0,showDiagnostics:!1,placeholder:`:session…`})]})]})}function Mne({wql:e,setWql:t}){let[n,r]=(0,W.useState)(!1);return(0,W.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),n?(0,G.jsxs)(`div`,{className:`rounded-lg border border-sky-500/50 bg-muted/60 shadow-lg shadow-sky-500/5`,children:[(0,G.jsx)(`div`,{className:`px-3 pt-2 text-[10px] font-mono text-muted-foreground select-none`,children:"```query:table"}),(0,G.jsx)(`div`,{className:`px-3 py-2`,children:(0,G.jsx)(eT,{query:e,onQueryChange:t,autoFocus:!0,showDiagnostics:!1,placeholder:`:session…`,className:`bg-transparent border-0 shadow-none`})}),(0,G.jsxs)(`div`,{className:`px-3 pb-2 flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-mono text-muted-foreground select-none`,children:"```"}),(0,G.jsx)(`button`,{onClick:()=>r(!1),className:`text-[10px] text-sky-400 hover:text-sky-300 font-mono`,children:`Esc / leave fence ↩`})]})]}):(0,G.jsx)(`button`,{onClick:()=>r(!0),className:`block w-full text-left hover:ring-1 hover:ring-border rounded-lg`,children:(0,G.jsx)(j9,{wql:e})})}var N9=[[`inline`,`A · in-flow expansion`],[`dock`,`B · bound dock`],[`fence`,`C · fence-as-composer`]];function Nne(){let[e,t]=Rt(),n=e.get(`v`)??`inline`,[r,i]=(0,W.useState)(Tne),a=e=>{let r=N9[(N9.findIndex(([e])=>e===n)+e+N9.length)%N9.length][0];t({v:r})};return(0,W.useEffect)(()=>{let e=e=>{e.target.closest(`input, textarea, [contenteditable]`)||(e.key===`ArrowLeft`&&a(-1),e.key===`ArrowRight`&&a(1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),(0,G.jsxs)(`div`,{className:`min-h-screen bg-background text-foreground p-6`,children:[(0,G.jsxs)(`div`,{className:`max-w-5xl mx-auto grid grid-cols-[1fr_320px] gap-6 items-start`,children:[(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-[11px] text-amber-500 mb-1`,children:`PROTOTYPE — throwaway · query:table editing via WqlComposer`}),(0,G.jsx)(`h1`,{className:`text-xl font-bold`,children:`Journal — 2026-09-13`})]}),(0,G.jsx)(M9,{children:O9.split("```time")[0].trim()}),(0,G.jsx)(Dne,{}),n===`inline`&&(0,G.jsx)(Ane,{wql:r,setWql:i}),n===`dock`&&(0,G.jsx)(jne,{wql:r,setWql:i}),n===`fence`&&(0,G.jsx)(Mne,{wql:r,setWql:i}),(0,G.jsx)(M9,{children:k9})]}),(0,G.jsx)(`div`,{className:`sticky top-6`,children:(0,G.jsx)(One,{wql:r})})]}),(0,G.jsxs)(`div`,{className:`fixed bottom-4 left-1/2 -translate-x-1/2 flex items-center gap-1 rounded-xl border border-border bg-card/95 backdrop-blur px-2 py-1.5 shadow-2xl z-50`,children:[(0,G.jsx)(`button`,{onClick:()=>a(-1),className:`px-2 text-muted-foreground hover:text-foreground`,children:`←`}),N9.map(([e,r])=>(0,G.jsx)(`button`,{onClick:()=>t({v:e}),className:`px-3 py-1 rounded-lg text-xs transition-colors ${n===e?`bg-sky-400 text-zinc-950 font-medium`:`text-muted-foreground hover:text-foreground`}`,children:r},e)),(0,G.jsx)(`button`,{onClick:()=>a(1),className:`px-2 text-muted-foreground hover:text-foreground`,children:`→`})]})]})}function P9(e,t,n=`absent`){return{id:e,fields:t,missPolicy:n,get:()=>void 0}}function Pne(){let e=new Ap;return e.register(P9(`effort`,{met:{dimension:Y,type:`number`},disciplineFactor:{dimension:Y,type:`number`},discipline:{dimension:Y,type:`string`},intensityTier:{dimension:Y,type:`string`},resolvedFrom:{dimension:Y,type:`string`}},`default-row`)),e.register(P9(`rpe-labels`,{rpe:{dimension:Y,type:`number`}})),e.register(P9(`profile`,{vo2max:{dimension:Y,type:`number`}})),e.register(P9(`disciplines`,{disciplineFactor:{dimension:Y,type:`number`}},`default-row`)),e}function Fne(e,t){for(let n of t)try{e.register(n)}catch{}}function F9(e,t=`segment`){let n=[],r=[];try{let i=Vd(e,{scope:t});r=i.defs;for(let e of i.warnings)n.push({severity:`warning`,message:e})}catch(e){return{defs:r,diagnostics:[{severity:`error`,message:e instanceof Error?e.message:String(e)}],dim:void 0,compound:void 0}}let i=new mp(Pne());Fne(i,[...Np,...Lp]);let a;for(let e of r){try{i.register(e)}catch(e){n.push({severity:`error`,message:e instanceof Error?e.message:String(e)});continue}let t=$d(e)??(e.kind===`library`?Object.keys(e.variants[0]?.nodes??{})[0]:void 0),r=[...e.variants].sort((e,t)=>t.priority-e.priority)[0],o=t&&r.nodeDims?.[t];o&&(a=o)}let o;return a&&(o=fd(a)),r.length===0&&n.push({severity:`warning`,message:`No calc line parsed.`}),{defs:r,diagnostics:n,dim:a,compound:o}}var Ine=[`segment`,`workout`,`store`],I9=[`when`,`where`,`key`,`grouped`,`label`,`emit`,`meta`,`estimated`,`library`,`on`,`by`,`without`,`and`,`or`,`not`],L9=[`convert`,`lookup`,`has`,`round`,`floor`,`ceil`,`abs`,`clamp`,`min`,`max`,`sum`,`avg`,`count`,`last`,`windowMean`,`windowSum`,`windowSd`,`mean`],R9=[{name:`elapsed`,dim:pd.elapsed.dim,detail:`s (time)`},{name:`reps`,dim:pd.reps.dim,detail:`count`},{name:`resistance`,dim:pd.resistance.dim,detail:`kg (mass)`},{name:`distance`,dim:pd.distance.dim,detail:`m (length)`},{name:`effort`,dim:md.effort,detail:`resolved effort slug`},{name:`effortLabel`,dim:md.effortLabel,detail:`raw effort label`}],z9=[{name:`sessionRpe`,dim:md.sessionRpe,detail:`captured session RPE`},{name:`session.duration`,dim:md[`session.duration`],detail:`workout duration`},{name:`profile.vo2max`,dim:md[`profile.vo2max`],detail:`user VO₂max (mL/kg/min)`}],B9=Object.keys(pd),Lne=Object.keys(hd),V9=[{name:`effort`,detail:`effort library`,fields:[`met`,`disciplineFactor`,`discipline`,`intensityTier`,`resolvedFrom`]},{name:`rpe-labels`,detail:`effort label → RPE`,fields:[`rpe`]},{name:`profile`,detail:`user profile`,fields:[`vo2max`]},{name:`disciplines`,detail:`canonical disciplines`,fields:[`disciplineFactor`]}],H9=Object.keys(yd),Rne=Object.keys(hd);function zne(e){return e?H9.filter(t=>{let n=yd[t];return n?n.dim.every((t,n)=>t===e[n]):!1}):H9}var Bne=new Set([...I9,...Ine,`lookup`]),Vne=new Set(L9),Hne=new Set([...R9.map(e=>e.name),...z9.map(e=>e.name),...B9,...V9.map(e=>e.name)]),Une=/^\d*\.?\d+(?:d)?/,Wne=/^[A-Za-z_][\w.]*/,Gne=Tr.define({name:`calcLine`,token(e){if(e.eatSpace())return null;if(e.match(`#`,!1))return e.skipToEnd(),`comment`;if(e.match(/^"([^"]*)"/)||e.match(/^'([^']*)'/))return`string`;if(e.match(/^(->|==|!=|<=|>=)/)||e.match(/^[+\-*/=<>(),:{}[\]]/))return`operator`;if(e.match(Une))return`number`;if(e.match(Wne)){let t=e.current();return Bne.has(t)?`keyword`:Vne.has(t)?`function`:(Hne.has(t),`variableName`)}return e.next(),null}}),Kne=Mr.define([{tag:U.keyword,color:`#c084fc`},{tag:U.function(U.variableName),color:`#60a5fa`},{tag:U.variableName,color:`#e4e4e7`},{tag:U.number,color:`#fbbf24`},{tag:U.string,color:`#34d399`},{tag:U.operator,color:`#a1a1aa`},{tag:U.comment,color:`#71717a`,fontStyle:`italic`}]);function qne(){return new Fr(Gne,[jr(Kne)])}var Jne=[`effort`,`thruster`,`push-press`,`front-squat`,`wall-ball`,`row`,`run`];function U9(e,t){return`${t?``:`"`}${e}"`}function Yne(e={}){let t=e.scope??`segment`,n=()=>{let t=e.effortKeys?.().filter(Boolean)??[];return[`effort`,...t.length?t:Jne.slice(1)]};return e=>{let r=e.state.sliceDoc(0,e.pos),i=e.matchBefore(/[\w./"]*/);if(!i)return null;if(/lookup\(\s*/.test(r)){let t=r.lastIndexOf(`lookup(`),i=r.slice(t+7);if(!/,/.test(i)&&/^"?[\w.-]*"?$/.test(i.replace(/"/g,``).trim()||``)){let t=i.replace(/"/g,``).trim(),n=i.trimStart().startsWith(`"`),r=V9.filter(e=>e.name.startsWith(t)).map(e=>({label:e.name,apply:U9(e.name,n),detail:e.detail}));if(r.length)return{from:e.pos-t.length,to:e.pos+ +(e.state.sliceDoc(e.pos,e.pos+1)===`"`),options:r,validFor:/^[\w.-]*$/}}let a=/lookup\(\s*"[^"]+"\s*,\s*[^,]+,\s*"?([\w-]*)"?$/.exec(r);if(a){let t=/lookup\(\s*"([^"]+)"/.exec(r)?.[1],n=V9.find(e=>e.name===t),i=e.pos-a[1].length,o=e.state.sliceDoc(i-1,i)===`"`,s=(n?.fields??[]).filter(e=>e.startsWith(a[1])).map(e=>({label:e,apply:U9(e,o),detail:`${t} field`}));return{from:i,to:e.pos+ +(e.state.sliceDoc(e.pos,e.pos+1)===`"`),options:s,validFor:/^[\w-]*$/}}let o=/lookup\(\s*"(effort)"\s*,\s*"?([\w.-]*)"?$/.exec(r);if(o){let t=n().filter(e=>e.startsWith(o[2])),r=e.pos-o[2].length,i=e.state.sliceDoc(r-1,r)===`"`,a=t.map(e=>({label:e,apply:e===`effort`?e:U9(e,i),detail:`effort key`}));return{from:r,to:e.pos+ +(e.state.sliceDoc(e.pos,e.pos+1)===`"`),options:a,validFor:/^[\w.-]*$/}}}let a=/->\s*([\w/]*)$/.exec(r);if(a){let n=e.state.doc.lineAt(e.pos).text,r=F9(n,t);if(!r.dim){let e=n.lastIndexOf(`->`);if(e>=0){let i=F9(n.slice(0,e),t);i.diagnostics.length===0&&(r=i)}}let i=r.diagnostics.length===0?r.dim:void 0,o=zne(i).filter(e=>e.startsWith(a[1])).map(e=>({label:e,detail:i?`matches inferred dimension`:`unit`}));return{from:e.pos-a[1].length,options:o,validFor:/^[\w/]*$/}}if(t===`store`){let e=/^(sum|avg|max|min|count|last):([\w.]*)$/.exec(i.text);if(e){let t=B9.filter(t=>t.startsWith(e[2])).map(e=>({label:e,detail:`metric key`}));return{from:i.from+i.text.indexOf(`:`)+1,options:t,validFor:/^[\w.]*$/}}}let o=[];if(t===`segment`)o.push(...R9.map(e=>({label:e.name,apply:e.name,detail:e.detail})));else if(o.push(...z9.map(e=>({label:e.name,apply:e.name,detail:e.detail}))),t===`workout`){for(let e of Lne)for(let t of[`reps`,`distance`,`segmentVolume`,`metMinutes`,`elapsed`,`effortRpe`])o.push({label:`${e}(${t})`,apply:`${e}(${t})`,detail:`aggregate`});o.push({label:`sum(reps, without: rest)`,apply:`sum(reps, without: rest)`,detail:`exclusion aggregate`})}o.push(...L9.map(e=>({label:`${e}()`,apply:`${e}()`,detail:`function`}))),t===`store`&&o.push(...Rne.map(e=>({label:`${e}:{}`,apply:`${e}:`,detail:`WQL atom`}))),o.push(...I9.map(e=>({label:e,apply:e===`when`?`when `:e,detail:`clause`}))),o.push({label:`estimated`,apply:`estimated`,detail:`variant origin`}),o.push({label:`(library)`,apply:`(library)`,detail:`library calc`});let s=o.filter(e=>e.label.startsWith(i.text)).slice(0,20);return s.length?{from:i.from,options:s,validFor:/^[\w./]*$/}:null}}function Xne(e){return Kr({override:[Yne(e)],interactionDelay:0})}function Zne({value:e,onChange:t,scope:n=`segment`,placeholder:r,readOnly:i=!1,autoFocus:a=!1,className:o}){let s=(0,W.useRef)(null),c=(0,W.useRef)(null),l=(0,W.useRef)(t);return l.current=t,(0,W.useEffect)(()=>{let t=s.current;if(!t)return;c.current?.destroy();let r=Dr.updateListener.of(e=>{e.docChanged&&l.current(e.state.doc.toString())}),o=new Dr({state:ei.create({doc:e,extensions:[qne(),Xne({scope:n,effortKeys:()=>jO().list().map(e=>e.slug)}),Hw,Xr(),ui(),br.of([Qr,...Zr,...ai]),Dr.lineWrapping,ei.readOnly.of(i),r,Dr.theme({"&":{height:`auto`,minHeight:`120px`,fontSize:`13px`,border:`1px solid rgb(63 63 70)`,borderRadius:`8px`},".cm-scroller":{fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,lineHeight:`1.55`},".cm-content":{padding:`8px 4px`},".cm-gutters":{borderRight:`1px solid rgb(63 63 70)`,minWidth:`28px`},"&.cm-focused":{outline:`2px solid rgb(139 92 246 / 0.5)`,outlineOffset:`1px`}})]}),parent:t});return a&&requestAnimationFrame(()=>o.focus()),c.current=o,()=>o.destroy()},[n,i]),(0,W.useEffect)(()=>{let t=c.current;if(!t)return;let n=t.state.doc.toString();n!==e&&t.dispatch({changes:{from:0,to:n.length,insert:e}})},[e]),(0,G.jsx)(`div`,{ref:s,className:`calc-line-editor ${o??``}`,"data-testid":`calc-line-editor`})}function Qne({analysis:e}){let{dim:t,compound:n,diagnostics:r}=e,i=r.filter(e=>e.severity===`error`),a=r.filter(e=>e.severity===`warning`),o=i.length===0&&a.length===0&&t!==void 0;return(0,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/60 px-3 py-2 text-xs`,"data-testid":`calc-diagnostics`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[t?(0,G.jsxs)(`div`,{className:`text-muted-foreground`,children:[`computes `,(0,G.jsx)(`b`,{className:`text-foreground`,children:$ne(t)}),n&&(0,G.jsxs)(`span`,{className:`text-purple-400 dark:text-purple-300`,children:[` → `,n]})]}):!o&&(0,G.jsx)(`div`,{className:`text-muted-foreground`,children:`dimension unknown`}),o&&(0,G.jsx)(`span`,{className:`text-signal-positive`,children:`✓ valid`})]}),i.map((e,t)=>(0,G.jsxs)(`div`,{className:`text-destructive`,children:[`⚠ `,e.message]},`e-${t}`)),a.map((e,t)=>(0,G.jsxs)(`div`,{className:`text-signal-caution`,children:[`⚠ `,e.message]},`w-${t}`)),i.length===0&&a.length===0&&t===void 0&&(0,G.jsx)(`div`,{className:`text-muted-foreground`,children:`Type a calc line to see diagnostics.`})]})}var W9=[[`L`,`length`],[`M`,`mass`],[`T`,`time`],[`C`,`count`],[`E`,`energy`]];function $ne(e){let t=[];return e.forEach((e,n)=>{e!==0&&t.push(e===1?W9[n][1]:`${W9[n][1]}${e}`)}),t.length?t.join(`·`):`dimensionless`}function G9(e){return new ua({outputType:e.outputType,timeSpan:e.timeSpan,sourceBlockKey:e.sourceBlockKey,stackLevel:e.stackLevel,sourceStatementId:e.sourceStatementId,line:e.line,text:e.text,dialect:e.dialect,metrics:e.metrics,parent:e.parent,completionReason:e.completionReason})}function K9(e){return{...e,metrics:e.metrics.filter(e=>e.origin!==`analyzed`)}}function ere(e){return e.output?.emitType??e.output?.key??e.id}function tre(e,t){for(let n of e){if(n.outputType!==`analytics`||!(n.metrics.find(e=>e.type?.toLowerCase()===`label`&&String(e.value)===t)??n.metrics.find(e=>String(e.value)===t)))continue;let e=n.metrics.find(e=>typeof e.value==`number`);if(e)return{value:e.value,unit:e.unit,origin:e.origin}}}function q9(e){return String(Number.isInteger(e)?e:Math.round(e*100)/100)}function J9(e,t,n){return Jp(e,{userProfile:t.vo2max===void 0?void 0:{vo2max:t.vo2max},calcs:n}).engine}function nre(e){let t=[],n=e.defs[0];if(!n)return{rows:[],errors:[`No calc line to preview.`]};let r=ere(n),i=e.logs.filter(e=>e.outputType===`segment`);if(e.scope===`segment`){let n=J9(e.block,e,e.defs),a=[];for(let e of i){let t=n.run(G9(K9(e))).metrics.rawMetrics.find(e=>e.type===r);if(!t){a.push(null);continue}let i=typeof t.value==`number`?t.value:NaN;if(!Number.isFinite(i)){a.push(null);continue}a.push({label:e.metrics.find(e=>e.type===`effort-data`)?.value?.label??`segment`,text:q9(i),unit:t.unit,estimated:t.origin===`analyzed-estimated`,raw:i})}return{rows:a,errors:t}}if(e.scope===`workout`){let n=i.map(K9),a=[];for(let t=1;t<=n.length;t++){let i=J9(e.block,e,e.defs);for(let e=0;e<t;e++)i.run(G9(n[e]));let o=tre(i.finalize(),r),s=o&&typeof o.value==`number`?o.value:NaN;o&&Number.isFinite(s)?a.push({label:`after line ${t}`,text:q9(s),unit:o.unit,estimated:o.origin===`analyzed-estimated`,raw:s}):a.push(null)}return{rows:a,errors:t}}return rre(n,t)}var Y9=[420,0,380,510,0,290,610,450,0,520,340,0,480,390,560,0,410,470,0,530,360,440,0,500,580,320,0,460];function rre(e,t){let n=[],r=e.variants[0]?.nodes[$d(e)??`value`]?.expression??``,i=e=>e.reduce((e,t)=>e+t,0)/e.length,a=e=>{let t=i(e);return Math.sqrt(i(e.map(e=>(e-t)**2)))},o=(e,t)=>Y9.map((n,r)=>r+1>=e?t(Y9.slice(r+1-e,r+1)):NaN),s=o(7,i),c=o(28,i),l=o(7,a),u=o(7,e=>e.reduce((e,t)=>e+t,0)),d=r.includes(`windowSd`)||r.length===0?s.map((e,t)=>e/l[t]):s.map((e,t)=>e/c[t]);return ire(r.includes(`windowSum`)||r.includes(` * sum`)?u:d,n),{rows:[],series:n,errors:t}}function ire(e,t){for(let n of e.slice(-7))t.push(Number.isNaN(n)?null:Number(Math.round(n*100)/100))}var are=[{label:`Thruster`,slug:`thruster`,met:8.5,discipline:`strength`,elapsedMs:15e4,reps:21,resistanceKg:43},{label:`Pull-up`,slug:`pull-up`,met:7,discipline:`gymnastics`,elapsedMs:12e4,reps:21,resistanceKg:0},{label:`Thruster`,slug:`thruster`,met:8.5,discipline:`strength`,elapsedMs:15e4,reps:15,resistanceKg:43},{label:`Pull-up`,slug:`pull-up`,met:7,discipline:`gymnastics`,elapsedMs:12e4,reps:15,resistanceKg:0},{label:`Thruster`,slug:`thruster`,met:8.5,discipline:`strength`,elapsedMs:15e4,reps:9,resistanceKg:43},{label:`Pull-up`,slug:`pull-up`,met:7,discipline:`gymnastics`,elapsedMs:12e4,reps:9,resistanceKg:0}];function ore(e){return{type:`effort-data`,origin:`analyzed`,value:{slug:e.slug,label:e.label,aliases:[],baseAttributes:{met:e.met,discipline:e.discipline},registrySource:`bundled`}}}function sre(e,t){let n=[ore(e)];return n.push({type:`elapsed`,value:e.elapsedMs,origin:`runtime`}),e.reps!==void 0&&n.push({type:`rep`,value:e.reps,origin:`runtime`}),e.resistanceKg!==void 0&&n.push({type:`resistance`,value:e.resistanceKg,origin:`runtime`}),PA(new ua({outputType:`segment`,timeSpan:{started:t*1e3,ended:t*1e3+e.elapsedMs},sourceBlockKey:`preview-block`,stackLevel:1,metrics:n}))}function cre(){return{id:`preview-block`,dialect:`time`,startLine:0,endLine:10,content:"```time\nFran preview\n```",state:`idle`,widgetIds:{},version:1,createdAt:0}}var lre=are.map((e,t)=>sre(e,t+1)),ure=cre();function dre(e){return e==null?`—`:String(e)}function fre({scope:e,analysis:t,vo2max:n}){let r=(0,W.useMemo)(()=>t.defs.filter(()=>t.diagnostics.length===0),[t]),i=r[0],a=(0,W.useMemo)(()=>{if(i)return nre({logs:lre,block:ure,defs:r,scope:e,vo2max:n})},[i,e,n]);return(0,G.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/60 p-3 text-xs`,"data-testid":`calc-preview`,children:[(0,G.jsxs)(`div`,{className:`mb-2 text-[11px] uppercase tracking-wide text-muted-foreground`,children:[`Live preview — `,e===`store`?`last 7 of 28 fixture days`:`Fran (fixture)`]}),!i&&(0,G.jsx)(`div`,{className:`text-muted-foreground`,children:`Enter a valid calc line to see live results.`}),i&&a?.rows&&(0,G.jsxs)(`div`,{className:`space-y-1 font-mono`,children:[a.rows.length===0&&(0,G.jsx)(`div`,{className:`text-muted-foreground`,children:`No applicable segments.`}),a.rows.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex justify-between text-foreground`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:e?e.label:`segment ${t+1}`}),(0,G.jsx)(`span`,{className:e?`text-sky-300 dark:text-sky-400`:`text-muted-foreground`,children:e?`${e.text}${e.unit?` ${e.unit}`:``}${e.estimated?` (est.)`:``}`:`—`})]},t))]}),i&&a?.series&&(0,G.jsx)(`div`,{className:`space-y-1 font-mono`,children:a.series.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex justify-between text-foreground`,children:[(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`D-`,6-t]}),(0,G.jsx)(`span`,{className:`text-sky-300 dark:text-sky-400`,children:dre(e)})]},t))}),a?.errors?.length?a.errors.map((e,t)=>(0,G.jsxs)(`div`,{className:`text-destructive`,children:[`⚠ `,e]},`e-${t}`)):null]})}var pre=[`segment`,`workout`,`store`];function mre(e,t){let n=e[0]?.id;if(n)return n;let r=/^[\s\S]*?^\s*([A-Za-z_][\w.-]*)\s*=.*$/m.exec(t);return r?r[1]:`custom-${Date.now().toString(36)}`}function hre({defaultScope:e=`segment`,initialId:t}){let[n,r]=(0,W.useState)(`# ${e} calc line
497
497
  segmentVolume = reps * resistance (library) when has(reps) and has(resistance)
498
498
  `),[i,a]=(0,W.useState)(e),[o,s]=(0,W.useState)([]),[c,l]=(0,W.useState)(),u=(0,W.useMemo)(()=>F9(n,i),[n,i]),d=mre(u.defs,n),f=u.diagnostics.every(e=>e.severity!==`error`)&&u.defs.length>0,p=async()=>{s(await P5())};(0,W.useEffect)(()=>{p()},[]),(0,W.useEffect)(()=>{t&&(async()=>{let e=(await P5()).find(e=>e.id===t);e&&(r(e.lineForm),l(`Loaded "${e.id}".`))})()},[t]);let m=async()=>{if(!f){l(`Cannot save: fix the errors first.`);return}try{await F5({id:d,lineForm:n,updatedAt:Date.now()}),await p(),l(`Saved "${d}".`)}catch(e){console.error(`[CalcAuthoringPanel] save failed:`,e),l(`Save failed: ${e instanceof Error?e.message:String(e)}`)}},h=async e=>{try{await I5(e),await p(),l(`Deleted "${e}".`)}catch(e){console.error(`[CalcAuthoringPanel] delete failed:`,e),l(`Delete failed: ${e instanceof Error?e.message:String(e)}`)}},g=e=>{let t=/^\s*(segment|workout|store)\b/.exec(e.lineForm);t&&a(t[1]),r(e.lineForm),l(`Loaded "${e.id}".`)};return(0,G.jsxs)(`div`,{className:`space-y-3`,"data-testid":`calc-authoring-panel`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`Scope`}),(0,G.jsx)(`div`,{className:`flex gap-1`,children:pre.map(e=>(0,G.jsx)(`button`,{onClick:()=>a(e),className:`rounded px-2.5 py-1 text-xs font-medium transition-colors ${i===e?`bg-purple-600 text-white dark:bg-purple-700 dark:text-white`:`bg-muted text-muted-foreground hover:bg-muted/80`}`,children:e},e))}),(0,G.jsx)(`div`,{className:`ml-auto flex gap-2`,children:(0,G.jsx)(`button`,{onClick:m,disabled:!f,className:`rounded bg-signal-positive px-3 py-1 text-xs font-medium text-white dark:text-white disabled:opacity-40`,children:`Save`})})]}),(0,G.jsx)(Zne,{value:n,onChange:r,scope:i,autoFocus:!0}),(0,G.jsx)(Qne,{analysis:u}),(0,G.jsx)(fre,{scope:i,analysis:u}),c&&(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:c}),o.length>0&&(0,G.jsxs)(`div`,{className:`mt-2`,children:[(0,G.jsx)(`div`,{className:`mb-1 text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Saved user calcs`}),(0,G.jsx)(`ul`,{className:`divide-y divide-border rounded-lg border border-border`,children:o.map(e=>(0,G.jsxs)(`li`,{className:`flex items-center justify-between px-3 py-2 text-sm`,children:[(0,G.jsx)(`button`,{onClick:()=>g(e),className:`text-left font-mono text-purple-300 dark:text-purple-400 hover:underline`,children:e.id}),(0,G.jsx)(`button`,{onClick:()=>h(e.id),className:`text-xs text-muted-foreground hover:text-destructive`,children:`delete`})]},e.id))})]})]})}function gre(){let e=dn(),[t]=un(`zip`),[n]=un(`z`),[r]=(0,W.useState)(()=>{let e=window.location.search;return e.includes(`zip=`)||e.includes(`z=`)});return(0,W.useEffect)(()=>{!t&&!n&&!r&&e(`/`,{replace:!0})},[t,n,e,r]),(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`})}async function X9(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 Z9(){let e=dn(),t=En(),{date:n}=Ut(),[r]=un(`zip`),[i,a]=(0,W.useState)({state:`loading`});return(0,W.useEffect)(()=>{if(!(t.pathname===`/load/journal`||t.pathname.startsWith(`/load/journal/`)))return;if(!r){e($.journal,{replace:!0});return}let i=!1,o=async()=>{try{a({state:`loading`});let t;try{t=await X9(r)}catch(e){console.error(`Failed to decode zip:`,e),a({state:`error`,error:`Failed to decode the journal entry`,onRetry:()=>{o()}}),Q({title:`Error`,description:`Failed to decode the journal entry. Please check the link.`,variant:`destructive`});return}if(i)return;let c;if(n){let t=gF(n);if(!t){a({state:`error`,error:`Invalid date format`}),Q({title:`Error`,description:`Invalid date format. Expected YYYY-MM-DD.`,variant:`destructive`}),e($.journal,{replace:!0});return}c=t.dateKey}else c=mF();if(i)return;if(hF(c)){a({state:`pending-confirmation`,content:t,dateKey:c,onConfirmBackdate:async()=>{i||await s(t,c)}});return}await s(t,c)}catch(e){console.error(`Unexpected error in journal zip processor:`,e),i||(a({state:`error`,error:`An unexpected error occurred`,onRetry:()=>{o()}}),Q({title:`Error`,description:`An unexpected error occurred.`,variant:`destructive`}))}},s=async(t,n)=>{if(!i)try{a({state:`creating`});let r=await bF.create({journalDate:n,title:n,rawContent:t});i||(a({state:`success`,content:t,dateKey:n}),e(BP(r.id),{replace:!0}))}catch(e){console.error(`Failed to create journal entry:`,e),i||(a({state:`error`,error:`Failed to create journal entry`,onRetry:()=>{s(t,n)}}),Q({title:`Error`,description:`Failed to create journal entry.`,variant:`destructive`}))}};return o(),()=>{i=!0}},[r,n,e]),i}var _re=({selectedDate:e,onImportToday:t,onDateSelect:n,entryDates:r,isLoading:i=!1,className:a})=>{let[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(!1),{triggerRef:u,align:d,recompute:f}=r2(`end`),p=async()=>{l(!0);try{await t()}finally{l(!1)}},m=async e=>{l(!0),s(!1);try{await n(e)}finally{l(!1)}},g=e=>{e&&f(),s(e)},_=e?Lb(e):`Date`,v=i||c;return(0,G.jsxs)(`div`,{className:K(`inline-flex items-stretch rounded-lg overflow-hidden border border-border/70`,`bg-muted text-muted-foreground shadow-sm hover:shadow-md transition-shadow font-medium`,`text-xs`,a),children:[(0,G.jsxs)(`button`,{type:`button`,title:`Import to today's journal`,onClick:p,disabled:v,className:K(`flex items-center gap-2 px-3 py-2 transition-colors`,`hover:bg-accent hover:text-accent-foreground`,v&&`opacity-60 cursor-not-allowed`),children:[c?(0,G.jsx)(`span`,{className:`inline-block animate-spin`,children:`⏳`}):(0,G.jsx)(cn,{className:`h-4 w-4 shrink-0`}),(0,G.jsx)(`span`,{children:`Import Today`})]}),(0,G.jsx)(`div`,{className:`w-px bg-border/60 self-stretch`}),(0,G.jsxs)(qV,{open:o,onOpenChange:g,children:[(0,G.jsx)(JV,{asChild:!0,children:(0,G.jsxs)(`button`,{ref:e=>{u.current=e},type:`button`,title:`Select a date to plan for the future`,className:K(`flex items-center gap-1.5 px-2.5 py-2 transition-colors`,`hover:bg-accent hover:text-accent-foreground`,e&&`text-primary`,v&&`opacity-60 cursor-not-allowed`),disabled:v,children:[(0,G.jsx)(h,{className:`h-4 w-4 shrink-0`}),e&&(0,G.jsx)(`span`,{className:`leading-none text-xs`,children:_})]})}),(0,G.jsx)(YV,{align:d,className:`p-0 w-auto`,children:(0,G.jsx)(I0,{selectedDate:e||null,onDateSelect:m,entryDates:r})})]})]})},vre=({dateKey:e,onConfirm:t,onCancel:n,isLoading:r=!1})=>{let[i,a]=W.useState(!1),o=Ib(new Date(`${e}T00:00:00`));return(0,G.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,className:`fixed inset-0 z-50 flex items-center justify-center`,onKeyDown:e=>{e.key===`Escape`&&n()},onClick:e=>{e.target===e.currentTarget&&n()},children:[(0,G.jsx)(`div`,{className:`absolute inset-0 bg-black/50 animate-in fade-in`}),(0,G.jsx)(`div`,{className:`relative z-10 w-full max-w-sm mx-auto px-4 animate-in zoom-in-95 fade-in`,children:(0,G.jsxs)(`div`,{className:`bg-background rounded-lg border border-border shadow-lg`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-border`,children:[(0,G.jsx)(`h2`,{className:`text-base font-semibold`,children:`Backdate Journal Entry`}),(0,G.jsx)(`button`,{onClick:n,className:`p-1 text-muted-foreground hover:text-foreground hover:bg-muted rounded transition-colors`,"aria-label":`Close modal`,children:(0,G.jsx)(yr,{className:`h-4 w-4`})})]}),(0,G.jsxs)(`div`,{className:`px-6 py-4 space-y-4`,children:[(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The date you selected is in the past.`}),(0,G.jsxs)(`p`,{className:`text-sm`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`Import to: `}),(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:o})]}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`This will create a journal entry for the selected date. Are you sure you want to proceed?`})]}),(0,G.jsxs)(`div`,{className:`px-6 py-4 border-t border-border flex gap-2 justify-end`,children:[(0,G.jsx)(q,{variant:`outline`,onClick:n,disabled:r||i,children:`Cancel`}),(0,G.jsx)(q,{onClick:async()=>{a(!0);try{await t()}finally{a(!1)}},disabled:r||i,className:K(r||i?`opacity-70`:``),children:i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`inline-block animate-spin mr-2`,children:`⏳`}),`Importing...`]}):`Confirm & Import`})]})]})})]})},yre={h1:({children:e})=>(0,G.jsx)(`h1`,{className:`text-3xl font-bold mt-8 mb-4 first:mt-0 text-foreground`,children:e}),h2:({children:e})=>(0,G.jsx)(`h2`,{className:`text-2xl font-bold mt-6 mb-3 text-foreground`,children:e}),h3:({children:e})=>(0,G.jsx)(`h3`,{className:`text-xl font-semibold mt-5 mb-2 text-foreground`,children:e}),h4:({children:e})=>(0,G.jsx)(`h4`,{className:`text-lg font-semibold mt-4 mb-2 text-foreground`,children:e}),h5:({children:e})=>(0,G.jsx)(`h5`,{className:`text-base font-semibold mt-3 mb-1 text-foreground`,children:e}),h6:({children:e})=>(0,G.jsx)(`h6`,{className:`text-sm font-semibold mt-2 mb-1 text-muted-foreground`,children:e}),p:({children:e})=>(0,G.jsx)(`p`,{className:`text-sm leading-relaxed mb-4 text-muted-foreground`,children:e}),strong:({children:e})=>(0,G.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e}),em:({children:e})=>(0,G.jsx)(`em`,{className:`italic text-muted-foreground`,children:e}),ul:({children:e})=>(0,G.jsx)(`ul`,{className:`list-disc list-inside space-y-1 mb-4 text-sm text-muted-foreground`,children:e}),ol:({children:e})=>(0,G.jsx)(`ol`,{className:`list-decimal list-inside space-y-1 mb-4 text-sm text-muted-foreground`,children:e}),li:({children:e})=>(0,G.jsx)(`li`,{className:`ml-2`,children:e}),code:({children:e,className:t})=>t?null:(0,G.jsx)(`code`,{className:`px-1.5 py-0.5 rounded bg-muted text-primary font-mono text-xs`,children:e}),pre:({children:e})=>(0,G.jsx)(`pre`,{className:`bg-muted rounded-lg p-4 overflow-x-auto mb-4 text-xs font-mono text-muted-foreground border border-border`,children:e}),blockquote:({children:e})=>(0,G.jsx)(`blockquote`,{className:`border-l-4 border-primary/30 pl-4 py-2 mb-4 italic text-muted-foreground text-sm`,children:e}),a:({href:e,children:t})=>(0,G.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary hover:underline font-medium`,children:t}),table:({children:e})=>(0,G.jsx)(`div`,{className:`my-4 overflow-x-auto rounded border border-border`,children:(0,G.jsx)(`table`,{className:`w-full text-xs`,children:e})}),thead:({children:e})=>(0,G.jsx)(`thead`,{className:`bg-muted/50`,children:e}),tbody:({children:e})=>(0,G.jsx)(`tbody`,{className:`divide-y divide-border/50`,children:e}),tr:({children:e})=>(0,G.jsx)(`tr`,{className:`hover:bg-muted/20 transition-colors`,children:e}),th:({children:e})=>(0,G.jsx)(`th`,{className:`px-3 py-2 text-left font-semibold text-foreground text-xs`,children:e}),td:({children:e})=>(0,G.jsx)(`td`,{className:`px-3 py-2 text-muted-foreground`,children:e}),hr:()=>(0,G.jsx)(`hr`,{className:`my-6 border-border/50`})};function Q9(){let e=dn(),t=Z9(),[n,r]=(0,W.useState)(!1),[i,a]=(0,W.useState)(null),{state:o,content:s,dateKey:c,error:l,onConfirmBackdate:u,onRetry:d}=t;return(0,G.jsxs)(`div`,{className:`flex flex-col h-screen bg-background`,children:[(0,G.jsxs)(`div`,{className:`border-b border-border/50 bg-muted/30 px-6 py-4 flex items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`button`,{onClick:()=>{e(-1)},className:`p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,title:`Go back`,children:(0,G.jsx)($t,{className:`h-5 w-5`})}),(0,G.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Import Journal Entry`})]}),o===`loading`?(0,G.jsxs)(`div`,{className:`text-xs text-muted-foreground flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`inline-block animate-spin`,children:`⏳`}),`Preparing preview...`]}):o===`error`?(0,G.jsx)(q,{variant:`outline`,size:`sm`,onClick:d,children:`Retry`}):o===`pending-confirmation`||o===`creating`?null:(0,G.jsx)(_re,{selectedDate:i,onImportToday:async()=>{u&&await u()},onDateSelect:async e=>{a(e);let t=new Date;t.setHours(0,0,0,0);let n=new Date(e);n.setHours(0,0,0,0),n<t?r(!0):u&&await u()},isLoading:o===`creating`})]}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-6`,children:[o===`loading`&&(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:[(0,G.jsx)(`div`,{className:`animate-spin`,children:`⏳`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Loading preview...`})]}),o===`error`&&(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:[(0,G.jsx)(`div`,{className:`bg-destructive/10 border border-destructive/50 rounded-lg p-4 max-w-md`,children:(0,G.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,G.jsx)(Dt,{className:`h-5 w-5 text-destructive mt-0.5 shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold text-foreground`,children:`Error Loading Preview`}),(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:l||`Failed to decode the zip content`})]})]})}),(0,G.jsx)(q,{onClick:d,variant:`outline`,children:`Try Again`})]}),o===`pending-confirmation`&&(0,G.jsx)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:(0,G.jsxs)(`div`,{className:`text-center`,children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-foreground mb-2`,children:`Backdate Confirmation Required`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm mb-4`,children:`This date is in the past. Please confirm to proceed.`})]})}),o===`creating`&&(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:[(0,G.jsx)(`div`,{className:`animate-spin`,children:`⏳`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Creating journal entry...`})]}),o===`success`&&(0,G.jsx)(`div`,{className:`flex flex-col items-center justify-center min-h-96 gap-4`,children:(0,G.jsxs)(`div`,{className:`text-center`,children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-foreground mb-2`,children:`✓ Entry Created`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Redirecting...`})]})}),o===`loading`||o===`error`||o===`pending-confirmation`||o===`creating`||o===`success`?null:s?(0,G.jsx)(`article`,{className:`prose prose-sm max-w-2xl mx-auto`,children:(0,G.jsx)(hn,{remarkPlugins:[Hn],components:yre,children:s})}):null]}),n&&c&&(0,G.jsx)(vre,{dateKey:c,onConfirm:async()=>{u&&(r(!1),await u())},onCancel:()=>r(!1),isLoading:o===`creating`})]})}function bre(){let e=En(),t=dn();return(0,W.useEffect)(()=>{let n=new URLSearchParams(e.search).get(`source`);t(n?`${$.notebooks}?feed=${encodeURIComponent(n)}`:$.notebooks,{replace:!0})},[e.search,t]),(0,G.jsx)(`div`,{className:`p-8 text-center text-xs text-muted-foreground`,"data-testid":`feed-subscription-intake`,children:`Redirecting to Library…`})}async function xre(e,t,n){let r=await Z.getNote(e);if(!r)return;let i=`:session{result:${n}}`;if(r.rawContent.includes(i))return;let a=Object.values(r.blocks??{}).find(e=>e.id===t);if(!a||a.to==null)return;let o=`${r.rawContent.slice(0,a.to)}\n\n\`\`\`query:table\n${i}\n\`\`\`${r.rawContent.slice(a.to)}`;await new Pk().updateRecord(r.id,{rawContent:o,expectedSourceRevision:r.sourceRevision})}function Sre(){let{runtimeId:e}=Ut(),t=dn(),n=(0,W.useRef)(e?B0.get(e):void 0),r=(0,W.useRef)(null),i=(0,W.useCallback)(async()=>{let t=n.current;if(!t||!e)throw Error(`The pending workout is unavailable.`);return t.captured?(r.current=t.captured,t.captured.block):(r.current||=t.snapshot?await Ij(t.snapshot,t.block,e,t.origin):await Lj(t.noteId,t.block,e,t.origin),r.current.block)},[e]);(0,W.useEffect)(()=>{e&&B0.delete(e)},[e]);let a=n.current,o=(0,W.useRef)(!1),s=(0,W.useCallback)((t,n)=>!n||!e||!a?Promise.reject(Error(`Run cannot be saved — its session data or runtime id is missing.`)):(o.current=n.completed,Wj.record({runBlock:a.block,blockId:a.block.id,noteId:a.noteId,resultId:e,data:n,createdAt:n.endTime||Date.now(),...a.origin?{origin:a.origin}:{}}).then(async()=>{if(n.completed)try{await xre(a.noteId,a.block.id,e)}catch{}})),[e,a]),c=(0,W.useCallback)(()=>{if(!a){t(`/`);return}if(o.current){t(KP(e),{replace:!0});return}if(a.returnTo){t(a.returnTo,{replace:!0});return}t(m0(YI(a.noteId)),{replace:!0})},[e,a,t]);if(!a)return(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-red-400`,children:`Runtime not found. Please start the workout from the editor.`});let l=r.current?.note.rawContent??a.captured?.note.rawContent??a.snapshot?.rawContent;return(0,G.jsx)(pQ,{block:a.block,noteContent:l,prepareRun:i,onClose:c,onCompleteWorkout:s,resultId:e,autoStart:!0})}var $9=null;async function Cre(e){(!$9||$9.attempt!==e)&&($9={attempt:e,promise:dW(wW.content)});try{return await $9.promise}finally{$9?.attempt===e&&($9=null)}}function wre(){let e=dn(),[t,n]=(0,W.useState)(!1),[r,i]=(0,W.useState)(0);return(0,W.useEffect)(()=>{let t=!1;return(async()=>{try{let n=await Cre(r);t||e(LP(n),{replace:!0})}catch{t||n(!0)}})(),()=>{t=!0}},[e,r]),t?(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-3 text-zinc-300 px-4 text-center`,children:[(0,G.jsx)(`p`,{role:`alert`,children:`Unable to create a new playground note.`}),(0,G.jsx)(`button`,{type:`button`,className:`rounded border border-zinc-600 px-3 py-1 text-sm hover:bg-zinc-800`,onClick:()=>{n(!1),i(e=>e+1)},children:`Try again`})]}):(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`})}function Tre(){let e=dn(),t=En(),[n]=un(`zip`),[r]=un(`z`),[i]=un(`by`),[a]=un(`src`);(0,W.useEffect)(()=>{if(t.pathname!==`/load`&&!(t.pathname===`/`&&r))return;if(r){let t=!1;return(async()=>{try{let e=await X9(r);if(e===null)throw Error(`Invalid workout link`);if(t)return;let n=O2(e,i??void 0);if(await fW(n,{reuseKey:`home`,title:`Home playground`}),t)return;j2({content:n,by:i??void 0})}catch(e){console.error(`Failed to decode zip:`,e),t||Q({title:`Could not import workout`,description:`The link was invalid or the workout could not be saved.`,variant:`destructive`})}t||e(`/`,{replace:!0})})(),()=>{t=!0}}if(!n)return;let o=!1,s=a&&a.startsWith(`/`)?a:void 0;return(async()=>{try{let t=await X9(n);if(t===null)throw Error(`Invalid workout link`);if(o)return;let r=s?await dW(t,{sourcePath:s}):await dW(t);o||e(LP(r),{replace:!0})}catch(t){console.error(`Failed to decode zip:`,t),o||(Q({title:`Could not import workout`,description:`The link was invalid or the workout could not be saved.`,variant:`destructive`}),e($.home,{replace:!0}))}})(),()=>{o=!0}},[n,r,i,a,e,t.pathname])}function Ere(){let{pathname:e,hash:t}=En(),{scrollToSection:n}=aP();return(0,W.useEffect)(()=>{if(t){let e=t.slice(1);n(e);let r=setTimeout(()=>{n(e)},50);return()=>clearTimeout(r)}window.scrollTo(0,0)},[e,t]),null}function Dre(){return Tre(),Z9(),(0,W.useEffect)(()=>{_k.current().catch(console.error),sk(),M3(),Mj().catch(()=>{})},[]),null}function Ore({settling:e}){let t=A3();if(e){let e=U4(t);return(0,G.jsxs)(`div`,{role:`status`,className:`flex min-h-dvh flex-col items-center justify-center gap-2 text-muted-foreground`,children:[(0,G.jsx)(`span`,{children:t?H4(t):`Loading library…`}),e&&(0,G.jsx)(`span`,{className:`text-xs`,"data-testid":`boot-progress-detail`,children:e})]})}return(0,G.jsxs)(`div`,{role:`alert`,className:`flex min-h-dvh flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,G.jsx)(`p`,{className:`text-sm font-semibold`,children:`The library's routed content failed to load.`}),(0,G.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:`The feed corpus has not supplied this page. Re-running the feed import usually restores it.`}),(0,G.jsx)(q,{variant:`outline`,size:`sm`,"data-testid":`root-refeed`,onClick:()=>{mN().then(()=>nk())},children:`Re-import library`})]})}function kre(){let e=(0,W.useRef)(()=>{}),t=Sz(),n=k3(),r=(0,W.useMemo)(()=>GR(()=>e.current(),t),[t]);return(0,G.jsx)(Di,{defaultTheme:`system`,storageKey:`wod-wiki-playground-theme`,children:(0,G.jsx)(Ab,{children:(0,G.jsx)(AN,{children:(0,G.jsx)(NN,{children:(0,G.jsx)(ute,{children:(0,G.jsx)(bt,{children:(0,G.jsxs)(ree,{children:[(0,G.jsx)(Dre,{}),(0,G.jsx)(eP,{}),(0,G.jsxs)(sP,{tree:r,children:[(0,G.jsx)(Ere,{}),(0,G.jsxs)(Pt,{children:[(0,G.jsx)(Tt,{path:$.home,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:`*`,element:t.length===0?(0,G.jsx)(Ore,{settling:n===`preparing`||YM()&&n!==`error`}):(0,G.jsx)(dne,{})}),(0,G.jsx)(Tt,{path:`/proto/calc-authoring`,element:(0,G.jsx)(Cne,{})}),(0,G.jsx)(Tt,{path:`/proto/query-block-composer`,element:(0,G.jsx)(Nne,{})}),(0,G.jsx)(Tt,{path:`/settings`,element:(0,G.jsx)(Jn,{to:`/settings/appearance`,replace:!0})}),(0,G.jsx)(Tt,{path:`/settings/appearance`,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.settingsProfile,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.settingsData,element:(0,G.jsx)(Jn,{to:$.settingsStorage,replace:!0})}),(0,G.jsx)(Tt,{path:$.settingsDatabase,element:(0,G.jsx)(Jn,{to:$.settingsStorage,replace:!0})}),(0,G.jsx)(Tt,{path:$.settingsStorage,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.settingsSync,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:`/settings/system`,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.settingsQueries,element:(0,G.jsx)(Jn,{to:$.journal,replace:!0})}),(0,G.jsx)(Tt,{path:$.settingsTags,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.settingsSoundProfiles,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:`/settings/library/calcs`,element:(0,G.jsx)(`div`,{className:`p-6`,children:(0,G.jsx)(hre,{})})}),(0,G.jsx)(Tt,{path:`/legacy`,element:(0,G.jsx)(Zte,{})}),(0,G.jsx)(Tt,{path:`/syntax`,element:(0,G.jsx)(une,{})}),(0,G.jsx)(Tt,{path:$.plan,element:(0,G.jsx)(Ute,{})}),(0,G.jsx)(Tt,{path:$.feeds,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.feed,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.notebooks,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.notebook,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.notebookTarget,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.notebookItem,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.subscribe,element:(0,G.jsx)(bre,{})}),(0,G.jsx)(Tt,{path:$.pages,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.page,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.load,element:(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,G.jsx)(gre,{})})}),(0,G.jsx)(Tt,{path:$.loadJournal,element:(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,G.jsx)(Q9,{})})}),(0,G.jsx)(Tt,{path:$.loadJournalDate,element:(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,G.jsx)(Q9,{})})}),(0,G.jsx)(Tt,{path:$.playgroundRoot,element:(0,G.jsx)(wre,{})}),(0,G.jsx)(Tt,{path:$.playground,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.playgrounds,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.notes,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.note,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.journal,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.day,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.run,element:(0,G.jsx)(W.Suspense,{fallback:(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-zinc-400`,children:`Loading…`}),children:(0,G.jsx)(Sre,{})})}),(0,G.jsx)(Tt,{path:$.tracker,element:(0,G.jsx)(Hte,{})}),(0,G.jsx)(Tt,{path:`/results/segments`,element:(0,G.jsx)(Vte,{})}),(0,G.jsx)(Tt,{path:$.sessionDetail,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.sessions,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.sessionDate,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:`/review/:runtimeId`,element:(0,G.jsx)(J7,{})}),(0,G.jsx)(Tt,{path:`/note/:noteId/review`,element:(0,G.jsx)(J7,{})}),(0,G.jsx)(Tt,{path:`/note/:noteId/review/:sectionId`,element:(0,G.jsx)(J7,{})}),(0,G.jsx)(Tt,{path:`/note/:noteId/review/:sectionId/:resultId`,element:(0,G.jsx)(J7,{})}),(0,G.jsx)(Tt,{path:$.efforts,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.effort,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.equipment,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.equipmentSlug,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.tags,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.tagCategory,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.tag,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.dashboards,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),(0,G.jsx)(Tt,{path:$.dashboardView,element:(0,G.jsx)(q7,{searchHandlerRef:e})}),t.map(({route:t})=>(0,G.jsx)(Tt,{path:t,element:(0,G.jsx)(q7,{searchHandlerRef:e})},t))]}),(0,G.jsx)(Wte,{})]})]})})})})})})})}function Are({error:e,onRetry:t}){let n=e instanceof Error?e.message:String(e);return mk(),(0,G.jsxs)(`div`,{role:`alert`,className:`flex min-h-dvh flex-col items-center justify-center gap-4 p-6 text-center`,children:[(0,G.jsx)(`p`,{className:`text-sm font-semibold`,children:`The API data store could not be opened.`}),(0,G.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground font-mono break-all`,"data-testid":`boot-recovery-error`,children:n}),(0,G.jsxs)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:[`Your stored data has not been cleared. Retry after resolving the error above.`,!1]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:t,"data-testid":`boot-recovery-retry`,className:`rounded-md border border-border bg-card px-3 py-1.5 text-xs font-medium hover:bg-accent`,children:`Retry`}),!1]}),!1]})}function jre(){let e=(0,W.useSyncExternalStore)(iS,rS),t=e.phase===`updating`;return(0,G.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex min-h-dvh flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,G.jsx)(`p`,{className:`text-sm font-semibold`,children:t?`Updating local database…`:`Checking for storage updates…`}),t&&e.fromVersion!==null&&(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Schema v`,e.fromVersion,` → v`,e.toVersion]}),e.message&&(0,G.jsx)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:e.message})]})}var Mre=(0,Ti.createRoot)(document.getElementById(`root`));function Nre(){let[e,t]=(0,W.useState)(!1),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(0),o=(0,W.useSyncExternalStore)(iS,rS);return(0,W.useEffect)(()=>{let e=!1,n;return Ck().then(()=>XA?tj():void 0).then(()=>AA.ensureNotebooks().catch(e=>Rj(`NotebookService`,`ensureNotebooks failed`,e))).then(()=>{e||(n=Ek(),t(!0))}).catch(t=>{e||r(t)}),()=>{e=!0,n?.()}},[i]),n?(0,G.jsx)(Are,{error:n,onRetry:()=>{r(null),a(e=>e+1)}}):o.phase===`checking`||o.phase===`updating`?(0,G.jsx)(jre,{}):e?(0,G.jsx)(kre,{}):(0,G.jsx)(`div`,{role:`status`,className:`flex min-h-dvh items-center justify-center text-muted-foreground`,children:`Opening local library…`})}Mre.render((0,G.jsx)(W.StrictMode,{children:(0,G.jsx)(Nre,{})}));export{SU as t};
499
- //# sourceMappingURL=main-Dpu5LAEU.js.map
499
+ //# sourceMappingURL=main-DjqhFoGB.js.map