@bitcobblers/wod-wiki-engine 0.59.2238 → 0.59.2243

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,8 +1,11 @@
1
- export { APP_ORIGIN, BUILD_TIME, CANVAS_CHUNK_ID, DASHBOARDS_CHUNK_ID, DirectoryHandleFeedTree, EFFORTS_CHUNK_ID, EQUIPMENT_CHUNK_ID, FEED_SUBSCRIPTIONS_META_KEY, FeedTreeError, GIT_SHA, HttpFeedTree, MemoryFeedTree, NOTE_ID_FRONTMATTER_KEY, PUBLISHED_FEED_META_KEY, QR_SCRIPT_ID, SEED_BROADCAST_CHANNEL, SEED_NAMESPACE, SEED_REGISTERED_WIDGETS, SEED_SCHEMA, SEMVER, SESSION_CSV_HEADER, TELEMETRY_CSV_HEADER, VERSION, applySeedChunk, applySeedChunks, assertNotebookIndex, assertSeedManifest, assertSeedRow, assertSeedRows, backfillFeedProvenance, buildNoteProvenance, buildStatementTree, canvasRouteSlug, checkUnpublishedFeedChanges, cloneRemoteRecord, composeNoteMarkdown, createIRFile, createUserNotebookLanding, csvToEquipmentLabels, csvToSessionRows, csvToTelemetryBundle, decodeUtf8, deleteFeedSourceHeadless, effortToMarkdown, emptySeedMeta, encodeUtf8, equipmentToCsv, equipmentToMarkdown, exportPortableFilesFromStorage, extractNoteIdentity, extractTypedTags, feedIdOfMetaKey, getNoteNotebooks, getNotePublicationSummary, ingestPortableFilesIntoStorage, injectIdentityFrontmatter, isIRFile, listFeedSubscriptionsHeadless, listScopedPropertyOverrides, makeNotebookLinkId, makeScopedOverrideId, migrateNotebookVocabulary, normalizeFeedTreePath, notebookSlugForChunkId, parseCsvLine, parseFrontmatterDateMs, parseNoteMarkdown, prepareJournalSessionRun, previewRemoteNotebook, previewRemoteRecord, promoteNoteToNotebooks, promoteReferencedOverridesToNotebook, publishFeedFromStorage, qrInlineScript, readFrontmatterMeta, recordPublishedFeedCheckpoint, removeNoteFromNotebook, removeSeedSourceContent, renderFeedLandingHtml, resolveScopedPropertyCatalog, resolveUpstreamProvenance, saveScopedPropertyOverride, seedMetaKey, seedNoteId, seedNoteSourceId, seedPrecedenceRank, seedSourceTier, sessionToCsv, setNoteNotebooks, setNotebookPublic, setSessionPublic, sha256HexAsync, splitCsvRecords, statementToNode, subscribeFeedSourceHeadless, telemetryBundleToCsv, unsubscribeFeedSourceHeadless } from './chunk-YUFWRUL6.mjs';
1
+ export { APP_ORIGIN, BUILD_TIME, CANVAS_CHUNK_ID, DASHBOARDS_CHUNK_ID, DirectoryHandleFeedTree, EFFORTS_CHUNK_ID, EQUIPMENT_CHUNK_ID, FEED_SUBSCRIPTIONS_META_KEY, FeedTreeError, GIT_SHA, HttpFeedTree, MemoryFeedTree, NOTE_ID_FRONTMATTER_KEY, PUBLISHED_FEED_META_KEY, QR_SCRIPT_ID, SEED_BROADCAST_CHANNEL, SEED_NAMESPACE, SEED_REGISTERED_WIDGETS, SEED_SCHEMA, SEMVER, SESSION_CSV_HEADER, TELEMETRY_CSV_HEADER, VERSION, applySeedChunk, applySeedChunks, assertNotebookIndex, assertSeedManifest, assertSeedRow, assertSeedRows, backfillFeedProvenance, buildNoteProvenance, buildQueryServiceStoresFromStorage, buildStatementTree, canvasRouteSlug, checkUnpublishedFeedChanges, cloneRemoteRecord, composeNoteMarkdown, createIRFile, createUserNotebookLanding, csvToEquipmentLabels, csvToSessionRows, csvToTelemetryBundle, decodeUtf8, deleteFeedSourceHeadless, effortToMarkdown, emptySeedMeta, encodeUtf8, equipmentToCsv, equipmentToMarkdown, exportPortableFilesFromStorage, extractNoteIdentity, extractTypedTags, feedIdOfMetaKey, getNoteNotebooks, getNotePublicationSummary, ingestPortableFilesIntoStorage, injectIdentityFrontmatter, isIRFile, listFeedSubscriptionsHeadless, listScopedPropertyOverrides, makeNotebookLinkId, makeScopedOverrideId, migrateNotebookVocabulary, normalizeFeedTreePath, notebookSlugForChunkId, parseCsvLine, parseFrontmatterDateMs, parseNoteMarkdown, prepareJournalSessionRun, previewRemoteNotebook, previewRemoteRecord, promoteNoteToNotebooks, promoteReferencedOverridesToNotebook, publishFeedFromStorage, qrInlineScript, readFrontmatterMeta, recordPublishedFeedCheckpoint, removeNoteFromNotebook, removeSeedSourceContent, renderFeedLandingHtml, resolveScopedPropertyCatalog, resolveUpstreamProvenance, saveScopedPropertyOverride, seedMetaKey, seedNoteId, seedNoteSourceId, seedPrecedenceRank, seedSourceTier, sessionToCsv, setNoteNotebooks, setNotebookPublic, setSessionPublic, sha256HexAsync, splitCsvRecords, statementToNode, subscribeFeedSourceHeadless, telemetryBundleToCsv, unsubscribeFeedSourceHeadless } from './chunk-CEPDTTJI.mjs';
2
+ import { reconcileNoteBlocks, blockContentId, MetricType } from '@bitcobblers/wod-wiki-core';
2
3
  export * from '@bitcobblers/wod-wiki-core';
3
4
  import { dialectRegistry, realtimeProcessorRegistry, summaryProcessorRegistry } from '@bitcobblers/wod-wiki-lang';
4
5
  export { ABSENT, AGGREGATE_BUILTINS, AUTHORITATIVE_CASTS, AmrapLogicStrategy, AnalyticsEngine, AnalyticsTransformer, BUILTIN_CALCS, BUNDLED_EFFORT_COUNT, BlockBuilder, BlockContext, ButtonBehavior, CONSUMED_HINTS, CONSUMED_HINT_KEYS, CONTEXT_ATOMS, CalcEngine, CalculationRegistry, CardioDialect, ChildSelectionBehavior, ChildrenStrategy, ChoiceGroupMetric, ClimbDialect, ClimbMetricType, CountdownTimerBehavior, CountupTimerBehavior, CrossFitDialect, DAY, DEFAULT_RESOLVER_OPTIONS, DEFAULT_RUNTIME_OPTIONS, DEFAULT_SOUND_PROFILE, DEFAULT_UNRESOLVED_EFFORT_MET, DIM_LENGTH, DIM_MASS, DIM_TIME, DIM_ZERO, DialectStack, EFFORT_DATA_METRIC_TYPE, EFFORT_REGISTRY_ORIGINS, EffortFallbackStrategy, EffortResolver, ErrorAction, EventBus, ExecutionContext, ExitBehavior, FixtureSyntaxError, GenericGroupStrategy, GenericLoopStrategy, GenericTimerStrategy, HabitsDialect, INTENSITY_TIERS, InMemoryEffortRegistry, IntervalLogicStrategy, JitCompiler, LabelingBehavior, LocalRuntimeSubscription, LookupRegistry, MAX_TAG_CONTRIBUTION_DEPTH, MdTimerRuntime, MemoryLocation, MemoryTypeEnum, NextEvent, OutputEmitter, PRODUCTION_STRATEGIES, PopBlockAction, PushBlockAction, RegisterEventHandlerAction, Registry, ReportOutputBehavior, ReportOutputStrategy, RoundsMetric, RuntimeAdapter, RuntimeClock, RuntimeFactory, RuntimeLogger, RuntimeMemory, RuntimeObservers, RuntimeStack, SEED_PRECEDENCE_RANK, SOUND_PLAY_EVENT, SOUND_PROFILE_METRIC, STORE_CALCS, STREAM_ATOMS, ScriptRuntime, SessionRootStrategy, SnapshotClock, SoundProfileBehavior, SoundStrategy, StandardAnalyticsProfile, StartSessionAction, StartWorkoutAction, SubscriptionManager, TAG_MARKER_PREFIX, TimeSpan, TypedMemoryReference, UNITS, UnitsDialect, UnregisterEventHandlerAction, VISIBILITY_ICONS, VISIBILITY_LABELS, WhiteboardScript, WodDialect, YogaDialect, buildTooltip, bundledEfforts, calculateDuration, calculateElapsed, canonicalizeType, collapseUnresolvedChoices, compareStatement, compileLineForm, compilePropertySummaryCalcs, compoundName, computeColumnLabel, computeLabel, computeWorkloadRollups, createAnalyticsEngineForBlock, createCalcEngine, createCompiler, createDialectStack, createMetricPresentationPolicy, createMockClock, createParser, dailySessionLoads, dayBucket, dedupeEntitiesByPrecedence, dialectRegistry, dialectStack, diffStatement, evaluate, extractMetrics, extractPropertyRulesFromMeta, extractStatements, extractTagPropertyRules, findBestFuzzyMatch, findTagContributionCycles, findUnresolvedChoices, formatDurationCompact, formatDurationSmart, formatSecondsHHMMSS, formatSecondsMMSS, formatSoundTrigger, formatTime, formatTimeHHMMSS, formatTimeMMSS, formatTimePrecise, formatTimestamp, frozenNow, getAnalyticsFromLogs, getAnalyticsFromRuntime, getHints, getMetricVisibility, getRuntimeNowMs, hasHint, hintMetric, hintsToContainer, interpolateSessionClockFrame, isCastSubscription, isChoiceResolved, isRequiredCountdownLocked, isTimeLikeMetric, isWithinThreshold, levenshteinDistance, metricPresentation, normalizeForFuzzy, observeSessionClockInputs, outputNodeId, outputNodeIds, parseCalcLine, parseExpression, parseMetricLine, parseScript, parseSoundTrigger, projectLiveSessionTelemetry, projectScriptOutline, projectSessionClock, realtimeProcessorRegistry, renderMetric, resolveEntityRank, resolveEntityTier, resolveProfileRules, resolvePropertyDashboardWidgets, resolveSoundProfile, resolveSourceRank, resolveSourceTier, resolveTagContributions, resolveVisualPolarity, roundToTenth, runMetricShakeOutQueue, strategyRegistry, summaryProcessorRegistry, synthesizeWorkoutFormat, tagContributionMetrics, tagMarkerSlug, tagMarkerSlugs, tagMarkerType, toStoredOutputStatement, truthy, wallClockNow, whiteboardParser, whiteboardScript, whiteboardScriptLanguage, writeChoiceSelection } from '@bitcobblers/wod-wiki-lang';
6
+ import { toEventRows, toSummaryEventRows } from '@bitcobblers/wod-wiki-wql';
5
7
  export { DASHBOARD_GRID_MAX_COLS, DASHBOARD_WIDGET_TYPES, DEFAULT_DASHBOARD_TITLE, DEFAULT_NOTEBOOK_SLUGS, PLANNED_WIDGET_TYPES, QueryService, WQL_AGGREGATORS, WQL_CALC_TARGETS, WQL_CHART_HEADS, WQL_COMPARISON_OPS, WQL_CONTENT_FILTER_KEYS, WQL_DISPLAY_UNITS, WQL_FIND_TARGETS, WQL_FUNCTION_HEADS, WQL_GRAINS, WQL_INTENSITY_TIERS, WQL_KEYWORDS, WQL_METRIC_AGGREGATES, WQL_METRIC_FAMILIES, WQL_RESULT_PLANES, WQL_ROLLUP_PERIODS, WQL_SOURCES, WQL_SOURCE_HEADS, WQL_SOURCE_VALUES, WQL_STANDARD_DATASETS, WQL_TAG_KEYS, WQL_TYPED_TAG_KEYS, WQL_VIRTUAL_DIMS, bindQueryParams, buildDashboardDocument, buildDashboardFromScope, buildDashboardScaffold, buildWidgetsForWqlScope, collectQueryBlockParams, collectQueryParams, dashboardSlug, defaultTokenValues, extractDashboardTokens, extractNoteWqlOverride, isAggregateQuery, isDashboardMeta, isDashboardWidgetType, isDefaultShorthandQueryBlock, isFindQuery, isNoteEditable, isPipelineQuery, isYamlQueryBlockBody, normalizeWql, notebookOfItem, notebookSlugFromId, notebooksOfItem, parseFilterFragment, parseQuery, parseQueryBlock, parseQueryWidgetSuffix, parseWqlSuffixes, queryBlockAttributes, queryBlockToDocumentText, resolveEntityScope, resolveWidgetType, serialize, serializeQueryBlock, serializeQueryBlockFence, splitAtWhere, substituteTokens, toNotebookId, unknownTokensMessage, unknownWidgetTypeMessage, wql, wqlLanguage, wqlParser, wqlTerms } from '@bitcobblers/wod-wiki-wql';
8
+ import { resetTestingVocabulary, buildDomainWorld } from '@bitcobblers/wod-wiki-core/testing';
6
9
 
7
10
  var activePacks = /* @__PURE__ */ new Map();
8
11
  function defineLanguagePack(pack) {
@@ -64,7 +67,7 @@ function inMemoryEventStore(events) {
64
67
  getEventsByTimeRange: async (start, end) => rows.filter((r) => r.timestamp >= start && r.timestamp <= end),
65
68
  getEventsByResult: async (resultId) => rows.filter((r) => r.resultId === resultId),
66
69
  getEventsForNote: async (noteId) => rows.filter((r) => r.noteId === noteId),
67
- getEventsByContent: async (blockContentId) => rows.filter((r) => r.blockContentId === blockContentId),
70
+ getEventsByContent: async (blockContentId2) => rows.filter((r) => r.blockContentId === blockContentId2),
68
71
  scanAll: async () => rows,
69
72
  appendEvents: async (appended) => {
70
73
  rows.push(...appended);
@@ -84,7 +87,515 @@ function inMemoryEventStore(events) {
84
87
  }
85
88
  };
86
89
  }
90
+ var PERSIST_WORLD_STORES = [
91
+ "notes",
92
+ "block_revisions",
93
+ "block_index",
94
+ "block_efforts",
95
+ "block_equipment",
96
+ "tags",
97
+ "tag_types",
98
+ "note_tags",
99
+ "notebook_links",
100
+ "property_overrides",
101
+ "efforts",
102
+ "equipment",
103
+ "page",
104
+ "page_notes",
105
+ "sessions",
106
+ "events"
107
+ ];
108
+ async function persistDomainWorld(storage, worldInput) {
109
+ const isBuiltWorld = worldInput !== void 0 && "revisions" in worldInput && Array.isArray(worldInput.revisions) && "events" in worldInput && Array.isArray(worldInput.events);
110
+ let world;
111
+ if (isBuiltWorld) {
112
+ world = worldInput;
113
+ } else {
114
+ resetTestingVocabulary();
115
+ world = buildDomainWorld(worldInput ?? {});
116
+ }
117
+ const explicitNoteIds = new Set(world.notes.map((n) => n.id));
118
+ await storage.transaction([...PERSIST_WORLD_STORES], "readwrite", async (tx) => {
119
+ for (const nb of world.notebooks) {
120
+ if (!explicitNoteIds.has(nb.id)) {
121
+ await tx.readwrite("notes").put(nb);
122
+ }
123
+ }
124
+ if (world.notes.length) await tx.readwrite("notes").putMany(world.notes);
125
+ if (world.revisions.length) await tx.readwrite("block_revisions").putMany(world.revisions);
126
+ if (world.blockIndex.length) await tx.readwrite("block_index").putMany(world.blockIndex);
127
+ if (world.blockEfforts.length) await tx.readwrite("block_efforts").putMany(world.blockEfforts);
128
+ if (world.blockEquipment.length) await tx.readwrite("block_equipment").putMany(world.blockEquipment);
129
+ if (world.tags.length) await tx.readwrite("tags").putMany(world.tags);
130
+ if (world.noteTags.length) await tx.readwrite("note_tags").putMany(world.noteTags);
131
+ if (world.notebookLinks.length) await tx.readwrite("notebook_links").putMany(world.notebookLinks);
132
+ for (const override of world.propertyOverrides) {
133
+ await tx.readwrite("property_overrides").put(override);
134
+ if (override.kind === "tag" && override.payload) {
135
+ await tx.readwrite("tags").put(override.payload);
136
+ } else if (override.kind === "tag-type" && override.payload) {
137
+ await tx.readwrite("tag_types").put(override.payload);
138
+ }
139
+ }
140
+ if (!isBuiltWorld && worldInput?.propertyNotes) {
141
+ for (const propInput of worldInput.propertyNotes ?? []) {
142
+ const isDefault = !propInput.asOverride && (propInput.notebookId === void 0 || propInput.notebookId === "notebook/defaults");
143
+ if (!isDefault) continue;
144
+ if (propInput.kind === "effort") {
145
+ const effortRow = {
146
+ id: propInput.id ?? `effort-${propInput.slug}`,
147
+ slug: propInput.slug,
148
+ label: propInput.label,
149
+ aliases: propInput.aliases ?? [],
150
+ baseAttributes: {
151
+ met: 5,
152
+ ...propInput.baseAttributes ?? {}
153
+ },
154
+ registrySource: "bundled",
155
+ sourceId: "core",
156
+ ...propInput.body ? { body: propInput.body } : {}
157
+ };
158
+ await tx.readwrite("efforts").put(effortRow);
159
+ } else if (propInput.kind === "equipment") {
160
+ const equipRow = {
161
+ id: propInput.id ?? `equipment-${propInput.slug}`,
162
+ slug: propInput.slug,
163
+ label: propInput.label,
164
+ aliases: propInput.aliases ?? [],
165
+ registrySource: "bundled",
166
+ sourceId: "core",
167
+ ...propInput.body ? { body: propInput.body } : {}
168
+ };
169
+ await tx.readwrite("equipment").put(equipRow);
170
+ }
171
+ }
172
+ }
173
+ if (world.pages.length) await tx.readwrite("page").putMany(world.pages);
174
+ if (world.pageNotes.length) await tx.readwrite("page_notes").putMany(world.pageNotes);
175
+ if (world.sessions.length) await tx.readwrite("sessions").putMany(world.sessions);
176
+ if (world.events.length) await tx.readwrite("events").putMany(world.events);
177
+ });
178
+ return world;
179
+ }
180
+ var SAMPLE_TAG = "sample";
181
+ var DAY = 864e5;
182
+ var WEEK = 7 * DAY;
183
+ var LB_TO_KG = 0.453592;
184
+ function round1(n) {
185
+ return Math.round(n * 10) / 10;
186
+ }
187
+ var INTENSITY_BY_EFFORT = {
188
+ thruster: "high",
189
+ "pull-up": "high",
190
+ "push-up": "moderate",
191
+ "air-squat": "moderate",
192
+ "double-under": "high",
193
+ "sit-up": "low",
194
+ rowing: "moderate",
195
+ running: "moderate",
196
+ "recovery-run": "low",
197
+ "back-squat": "high",
198
+ "bench-press": "high",
199
+ deadlift: "high",
200
+ "max-hang": "high",
201
+ climb: "high"
202
+ };
203
+ var SESSION_INTENSITY = {
204
+ fran: "high",
205
+ cindy: "moderate",
206
+ annie: "moderate",
207
+ rowing: "moderate",
208
+ running: "moderate",
209
+ strength: "high",
210
+ recoveryRun: "low",
211
+ hangboard: "high"
212
+ };
213
+ function buildFran(now, weekOffset, attempt) {
214
+ const baseDuration = 330 - attempt * 16;
215
+ const durationSeconds = Math.max(180, round1(baseDuration + Math.sin(weekOffset) * 10));
216
+ const loadLbs = 95 + attempt * 5;
217
+ const reps = 45;
218
+ return {
219
+ noteId: `sample-fran-${weekOffset}`,
220
+ title: `Sample \u2014 Fran (week ${16 - weekOffset})`,
221
+ workoutType: "fran",
222
+ timestamp: now - weekOffset * WEEK - 2 * DAY,
223
+ durationSeconds,
224
+ tags: [SAMPLE_TAG, "benchmark", "crossfit"],
225
+ movements: [
226
+ { effortSlug: "thruster", discipline: "strength", reps, loadLbs, tisSeconds: round1(reps * 2.2) },
227
+ { effortSlug: "pull-up", discipline: "gymnastics", reps, loadLbs: 0, tisSeconds: round1(reps * 1.6) }
228
+ ]
229
+ };
230
+ }
231
+ function buildCindy(now, weekOffset, attempt) {
232
+ const rounds = 10 + attempt + weekOffset % 3;
233
+ return {
234
+ noteId: `sample-cindy-${weekOffset}`,
235
+ title: `Sample \u2014 Cindy (week ${16 - weekOffset})`,
236
+ workoutType: "cindy",
237
+ timestamp: now - weekOffset * WEEK - 2 * DAY,
238
+ durationSeconds: 1200,
239
+ tags: [SAMPLE_TAG, "benchmark", "crossfit"],
240
+ movements: [
241
+ { effortSlug: "pull-up", discipline: "gymnastics", reps: rounds * 5, loadLbs: 0, tisSeconds: round1(rounds * 5 * 1.5) },
242
+ { effortSlug: "push-up", discipline: "gymnastics", reps: rounds * 10, loadLbs: 0, tisSeconds: round1(rounds * 10 * 1.2) },
243
+ { effortSlug: "air-squat", discipline: "bodyweight", reps: rounds * 15, loadLbs: 0, tisSeconds: round1(rounds * 15 * 1.1) }
244
+ ]
245
+ };
246
+ }
247
+ function buildAnnie(now, weekOffset, attempt) {
248
+ const baseDuration = 540 - attempt * 22;
249
+ const durationSeconds = Math.max(360, round1(baseDuration + Math.cos(weekOffset) * 15));
250
+ const reps = 150;
251
+ return {
252
+ noteId: `sample-annie-${weekOffset}`,
253
+ title: `Sample \u2014 Annie (week ${16 - weekOffset})`,
254
+ workoutType: "annie",
255
+ timestamp: now - weekOffset * WEEK - 2 * DAY,
256
+ durationSeconds,
257
+ tags: [SAMPLE_TAG, "benchmark", "crossfit"],
258
+ movements: [
259
+ { effortSlug: "double-under", discipline: "gymnastics", reps, loadLbs: 0, tisSeconds: round1(reps * 0.5) },
260
+ { effortSlug: "sit-up", discipline: "bodyweight", reps, loadLbs: 0, tisSeconds: round1(reps * 1.3) }
261
+ ]
262
+ };
263
+ }
264
+ function buildStrengthAccessory(now, weekOffset, attempt) {
265
+ const baseBackSquat = 135 + attempt * 5;
266
+ const baseBenchPress = 115 + attempt * 5;
267
+ const baseDeadlift = 185 + attempt * 5;
268
+ const backSquatReps = 25;
269
+ const benchPressReps = 25;
270
+ const deadliftReps = 15;
271
+ return {
272
+ noteId: `sample-strength-${weekOffset}`,
273
+ title: `Sample \u2014 Strength accessory (week ${16 - weekOffset})`,
274
+ workoutType: "strength",
275
+ timestamp: now - weekOffset * WEEK - 4 * DAY,
276
+ durationSeconds: 2400,
277
+ tags: [SAMPLE_TAG, "strength"],
278
+ movements: [
279
+ { effortSlug: "back-squat", discipline: "strength", reps: backSquatReps, loadLbs: baseBackSquat, tisSeconds: round1(backSquatReps * 2.5) },
280
+ { effortSlug: "bench-press", discipline: "strength", reps: benchPressReps, loadLbs: baseBenchPress, tisSeconds: round1(benchPressReps * 2) },
281
+ { effortSlug: "deadlift", discipline: "strength", reps: deadliftReps, loadLbs: baseDeadlift, tisSeconds: round1(deadliftReps * 2.8) }
282
+ ]
283
+ };
284
+ }
285
+ function buildRowing(now, weekOffset, attempt) {
286
+ const distanceMeters = 2e3 + attempt * 250;
287
+ const durationSeconds = round1(distanceMeters / 2);
288
+ return {
289
+ noteId: `sample-rowing-${weekOffset}`,
290
+ title: `Sample \u2014 Rowing (week ${16 - weekOffset})`,
291
+ workoutType: "rowing",
292
+ timestamp: now - weekOffset * WEEK - 5 * DAY,
293
+ durationSeconds,
294
+ tags: [SAMPLE_TAG, "endurance", "rowing"],
295
+ movements: [
296
+ { effortSlug: "rowing", discipline: "rowing", reps: 1, loadLbs: 0, tisSeconds: durationSeconds, distanceMeters }
297
+ ]
298
+ };
299
+ }
300
+ function buildRunning(now, weekOffset, attempt) {
301
+ const distanceMeters = 5e3 + attempt * 500;
302
+ const durationSeconds = round1(distanceMeters / 2.8);
303
+ return {
304
+ noteId: `sample-running-${weekOffset}`,
305
+ title: `Sample \u2014 Running (week ${16 - weekOffset})`,
306
+ workoutType: "running",
307
+ timestamp: now - weekOffset * WEEK - 5 * DAY,
308
+ durationSeconds,
309
+ tags: [SAMPLE_TAG, "endurance", "running"],
310
+ movements: [
311
+ { effortSlug: "running", discipline: "running", reps: 1, loadLbs: 0, tisSeconds: durationSeconds, distanceMeters }
312
+ ]
313
+ };
314
+ }
315
+ function buildRecoveryRun(now, weekOffset, attempt) {
316
+ const distanceMeters = 3e3 + attempt * 50;
317
+ const durationSeconds = round1(distanceMeters / 2.2);
318
+ return {
319
+ noteId: `sample-recovery-run-${weekOffset}`,
320
+ title: `Sample \u2014 Recovery run (week ${16 - weekOffset})`,
321
+ workoutType: "recoveryRun",
322
+ timestamp: now - weekOffset * WEEK - 6 * DAY,
323
+ durationSeconds,
324
+ tags: [SAMPLE_TAG, "recovery", "running"],
325
+ movements: [
326
+ { effortSlug: "recovery-run", discipline: "running", reps: 1, loadLbs: 0, tisSeconds: durationSeconds, distanceMeters }
327
+ ]
328
+ };
329
+ }
330
+ function buildHangboard(now, weekOffset, attempt) {
331
+ const durationSeconds = 1200;
332
+ const grade = `V${Math.min(8, 5 + attempt % 4)}`;
333
+ return {
334
+ noteId: `sample-hangboard-${weekOffset}`,
335
+ title: `Sample \u2014 Hangboard session (week ${16 - weekOffset})`,
336
+ workoutType: "hangboard",
337
+ timestamp: now - weekOffset * WEEK - 3 * DAY,
338
+ durationSeconds,
339
+ tags: [SAMPLE_TAG, "hangboard", "climbing"],
340
+ movements: [
341
+ { effortSlug: "max-hang", discipline: "climbing", reps: 5, loadLbs: 35, tisSeconds: 60 },
342
+ { effortSlug: "climb", discipline: "climbing", reps: 3, loadLbs: 0, tisSeconds: 180, grade }
343
+ ]
344
+ };
345
+ }
346
+ function generateSampleSessions(anchorNow = Date.now()) {
347
+ const sessions = [];
348
+ for (let weekOffset = 0; weekOffset < 16; weekOffset++) {
349
+ const block = Math.floor(weekOffset / 4);
350
+ sessions.push(buildStrengthAccessory(anchorNow, weekOffset, weekOffset));
351
+ if (weekOffset % 4 === 0) {
352
+ sessions.push(buildFran(anchorNow, weekOffset, block));
353
+ } else if (weekOffset % 4 === 1) {
354
+ sessions.push(buildCindy(anchorNow, weekOffset, block));
355
+ } else if (weekOffset % 4 === 2) {
356
+ sessions.push(buildAnnie(anchorNow, weekOffset, block));
357
+ } else if (weekOffset === 3 || weekOffset === 11) {
358
+ sessions.push(buildRowing(anchorNow, weekOffset, block));
359
+ } else if (weekOffset === 7 || weekOffset === 15) {
360
+ sessions.push(buildRunning(anchorNow, weekOffset, block));
361
+ }
362
+ sessions.push(buildRecoveryRun(anchorNow, weekOffset, weekOffset));
363
+ if (weekOffset % 2 === 0) {
364
+ sessions.push(buildHangboard(anchorNow, weekOffset, weekOffset));
365
+ }
366
+ }
367
+ return sessions.sort((a, b) => a.timestamp - b.timestamp);
368
+ }
369
+ function buildSessionLogs(session) {
370
+ const startedAt = session.timestamp;
371
+ const sessionIntensity = SESSION_INTENSITY[session.workoutType];
372
+ const totalReps = session.movements.reduce((sum, m) => sum + m.reps, 0);
373
+ const totalVolumeLbs = session.movements.reduce((sum, m) => sum + m.reps * m.loadLbs, 0);
374
+ const totalTis = session.movements.reduce((sum, m) => sum + m.tisSeconds, 0);
375
+ const totalDistance = session.movements.reduce((sum, m) => sum + (m.distanceMeters ?? 0), 0);
376
+ const sessionLoad = round1(totalVolumeLbs / 100 + totalReps + session.durationSeconds / 10);
377
+ const logs = [];
378
+ const push = (label, value, unit, canonicalKey, tags) => {
379
+ const metadata = { canonicalKey };
380
+ if (tags?.effortSlug) metadata.effortSlug = tags.effortSlug;
381
+ if (tags?.discipline) metadata.effortDiscipline = tags.discipline;
382
+ if (tags?.intensityTier) metadata.effortIntensityTier = tags.intensityTier;
383
+ if (tags?.grade) metadata.grade = tags.grade;
384
+ logs.push({
385
+ id: logs.length,
386
+ outputType: "analytics",
387
+ timeSpan: { started: startedAt },
388
+ metrics: [
389
+ { type: MetricType.Label, value: label, origin: "analyzed" },
390
+ { type: MetricType.Metric, value, unit, metadata, origin: "analyzed" }
391
+ ],
392
+ sourceBlockKey: "",
393
+ stackLevel: 0
394
+ });
395
+ };
396
+ const isBenchmark = session.workoutType === "fran" || session.workoutType === "cindy" || session.workoutType === "annie";
397
+ const workoutEffortSlug = isBenchmark ? session.workoutType : void 0;
398
+ push("Elapsed time", session.durationSeconds, "s", "elapsed", {
399
+ effortSlug: workoutEffortSlug,
400
+ intensityTier: sessionIntensity
401
+ });
402
+ push("Total reps", totalReps, "reps", "totalReps", { intensityTier: sessionIntensity });
403
+ push("Time in motion", round1(totalTis), "s", "tis", { intensityTier: sessionIntensity });
404
+ if (totalVolumeLbs > 0) {
405
+ const discipline = session.workoutType === "strength" ? "strength" : void 0;
406
+ push("Total volume", round1(totalVolumeLbs * LB_TO_KG), "kg", "totalVolume", {
407
+ discipline,
408
+ intensityTier: sessionIntensity
409
+ });
410
+ }
411
+ if (totalDistance > 0) {
412
+ const distanceDiscipline = session.movements.find((m) => m.distanceMeters && m.distanceMeters > 0)?.discipline;
413
+ push("Total distance", round1(totalDistance), "m", "totalDistance", {
414
+ discipline: distanceDiscipline,
415
+ intensityTier: sessionIntensity
416
+ });
417
+ }
418
+ const sessionDiscipline = session.workoutType === "strength" ? "strength" : void 0;
419
+ push("Session load", sessionLoad, "AU", "sessionLoad", {
420
+ discipline: sessionDiscipline,
421
+ intensityTier: sessionIntensity
422
+ });
423
+ for (const m of session.movements) {
424
+ const movementVolumeLbs = m.reps * m.loadLbs;
425
+ const movementIntensity = INTENSITY_BY_EFFORT[m.effortSlug] ?? "moderate";
426
+ const tags = {
427
+ effortSlug: m.effortSlug,
428
+ discipline: m.discipline,
429
+ intensityTier: movementIntensity,
430
+ grade: m.grade
431
+ };
432
+ push("Total reps", m.reps, "reps", "totalReps", tags);
433
+ push("Time in motion", m.tisSeconds, "s", "tis", tags);
434
+ if (movementVolumeLbs > 0) {
435
+ push("Total volume", round1(movementVolumeLbs * LB_TO_KG), "kg", "totalVolume", tags);
436
+ }
437
+ push(
438
+ "Session load",
439
+ round1(movementVolumeLbs / 100 + m.reps + m.tisSeconds / 10),
440
+ "AU",
441
+ "sessionLoad",
442
+ tags
443
+ );
444
+ if (m.discipline === "strength" && m.loadLbs > 0) {
445
+ const loadKg = round1(m.loadLbs * LB_TO_KG);
446
+ const e1rm = round1(loadKg * (1 + m.reps / 30));
447
+ const pct1rm = round1(100 / (1 + m.reps / 30));
448
+ push("Estimated 1RM", e1rm, "kg", "calc.e1rm", tags);
449
+ push("%1RM intensity", pct1rm, "%", "calc.pct1rm", tags);
450
+ }
451
+ if (m.effortSlug === "max-hang") {
452
+ const mvcBw = round1(28 + session.timestamp / DAY % 8);
453
+ push("Max Hang %BW", mvcBw, "%", "calc.mvcBw", tags);
454
+ }
455
+ if (m.effortSlug === "climb" && m.grade) {
456
+ push("Sends", m.reps, "count", "calc.sends", tags);
457
+ }
458
+ }
459
+ const dayPhase = (salt) => {
460
+ const x = Math.sin(session.timestamp / DAY * (12.9898 + salt) + salt * 78.233) * 43758.5453;
461
+ return x - Math.floor(x);
462
+ };
463
+ const soreness = 2 + Math.round(dayPhase(1) * 4);
464
+ const sleepHours = round1(6.8 + dayPhase(2) * 1.6);
465
+ const hrvMs = Math.round(52 + dayPhase(3) * 22);
466
+ const readiness = round1((10 - soreness) / 10 * 40 + sleepHours / 8 * 30 + hrvMs / 90 * 30);
467
+ const monotony = round1(1.1 + dayPhase(4) * 0.7);
468
+ const acwr = round1(0.85 + dayPhase(5) * 0.4);
469
+ push("Readiness", readiness, "pts", "calc.readiness", { intensityTier: sessionIntensity });
470
+ push("HRV", hrvMs, "pts", "calc.hrv", { intensityTier: sessionIntensity });
471
+ push("Sleep", sleepHours, "pts", "calc.sleep", { intensityTier: sessionIntensity });
472
+ push("Soreness", soreness, "rating", "calc.soreness", { intensityTier: sessionIntensity });
473
+ push("Monotony", monotony, "ratio", "calc.monotony", { intensityTier: sessionIntensity });
474
+ push("ACWR", acwr, "ratio", "calc.acwr", { intensityTier: sessionIntensity });
475
+ const ctl = round1(45 + dayPhase(6) * 15);
476
+ const atl = round1(50 + dayPhase(7) * 20);
477
+ const tsb = round1(ctl - atl);
478
+ push("Fitness (CTL)", ctl, "AU", "calc.ctl", { intensityTier: sessionIntensity });
479
+ push("Fatigue (ATL)", atl, "AU", "calc.atl", { intensityTier: sessionIntensity });
480
+ push("Form (TSB)", tsb, "AU", "calc.tsb", { intensityTier: sessionIntensity });
481
+ const adherence = round1(0.8 + dayPhase(8) * 0.2);
482
+ push("Adherence", adherence, "ratio", "calc.adherence", { intensityTier: sessionIntensity });
483
+ if (session.workoutType === "running" || session.workoutType === "recoveryRun") {
484
+ const paceMPerS = round1(totalDistance / session.durationSeconds);
485
+ const ef = round1(paceMPerS / 140 * 1e5);
486
+ push("Efficiency factor", ef, "pts", "calc.ef", { intensityTier: sessionIntensity });
487
+ }
488
+ return logs;
489
+ }
490
+ function buildSampleResult(session, contentId, createdAt) {
491
+ const baseId = `sample-${session.noteId}`;
492
+ const resultId = `${baseId}-result`;
493
+ const startTime = session.timestamp;
494
+ const endTime = startTime + session.durationSeconds * 1e3;
495
+ return {
496
+ id: resultId,
497
+ noteId: session.noteId,
498
+ blockId: "blk-0",
499
+ blockVersion: 1,
500
+ blockContentId: contentId,
501
+ origin: "journal",
502
+ status: "completed",
503
+ createdAt,
504
+ startTime,
505
+ endTime,
506
+ duration: session.durationSeconds * 1e3,
507
+ completed: true
508
+ };
509
+ }
510
+ function buildSampleBundle(session, now = Date.now()) {
511
+ const body = session.movements.map(
512
+ (m) => `${m.distanceMeters ? `${m.distanceMeters}m` : m.reps} ${m.effortSlug.replaceAll("-", " ")}${m.loadLbs ? ` ${m.loadLbs}lb` : ""}`
513
+ ).join("\n");
514
+ const rawContent = `# ${session.title}
515
+
516
+ \`\`\`log
517
+ ${body}
518
+ \`\`\`
519
+ `;
520
+ const blocks = reconcileNoteBlocks(rawContent, { sourceRevision: 1, createId: () => "blk-0" });
521
+ const logs = buildSessionLogs(session);
522
+ const result = buildSampleResult(session, blockContentId(body), now);
523
+ const identity = {
524
+ noteId: session.noteId,
525
+ resultId: result.id,
526
+ blockId: "blk-0",
527
+ blockVersion: 1,
528
+ blockContentId: result.blockContentId,
529
+ origin: result.origin,
530
+ pageId: result.pageId,
531
+ workoutTimestamp: session.timestamp
532
+ };
533
+ const rawEvents = toEventRows(logs, identity);
534
+ const summaries = toSummaryEventRows(logs, identity).map((r) => {
535
+ const metric = r.metrics[0];
536
+ if (metric && typeof metric.value === "number") {
537
+ return {
538
+ ...r,
539
+ reducerStats: {
540
+ observedCount: 1,
541
+ sum: metric.value,
542
+ min: metric.value,
543
+ max: metric.value
544
+ }
545
+ };
546
+ }
547
+ return r;
548
+ });
549
+ const bundle = {
550
+ note: {
551
+ id: session.noteId,
552
+ title: session.title,
553
+ createdAt: session.timestamp,
554
+ updatedAt: session.timestamp,
555
+ targetDate: session.timestamp,
556
+ rawContent,
557
+ sourceRevision: 1,
558
+ blocks,
559
+ tags: session.tags,
560
+ type: "playground"
561
+ },
562
+ sessions: [result],
563
+ events: [...rawEvents, ...summaries]
564
+ };
565
+ return { bundle, rawContent, blocks, result, rawEvents, summaries };
566
+ }
567
+ function buildSampleWorld(anchorNow = Date.now()) {
568
+ const sessions = generateSampleSessions(anchorNow);
569
+ const testNotes = [];
570
+ const testSessions = [];
571
+ for (const session of sessions) {
572
+ const { rawContent, result, rawEvents, summaries } = buildSampleBundle(session, anchorNow);
573
+ testNotes.push({
574
+ id: session.noteId,
575
+ title: session.title,
576
+ rawContent,
577
+ createdAt: session.timestamp,
578
+ tags: session.tags,
579
+ type: "playground"
580
+ });
581
+ testSessions.push({
582
+ id: result.id,
583
+ noteId: session.noteId,
584
+ blockId: "blk-0",
585
+ blockVersion: 1,
586
+ startedAt: result.startTime,
587
+ completedAt: result.endTime,
588
+ durationMs: result.duration,
589
+ origin: result.origin,
590
+ events: [...rawEvents, ...summaries]
591
+ });
592
+ }
593
+ return {
594
+ notes: testNotes,
595
+ sessions: testSessions
596
+ };
597
+ }
87
598
 
88
- export { defineLanguagePack, getRegisteredLanguagePacks, inMemoryEventStore, listLanguagePacks, registerLanguagePack, unregisterLanguagePack };
599
+ export { PERSIST_WORLD_STORES, SAMPLE_TAG, buildSampleBundle, buildSampleWorld, buildSessionLogs, defineLanguagePack, generateSampleSessions, getRegisteredLanguagePacks, inMemoryEventStore, listLanguagePacks, persistDomainWorld, registerLanguagePack, round1, unregisterLanguagePack };
89
600
  //# sourceMappingURL=index.mjs.map
90
601
  //# sourceMappingURL=index.mjs.map