@doenet/v06-to-v07 0.7.26-dev.545 → 0.7.26-dev.546

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.
@@ -47282,7 +47282,7 @@ async function cidFromArrayBuffer(data) {
47282
47282
  await crypto.subtle.digest("SHA-256", new Uint8Array());
47283
47283
  digest = (data2) => crypto.subtle.digest("SHA-256", data2);
47284
47284
  } catch (e22) {
47285
- const sha256 = (await import("./sha256-DT5xJ2Hv-CgHLfxWZ-kZCUXDZV.js").then((n2) => n2.s)).default;
47285
+ const sha256 = (await import("./sha256-DT5xJ2Hv-B_Fz0Lp3-K5IslGl5.js").then((n2) => n2.s)).default;
47286
47286
  digest = (data2) => sha256(data2, {
47287
47287
  asBytes: true
47288
47288
  });
@@ -48538,6 +48538,182 @@ function find_effective_domains_piecewise_children({
48538
48538
  }
48539
48539
  return effectiveChildDomains;
48540
48540
  }
48541
+ function groupCompositeRanges({
48542
+ children,
48543
+ ranges,
48544
+ isAbsent = () => false,
48545
+ isBlank = () => false,
48546
+ skipRange = () => false,
48547
+ trimEnd = (value) => value,
48548
+ startInd = 0,
48549
+ endInd = children.length - 1,
48550
+ removedInd = null
48551
+ }) {
48552
+ const ordered = (ranges ?? []).flatMap((range2) => {
48553
+ const span = shiftForRemovedChild(range2, removedInd);
48554
+ return span && span.firstInd >= startInd && span.lastInd <= endInd ? [{ range: range2, ...span }] : [];
48555
+ }).sort((a2, b2) => a2.firstInd - b2.firstInd || b2.lastInd - a2.lastInd);
48556
+ const root2 = {
48557
+ range: null,
48558
+ firstInd: startInd,
48559
+ lastInd: endInd,
48560
+ nextInd: startInd,
48561
+ eligibility: null,
48562
+ items: [],
48563
+ eligible: []
48564
+ };
48565
+ const open = [root2];
48566
+ function addPlainChildren(node, upTo) {
48567
+ for (; node.nextInd < upTo; node.nextInd++) {
48568
+ const value = children[node.nextInd];
48569
+ if (isAbsent(value)) {
48570
+ continue;
48571
+ }
48572
+ node.items.push({ kind: "child", value, index: node.nextInd });
48573
+ if (node.eligibility) {
48574
+ node.eligible.push(
48575
+ node.eligibility[node.nextInd - node.firstInd] ?? false
48576
+ );
48577
+ }
48578
+ }
48579
+ }
48580
+ function closeInnermost() {
48581
+ const node = open.pop();
48582
+ addPlainChildren(node, node.lastInd + 1);
48583
+ if (node.items.length === 0) {
48584
+ return;
48585
+ }
48586
+ const parent = open[open.length - 1];
48587
+ const listItems = node.items.filter(
48588
+ (item) => !isBlankGroup(item, isBlank)
48589
+ );
48590
+ const allEligible = node.eligible.every(
48591
+ (value, ind) => value || isBlankGroup(node.items[ind], isBlank)
48592
+ );
48593
+ const asList = Boolean(node.range.asList) && allEligible && listItems.length > 1;
48594
+ parent.items.push({
48595
+ kind: "composite",
48596
+ range: node.range,
48597
+ asList,
48598
+ items: asList ? prepareListItems(node.items, isBlank, trimEnd) : node.items
48599
+ });
48600
+ if (parent.eligibility) {
48601
+ parent.eligible.push(allEligible);
48602
+ }
48603
+ }
48604
+ for (const { range: range2, firstInd, lastInd } of ordered) {
48605
+ while (open.length > 1 && lastInd > open[open.length - 1].lastInd) {
48606
+ closeInnermost();
48607
+ }
48608
+ const parent = open[open.length - 1];
48609
+ if (firstInd < parent.nextInd) {
48610
+ continue;
48611
+ }
48612
+ addPlainChildren(parent, firstInd);
48613
+ parent.nextInd = lastInd + 1;
48614
+ if (skipRange(range2)) {
48615
+ continue;
48616
+ }
48617
+ open.push({
48618
+ range: range2,
48619
+ firstInd,
48620
+ lastInd,
48621
+ nextInd: firstInd,
48622
+ eligibility: range2.potentialListComponents ?? null,
48623
+ items: [],
48624
+ eligible: []
48625
+ });
48626
+ }
48627
+ while (open.length > 1) {
48628
+ closeInnermost();
48629
+ }
48630
+ addPlainChildren(root2, endInd + 1);
48631
+ return root2.items;
48632
+ }
48633
+ function shiftForRemovedChild(range2, removedInd) {
48634
+ let { firstInd, lastInd } = range2;
48635
+ if (removedInd === null) {
48636
+ return { firstInd, lastInd };
48637
+ }
48638
+ if (firstInd === removedInd || lastInd === removedInd) {
48639
+ return void 0;
48640
+ }
48641
+ if (firstInd > removedInd) {
48642
+ firstInd -= 1;
48643
+ }
48644
+ if (lastInd > removedInd) {
48645
+ lastInd -= 1;
48646
+ }
48647
+ return { firstInd, lastInd };
48648
+ }
48649
+ function isBlankGroup(group2, isBlank) {
48650
+ if (group2.kind === "child") {
48651
+ return isBlank(group2.value);
48652
+ }
48653
+ return group2.items.every((item) => isBlankGroup(item, isBlank));
48654
+ }
48655
+ function listCommaPositions(blank) {
48656
+ const commaBefore = new Array(blank.length);
48657
+ let itemAtOrAfter = false;
48658
+ for (let ind = blank.length - 1; ind >= 0; ind--) {
48659
+ itemAtOrAfter ||= !blank[ind];
48660
+ commaBefore[ind] = ind > 0 && !blank[ind - 1] && itemAtOrAfter;
48661
+ }
48662
+ return commaBefore;
48663
+ }
48664
+ function joinListText(parts, blank) {
48665
+ const commaBefore = listCommaPositions(blank);
48666
+ return parts.map((part, ind) => commaBefore[ind + 1] ? part.trimEnd() : part).map((part, ind) => commaBefore[ind] ? ", " + part : part).join("");
48667
+ }
48668
+ function prepareListItems(items, isBlank, trimEnd) {
48669
+ const firstItemInd = items.findIndex(
48670
+ (item) => !isBlankGroup(item, isBlank)
48671
+ );
48672
+ let lastItemInd = items.length - 1;
48673
+ while (lastItemInd > firstItemInd && isBlankGroup(items[lastItemInd], isBlank)) {
48674
+ lastItemInd--;
48675
+ }
48676
+ const prepared = [];
48677
+ for (const [ind, item] of items.entries()) {
48678
+ if (ind < firstItemInd || ind >= lastItemInd) {
48679
+ prepared.push(item);
48680
+ } else if (!isBlankGroup(item, isBlank)) {
48681
+ prepared.push(trimItemEnd(item, isBlank, trimEnd));
48682
+ } else if (item.kind === "composite") {
48683
+ prepared.push(withoutBlankChildren(item));
48684
+ }
48685
+ }
48686
+ return prepared;
48687
+ }
48688
+ function withoutBlankChildren(group2) {
48689
+ return {
48690
+ ...group2,
48691
+ items: group2.items.flatMap(
48692
+ (item) => item.kind === "composite" ? [withoutBlankChildren(item)] : []
48693
+ )
48694
+ };
48695
+ }
48696
+ function trimItemEnd(item, isBlank, trimEnd) {
48697
+ if (item.kind === "child") {
48698
+ const trimmed = trimEnd(item.value);
48699
+ return trimmed === item.value ? item : { ...item, value: trimmed };
48700
+ }
48701
+ let end = item.items.length;
48702
+ while (isBlankGroup(item.items[end - 1], isBlank)) {
48703
+ end--;
48704
+ }
48705
+ const emptiedComposites = item.items.slice(end).flatMap(
48706
+ (sub2) => sub2.kind === "composite" ? [withoutBlankChildren(sub2)] : []
48707
+ );
48708
+ return {
48709
+ ...item,
48710
+ items: [
48711
+ ...item.items.slice(0, end - 1),
48712
+ trimItemEnd(item.items[end - 1], isBlank, trimEnd),
48713
+ ...emptiedComposites
48714
+ ]
48715
+ };
48716
+ }
48541
48717
  const { gcd: gcd$3, lcm: lcm$1 } = Context.math;
48542
48718
  function enumerateSelectionCombinations({
48543
48719
  numberOfIndices,
@@ -55808,11 +55984,11 @@ async function determineParentAndIndexResolutionForResolver({
55808
55984
  let update_start = updateOldReplacementsStart;
55809
55985
  let update_end = updateOldReplacementsEnd;
55810
55986
  if (updateOldReplacementsStart !== void 0 && updateOldReplacementsEnd !== void 0) {
55811
- for (const [i2, isBlankString] of (blankStringReplacements ?? []).entries()) {
55987
+ for (const [i2, isBlankString2] of (blankStringReplacements ?? []).entries()) {
55812
55988
  if (i2 >= updateOldReplacementsEnd) {
55813
55989
  break;
55814
55990
  }
55815
- if (isBlankString) {
55991
+ if (isBlankString2) {
55816
55992
  update_end--;
55817
55993
  if (i2 < updateOldReplacementsStart) {
55818
55994
  update_start--;
@@ -56876,7 +57052,8 @@ function recursivelyReplaceCompositesWithReplacements({
56876
57052
  replacements,
56877
57053
  recurseNonStandardComposites = false,
56878
57054
  includeWithheldReplacements = false,
56879
- stopIfHaveProp
57055
+ stopIfHaveProp,
57056
+ stopAtListComposites = false
56880
57057
  }) {
56881
57058
  let compositesFound = [];
56882
57059
  let newReplacements = [];
@@ -56901,6 +57078,10 @@ function recursivelyReplaceCompositesWithReplacements({
56901
57078
  continue;
56902
57079
  }
56903
57080
  }
57081
+ if (stopAtListComposites && "asList" in replacement.state) {
57082
+ newReplacements.push(replacement);
57083
+ continue;
57084
+ }
56904
57085
  compositesFound.push(replacement.componentIdx);
56905
57086
  if (!replacement.isExpanded) {
56906
57087
  if (replacement.state.readyToExpandWhenResolved.isResolved) {
@@ -56923,7 +57104,8 @@ function recursivelyReplaceCompositesWithReplacements({
56923
57104
  replacements: replacementReplacements,
56924
57105
  recurseNonStandardComposites,
56925
57106
  includeWithheldReplacements,
56926
- stopIfHaveProp
57107
+ stopIfHaveProp,
57108
+ stopAtListComposites
56927
57109
  });
56928
57110
  compositesFound.push(...recursionResult.compositesFound);
56929
57111
  newReplacements.push(...recursionResult.newReplacements);
@@ -63628,6 +63810,7 @@ const _ReplacementDependency = class _ReplacementDependency2 extends Dependency
63628
63810
  }
63629
63811
  }
63630
63812
  this.stopIfHaveProp = this.definition.stopIfHaveProp;
63813
+ this.stopAtListComposites = this.definition.stopAtListComposites;
63631
63814
  this.includeWithheldReplacements = this.definition.includeWithheldReplacements;
63632
63815
  this.expandReplacements = true;
63633
63816
  }
@@ -63736,6 +63919,7 @@ const _ReplacementDependency = class _ReplacementDependency2 extends Dependency
63736
63919
  core: this.dependencyHandler.core,
63737
63920
  replacements,
63738
63921
  recurseNonStandardComposites: this.recurseNonStandardComposites,
63922
+ stopAtListComposites: this.stopAtListComposites,
63739
63923
  includeWithheldReplacements: this.includeWithheldReplacements,
63740
63924
  stopIfHaveProp: this.stopIfHaveProp
63741
63925
  });
@@ -76564,98 +76748,33 @@ function textFromComponent(component) {
76564
76748
  return " ";
76565
76749
  }
76566
76750
  }
76751
+ function isBlankString(child) {
76752
+ return typeof child === "string" && child.trim() === "";
76753
+ }
76567
76754
  function textFromChildren(children, textFromComponentConverter = textFromComponent) {
76568
- let result2 = textFromChildrenSub({
76569
- compositeReplacementRange: children.compositeReplacementRange,
76755
+ const groups = groupCompositeRanges({
76570
76756
  children,
76571
- startInd: 0,
76572
- endInd: children.length - 1,
76573
- textFromComponentConverter
76757
+ ranges: children.compositeReplacementRange,
76758
+ isBlank: isBlankString,
76759
+ // A hidden composite contributes nothing, not even its children's text.
76760
+ skipRange: (range2) => Boolean(range2.hidden)
76574
76761
  });
76575
- return result2.newChildren.map(textFromComponentConverter).join("");
76762
+ return groups.map((group2) => textFromGroup(group2, textFromComponentConverter)).join("");
76576
76763
  }
76577
- function textFromChildrenSub({
76578
- compositeReplacementRange,
76579
- children,
76580
- startInd,
76581
- endInd,
76582
- textFromComponentConverter,
76583
- potentialListComponents
76584
- }) {
76585
- let newChildren = [];
76586
- let newPotentialListComponents = [];
76587
- let lastChildInd = startInd - 1;
76588
- let lastChildIndIncludingEmptyComposites = lastChildInd;
76589
- for (let rangeInd = 0; rangeInd < compositeReplacementRange.length; rangeInd++) {
76590
- let range2 = compositeReplacementRange[rangeInd];
76591
- let rangeFirstInd = range2.firstInd;
76592
- let rangeLastInd = range2.lastInd;
76593
- if (rangeFirstInd > lastChildInd && rangeLastInd <= endInd) {
76594
- if (lastChildInd + 1 < rangeFirstInd) {
76595
- newChildren.push(
76596
- ...children.slice(lastChildInd + 1, rangeFirstInd)
76597
- );
76598
- if (potentialListComponents) {
76599
- newPotentialListComponents.push(
76600
- ...potentialListComponents.slice(
76601
- lastChildInd - startInd + 1,
76602
- rangeFirstInd - startInd
76603
- )
76604
- );
76605
- }
76606
- }
76607
- if (!range2.hidden) {
76608
- let subReplacementRange = compositeReplacementRange.slice(
76609
- rangeInd + 1
76610
- );
76611
- let {
76612
- newChildren: childrenInRange,
76613
- newPotentialListComponents: potentialListComponentsInRange
76614
- } = textFromChildrenSub({
76615
- compositeReplacementRange: subReplacementRange,
76616
- children,
76617
- startInd: rangeFirstInd,
76618
- endInd: rangeLastInd,
76619
- textFromComponentConverter,
76620
- potentialListComponents: range2.potentialListComponents
76621
- });
76622
- let allAreListComponents = potentialListComponentsInRange.every(
76623
- (x2) => x2
76624
- );
76625
- if (range2.asList && allAreListComponents && childrenInRange.length > 1) {
76626
- newChildren.push(
76627
- childrenInRange.map(textFromComponentConverter).filter((v2) => v2 !== "").map(
76628
- (v2, i2, a2) => i2 === a2.length - 1 ? v2 : v2.trimEnd()
76629
- ).join(", ")
76630
- );
76631
- } else {
76632
- newChildren.push(
76633
- childrenInRange.map(textFromComponentConverter).join("")
76634
- );
76635
- }
76636
- if (potentialListComponents) {
76637
- newPotentialListComponents.push(allAreListComponents);
76638
- }
76639
- }
76640
- lastChildInd = rangeLastInd;
76641
- lastChildIndIncludingEmptyComposites = Math.max(
76642
- rangeFirstInd,
76643
- rangeLastInd
76644
- );
76645
- }
76764
+ function textFromGroup(group2, convert) {
76765
+ if (group2.kind === "child") {
76766
+ return convert(group2.value);
76646
76767
  }
76647
- if (lastChildInd < endInd) {
76648
- newChildren.push(...children.slice(lastChildInd + 1, endInd + 1));
76649
- if (potentialListComponents) {
76650
- newPotentialListComponents.push(
76651
- ...potentialListComponents.slice(
76652
- lastChildIndIncludingEmptyComposites - startInd + 1,
76653
- endInd - startInd + 1
76654
- )
76655
- );
76656
- }
76768
+ const parts = group2.items.map((item) => textFromGroup(item, convert));
76769
+ if (!group2.asList) {
76770
+ return parts.join("");
76657
76771
  }
76658
- return { newChildren, newPotentialListComponents };
76772
+ return joinListText(
76773
+ parts,
76774
+ group2.items.map(
76775
+ (item, ind) => parts[ind] === "" || isBlankGroup(item, isBlankString)
76776
+ )
76777
+ );
76659
76778
  }
76660
76779
  function returnTextPieceStateVariableDefinitions() {
76661
76780
  let stateVariableDefinitions = {};
@@ -79319,198 +79438,111 @@ function createInputStringFromChildren({
79319
79438
  nonStringInd++;
79320
79439
  }
79321
79440
  }
79322
- let result2 = createInputStringFromChildrenSub({
79323
- compositeReplacementRange: children.compositeReplacementRange,
79441
+ const groups = groupCompositeRanges({
79442
+ children,
79443
+ ranges: children.compositeReplacementRange,
79444
+ isBlank: (child) => typeof child === "string" && child.trim() === ""
79445
+ });
79446
+ const context = {
79324
79447
  children,
79325
- startInd: 0,
79326
- endInd: children.length - 1,
79327
79448
  nonStringIndByChild,
79328
79449
  format: format2,
79329
79450
  codePre,
79330
79451
  createInternalLists,
79331
79452
  nextInternalListInd: nonStringInd,
79453
+ internalLists: {},
79332
79454
  parser: parser2,
79333
79455
  createDisplayedMathString,
79334
79456
  displayedMathSlotForChild
79335
- });
79457
+ };
79336
79458
  let joinString = createDisplayedMathString ? " " : "";
79337
79459
  return {
79338
- string: result2.newChildren.join(joinString),
79339
- internalLists: result2.internalLists
79460
+ string: stringFromGroups(groups, context).join(joinString),
79461
+ internalLists: context.internalLists
79340
79462
  };
79341
79463
  }
79342
- function createInputStringFromChildrenSub({
79343
- compositeReplacementRange,
79344
- children,
79345
- startInd,
79346
- endInd,
79347
- nonStringIndByChild,
79348
- format: format2,
79349
- codePre,
79350
- potentialListComponents,
79351
- createInternalLists,
79352
- nextInternalListInd,
79353
- parser: parser2,
79354
- createDisplayedMathString,
79355
- displayedMathSlotForChild
79356
- }) {
79357
- let newChildren = [];
79358
- let newPotentialListComponents = [];
79359
- let lastChildInd = startInd - 1;
79360
- let internalLists = {};
79361
- let leftDelimiters = ["{", "[", "(", "|", ","];
79362
- let rightDelimiters = ["}", "]", ")", "|", ","];
79363
- if (compositeReplacementRange) {
79364
- for (let rangeInd = 0; rangeInd < compositeReplacementRange.length; rangeInd++) {
79365
- let range2 = compositeReplacementRange[rangeInd];
79366
- let rangeFirstInd = range2.firstInd;
79367
- let rangeLastInd = range2.lastInd;
79368
- if (rangeFirstInd > lastChildInd && rangeLastInd <= endInd) {
79369
- if (lastChildInd + 1 < rangeFirstInd) {
79370
- for (let ind = lastChildInd + 1; ind < rangeFirstInd; ind++) {
79371
- newChildren.push(
79372
- baseStringFromChildren({
79373
- children,
79374
- startInd: ind,
79375
- endInd: ind,
79376
- nonStringIndByChild,
79377
- format: format2,
79378
- codePre,
79379
- createDisplayedMathString,
79380
- displayedMathSlotForChild
79381
- })
79382
- );
79383
- }
79384
- if (potentialListComponents) {
79385
- newPotentialListComponents.push(
79386
- ...potentialListComponents.slice(
79387
- lastChildInd - startInd + 1,
79388
- rangeFirstInd - startInd
79389
- )
79390
- );
79391
- }
79392
- }
79393
- let subReplacementRange = compositeReplacementRange.slice(
79394
- rangeInd + 1
79395
- );
79396
- let {
79397
- newChildren: childrenInRange,
79398
- newPotentialListComponents: potentialListComponentsInRange,
79399
- internalLists: newInternalLists
79400
- } = createInputStringFromChildrenSub({
79401
- compositeReplacementRange: subReplacementRange,
79402
- children,
79403
- startInd: rangeFirstInd,
79404
- endInd: rangeLastInd,
79405
- nonStringIndByChild,
79406
- format: format2,
79407
- codePre,
79408
- potentialListComponents: range2.potentialListComponents,
79409
- createInternalLists,
79410
- nextInternalListInd,
79411
- parser: parser2,
79412
- createDisplayedMathString,
79413
- displayedMathSlotForChild
79414
- });
79415
- Object.assign(internalLists, newInternalLists);
79416
- nextInternalListInd += Object.keys(newInternalLists).length;
79417
- let allAreListComponents = potentialListComponentsInRange.every(
79418
- (x2) => x2
79419
- );
79420
- if (range2.asList && allAreListComponents && childrenInRange.length > 1) {
79421
- let listString = childrenInRange.filter((v2) => v2.trim() !== "").map(
79422
- (v2, i2, a2) => i2 === a2.length - 1 ? v2 : v2.trimEnd()
79423
- ).join(", ");
79424
- let wrap2 = false;
79425
- for (let prevInd = rangeFirstInd - 1; prevInd >= 0; prevInd--) {
79426
- let prevChild = children[prevInd];
79427
- if (typeof prevChild !== "string") {
79428
- wrap2 = true;
79429
- break;
79430
- }
79431
- prevChild = prevChild.trim();
79432
- if (prevChild.length === 0) {
79433
- continue;
79434
- }
79435
- if (!leftDelimiters.includes(
79436
- prevChild[prevChild.length - 1]
79437
- )) {
79438
- wrap2 = true;
79439
- }
79440
- break;
79441
- }
79442
- if (!wrap2) {
79443
- for (let nextInd = rangeLastInd + 1; nextInd < children.length; nextInd++) {
79444
- let nextChild = children[nextInd];
79445
- if (typeof nextChild !== "string") {
79446
- wrap2 = true;
79447
- break;
79448
- }
79449
- nextChild = nextChild.trim();
79450
- if (nextChild.length === 0) {
79451
- continue;
79452
- }
79453
- let nextChar = nextChild[0];
79454
- if (format2 === "latex" && nextChar === "\\" && nextChild.length > 1) {
79455
- nextChar = nextChild[1];
79456
- }
79457
- if (!rightDelimiters.includes(nextChar)) {
79458
- wrap2 = true;
79459
- }
79460
- break;
79461
- }
79462
- }
79463
- if (wrap2) {
79464
- if (createInternalLists) {
79465
- let code = codePre + nextInternalListInd;
79466
- internalLists[code] = parser2?.(listString) ?? "";
79467
- nextInternalListInd++;
79468
- listString = returnStringForCode(format2, code);
79469
- } else if (!createDisplayedMathString) {
79470
- listString = "(" + listString + ")";
79471
- }
79472
- }
79473
- newChildren.push(listString);
79474
- } else {
79475
- let joinString = createDisplayedMathString ? " " : "";
79476
- newChildren.push(childrenInRange.join(joinString));
79477
- }
79478
- if (potentialListComponents) {
79479
- newPotentialListComponents.push(allAreListComponents);
79480
- }
79481
- lastChildInd = rangeLastInd;
79482
- }
79483
- }
79484
- }
79485
- if (lastChildInd < endInd) {
79486
- for (let ind = lastChildInd + 1; ind <= endInd; ind++) {
79487
- newChildren.push(
79464
+ function stringFromGroups(groups, context) {
79465
+ const strings = [];
79466
+ for (const group2 of groups) {
79467
+ if (group2.kind === "child") {
79468
+ strings.push(
79488
79469
  baseStringFromChildren({
79489
- children,
79490
- startInd: ind,
79491
- endInd: ind,
79492
- nonStringIndByChild,
79493
- format: format2,
79494
- codePre,
79495
- createDisplayedMathString,
79496
- displayedMathSlotForChild
79470
+ ...context,
79471
+ startInd: group2.index,
79472
+ endInd: group2.index
79497
79473
  })
79498
79474
  );
79475
+ continue;
79499
79476
  }
79500
- if (potentialListComponents) {
79501
- newPotentialListComponents.push(
79502
- ...potentialListComponents.slice(
79503
- lastChildInd - startInd + 1,
79504
- endInd - startInd + 1
79505
- )
79477
+ const parts = stringFromGroups(group2.items, context);
79478
+ if (!group2.asList) {
79479
+ strings.push(
79480
+ parts.join(context.createDisplayedMathString ? " " : "")
79506
79481
  );
79482
+ continue;
79507
79483
  }
79484
+ const listString = joinListText(
79485
+ parts,
79486
+ parts.map((part) => part.trim() === "")
79487
+ );
79488
+ strings.push(wrapListIfNeeded(listString, group2.range, context));
79489
+ }
79490
+ return strings;
79491
+ }
79492
+ function wrapListIfNeeded(listString, range2, context) {
79493
+ const { children, format: format2, codePre, createInternalLists, parser: parser2 } = context;
79494
+ const leftDelimiters = ["{", "[", "(", "|", ","];
79495
+ const rightDelimiters = ["}", "]", ")", "|", ","];
79496
+ let wrap2 = false;
79497
+ for (let prevInd = range2.firstInd - 1; prevInd >= 0; prevInd--) {
79498
+ let prevChild = children[prevInd];
79499
+ if (typeof prevChild !== "string") {
79500
+ wrap2 = true;
79501
+ break;
79502
+ }
79503
+ prevChild = prevChild.trim();
79504
+ if (prevChild.length === 0) {
79505
+ continue;
79506
+ }
79507
+ if (!leftDelimiters.includes(prevChild[prevChild.length - 1])) {
79508
+ wrap2 = true;
79509
+ }
79510
+ break;
79508
79511
  }
79509
- return {
79510
- newChildren,
79511
- newPotentialListComponents,
79512
- internalLists
79513
- };
79512
+ if (!wrap2) {
79513
+ for (let nextInd = range2.lastInd + 1; nextInd < children.length; nextInd++) {
79514
+ let nextChild = children[nextInd];
79515
+ if (typeof nextChild !== "string") {
79516
+ wrap2 = true;
79517
+ break;
79518
+ }
79519
+ nextChild = nextChild.trim();
79520
+ if (nextChild.length === 0) {
79521
+ continue;
79522
+ }
79523
+ let nextChar = nextChild[0];
79524
+ if (format2 === "latex" && nextChar === "\\" && nextChild.length > 1) {
79525
+ nextChar = nextChild[1];
79526
+ }
79527
+ if (!rightDelimiters.includes(nextChar)) {
79528
+ wrap2 = true;
79529
+ }
79530
+ break;
79531
+ }
79532
+ }
79533
+ if (!wrap2) {
79534
+ return listString;
79535
+ }
79536
+ if (createInternalLists) {
79537
+ const code = codePre + context.nextInternalListInd;
79538
+ context.internalLists[code] = parser2?.(listString) ?? "";
79539
+ context.nextInternalListInd++;
79540
+ return returnStringForCode(format2, code);
79541
+ }
79542
+ if (context.createDisplayedMathString) {
79543
+ return listString;
79544
+ }
79545
+ return "(" + listString + ")";
79514
79546
  }
79515
79547
  function baseStringFromChildren({
79516
79548
  children,
@@ -235526,6 +235558,12 @@ class Copy extends CompositeComponent {
235526
235558
  compositeIdx: stateValues.extendedComponent.componentIdx,
235527
235559
  recursive: true,
235528
235560
  recurseNonStandardComposites: stateValues.unresolvedPath != null,
235561
+ // While a path is still to be resolved, the
235562
+ // recursion has to reach every replacement. Once
235563
+ // the reference has resolved to the composite
235564
+ // itself, a list composite among its replacements
235565
+ // is kept whole, so the copy shows its commas.
235566
+ stopAtListComposites: stateValues.unresolvedPath == null,
235529
235567
  includeWithheldReplacements: true,
235530
235568
  stopIfHaveProp: firstPropNameFromPath
235531
235569
  };
@@ -241107,4 +241145,4 @@ export {
241107
241145
  getDefaultExportFromCjs$1 as g,
241108
241146
  updateSyntaxFromV06toV07 as u
241109
241147
  };
241110
- //# sourceMappingURL=index-BsToiKop.js.map
241148
+ //# sourceMappingURL=index-CJq47FJf.js.map