@bitcobblers/wod-wiki-lang 0.60.2257 → 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,21 +3138,92 @@ 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
  }
3146
+ var ACTION_CUE_COMPLETIONS = [
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 }
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
+ };
3164
+ var completionAliases = /* @__PURE__ */ new WeakMap();
3092
3165
  function toCompletions(values, detail, quoteValues = false) {
3166
+ const defaultSection = DEFAULT_SECTION_BY_KIND[detail];
3167
+ const completionType = COMPLETION_TYPE_BY_KIND[detail] ?? "text";
3093
3168
  return values.map((value) => {
3094
3169
  const insertText = quoteValues ? !/^[A-Za-z][A-Za-z0-9]*$/.test(value.value) ? JSON.stringify(value.value) : value.value : value.label ?? value.value;
3095
- return {
3170
+ const resolvedSection = resolveSection(value.section) ?? defaultSection;
3171
+ const item = {
3096
3172
  label: value.label ?? value.value,
3097
3173
  apply: insertText,
3098
3174
  detail: value.detail ?? (value.label && value.label !== value.value ? value.value : detail),
3099
- type: "text",
3100
- info: value.info
3175
+ type: completionType,
3176
+ info: value.info,
3177
+ ...value.boost !== void 0 ? { boost: value.boost } : {},
3178
+ ...resolvedSection ? { section: resolvedSection } : {}
3101
3179
  };
3180
+ if (value.aliases?.length) {
3181
+ completionAliases.set(item, value.aliases.map((a) => a.toLowerCase()));
3182
+ }
3183
+ return item;
3184
+ });
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));
3102
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
+ }
3216
+ function completionMatchesAliasOnly(option, typedLower) {
3217
+ const aliases = completionAliases.get(option);
3218
+ return aliases ? aliases.some((alias) => alias.includes(typedLower)) : false;
3219
+ }
3220
+ function completionMatchesWord(option, typedLower) {
3221
+ const inserted = (typeof option.apply === "string" ? option.apply : option.label).toLowerCase();
3222
+ const label = option.label.toLowerCase();
3223
+ if (inserted.startsWith(typedLower) || label.startsWith(typedLower)) return "prefix";
3224
+ if (inserted.includes(typedLower) || label.includes(typedLower)) return "word";
3225
+ if (completionMatchesAliasOnly(option, typedLower)) return "alias";
3226
+ return null;
3103
3227
  }
3104
3228
  function dialectWords(sport) {
3105
3229
  if (!sport) return [];
@@ -3152,24 +3276,64 @@ function inNode(context, names) {
3152
3276
  }
3153
3277
  return false;
3154
3278
  }
3155
- 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"]);
3156
3281
  function whiteboardScriptCompletionSource(options = {}) {
3157
3282
  const sportWords = dialectWords(options.sport);
3158
3283
  const keywords = structureKeywords();
3159
3284
  const snippets = snippetCompletions();
3285
+ const snippetLabels = new Set(snippets.map((s) => s.label));
3286
+ const startKeywords = keywords.filter((k) => !snippetLabels.has(k.label));
3160
3287
  const units = options.units ?? UnitRegistry.standard();
3161
- const allUnitOptions = unitCompletions(units);
3162
- const massUnitOptions = unitCompletions(units, "mass");
3163
3288
  return async (context) => {
3164
- if (inNode(context, SUPPRESSED_NODES)) return null;
3289
+ if (inNode(context, ALWAYS_SUPPRESSED_NODES)) return null;
3165
3290
  const pos = context.pos;
3166
3291
  const line = context.state.doc.lineAt(pos);
3167
3292
  const before = line.text.slice(0, pos - line.from);
3168
3293
  const word = /([A-Za-z0-9-]*)$/.exec(before)[1];
3169
3294
  const beforeWord = before.slice(0, before.length - word.length);
3170
- if (beforeWord.endsWith("#") && options.tags) {
3171
- return { from: pos - word.length, options: toCompletions(await options.tags(), "tag") };
3295
+ const actionMatch = /(\[:[a-zA-Z0-9-]*)$/.exec(before);
3296
+ if (actionMatch) {
3297
+ return {
3298
+ from: pos - actionMatch[1].length,
3299
+ options: ACTION_CUE_COMPLETIONS,
3300
+ validFor: /^\[:[a-zA-Z0-9-]*\]?$/
3301
+ };
3302
+ }
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
+ };
3172
3335
  }
3336
+ if (inNode(context, HEADING_NODES)) return null;
3173
3337
  const statement = currentStatement(context);
3174
3338
  if (statement?.name === "Property") {
3175
3339
  const keyNode = statement.firstChild;
@@ -3186,14 +3350,44 @@ function whiteboardScriptCompletionSource(options = {}) {
3186
3350
  label: eq.label ?? eq.value,
3187
3351
  apply: `${eq.label ?? eq.value} `,
3188
3352
  detail: eq.detail ?? "equipment",
3189
- type: "text"
3353
+ type: "text",
3354
+ section: resolveSection(eq.section) ?? COMPLETION_SECTIONS.equipment,
3355
+ ...eq.boost !== void 0 ? { boost: eq.boost } : {}
3190
3356
  })) : [];
3357
+ const postQuantityEffortOptions = [...efforts, ...equipmentPrefixes, ...sportWords];
3191
3358
  const effortOptions = [...keywords, ...efforts, ...equipmentPrefixes, ...sportWords];
3192
3359
  if (/^[ \t]*[A-Za-z][A-Za-z0-9]*$/.test(before)) {
3193
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
+ }));
3369
+ const allStartOptions = [
3370
+ ...snippets,
3371
+ ...startKeywords,
3372
+ ...efforts,
3373
+ ...sportWords,
3374
+ ...propertyOptions
3375
+ ];
3376
+ const typedRaw = before.trimStart();
3377
+ const typedStart = typedRaw.toLowerCase();
3378
+ const hasAliasHit = typedStart.length >= 2 && effortOptions.some((opt) => completionMatchesWord(opt, typedStart) === "alias");
3379
+ if (hasAliasHit) {
3380
+ const matched = allStartOptions.filter((opt) => completionMatchesWord(opt, typedStart) !== null);
3381
+ return {
3382
+ from: pos - typedRaw.length,
3383
+ options: appendCreateEffortOption(matched, typedRaw, options.onCreateEffort),
3384
+ filter: false,
3385
+ validFor: /^[A-Za-z]*$/
3386
+ };
3387
+ }
3194
3388
  return {
3195
- from: pos - before.trimStart().length,
3196
- options: [...COMPLETION_PROPERTY_KEYS.filter((key) => !supplied.has(key)).map((key) => ({ label: key, detail: "property", type: "property", boost: 5 })), ...snippets, ...keywords, ...efforts, ...sportWords],
3389
+ from: pos - typedRaw.length,
3390
+ options: appendCreateEffortOption(allStartOptions, typedRaw, options.onCreateEffort),
3197
3391
  validFor: /^[A-Za-z]*$/
3198
3392
  };
3199
3393
  }
@@ -3208,14 +3402,38 @@ function whiteboardScriptCompletionSource(options = {}) {
3208
3402
  (fragment) => fragment.firstChild?.name === "Action" && fragment.from < (quantity?.from ?? pos) && !context.state.doc.sliceString(fragment.from, fragment.to).includes(":")
3209
3403
  );
3210
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
+ );
3413
+ const wordText = completingWord ? context.state.doc.sliceString(last.from, pos).toLowerCase() : "";
3414
+ const hasAliasHit = wordText.length >= 2 && postQuantityEffortOptions.some((opt) => completionMatchesWord(opt, wordText) === "alias");
3415
+ const pool = [...unitPool, ...postQuantityEffortOptions];
3416
+ if (hasAliasHit && completingWord) {
3417
+ const rawPhrase = context.state.doc.sliceString(last.from, pos);
3418
+ return {
3419
+ from: last.from,
3420
+ options: appendCreateEffortOption(
3421
+ pool.filter((opt) => completionMatchesWord(opt, wordText) !== null),
3422
+ rawPhrase,
3423
+ options.onCreateEffort
3424
+ ),
3425
+ filter: false,
3426
+ validFor: /^[A-Za-z]*$/
3427
+ };
3428
+ }
3211
3429
  return {
3212
3430
  from: completingWord ? last.from : pos,
3213
- options: [...quantity.getChild("AtSign") ? massUnitOptions : allUnitOptions, ...effortOptions],
3431
+ options: completingWord ? appendCreateEffortOption(pool, context.state.doc.sliceString(last.from, pos), options.onCreateEffort) : pool,
3214
3432
  validFor: /^[A-Za-z]*$/
3215
3433
  };
3216
3434
  }
3217
3435
  if (before.trim() === "") {
3218
- return { from: pos, options: [...snippets, ...keywords, ...efforts, ...sportWords] };
3436
+ return { from: pos, options: [...snippets, ...startKeywords, ...efforts, ...sportWords] };
3219
3437
  }
3220
3438
  if (word.length === 0 && /[ \t]$/.test(before)) {
3221
3439
  const effortRun = trailingEffortRun(context, statement, units);
@@ -3228,12 +3446,16 @@ function whiteboardScriptCompletionSource(options = {}) {
3228
3446
  const first = effortRun[0];
3229
3447
  const last2 = effortRun[effortRun.length - 1];
3230
3448
  if (!first || !last2 || last2.to < pos) return null;
3231
- const typed = context.state.doc.sliceString(first.from, pos).toLowerCase();
3232
- const compatible = effortOptions.filter((option) => {
3233
- const inserted = typeof option.apply === "string" ? option.apply : option.label;
3234
- return inserted.toLowerCase().startsWith(typed) || option.label.toLowerCase().startsWith(typed);
3235
- });
3236
- return { from: first.from, options: compatible, validFor: /^[A-Za-z ]*$/ };
3449
+ const rawPhrase = context.state.doc.sliceString(first.from, pos);
3450
+ const typed = rawPhrase.toLowerCase();
3451
+ const compatible = effortOptions.filter((option) => completionMatchesWord(option, typed) !== null);
3452
+ const usesAlias = compatible.some((option) => completionMatchesWord(option, typed) === "alias");
3453
+ return {
3454
+ from: first.from,
3455
+ options: appendCreateEffortOption(compatible, rawPhrase, options.onCreateEffort),
3456
+ ...usesAlias ? { filter: false } : {},
3457
+ validFor: /^[A-Za-z ]*$/
3458
+ };
3237
3459
  }
3238
3460
  return null;
3239
3461
  };
@@ -15889,6 +16111,6 @@ function compareStatement(expectations, actual, mode) {
15889
16111
  return diffs;
15890
16112
  }
15891
16113
 
15892
- 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 };
15893
16115
  //# sourceMappingURL=index.mjs.map
15894
16116
  //# sourceMappingURL=index.mjs.map