@bitcobblers/wod-wiki-lang 0.60.2258 → 0.61.2259

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
@@ -2970,59 +2970,59 @@ tagHighlighter([
2970
2970
  { tag: tags.punctuation, class: "tok-punctuation" }
2971
2971
  ]);
2972
2972
  var whiteboardScriptSnippets = [
2973
- {
2974
- name: "circuit",
2975
- label: "Circuit",
2976
- detail: "Rounds over indented movements",
2977
- template: "(${1:3})\n ${2:10 Air Squats}\n ${3:10 Push Ups}\n ${4:10 Ring Rows}\n${0}"
2978
- },
2979
- {
2980
- name: "5x5",
2981
- label: "5x5",
2982
- detail: "Inline strength sets",
2983
- template: "${1:5}x${2:5} ${3:Back Squat} @${4:100kg}\n${0}"
2984
- },
2985
2973
  {
2986
2974
  name: "emom",
2987
2975
  label: "EMOM",
2988
2976
  detail: "Every minute on the minute",
2989
- template: "(${1:10}) ${2::60 EMOM}\n + ${3:5 Burpees}\n + ${4:10 Kettlebell Swings 24kg}\n${0}"
2977
+ template: "(${1:10}) ${2::60 EMOM}\n + ${3:10 Kettlebell Swing} @${4:24kg} #emom\n${0}"
2990
2978
  },
2991
2979
  {
2992
2980
  name: "amrap",
2993
2981
  label: "AMRAP",
2994
- detail: "As many rounds as possible",
2995
- template: "${1:10:00 AMRAP}\n ${2:5 Pull Ups}\n ${3:10 Push Ups}\n ${4:15 Air Squats}\n${0}"
2982
+ detail: "As many rounds as possible in time cap",
2983
+ template: "${1:12:00 AMRAP}\n ${2:10 Pull-up}\n ${3:15 Push-up}\n ${4:200m Run} #amrap\n${0}"
2996
2984
  },
2997
2985
  {
2998
2986
  name: "tabata",
2999
2987
  label: "Tabata",
3000
- detail: "Work/rest intervals",
3001
- template: "(${1:8}) ${2::20 Work}\n * ${3::10 Rest}\n ${4:KB Snatch 16kg}\n${0}"
2988
+ detail: "8 intervals of 20s work / 10s rest",
2989
+ template: "(${1:8}) ${2::20 Work}\n * ${3::10} [:rest]\n ${4:10 Air Squat} #tabata\n${0}"
2990
+ },
2991
+ {
2992
+ name: "5x5",
2993
+ label: "5x5",
2994
+ detail: "Sets \xD7 reps barbell progression",
2995
+ template: "${1:5}x${2:5} ${3:Back Squat} @${4:100kg} *${5:2:00} #strength\n${0}"
2996
+ },
2997
+ {
2998
+ name: "circuit",
2999
+ label: "Circuit",
3000
+ detail: "Multi-station timed rounds",
3001
+ template: "(${1:3})\n ${2:400m Run}\n ${3:15 Wall Ball} @${4:9kg}\n *${5:1:00} [:rest]\n${0}"
3002
3002
  },
3003
3003
  {
3004
3004
  name: "ladder",
3005
3005
  label: "Ladder",
3006
- detail: "Rep ladder (21-15-9)",
3007
- template: "(${1:21-15-9})\n ${2:Thrusters 95lb}\n ${3:Pull-ups}\n${0}"
3006
+ detail: "Descending rep scheme (21-15-9)",
3007
+ template: "(${1:21-15-9})\n ${2:Thruster} @${3:43kg}\n ${4:Pull-up} #for-time\n${0}"
3008
3008
  },
3009
3009
  {
3010
3010
  name: "choice",
3011
3011
  label: "Choice",
3012
- detail: "Athlete choice between alternatives",
3013
- template: "${1:10 Power Cleans 135/95 lb}\n${0}"
3012
+ detail: "Scaled or equipment alternative (A | B)",
3013
+ template: "(${1:5})\n ${2:15 Kettlebell Swing} ${3:24 | 16 kg}\n${0}"
3014
3014
  },
3015
3015
  {
3016
3016
  name: "superset",
3017
3017
  label: "Superset",
3018
3018
  detail: "Compound set via + lap markers",
3019
- template: "+ ${1:5 Pull Ups}\n+ ${2:10 Push Ups}\n${0}"
3019
+ template: "+ ${1:5 Pull-up}\n+ ${2:10 Push-up}\n${0}"
3020
3020
  },
3021
3021
  {
3022
3022
  name: "collectible",
3023
3023
  label: "Collectible",
3024
- detail: "Measure time instead of prescribing it (:?)",
3025
- template: "${1::? 400m Run}\n${0}"
3024
+ detail: "Open clock measure-until-done (:?)",
3025
+ template: "${1::? 2000m Row} #for-time\n${0}"
3026
3026
  }
3027
3027
  ];
3028
3028
  function applyTemplateDefaults(template) {
@@ -3033,6 +3033,8 @@ function snippetCompletions() {
3033
3033
  (snippet) => snippetCompletion(snippet.template, {
3034
3034
  label: snippet.label,
3035
3035
  detail: snippet.detail,
3036
+ info: applyTemplateDefaults(snippet.template).trim(),
3037
+ section: { name: "Templates", rank: 3 },
3036
3038
  type: "text",
3037
3039
  boost: 10
3038
3040
  })
@@ -3040,17 +3042,66 @@ function snippetCompletions() {
3040
3042
  }
3041
3043
 
3042
3044
  // src/parser/completion.ts
3045
+ var COMPLETION_SECTIONS = {
3046
+ units: { name: "Units", rank: 1 },
3047
+ inNotebook: { name: "In this notebook", rank: 2 },
3048
+ templates: { name: "Templates", rank: 3 },
3049
+ actionCues: { name: "Action Cues", rank: 4 },
3050
+ structure: { name: "Structure", rank: 5 },
3051
+ movements: { name: "Movements", rank: 6 },
3052
+ tags: { name: "Tags", rank: 7 },
3053
+ equipment: { name: "Equipment", rank: 8 },
3054
+ sounds: { name: "Sounds", rank: 9 },
3055
+ dialect: { name: "Dialect", rank: 10 },
3056
+ blockProperties: { name: "Block Properties", rank: 20 },
3057
+ unitAliases: { name: "Unit Aliases", rank: 50 },
3058
+ create: { name: "Create", rank: 90 }
3059
+ };
3060
+ var SECTION_BY_NAME = Object.fromEntries(
3061
+ Object.values(COMPLETION_SECTIONS).map((section) => [section.name.toLowerCase(), section])
3062
+ );
3063
+ function resolveSection(section) {
3064
+ if (!section) return void 0;
3065
+ if (typeof section === "object") return section;
3066
+ return SECTION_BY_NAME[section.toLowerCase()] ?? { name: section, rank: 15 };
3067
+ }
3043
3068
  var COMPLETION_PROPERTY_KEYS = ["effort", "equipment", ...Object.keys(PROPERTY_KEY_TO_METRIC_TYPE)];
3044
3069
  var STRUCTURE_KEYWORD_LABELS = ["amrap", "emom", "tabata", "for time", "rest"];
3045
3070
  var STRUCTURE_KEYWORD_DISPLAY = {
3046
3071
  "for time": "FOR TIME",
3047
3072
  rest: "Rest"
3048
3073
  };
3049
- function unitCompletions(units, dimension) {
3050
- return units.toArray().filter((def) => !dimension || def.dimension === dimension).flatMap((def) => [
3051
- { label: def.canonical, detail: def.dimension, type: "unit", boost: 1 },
3052
- ...def.aliases.map((alias) => ({ label: alias, detail: def.dimension, type: "unit" }))
3053
- ]);
3074
+ var PRIMARY_UNIT_BOOST = {
3075
+ kg: 30,
3076
+ lb: 29,
3077
+ m: 28,
3078
+ km: 27,
3079
+ cal: 26,
3080
+ mi: 25,
3081
+ ft: 24,
3082
+ kcal: 23
3083
+ };
3084
+ function unitCompletions(units, dimension, preferredSet) {
3085
+ return units.toArray().filter((def) => !dimension || def.dimension === dimension).flatMap((def) => {
3086
+ const canonicalLower = def.canonical.toLowerCase();
3087
+ const canonicalBoost = preferredSet?.has(canonicalLower) ? 40 : PRIMARY_UNIT_BOOST[canonicalLower] ?? 20;
3088
+ return [
3089
+ {
3090
+ label: def.canonical,
3091
+ detail: def.dimension,
3092
+ type: "unit",
3093
+ section: COMPLETION_SECTIONS.units,
3094
+ boost: canonicalBoost
3095
+ },
3096
+ ...def.aliases.map((alias) => ({
3097
+ label: alias,
3098
+ detail: def.dimension,
3099
+ type: "unit",
3100
+ section: COMPLETION_SECTIONS.unitAliases,
3101
+ boost: preferredSet?.has(alias.toLowerCase()) ? 35 : 5
3102
+ }))
3103
+ ];
3104
+ });
3054
3105
  }
3055
3106
  function titleCase(word) {
3056
3107
  return word.toLowerCase().replace(/(^|[\s])([a-z])/g, (_, lead, ch) => lead + ch.toUpperCase());
@@ -3062,22 +3113,24 @@ var SPORT_VOCABULARY = {
3062
3113
  cardio: () => unique(CARDIO_ACTIVITY_KEYWORDS.flatMap((activity) => activity.keywords)).map((word) => ({
3063
3114
  label: titleCase(word),
3064
3115
  detail: "cardio",
3065
- type: "text"
3116
+ type: "text",
3117
+ section: COMPLETION_SECTIONS.dialect
3066
3118
  })),
3067
3119
  yoga: () => unique([
3068
3120
  ...YogaDialect.POSE_KEYWORDS,
3069
3121
  ...YogaDialect.FLOW_KEYWORDS,
3070
3122
  ...YogaDialect.BREATHING_KEYWORDS,
3071
3123
  ...YogaDialect.MEDITATION_KEYWORDS
3072
- ]).filter((word) => /^[A-Z ]+$/.test(word)).map((word) => ({ label: titleCase(word), detail: "yoga", type: "text" })),
3124
+ ]).filter((word) => /^[A-Z ]+$/.test(word)).map((word) => ({ label: titleCase(word), detail: "yoga", type: "text", section: COMPLETION_SECTIONS.dialect })),
3073
3125
  habits: () => unique([...HabitsDialect.HABIT_KEYWORDS, ...HabitsDialect.STREAK_KEYWORDS]).map((word) => ({
3074
3126
  label: titleCase(word),
3075
3127
  detail: "habits",
3076
- type: "text"
3128
+ type: "text",
3129
+ section: COMPLETION_SECTIONS.dialect
3077
3130
  })),
3078
3131
  climb: () => [
3079
- ...unique(Object.values(SEND_ALIASES)).map((send) => ({ label: send, detail: "send", type: "text" })),
3080
- ...unique(Object.values(DISCIPLINE_KEYWORDS)).map((discipline) => ({ label: discipline, detail: "discipline", type: "text" }))
3132
+ ...unique(Object.values(SEND_ALIASES)).map((send) => ({ label: send, detail: "send", type: "text", section: COMPLETION_SECTIONS.dialect })),
3133
+ ...unique(Object.values(DISCIPLINE_KEYWORDS)).map((discipline) => ({ label: discipline, detail: "discipline", type: "text", section: COMPLETION_SECTIONS.dialect }))
3081
3134
  ]
3082
3135
  };
3083
3136
  function structureKeywords() {
@@ -3085,26 +3138,44 @@ function structureKeywords() {
3085
3138
  label: STRUCTURE_KEYWORD_DISPLAY[word] ?? word.toUpperCase(),
3086
3139
  detail: "structure",
3087
3140
  type: "keyword",
3141
+ section: COMPLETION_SECTIONS.structure,
3088
3142
  boost: 5,
3089
3143
  apply: STRUCTURE_KEYWORD_DISPLAY[word] ?? word.toUpperCase()
3090
3144
  }));
3091
3145
  }
3092
3146
  var ACTION_CUE_COMPLETIONS = [
3093
- { label: "[:rest]", detail: "Rest cue", type: "keyword", apply: "[:rest] ", boost: 20 },
3094
- { label: "[:next]", detail: "Advance segment", type: "keyword", apply: "[:next] ", boost: 15 },
3095
- { label: "[:done]", detail: "Complete block", type: "keyword", apply: "[:done] ", boost: 12 },
3096
- { label: "[:mark]", detail: "Split / lap marker", type: "keyword", apply: "[:mark] ", boost: 10 }
3147
+ { label: "[:rest]", detail: "Rest cue", type: "keyword", section: COMPLETION_SECTIONS.actionCues, apply: "[:rest] ", boost: 20 },
3148
+ { label: "[:next]", detail: "Advance segment", type: "keyword", section: COMPLETION_SECTIONS.actionCues, apply: "[:next] ", boost: 15 },
3149
+ { label: "[:done]", detail: "Complete block", type: "keyword", section: COMPLETION_SECTIONS.actionCues, apply: "[:done] ", boost: 12 },
3150
+ { label: "[:mark]", detail: "Split / lap marker", type: "keyword", section: COMPLETION_SECTIONS.actionCues, apply: "[:mark] ", boost: 10 }
3097
3151
  ];
3152
+ var DEFAULT_SECTION_BY_KIND = {
3153
+ effort: COMPLETION_SECTIONS.movements,
3154
+ equipment: COMPLETION_SECTIONS.equipment,
3155
+ sound: COMPLETION_SECTIONS.sounds,
3156
+ tag: COMPLETION_SECTIONS.tags
3157
+ };
3158
+ var COMPLETION_TYPE_BY_KIND = {
3159
+ effort: "variable",
3160
+ equipment: "text",
3161
+ sound: "constant",
3162
+ tag: "constant"
3163
+ };
3098
3164
  var completionAliases = /* @__PURE__ */ new WeakMap();
3099
3165
  function toCompletions(values, detail, quoteValues = false) {
3166
+ const defaultSection = DEFAULT_SECTION_BY_KIND[detail];
3167
+ const completionType = COMPLETION_TYPE_BY_KIND[detail] ?? "text";
3100
3168
  return values.map((value) => {
3101
3169
  const insertText = quoteValues ? !/^[A-Za-z][A-Za-z0-9]*$/.test(value.value) ? JSON.stringify(value.value) : value.value : value.label ?? value.value;
3170
+ const resolvedSection = resolveSection(value.section) ?? defaultSection;
3102
3171
  const item = {
3103
3172
  label: value.label ?? value.value,
3104
3173
  apply: insertText,
3105
3174
  detail: value.detail ?? (value.label && value.label !== value.value ? value.value : detail),
3106
- type: "text",
3107
- info: value.info
3175
+ type: completionType,
3176
+ info: value.info,
3177
+ ...value.boost !== void 0 ? { boost: value.boost } : {},
3178
+ ...resolvedSection ? { section: resolvedSection } : {}
3108
3179
  };
3109
3180
  if (value.aliases?.length) {
3110
3181
  completionAliases.set(item, value.aliases.map((a) => a.toLowerCase()));
@@ -3112,6 +3183,36 @@ function toCompletions(values, detail, quoteValues = false) {
3112
3183
  return item;
3113
3184
  });
3114
3185
  }
3186
+ function appendCreateEffortOption(pool, typedPhrase, onCreateEffort) {
3187
+ if (!onCreateEffort) return pool;
3188
+ const trimmed = typedPhrase.trim();
3189
+ if (trimmed.length < 3 || !/^[A-Za-z][A-Za-z0-9 -]*$/.test(trimmed)) return pool;
3190
+ const lower = trimmed.toLowerCase();
3191
+ const hasMatch = pool.some((opt) => {
3192
+ const labelLower = opt.label.toLowerCase();
3193
+ const applyLower = typeof opt.apply === "string" ? opt.apply.toLowerCase().trim() : "";
3194
+ const aliases = completionAliases.get(opt);
3195
+ return labelLower === lower || applyLower === lower || Boolean(aliases?.includes(lower));
3196
+ });
3197
+ if (hasMatch) return pool;
3198
+ const createOption = {
3199
+ label: trimmed,
3200
+ displayLabel: `+ Create "${trimmed}"`,
3201
+ detail: "Add to Effort Library",
3202
+ type: "create",
3203
+ section: COMPLETION_SECTIONS.create,
3204
+ boost: -25,
3205
+ apply: (view, _completion, from, to) => {
3206
+ view.dispatch({
3207
+ changes: { from, to, insert: trimmed },
3208
+ selection: { anchor: from + trimmed.length },
3209
+ userEvent: "input.complete"
3210
+ });
3211
+ void onCreateEffort(trimmed);
3212
+ }
3213
+ };
3214
+ return [...pool, createOption];
3215
+ }
3115
3216
  function completionMatchesAliasOnly(option, typedLower) {
3116
3217
  const aliases = completionAliases.get(option);
3117
3218
  return aliases ? aliases.some((alias) => alias.includes(typedLower)) : false;
@@ -3175,16 +3276,17 @@ function inNode(context, names) {
3175
3276
  }
3176
3277
  return false;
3177
3278
  }
3178
- var SUPPRESSED_NODES = /* @__PURE__ */ new Set(["Text", "textComment", "Heading", "heading", "MetricObject"]);
3279
+ var ALWAYS_SUPPRESSED_NODES = /* @__PURE__ */ new Set(["Text", "textComment", "MetricObject"]);
3280
+ var HEADING_NODES = /* @__PURE__ */ new Set(["Heading", "heading"]);
3179
3281
  function whiteboardScriptCompletionSource(options = {}) {
3180
3282
  const sportWords = dialectWords(options.sport);
3181
3283
  const keywords = structureKeywords();
3182
3284
  const snippets = snippetCompletions();
3285
+ const snippetLabels = new Set(snippets.map((s) => s.label));
3286
+ const startKeywords = keywords.filter((k) => !snippetLabels.has(k.label));
3183
3287
  const units = options.units ?? UnitRegistry.standard();
3184
- const allUnitOptions = unitCompletions(units);
3185
- const massUnitOptions = unitCompletions(units, "mass");
3186
3288
  return async (context) => {
3187
- if (inNode(context, SUPPRESSED_NODES)) return null;
3289
+ if (inNode(context, ALWAYS_SUPPRESSED_NODES)) return null;
3188
3290
  const pos = context.pos;
3189
3291
  const line = context.state.doc.lineAt(pos);
3190
3292
  const before = line.text.slice(0, pos - line.from);
@@ -3198,9 +3300,40 @@ function whiteboardScriptCompletionSource(options = {}) {
3198
3300
  validFor: /^\[:[a-zA-Z0-9-]*\]?$/
3199
3301
  };
3200
3302
  }
3201
- if (beforeWord.endsWith("#") && options.tags) {
3202
- return { from: pos - word.length, options: toCompletions(await options.tags(), "tag") };
3303
+ if (/(?:^|[\s:])#$/.test(beforeWord) && (options.tags || options.onCreateTag)) {
3304
+ const rawTags = options.tags ? await options.tags() : [];
3305
+ const tagOptions = toCompletions(rawTags, "tag");
3306
+ if (options.onCreateTag && word.length >= 2) {
3307
+ const slug = word.toLowerCase();
3308
+ const exists = rawTags.some(
3309
+ (tag) => tag.value.toLowerCase() === slug || (tag.label ?? "").toLowerCase() === slug
3310
+ );
3311
+ if (!exists) {
3312
+ tagOptions.push({
3313
+ label: slug,
3314
+ displayLabel: `+ Create "#${slug}"`,
3315
+ detail: "New tag",
3316
+ type: "create",
3317
+ section: COMPLETION_SECTIONS.create,
3318
+ boost: -20,
3319
+ apply: (view, _completion, from, to) => {
3320
+ view.dispatch({
3321
+ changes: { from, to, insert: slug },
3322
+ selection: { anchor: from + slug.length },
3323
+ userEvent: "input.complete"
3324
+ });
3325
+ void options.onCreateTag?.(slug);
3326
+ }
3327
+ });
3328
+ }
3329
+ }
3330
+ return {
3331
+ from: pos - word.length,
3332
+ options: tagOptions,
3333
+ validFor: /^[A-Za-z0-9-]*$/
3334
+ };
3203
3335
  }
3336
+ if (inNode(context, HEADING_NODES)) return null;
3204
3337
  const statement = currentStatement(context);
3205
3338
  if (statement?.name === "Property") {
3206
3339
  const keyNode = statement.firstChild;
@@ -3217,32 +3350,44 @@ function whiteboardScriptCompletionSource(options = {}) {
3217
3350
  label: eq.label ?? eq.value,
3218
3351
  apply: `${eq.label ?? eq.value} `,
3219
3352
  detail: eq.detail ?? "equipment",
3220
- type: "text"
3353
+ type: "text",
3354
+ section: resolveSection(eq.section) ?? COMPLETION_SECTIONS.equipment,
3355
+ ...eq.boost !== void 0 ? { boost: eq.boost } : {}
3221
3356
  })) : [];
3357
+ const postQuantityEffortOptions = [...efforts, ...equipmentPrefixes, ...sportWords];
3222
3358
  const effortOptions = [...keywords, ...efforts, ...equipmentPrefixes, ...sportWords];
3223
3359
  if (/^[ \t]*[A-Za-z][A-Za-z0-9]*$/.test(before)) {
3224
3360
  const supplied = suppliedPropertyKeys(context);
3361
+ const propertyOptions = COMPLETION_PROPERTY_KEYS.filter((key) => !supplied.has(key)).map((key) => ({
3362
+ label: key,
3363
+ apply: `${key}: `,
3364
+ detail: "block property",
3365
+ type: "property",
3366
+ section: COMPLETION_SECTIONS.blockProperties,
3367
+ boost: -10
3368
+ }));
3225
3369
  const allStartOptions = [
3226
- ...COMPLETION_PROPERTY_KEYS.filter((key) => !supplied.has(key)).map((key) => ({ label: key, detail: "property", type: "property", boost: 5 })),
3227
3370
  ...snippets,
3228
- ...keywords,
3371
+ ...startKeywords,
3229
3372
  ...efforts,
3230
- ...sportWords
3373
+ ...sportWords,
3374
+ ...propertyOptions
3231
3375
  ];
3232
- const typedStart = before.trimStart().toLowerCase();
3376
+ const typedRaw = before.trimStart();
3377
+ const typedStart = typedRaw.toLowerCase();
3233
3378
  const hasAliasHit = typedStart.length >= 2 && effortOptions.some((opt) => completionMatchesWord(opt, typedStart) === "alias");
3234
3379
  if (hasAliasHit) {
3235
3380
  const matched = allStartOptions.filter((opt) => completionMatchesWord(opt, typedStart) !== null);
3236
3381
  return {
3237
- from: pos - before.trimStart().length,
3238
- options: matched,
3382
+ from: pos - typedRaw.length,
3383
+ options: appendCreateEffortOption(matched, typedRaw, options.onCreateEffort),
3239
3384
  filter: false,
3240
3385
  validFor: /^[A-Za-z]*$/
3241
3386
  };
3242
3387
  }
3243
3388
  return {
3244
- from: pos - before.trimStart().length,
3245
- options: allStartOptions,
3389
+ from: pos - typedRaw.length,
3390
+ options: appendCreateEffortOption(allStartOptions, typedRaw, options.onCreateEffort),
3246
3391
  validFor: /^[A-Za-z]*$/
3247
3392
  };
3248
3393
  }
@@ -3257,25 +3402,38 @@ function whiteboardScriptCompletionSource(options = {}) {
3257
3402
  (fragment) => fragment.firstChild?.name === "Action" && fragment.from < (quantity?.from ?? pos) && !context.state.doc.sliceString(fragment.from, fragment.to).includes(":")
3258
3403
  );
3259
3404
  if (quantity && !incompleteAction) {
3405
+ const preferredSet = new Set(
3406
+ (options.preferredUnits?.() ?? []).map((u) => u.toLowerCase())
3407
+ );
3408
+ const unitPool = unitCompletions(
3409
+ units,
3410
+ quantity.getChild("AtSign") ? "mass" : void 0,
3411
+ preferredSet.size > 0 ? preferredSet : void 0
3412
+ );
3260
3413
  const wordText = completingWord ? context.state.doc.sliceString(last.from, pos).toLowerCase() : "";
3261
- const hasAliasHit = wordText.length >= 2 && effortOptions.some((opt) => completionMatchesWord(opt, wordText) === "alias");
3262
- const pool = [...quantity.getChild("AtSign") ? massUnitOptions : allUnitOptions, ...effortOptions];
3414
+ const hasAliasHit = wordText.length >= 2 && postQuantityEffortOptions.some((opt) => completionMatchesWord(opt, wordText) === "alias");
3415
+ const pool = [...unitPool, ...postQuantityEffortOptions];
3263
3416
  if (hasAliasHit && completingWord) {
3417
+ const rawPhrase = context.state.doc.sliceString(last.from, pos);
3264
3418
  return {
3265
3419
  from: last.from,
3266
- options: pool.filter((opt) => completionMatchesWord(opt, wordText) !== null),
3420
+ options: appendCreateEffortOption(
3421
+ pool.filter((opt) => completionMatchesWord(opt, wordText) !== null),
3422
+ rawPhrase,
3423
+ options.onCreateEffort
3424
+ ),
3267
3425
  filter: false,
3268
3426
  validFor: /^[A-Za-z]*$/
3269
3427
  };
3270
3428
  }
3271
3429
  return {
3272
3430
  from: completingWord ? last.from : pos,
3273
- options: pool,
3431
+ options: completingWord ? appendCreateEffortOption(pool, context.state.doc.sliceString(last.from, pos), options.onCreateEffort) : pool,
3274
3432
  validFor: /^[A-Za-z]*$/
3275
3433
  };
3276
3434
  }
3277
3435
  if (before.trim() === "") {
3278
- return { from: pos, options: [...snippets, ...keywords, ...efforts, ...sportWords] };
3436
+ return { from: pos, options: [...snippets, ...startKeywords, ...efforts, ...sportWords] };
3279
3437
  }
3280
3438
  if (word.length === 0 && /[ \t]$/.test(before)) {
3281
3439
  const effortRun = trailingEffortRun(context, statement, units);
@@ -3288,12 +3446,13 @@ function whiteboardScriptCompletionSource(options = {}) {
3288
3446
  const first = effortRun[0];
3289
3447
  const last2 = effortRun[effortRun.length - 1];
3290
3448
  if (!first || !last2 || last2.to < pos) return null;
3291
- const typed = context.state.doc.sliceString(first.from, pos).toLowerCase();
3449
+ const rawPhrase = context.state.doc.sliceString(first.from, pos);
3450
+ const typed = rawPhrase.toLowerCase();
3292
3451
  const compatible = effortOptions.filter((option) => completionMatchesWord(option, typed) !== null);
3293
3452
  const usesAlias = compatible.some((option) => completionMatchesWord(option, typed) === "alias");
3294
3453
  return {
3295
3454
  from: first.from,
3296
- options: compatible,
3455
+ options: appendCreateEffortOption(compatible, rawPhrase, options.onCreateEffort),
3297
3456
  ...usesAlias ? { filter: false } : {},
3298
3457
  validFor: /^[A-Za-z ]*$/
3299
3458
  };
@@ -15952,6 +16111,6 @@ function compareStatement(expectations, actual, mode) {
15952
16111
  return diffs;
15953
16112
  }
15954
16113
 
15955
- export { ABSENT, AGGREGATE_BUILTINS, AUTHORITATIVE_CASTS, AbortSessionAction, AmrapLogicStrategy, AnalyticsEngine, AnalyticsTransformer, BUILTIN_CALCS, BUNDLED_EFFORT_COUNT, BehaviorContext, BlockBuilder, BlockContext, ButtonBehavior, COMPLETION_PROPERTY_KEYS, CONTEXT_ATOMS, CalcEngine, CalcEvalError, CalcParseError, CalcRegistrationError, CalcUnitError, CalculationRegistry, CardioDialect, ChildSelectionBehavior, ChildrenStrategy, ChoiceGroupMetric, ClearChildrenAction, ClimbDialect, ClimbMetricType, CompileAndPushBlockAction, CompletionTimestampBehavior, CompositeEffortRegistry, CompositeEquipmentRegistry, CompositePropertyRegistry, CountdownTimerBehavior, CountupTimerBehavior, CrossFitDialect, DAY, DEFAULT_RESOLVER_OPTIONS, DEFAULT_RUNTIME_OPTIONS, DEFAULT_SOUND_PROFILE, DEFAULT_UNRESOLVED_EFFORT_MET, DIM_COUNT, DIM_ENERGY, DIM_LENGTH, DIM_MASS, DIM_TIME, DIM_ZERO, DISCIPLINE_FACTORS, DialectStack, EFFORT_DATA_METRIC_TYPE, EFFORT_DISCIPLINES, EFFORT_REGISTRY_ORIGINS, EffortBlock, EffortFallbackStrategy, EffortResolver, EmitEventAction, EmitSystemOutputAction, ErrorAction, EventBus, ExecutionContext, ExitBehavior, FixtureSyntaxError, GenericGroupStrategy, GenericLoopStrategy, GenericTimerStrategy, HabitsDialect, INTENSITY_TIERS, InMemoryEffortRegistry, IntervalLogicStrategy, JitCompiler, LabelingBehavior, LocalEventProvider, LocalRuntimeSubscription, LookupRegistry, MdTimerRuntime, MemoryLocation, MemoryTypeEnum, MetricPromotionBehavior, NAMED_COMPOUNDS, NextAction, NextEvent, NextEventHandler, OutputEmitter, PRODUCTION_STRATEGIES, PROPERTY_KEY_TO_METRIC_TYPE, PopBlockAction, PushBlockAction, PushRestBlockAction, REFERENCE_PAIR_KEYS, REST_EXCLUSION, RPE_LABELS, RUNTIME_LOG_SUBJECT_WIDTH, RegisterEventHandlerAction, Registry, ReportOutputBehavior, ReportOutputStrategy, RestBlock, RoundsMetric, RuntimeAdapter, RuntimeBlock, RuntimeBuilder, RuntimeClock, RuntimeFactory, RuntimeLogger, RuntimeMemory, RuntimeObservers, RuntimeStack, SEED_PRECEDENCE_RANK, SOUND_PLAY_EVENT, SOUND_PROFILE_METRIC, STORE_CALCS, STREAM_ATOMS, STRUCTURAL_EFFORT_WORDS, ScriptRuntime, SessionRootBlock, SessionRootStrategy, SnapshotClock, SoundProfileBehavior, SoundStrategy, SpanTrackingBehavior, StandardAnalyticsProfile, StartSessionAction, StartWorkoutAction, SubscriptionManager, ThrowError, ThrowErrorAction, TwoPassEffortResolutionProcess, TypedMemoryReference, UNITS, UnitsDialect, UnregisterEventHandlerAction, UpdateNextPreviewAction, VISIBILITY_ICONS, VISIBILITY_LABELS, WaitingToStartBlock, WaitingToStartInjectorBehavior, WhiteboardScript, WodDialect, YogaDialect, addAliasToEffort, addDim, applyTemplateDefaults, buildStaticLookups, bundledEfforts, calculateElapsed, canonicalizeType, checkCalcLine, classifyStatements, closeCurrentSpan, collapseUnresolvedChoices, commonFixtureSet, compareStatement, compileLineForm, compilePropertySummaryCalcs, compilePropertySummaryCalcsWithDiagnostics, composeDivUnit, composeMulUnit, compoundName, computeWorkloadRollups, convertScalar, createAnalyticsEngineForBlock, createCalcEngine, createCalcStack, createCompiler, createDialectStack, createDisciplinesTable, createEffortTable, createLineLocator, createMockClock, createParser, createProfileTable, createReferenceIndex, createRpeLabelsTable, dailySessionLoads, dayBucket, dedupeEntitiesByPrecedence, dialectRegistry, dialectStack, diffStatement, dimEquals, disciplineFactorFor, documentToEffort, documentToEquipment, documentToTag, effortToDocument, equipmentToDocument, evaluate, extractEffortData, extractMetrics, extractPropertyRulesFromMeta, extractStatementRefs, extractStatements, extractStatementsRaw, extractSyntaxFacts, extractTagPropertyRules, filterTagsByVisibility, findBestFuzzyMatch, findUnresolvedChoices, fixtureBackSquat, fixtureBurpee, fixturePlank, fixtureRowing, fixtureRunning, fixtureUserCustom, fixtureUserOverride, formatDim, formatDuration, formatRuntimeLogLine, formatRuntimeLogRule, formatRuntimeTimestamp, formatSoundTrigger, metricsToLabel as fragmentsToLabel, fullFixtureSet, fuseUnits, fuseUnitsInMetrics, getAnalyticsFromLogs, getAnalyticsFromRuntime, getMetricVisibility, getUnit, inferDim, isCastSubscription, isChoiceResolved, isDimensionless, isEffortDiscipline, isFragmentTag, isWithinThreshold, levenshteinDistance, mutateTimerSpans, normalizeForFuzzy, num, openSpan, outputNodeId, outputNodeIds, padRuntimeLogEvent, padRuntimeLogSubject, parseCalcLine, parseEffortFile, parseEquipmentFile, parseExpression, parseMetricLine, parseScript, parseSoundTrigger, printCalculation, readNestedSection, readTimer, realtimeProcessorRegistry, renderMetric, resolveDominantOrigin, resolveEntityRank, resolveEntityTier, resolveFusedEffortReferences, resolveProfileRules, resolvePropertyDashboardWidgets, resolveSoundProfile, resolveSourceRank, resolveSourceTier, runMetricShakeOutQueue, slugifyRefLabel, snippetCompletions, startSpan, str, strategyRegistry, subDim, summaryProcessorRegistry, tagCategoryRecordToDocument, tagCategoryToDocument, tagRecordToDocument, tagToDocument, toStoredOutputStatement, truthy, validateOutputUnit, parser as whiteboardParser, whiteboardScript, whiteboardScriptCompletion, whiteboardScriptCompletionSource, whiteboardScriptLanguage, whiteboardScriptSnippets, writeChoiceSelection };
16114
+ export { ABSENT, AGGREGATE_BUILTINS, AUTHORITATIVE_CASTS, AbortSessionAction, AmrapLogicStrategy, AnalyticsEngine, AnalyticsTransformer, BUILTIN_CALCS, BUNDLED_EFFORT_COUNT, BehaviorContext, BlockBuilder, BlockContext, ButtonBehavior, COMPLETION_PROPERTY_KEYS, COMPLETION_SECTIONS, CONTEXT_ATOMS, CalcEngine, CalcEvalError, CalcParseError, CalcRegistrationError, CalcUnitError, CalculationRegistry, CardioDialect, ChildSelectionBehavior, ChildrenStrategy, ChoiceGroupMetric, ClearChildrenAction, ClimbDialect, ClimbMetricType, CompileAndPushBlockAction, CompletionTimestampBehavior, CompositeEffortRegistry, CompositeEquipmentRegistry, CompositePropertyRegistry, CountdownTimerBehavior, CountupTimerBehavior, CrossFitDialect, DAY, DEFAULT_RESOLVER_OPTIONS, DEFAULT_RUNTIME_OPTIONS, DEFAULT_SOUND_PROFILE, DEFAULT_UNRESOLVED_EFFORT_MET, DIM_COUNT, DIM_ENERGY, DIM_LENGTH, DIM_MASS, DIM_TIME, DIM_ZERO, DISCIPLINE_FACTORS, DialectStack, EFFORT_DATA_METRIC_TYPE, EFFORT_DISCIPLINES, EFFORT_REGISTRY_ORIGINS, EffortBlock, EffortFallbackStrategy, EffortResolver, EmitEventAction, EmitSystemOutputAction, ErrorAction, EventBus, ExecutionContext, ExitBehavior, FixtureSyntaxError, GenericGroupStrategy, GenericLoopStrategy, GenericTimerStrategy, HabitsDialect, INTENSITY_TIERS, InMemoryEffortRegistry, IntervalLogicStrategy, JitCompiler, LabelingBehavior, LocalEventProvider, LocalRuntimeSubscription, LookupRegistry, MdTimerRuntime, MemoryLocation, MemoryTypeEnum, MetricPromotionBehavior, NAMED_COMPOUNDS, NextAction, NextEvent, NextEventHandler, OutputEmitter, PRODUCTION_STRATEGIES, PROPERTY_KEY_TO_METRIC_TYPE, PopBlockAction, PushBlockAction, PushRestBlockAction, REFERENCE_PAIR_KEYS, REST_EXCLUSION, RPE_LABELS, RUNTIME_LOG_SUBJECT_WIDTH, RegisterEventHandlerAction, Registry, ReportOutputBehavior, ReportOutputStrategy, RestBlock, RoundsMetric, RuntimeAdapter, RuntimeBlock, RuntimeBuilder, RuntimeClock, RuntimeFactory, RuntimeLogger, RuntimeMemory, RuntimeObservers, RuntimeStack, SEED_PRECEDENCE_RANK, SOUND_PLAY_EVENT, SOUND_PROFILE_METRIC, STORE_CALCS, STREAM_ATOMS, STRUCTURAL_EFFORT_WORDS, ScriptRuntime, SessionRootBlock, SessionRootStrategy, SnapshotClock, SoundProfileBehavior, SoundStrategy, SpanTrackingBehavior, StandardAnalyticsProfile, StartSessionAction, StartWorkoutAction, SubscriptionManager, ThrowError, ThrowErrorAction, TwoPassEffortResolutionProcess, TypedMemoryReference, UNITS, UnitsDialect, UnregisterEventHandlerAction, UpdateNextPreviewAction, VISIBILITY_ICONS, VISIBILITY_LABELS, WaitingToStartBlock, WaitingToStartInjectorBehavior, WhiteboardScript, WodDialect, YogaDialect, addAliasToEffort, addDim, applyTemplateDefaults, buildStaticLookups, bundledEfforts, calculateElapsed, canonicalizeType, checkCalcLine, classifyStatements, closeCurrentSpan, collapseUnresolvedChoices, commonFixtureSet, compareStatement, compileLineForm, compilePropertySummaryCalcs, compilePropertySummaryCalcsWithDiagnostics, composeDivUnit, composeMulUnit, compoundName, computeWorkloadRollups, convertScalar, createAnalyticsEngineForBlock, createCalcEngine, createCalcStack, createCompiler, createDialectStack, createDisciplinesTable, createEffortTable, createLineLocator, createMockClock, createParser, createProfileTable, createReferenceIndex, createRpeLabelsTable, dailySessionLoads, dayBucket, dedupeEntitiesByPrecedence, dialectRegistry, dialectStack, diffStatement, dimEquals, disciplineFactorFor, documentToEffort, documentToEquipment, documentToTag, effortToDocument, equipmentToDocument, evaluate, extractEffortData, extractMetrics, extractPropertyRulesFromMeta, extractStatementRefs, extractStatements, extractStatementsRaw, extractSyntaxFacts, extractTagPropertyRules, filterTagsByVisibility, findBestFuzzyMatch, findUnresolvedChoices, fixtureBackSquat, fixtureBurpee, fixturePlank, fixtureRowing, fixtureRunning, fixtureUserCustom, fixtureUserOverride, formatDim, formatDuration, formatRuntimeLogLine, formatRuntimeLogRule, formatRuntimeTimestamp, formatSoundTrigger, metricsToLabel as fragmentsToLabel, fullFixtureSet, fuseUnits, fuseUnitsInMetrics, getAnalyticsFromLogs, getAnalyticsFromRuntime, getMetricVisibility, getUnit, inferDim, isCastSubscription, isChoiceResolved, isDimensionless, isEffortDiscipline, isFragmentTag, isWithinThreshold, levenshteinDistance, mutateTimerSpans, normalizeForFuzzy, num, openSpan, outputNodeId, outputNodeIds, padRuntimeLogEvent, padRuntimeLogSubject, parseCalcLine, parseEffortFile, parseEquipmentFile, parseExpression, parseMetricLine, parseScript, parseSoundTrigger, printCalculation, readNestedSection, readTimer, realtimeProcessorRegistry, renderMetric, resolveDominantOrigin, resolveEntityRank, resolveEntityTier, resolveFusedEffortReferences, resolveProfileRules, resolvePropertyDashboardWidgets, resolveSoundProfile, resolveSourceRank, resolveSourceTier, runMetricShakeOutQueue, slugifyRefLabel, snippetCompletions, startSpan, str, strategyRegistry, subDim, summaryProcessorRegistry, tagCategoryRecordToDocument, tagCategoryToDocument, tagRecordToDocument, tagToDocument, toStoredOutputStatement, truthy, validateOutputUnit, parser as whiteboardParser, whiteboardScript, whiteboardScriptCompletion, whiteboardScriptCompletionSource, whiteboardScriptLanguage, whiteboardScriptSnippets, writeChoiceSelection };
15956
16115
  //# sourceMappingURL=index.mjs.map
15957
16116
  //# sourceMappingURL=index.mjs.map