@cs-object/react 0.1.0 → 1.0.0
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.cjs +2858 -399
- package/dist/index.d.cts +53 -2
- package/dist/index.d.ts +53 -2
- package/dist/index.js +2832 -366
- package/dist/style.css +1 -1
- package/package.json +10 -8
package/dist/index.cjs
CHANGED
|
@@ -53,18 +53,22 @@ __export(index_exports, {
|
|
|
53
53
|
DocumentPreparationError: () => DocumentPreparationError,
|
|
54
54
|
FormulaSheet: () => FormulaSheet,
|
|
55
55
|
PreparedFormulaSheet: () => PreparedFormulaSheet,
|
|
56
|
+
measureComparisons: () => measureComparisons,
|
|
57
|
+
partitionRowAxis: () => partitionRowAxis,
|
|
58
|
+
planComparisonParts: () => planComparisonParts,
|
|
56
59
|
prepareExecutionDocument: () => prepareExecutionDocument,
|
|
57
60
|
prepareLegacyDocument: () => prepareLegacyDocument,
|
|
58
|
-
printFormulaSheet: () => printFormulaSheet
|
|
61
|
+
printFormulaSheet: () => printFormulaSheet,
|
|
62
|
+
renderComparisonParts: () => renderComparisonParts
|
|
59
63
|
});
|
|
60
64
|
module.exports = __toCommonJS(index_exports);
|
|
61
65
|
|
|
62
66
|
// src/formula-sheet/tokens.ts
|
|
63
|
-
var headerTextClass = "font-['Plus_Jakarta_Sans'] text-[12px] text-
|
|
67
|
+
var headerTextClass = "font-['Plus_Jakarta_Sans'] text-[12px] text-slate-600";
|
|
64
68
|
var valueTextClass = "font-['KaTeX_Main'] text-[16.335px]";
|
|
65
69
|
var FORMULA_SHEET_SPACER_CELL_CLASS = "w-[1.5%] p-[3px]";
|
|
66
70
|
var FORMULA_SHEET_DESCRIPTION_CELL_CLASS = `flex w-[37%] flex-col justify-start py-[3px] ${headerTextClass}`;
|
|
67
|
-
var FORMULA_SHEET_COMMENT_CELL_CLASS = `flex w-[23.5%] flex-col justify-start py-[3px]
|
|
71
|
+
var FORMULA_SHEET_COMMENT_CELL_CLASS = `flex w-[23.5%] flex-col justify-start py-[3px] ${headerTextClass}`;
|
|
68
72
|
var FORMULA_SHEET_SYMBOL_CELL_BASE_CLASS = "flex w-[14%] min-w-[14%] items-center justify-end overflow-visible border-r border-gray-300";
|
|
69
73
|
var FORMULA_SHEET_SYMBOL_CELL_HEADER_CLASS = `p-[3px] ${headerTextClass}`;
|
|
70
74
|
var FORMULA_SHEET_SYMBOL_CELL_VALUE_CLASS = `p-[3px] pr-[5px] ${valueTextClass}`;
|
|
@@ -195,11 +199,6 @@ var import_core2 = require("@cs-object/core");
|
|
|
195
199
|
|
|
196
200
|
// src/ascii-math/NotationMathmlView.tsx
|
|
197
201
|
var import_core = require("@cs-object/core");
|
|
198
|
-
|
|
199
|
-
// src/mathml/constants.ts
|
|
200
|
-
var MATHML_FONT_SIZE = "15px";
|
|
201
|
-
|
|
202
|
-
// src/ascii-math/NotationMathmlView.tsx
|
|
203
202
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
204
203
|
var fenceCharacters = {
|
|
205
204
|
round: ["(", ")"],
|
|
@@ -292,8 +291,8 @@ var NotationNodeMathmlView = ({
|
|
|
292
291
|
);
|
|
293
292
|
case "fraction":
|
|
294
293
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("mfrac", { children: [
|
|
295
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("
|
|
296
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("
|
|
294
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("mrow", { children: renderNode(node.numerator) }),
|
|
295
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("mrow", { children: renderNode(node.denominator) })
|
|
297
296
|
] });
|
|
298
297
|
case "subscript":
|
|
299
298
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("msub", { children: [
|
|
@@ -341,6 +340,9 @@ var AsciiMathView = (_a) => {
|
|
|
341
340
|
);
|
|
342
341
|
};
|
|
343
342
|
|
|
343
|
+
// src/mathml/constants.ts
|
|
344
|
+
var MATHML_FONT_SIZE = "15px";
|
|
345
|
+
|
|
344
346
|
// src/mathml/props.ts
|
|
345
347
|
var defaultMathBlockProps = {
|
|
346
348
|
style: {
|
|
@@ -384,47 +386,70 @@ var UnitMathBlock = ({
|
|
|
384
386
|
) }));
|
|
385
387
|
|
|
386
388
|
// src/formula-sheet/FormulaSheetSymbolRow.tsx
|
|
387
|
-
var
|
|
389
|
+
var import_core10 = require("@cs-object/core");
|
|
388
390
|
|
|
389
391
|
// src/formula-sheet/FormulaSheetResultCell.tsx
|
|
392
|
+
var import_core4 = require("@cs-object/core");
|
|
393
|
+
|
|
394
|
+
// src/formula-sheet/NumericalValue.tsx
|
|
390
395
|
var import_core3 = require("@cs-object/core");
|
|
391
396
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
397
|
+
var NumericalValue = ({
|
|
398
|
+
value,
|
|
399
|
+
numericKind
|
|
400
|
+
}) => {
|
|
401
|
+
const formatted = Object.is(value, -0) ? "-0" : numericKind === "int" ? String(value) : (0, import_core3.formatNumerical)(value);
|
|
402
|
+
const text = formatted.startsWith("(") ? formatted.slice(1, -1) : formatted;
|
|
403
|
+
const scientific = /^(-?[\d.]+)e([+-]?\d+)$/u.exec(text);
|
|
404
|
+
return scientific ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("math", { style: { fontSize: "inherit", fontFamily: "inherit" }, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("mrow", { children: [
|
|
405
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("mn", { children: scientific[1] }),
|
|
406
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("mo", { children: "\xD7" }),
|
|
407
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("msup", { children: [
|
|
408
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("mn", { children: "10" }),
|
|
409
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("mn", { children: String(Number(scientific[2])) })
|
|
410
|
+
] })
|
|
411
|
+
] }) }) : formatted;
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
// src/formula-sheet/FormulaSheetResultCell.tsx
|
|
415
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
392
416
|
var FormulaSheetResultCell = ({
|
|
393
|
-
literal
|
|
417
|
+
literal,
|
|
418
|
+
numericKind
|
|
394
419
|
}) => {
|
|
395
|
-
const formattedValue = (0,
|
|
396
|
-
return /* @__PURE__ */ (0,
|
|
420
|
+
const formattedValue = literal.kind === "number" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(NumericalValue, { value: literal.value, numericKind }) : (0, import_core4.sheetLiteralToDisplayString)(literal);
|
|
421
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(FormulaSheetValueCell, { children: (0, import_core4.isSheetLiteralEmpty)(literal) ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "rounded-sm bg-orange-500 px-1.5 py-0 text-black opacity-70", children: "NaN" }) : formattedValue });
|
|
397
422
|
};
|
|
398
423
|
|
|
399
424
|
// src/formula-sheet/FormulaSheetValueTree.tsx
|
|
400
|
-
var
|
|
425
|
+
var import_core9 = require("@cs-object/core");
|
|
401
426
|
|
|
402
427
|
// src/mathml/symbol-value/ValueTreeMathmlRenderer.tsx
|
|
403
|
-
var
|
|
428
|
+
var import_core8 = require("@cs-object/core");
|
|
404
429
|
|
|
405
430
|
// src/mathml/function-renderers.tsx
|
|
406
|
-
var
|
|
407
|
-
var baseStyle = {
|
|
408
|
-
var
|
|
431
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
432
|
+
var baseStyle = { textAlign: "left" };
|
|
433
|
+
var branchStyle = __spreadProps(__spreadValues({}, baseStyle), { paddingBlock: "0.4em" });
|
|
409
434
|
var ConditionalFunctionMathml = ({
|
|
410
435
|
argCnd,
|
|
411
436
|
argTrue,
|
|
412
437
|
argFalse
|
|
413
438
|
}) => {
|
|
414
|
-
return /* @__PURE__ */ (0,
|
|
415
|
-
/* @__PURE__ */ (0,
|
|
416
|
-
/* @__PURE__ */ (0,
|
|
417
|
-
/* @__PURE__ */ (0,
|
|
418
|
-
/* @__PURE__ */ (0,
|
|
419
|
-
/* @__PURE__ */ (0,
|
|
420
|
-
/* @__PURE__ */ (0,
|
|
421
|
-
/* @__PURE__ */ (0,
|
|
439
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("mrow", { style: baseStyle, children: [
|
|
440
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mo", { children: "{" }),
|
|
441
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("mtable", { columnalign: "left", style: baseStyle, children: [
|
|
442
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("mtr", { children: [
|
|
443
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mtd", { style: __spreadProps(__spreadValues({}, branchStyle), { paddingRight: "0.5em" }), children: argTrue }),
|
|
444
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("mtd", { style: branchStyle, children: [
|
|
445
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mtext", { children: "if " }),
|
|
446
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mspace", { width: "5px" }),
|
|
422
447
|
argCnd
|
|
423
448
|
] })
|
|
424
449
|
] }),
|
|
425
|
-
/* @__PURE__ */ (0,
|
|
426
|
-
/* @__PURE__ */ (0,
|
|
427
|
-
/* @__PURE__ */ (0,
|
|
450
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("mtr", { children: [
|
|
451
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mtd", { style: __spreadProps(__spreadValues({}, branchStyle), { paddingRight: "0.5em" }), children: argFalse }),
|
|
452
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mtd", { style: branchStyle, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mtext", { children: "otherwise." }) })
|
|
428
453
|
] })
|
|
429
454
|
] })
|
|
430
455
|
] });
|
|
@@ -433,39 +458,39 @@ var FractionFunctionMathml = ({
|
|
|
433
458
|
numerator,
|
|
434
459
|
denominator
|
|
435
460
|
}) => {
|
|
436
|
-
return /* @__PURE__ */ (0,
|
|
437
|
-
/* @__PURE__ */ (0,
|
|
438
|
-
/* @__PURE__ */ (0,
|
|
461
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("mfrac", { children: [
|
|
462
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mrow", { style: { fontSize: "1em" }, children: numerator }),
|
|
463
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mrow", { style: { fontSize: "1em" }, children: denominator })
|
|
439
464
|
] });
|
|
440
465
|
};
|
|
441
466
|
var PowerFunctionMathml = ({
|
|
442
467
|
base,
|
|
443
468
|
exponent
|
|
444
469
|
}) => {
|
|
445
|
-
return /* @__PURE__ */ (0,
|
|
446
|
-
/* @__PURE__ */ (0,
|
|
447
|
-
/* @__PURE__ */ (0,
|
|
470
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("msup", { children: [
|
|
471
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mrow", { children: base }),
|
|
472
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mrow", { children: exponent })
|
|
448
473
|
] });
|
|
449
474
|
};
|
|
450
475
|
var SquareRootFunctionMathml = ({
|
|
451
476
|
value
|
|
452
477
|
}) => {
|
|
453
|
-
return /* @__PURE__ */ (0,
|
|
478
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("msqrt", { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mstyle", { style: { padding: "0.2em" }, children: value }) });
|
|
454
479
|
};
|
|
455
480
|
var AbsoluteValueFunctionMathml = ({
|
|
456
481
|
value
|
|
457
482
|
}) => {
|
|
458
|
-
return /* @__PURE__ */ (0,
|
|
459
|
-
/* @__PURE__ */ (0,
|
|
483
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("mrow", { children: [
|
|
484
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mo", { fence: "true", stretchy: "true", children: "|" }),
|
|
460
485
|
value,
|
|
461
|
-
/* @__PURE__ */ (0,
|
|
486
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mo", { fence: "true", stretchy: "true", children: "|" })
|
|
462
487
|
] });
|
|
463
488
|
};
|
|
464
489
|
var UnaryMinusFunctionMathml = ({
|
|
465
490
|
value
|
|
466
491
|
}) => {
|
|
467
|
-
return /* @__PURE__ */ (0,
|
|
468
|
-
/* @__PURE__ */ (0,
|
|
492
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("mrow", { children: [
|
|
493
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mo", { children: "-" }),
|
|
469
494
|
value
|
|
470
495
|
] });
|
|
471
496
|
};
|
|
@@ -473,17 +498,42 @@ var renderSpecialValueFunction = ({
|
|
|
473
498
|
functionId,
|
|
474
499
|
argReactNodes
|
|
475
500
|
}) => {
|
|
501
|
+
if (functionId === "fg.not" && argReactNodes.length === 1) {
|
|
502
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("mrow", { children: [
|
|
503
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mo", { form: "prefix", rspace: "0.3em", children: "not" }),
|
|
504
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("mrow", { children: [
|
|
505
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mo", { fence: "true", children: "(" }),
|
|
506
|
+
argReactNodes[0],
|
|
507
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mo", { fence: "true", children: ")" })
|
|
508
|
+
] })
|
|
509
|
+
] });
|
|
510
|
+
}
|
|
511
|
+
if (functionId === "fg.xor" && argReactNodes.length === 2) {
|
|
512
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("mrow", { children: [
|
|
513
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("mrow", { children: [
|
|
514
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mo", { fence: "true", children: "(" }),
|
|
515
|
+
argReactNodes[0],
|
|
516
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mo", { fence: "true", children: ")" })
|
|
517
|
+
] }),
|
|
518
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mo", { form: "infix", lspace: "0.3em", rspace: "0.3em", children: "xor" }),
|
|
519
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("mrow", { children: [
|
|
520
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mo", { fence: "true", children: "(" }),
|
|
521
|
+
argReactNodes[1],
|
|
522
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mo", { fence: "true", children: ")" })
|
|
523
|
+
] })
|
|
524
|
+
] });
|
|
525
|
+
}
|
|
476
526
|
if (functionId === "fg.abs" && argReactNodes.length === 1) {
|
|
477
|
-
return /* @__PURE__ */ (0,
|
|
527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AbsoluteValueFunctionMathml, { value: argReactNodes[0] });
|
|
478
528
|
}
|
|
479
529
|
if (functionId === "fg.sqrt" && argReactNodes.length === 1) {
|
|
480
|
-
return /* @__PURE__ */ (0,
|
|
530
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SquareRootFunctionMathml, { value: argReactNodes[0] });
|
|
481
531
|
}
|
|
482
532
|
if (functionId === "fg.uminus" && argReactNodes.length === 1) {
|
|
483
|
-
return /* @__PURE__ */ (0,
|
|
533
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(UnaryMinusFunctionMathml, { value: argReactNodes[0] });
|
|
484
534
|
}
|
|
485
535
|
if (functionId === "fg.cnd" && argReactNodes.length === 3) {
|
|
486
|
-
return /* @__PURE__ */ (0,
|
|
536
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
487
537
|
ConditionalFunctionMathml,
|
|
488
538
|
{
|
|
489
539
|
argCnd: argReactNodes[0],
|
|
@@ -493,7 +543,7 @@ var renderSpecialValueFunction = ({
|
|
|
493
543
|
);
|
|
494
544
|
}
|
|
495
545
|
if (functionId === "fg.divide" && argReactNodes.length === 2) {
|
|
496
|
-
return /* @__PURE__ */ (0,
|
|
546
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
497
547
|
FractionFunctionMathml,
|
|
498
548
|
{
|
|
499
549
|
numerator: argReactNodes[0],
|
|
@@ -502,7 +552,7 @@ var renderSpecialValueFunction = ({
|
|
|
502
552
|
);
|
|
503
553
|
}
|
|
504
554
|
if (functionId === "fg.pow" && argReactNodes.length === 2) {
|
|
505
|
-
return /* @__PURE__ */ (0,
|
|
555
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
506
556
|
PowerFunctionMathml,
|
|
507
557
|
{
|
|
508
558
|
base: argReactNodes[0],
|
|
@@ -514,9 +564,9 @@ var renderSpecialValueFunction = ({
|
|
|
514
564
|
};
|
|
515
565
|
|
|
516
566
|
// src/mathml/symbol-value/components.tsx
|
|
517
|
-
var
|
|
567
|
+
var import_core5 = require("@cs-object/core");
|
|
518
568
|
var import_react = require("react");
|
|
519
|
-
var
|
|
569
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
520
570
|
var isDraftPositionValid = ({
|
|
521
571
|
draft,
|
|
522
572
|
position
|
|
@@ -552,43 +602,39 @@ var stableReactNodeKey = (node) => {
|
|
|
552
602
|
var SymbolValueRootMathmlView = ({
|
|
553
603
|
children
|
|
554
604
|
}) => {
|
|
555
|
-
return /* @__PURE__ */ (0,
|
|
605
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("math", { children: children != null ? children : "Tree Without Root" });
|
|
556
606
|
};
|
|
557
607
|
var SymbolValueDraftMathmlView = ({
|
|
558
608
|
draft,
|
|
559
609
|
position
|
|
560
610
|
}) => {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
position
|
|
564
|
-
|
|
565
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mrow", { style: { fontSize: MATHML_FONT_SIZE }, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("mtext", { style: textStyle, children: draft }) });
|
|
611
|
+
return position !== void 0 && isDraftPositionValid({ draft, position }) ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("mrow", { children: [
|
|
612
|
+
position > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("mtext", { children: draft.substring(0, position) }),
|
|
613
|
+
position < draft.length && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("mtext", { children: draft.substring(position) })
|
|
614
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("mrow", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("mtext", { children: draft }) });
|
|
566
615
|
};
|
|
567
616
|
var SymbolValueLiteralMathmlView = ({
|
|
568
617
|
literal
|
|
569
618
|
}) => {
|
|
570
|
-
const mathProps = {
|
|
571
|
-
style: { fontSize: MATHML_FONT_SIZE }
|
|
572
|
-
};
|
|
573
619
|
switch (literal == null ? void 0 : literal.kind) {
|
|
574
620
|
case void 0:
|
|
575
621
|
case "empty":
|
|
576
|
-
return /* @__PURE__ */ (0,
|
|
622
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("mi", { children: "\u25A2" });
|
|
577
623
|
case "boolean":
|
|
578
|
-
return /* @__PURE__ */ (0,
|
|
624
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("mi", { children: literal.value ? "true" : "false" });
|
|
579
625
|
case "number":
|
|
580
|
-
return /* @__PURE__ */ (0,
|
|
626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("mn", { children: (0, import_core5.formatNumerical)(literal.value) });
|
|
581
627
|
case "string":
|
|
582
|
-
return /* @__PURE__ */ (0,
|
|
628
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("mtext", { children: literal.value });
|
|
583
629
|
default:
|
|
584
|
-
return (0,
|
|
630
|
+
return (0, import_core5.assertNever)(literal);
|
|
585
631
|
}
|
|
586
632
|
};
|
|
587
633
|
var SymbolValueGlyphMathmlView = ({
|
|
588
634
|
glyph
|
|
589
635
|
}) => {
|
|
590
636
|
const mathProps = {};
|
|
591
|
-
return /* @__PURE__ */ (0,
|
|
637
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(AsciiMathView, __spreadValues({ expression: glyph }, mathProps));
|
|
592
638
|
};
|
|
593
639
|
var SymbolValueGroupMathmlView = ({
|
|
594
640
|
prefix,
|
|
@@ -599,21 +645,21 @@ var SymbolValueGroupMathmlView = ({
|
|
|
599
645
|
const mathProps = {
|
|
600
646
|
mathbackground: cursor ? "lightgray" : void 0
|
|
601
647
|
};
|
|
602
|
-
return /* @__PURE__ */ (0,
|
|
648
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("mrow", __spreadProps(__spreadValues({}, mathProps), { children: [
|
|
603
649
|
prefix,
|
|
604
|
-
(children.length > 0 || empty === "fence") && /* @__PURE__ */ (0,
|
|
605
|
-
/* @__PURE__ */ (0,
|
|
650
|
+
(children.length > 0 || empty === "fence") && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
651
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("mo", { fence: "true", children: "(" }),
|
|
606
652
|
children.flatMap((child, argIndex, arr) => {
|
|
607
653
|
const next = arr[argIndex + 1];
|
|
608
654
|
const separatorKey = `sep-${stableReactNodeKey(child)}-to-${stableReactNodeKey(next)}`;
|
|
609
655
|
return [
|
|
610
656
|
child,
|
|
611
657
|
...argIndex < arr.length - 1 ? [
|
|
612
|
-
/* @__PURE__ */ (0,
|
|
658
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("mo", { separator: "true", children: "," }, separatorKey)
|
|
613
659
|
] : []
|
|
614
660
|
];
|
|
615
661
|
}),
|
|
616
|
-
/* @__PURE__ */ (0,
|
|
662
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("mo", { fence: "true", children: ")" })
|
|
617
663
|
] })
|
|
618
664
|
] }));
|
|
619
665
|
};
|
|
@@ -623,25 +669,25 @@ var SymbolValueBinaryOperatorMathmlView = ({
|
|
|
623
669
|
argRight
|
|
624
670
|
}) => {
|
|
625
671
|
const spacing = operator.id === "fg.and" || operator.id === "fg.or" ? "0.3em" : void 0;
|
|
626
|
-
return /* @__PURE__ */ (0,
|
|
672
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("mrow", { children: [
|
|
627
673
|
argLeft,
|
|
628
|
-
/* @__PURE__ */ (0,
|
|
674
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("mo", { lspace: spacing, rspace: spacing, children: operator.glyph }),
|
|
629
675
|
argRight
|
|
630
676
|
] });
|
|
631
677
|
};
|
|
632
678
|
|
|
633
679
|
// src/mathml/symbol-value/literal-display.ts
|
|
634
|
-
var
|
|
680
|
+
var import_core6 = require("@cs-object/core");
|
|
635
681
|
var displayedLiteralDraft = ({
|
|
636
682
|
node,
|
|
637
683
|
literalsAsDrafts
|
|
638
684
|
}) => {
|
|
639
685
|
var _a;
|
|
640
|
-
return (literalsAsDrafts || (0,
|
|
686
|
+
return (literalsAsDrafts || (0, import_core6.isSheetLiteralEmpty)(node.value)) && ((_a = node.draft) != null ? _a : "").length > 0 ? node.draft : void 0;
|
|
641
687
|
};
|
|
642
688
|
|
|
643
689
|
// src/mathml/symbol-value/operand-grouping.ts
|
|
644
|
-
var
|
|
690
|
+
var import_core7 = require("@cs-object/core");
|
|
645
691
|
var requiresExplicitOperandGroup = ({
|
|
646
692
|
sheet,
|
|
647
693
|
node,
|
|
@@ -659,7 +705,7 @@ var requiresExplicitOperandGroup = ({
|
|
|
659
705
|
literal = node.value;
|
|
660
706
|
break;
|
|
661
707
|
case "symbol":
|
|
662
|
-
literal = numerical ? (_a = (0,
|
|
708
|
+
literal = numerical ? (_a = (0, import_core7.getSymbolById)(sheet, node.symbolId)) == null ? void 0 : _a.valueTree.result : void 0;
|
|
663
709
|
break;
|
|
664
710
|
case "function":
|
|
665
711
|
break;
|
|
@@ -669,22 +715,22 @@ var requiresExplicitOperandGroup = ({
|
|
|
669
715
|
}
|
|
670
716
|
}
|
|
671
717
|
const negative = draft !== void 0 ? /^\s*[-−]/u.test(draft) : (literal == null ? void 0 : literal.kind) === "number" && (literal.value < 0 || Object.is(literal.value, -0));
|
|
672
|
-
return argumentIndex === 0 && (parentFunctionId === "fg.pow" && (node.kind === "function" || negative) || parentFunctionId === "fg.uminus" && node.kind === "function") || argumentIndex === 1 && (parentFunctionId === "fg.add" || parentFunctionId === "fg.multiply" || parentFunctionId === "fg.subtract") && (negative || node.kind === "function" && node.functionId === "fg.uminus");
|
|
718
|
+
return (parentFunctionId === "fg.and" || parentFunctionId === "fg.or") && node.kind === "function" && node.functionId === "fg.xor" || argumentIndex === 0 && (parentFunctionId === "fg.pow" && (node.kind === "function" || negative) || parentFunctionId === "fg.uminus" && node.kind === "function") || argumentIndex === 1 && (parentFunctionId === "fg.add" || parentFunctionId === "fg.multiply" || parentFunctionId === "fg.subtract") && (negative || node.kind === "function" && node.functionId === "fg.uminus");
|
|
673
719
|
};
|
|
674
720
|
|
|
675
721
|
// src/mathml/symbol-value/ValueTreeMathmlRenderer.tsx
|
|
676
|
-
var
|
|
722
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
677
723
|
var ValueTreeMathmlRenderer = ({
|
|
678
724
|
sheet,
|
|
679
725
|
valueTree,
|
|
680
726
|
viewOptions,
|
|
681
727
|
noRootContainer
|
|
682
728
|
}) => {
|
|
683
|
-
const rootNode = (0,
|
|
729
|
+
const rootNode = (0, import_core8.getValueNodeByKeyOrUndefined)(valueTree, valueTree.rootKey);
|
|
684
730
|
if (!rootNode) {
|
|
685
|
-
return /* @__PURE__ */ (0,
|
|
731
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: "Empty Value" });
|
|
686
732
|
}
|
|
687
|
-
const rootValue = /* @__PURE__ */ (0,
|
|
733
|
+
const rootValue = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
688
734
|
ValueTreeNodeMathmlView,
|
|
689
735
|
{
|
|
690
736
|
sheet,
|
|
@@ -693,7 +739,7 @@ var ValueTreeMathmlRenderer = ({
|
|
|
693
739
|
viewOptions
|
|
694
740
|
}
|
|
695
741
|
);
|
|
696
|
-
return noRootContainer ? rootValue : /* @__PURE__ */ (0,
|
|
742
|
+
return noRootContainer ? rootValue : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SymbolValueRootMathmlView, { children: rootValue });
|
|
697
743
|
};
|
|
698
744
|
var ValueTreeNodeMathmlView = ({
|
|
699
745
|
sheet,
|
|
@@ -708,24 +754,24 @@ var ValueTreeNodeMathmlView = ({
|
|
|
708
754
|
literalsAsDrafts: viewOptions.literalsAsDrafts
|
|
709
755
|
});
|
|
710
756
|
if (draft !== void 0) {
|
|
711
|
-
return /* @__PURE__ */ (0,
|
|
757
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SymbolValueDraftMathmlView, { draft });
|
|
712
758
|
}
|
|
713
|
-
return /* @__PURE__ */ (0,
|
|
759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SymbolValueLiteralMathmlView, { literal: node.value });
|
|
714
760
|
}
|
|
715
761
|
if (node.kind === "symbol") {
|
|
716
|
-
const nodeSymbol = (0,
|
|
762
|
+
const nodeSymbol = (0, import_core8.getSymbolById)(sheet, node.symbolId);
|
|
717
763
|
if (!viewOptions.numerical) {
|
|
718
|
-
return /* @__PURE__ */ (0,
|
|
764
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SymbolValueGlyphMathmlView, { glyph: (nodeSymbol == null ? void 0 : nodeSymbol.glyph) || "" });
|
|
719
765
|
}
|
|
720
|
-
return /* @__PURE__ */ (0,
|
|
766
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
721
767
|
SymbolValueLiteralMathmlView,
|
|
722
768
|
{
|
|
723
|
-
literal: (_a = nodeSymbol == null ? void 0 : nodeSymbol.valueTree.result) != null ? _a : (0,
|
|
769
|
+
literal: (_a = nodeSymbol == null ? void 0 : nodeSymbol.valueTree.result) != null ? _a : (0, import_core8.emptyLiteral)()
|
|
724
770
|
}
|
|
725
771
|
);
|
|
726
772
|
}
|
|
727
773
|
if (node.kind === "function") {
|
|
728
|
-
return /* @__PURE__ */ (0,
|
|
774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
729
775
|
ValueTreeFunctionMathmlView,
|
|
730
776
|
{
|
|
731
777
|
sheet,
|
|
@@ -735,7 +781,7 @@ var ValueTreeNodeMathmlView = ({
|
|
|
735
781
|
}
|
|
736
782
|
);
|
|
737
783
|
}
|
|
738
|
-
return /* @__PURE__ */ (0,
|
|
784
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: "Error (Unknown value-tree node)" });
|
|
739
785
|
};
|
|
740
786
|
var ValueTreeFunctionMathmlView = ({
|
|
741
787
|
sheet,
|
|
@@ -744,13 +790,13 @@ var ValueTreeFunctionMathmlView = ({
|
|
|
744
790
|
viewOptions
|
|
745
791
|
}) => {
|
|
746
792
|
if (node.kind !== "function") {
|
|
747
|
-
return /* @__PURE__ */ (0,
|
|
793
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children: "Error (Expected function value-tree node)" });
|
|
748
794
|
}
|
|
749
795
|
const argNodes = node.argKeys.map(
|
|
750
|
-
(argKey) => (0,
|
|
796
|
+
(argKey) => (0, import_core8.getValueNodeByKey)(valueTree, argKey)
|
|
751
797
|
);
|
|
752
798
|
const argReactNodes = argNodes.map((argNode, index) => {
|
|
753
|
-
const rendered = /* @__PURE__ */ (0,
|
|
799
|
+
const rendered = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
754
800
|
ValueTreeNodeMathmlView,
|
|
755
801
|
{
|
|
756
802
|
sheet,
|
|
@@ -768,7 +814,7 @@ var ValueTreeFunctionMathmlView = ({
|
|
|
768
814
|
parentFunctionId: node.functionId,
|
|
769
815
|
argumentIndex: index
|
|
770
816
|
});
|
|
771
|
-
return grouped ? /* @__PURE__ */ (0,
|
|
817
|
+
return grouped ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SymbolValueGroupMathmlView, { cursor: void 0, children: [rendered] }, argNode.key) : rendered;
|
|
772
818
|
});
|
|
773
819
|
const specialFunction = renderSpecialValueFunction({
|
|
774
820
|
functionId: node.functionId,
|
|
@@ -777,27 +823,27 @@ var ValueTreeFunctionMathmlView = ({
|
|
|
777
823
|
if (specialFunction) {
|
|
778
824
|
return specialFunction;
|
|
779
825
|
}
|
|
780
|
-
const operator = (0,
|
|
781
|
-
if (operator && argNodes.length
|
|
782
|
-
return /* @__PURE__ */ (0,
|
|
826
|
+
const operator = (0, import_core8.getFunctionBinaryOperatorById)(node.functionId);
|
|
827
|
+
if (operator && argNodes.length >= 2 && (node.functionId === "fg.and" || node.functionId === "fg.or")) {
|
|
828
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("mtable", { columnalign: "left", "data-logical-lines": "true", children: argReactNodes.map((argument, index) => {
|
|
783
829
|
const child = argNodes[index];
|
|
784
|
-
const childOperator = child.kind === "function" ? (0,
|
|
785
|
-
const grouped = childOperator !== void 0 && childOperator.priority < operator.priority;
|
|
786
|
-
return /* @__PURE__ */ (0,
|
|
787
|
-
index > 0 && /* @__PURE__ */ (0,
|
|
788
|
-
grouped ? /* @__PURE__ */ (0,
|
|
789
|
-
] }, child.key);
|
|
830
|
+
const childOperator = child.kind === "function" ? (0, import_core8.getFunctionBinaryOperatorById)(child.functionId) : void 0;
|
|
831
|
+
const grouped = childOperator !== void 0 && (childOperator.priority < operator.priority || index > 0 && childOperator.priority === operator.priority);
|
|
832
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("mtr", { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("mtd", { style: { textAlign: "left" }, children: [
|
|
833
|
+
index > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("mo", { form: "infix", lspace: "0.3em", rspace: "0.3em", children: operator.glyph }),
|
|
834
|
+
grouped ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SymbolValueGroupMathmlView, { cursor: void 0, children: [argument] }) : argument
|
|
835
|
+
] }) }, child.key);
|
|
790
836
|
}) });
|
|
791
837
|
}
|
|
792
838
|
if (operator && argNodes.length === 2) {
|
|
793
839
|
const [argOperatorLeft, argOperatorRight] = argNodes.map(
|
|
794
|
-
(argNode) => argNode.kind === "function" ? (0,
|
|
840
|
+
(argNode) => argNode.kind === "function" ? (0, import_core8.getFunctionBinaryOperatorById)(argNode.functionId) : void 0
|
|
795
841
|
);
|
|
796
842
|
const implicitParenthesisLeft = argOperatorLeft && argOperatorLeft.priority < operator.priority;
|
|
797
843
|
const implicitParenthesisRight = argOperatorRight && argOperatorRight.priority <= operator.priority;
|
|
798
|
-
const argLeft = implicitParenthesisLeft ? /* @__PURE__ */ (0,
|
|
799
|
-
const argRight = implicitParenthesisRight ? /* @__PURE__ */ (0,
|
|
800
|
-
return /* @__PURE__ */ (0,
|
|
844
|
+
const argLeft = implicitParenthesisLeft ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SymbolValueGroupMathmlView, { cursor: void 0, children: [argReactNodes[0]] }) : argReactNodes[0];
|
|
845
|
+
const argRight = implicitParenthesisRight ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SymbolValueGroupMathmlView, { cursor: void 0, children: [argReactNodes[1]] }) : argReactNodes[1];
|
|
846
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
801
847
|
SymbolValueBinaryOperatorMathmlView,
|
|
802
848
|
{
|
|
803
849
|
operator,
|
|
@@ -806,16 +852,16 @@ var ValueTreeFunctionMathmlView = ({
|
|
|
806
852
|
}
|
|
807
853
|
);
|
|
808
854
|
}
|
|
809
|
-
const nodeFunction = (0,
|
|
855
|
+
const nodeFunction = (0, import_core8.getFunctionSpec)(node.functionId);
|
|
810
856
|
const functionNameGlyph = (nodeFunction == null ? void 0 : nodeFunction.glyph) || "";
|
|
811
|
-
const groupPrefix = node.functionId === "fg.noop" ? "" : node.functionId === "fg.stub" ? /* @__PURE__ */ (0,
|
|
812
|
-
return /* @__PURE__ */ (0,
|
|
857
|
+
const groupPrefix = node.functionId === "fg.noop" ? "" : node.functionId === "fg.stub" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SymbolValueDraftMathmlView, { draft: "" }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SymbolValueGlyphMathmlView, { glyph: functionNameGlyph });
|
|
858
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
813
859
|
SymbolValueGroupMathmlView,
|
|
814
860
|
{
|
|
815
861
|
prefix: groupPrefix,
|
|
816
862
|
cursor: void 0,
|
|
817
863
|
empty: node.functionId === "fg.pi" || node.functionId === "fg.noop" || node.functionId === "fg.stub" ? "omit" : "fence",
|
|
818
|
-
children: node.argKeys.map((key) => (0,
|
|
864
|
+
children: node.argKeys.map((key) => (0, import_core8.getValueNodeByKey)(valueTree, key)).map((argNode) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
819
865
|
ValueTreeNodeMathmlView,
|
|
820
866
|
{
|
|
821
867
|
sheet,
|
|
@@ -830,14 +876,14 @@ var ValueTreeFunctionMathmlView = ({
|
|
|
830
876
|
};
|
|
831
877
|
|
|
832
878
|
// src/mathml/symbol-value/SymbolValueMathmlView.tsx
|
|
833
|
-
var
|
|
879
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
834
880
|
var SymbolValueMathmlView = ({
|
|
835
881
|
sheet,
|
|
836
882
|
valueTree,
|
|
837
883
|
viewOptions,
|
|
838
884
|
noRootContainer
|
|
839
885
|
}) => {
|
|
840
|
-
return /* @__PURE__ */ (0,
|
|
886
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
841
887
|
ValueTreeMathmlRenderer,
|
|
842
888
|
{
|
|
843
889
|
sheet,
|
|
@@ -849,7 +895,7 @@ var SymbolValueMathmlView = ({
|
|
|
849
895
|
};
|
|
850
896
|
|
|
851
897
|
// src/mathml/SymbolValueMathBlock.tsx
|
|
852
|
-
var
|
|
898
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
853
899
|
var SymbolValueMathBlock = ({
|
|
854
900
|
sheet,
|
|
855
901
|
symbol,
|
|
@@ -877,33 +923,37 @@ var SymbolValueMathBlock = ({
|
|
|
877
923
|
flexShrink: "0"
|
|
878
924
|
}
|
|
879
925
|
};
|
|
880
|
-
return /* @__PURE__ */ (0,
|
|
881
|
-
showGlyph && /* @__PURE__ */ (0,
|
|
882
|
-
showSymbolic &&
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
{
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
926
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { children: [
|
|
927
|
+
showGlyph && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", __spreadProps(__spreadValues({}, divProps), { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("math", __spreadProps(__spreadValues({}, baseMathProps), { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("mrow", { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AsciiMathView, { expression: symbol.glyph }) }) })) })),
|
|
928
|
+
showSymbolic && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", __spreadProps(__spreadValues({}, divProps), { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("math", __spreadProps(__spreadValues({}, baseMathProps), { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("mrow", { children: [
|
|
929
|
+
showGlyph && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("mo", { className: "px-1 py-2", children: "=" }),
|
|
930
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
931
|
+
SymbolValueMathmlView,
|
|
932
|
+
{
|
|
933
|
+
sheet,
|
|
934
|
+
valueTree: symbol.valueTree,
|
|
935
|
+
noRootContainer: true,
|
|
936
|
+
viewOptions: { literalsAsDrafts: true }
|
|
937
|
+
}
|
|
938
|
+
)
|
|
939
|
+
] }) })) })),
|
|
940
|
+
showNumeric && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", __spreadProps(__spreadValues({}, divProps), { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("math", __spreadProps(__spreadValues({}, baseMathProps), { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("mrow", { children: [
|
|
941
|
+
(showGlyph || showSymbolic) && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("mo", { className: "px-1 py-2", children: "=" }),
|
|
942
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
943
|
+
SymbolValueMathmlView,
|
|
944
|
+
{
|
|
945
|
+
sheet,
|
|
946
|
+
valueTree: symbol.valueTree,
|
|
947
|
+
noRootContainer: true,
|
|
948
|
+
viewOptions: { numerical: true, literalsAsDrafts: true }
|
|
949
|
+
}
|
|
950
|
+
)
|
|
951
|
+
] }) })) }))
|
|
902
952
|
] });
|
|
903
953
|
};
|
|
904
954
|
|
|
905
955
|
// src/formula-sheet/FormulaSheetValueTree.tsx
|
|
906
|
-
var
|
|
956
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
907
957
|
var additionTerms = (tree, key, ancestors = /* @__PURE__ */ new Set()) => {
|
|
908
958
|
if (ancestors.has(key)) {
|
|
909
959
|
throw new Error(`Recursive formula node '${key}'`);
|
|
@@ -934,117 +984,182 @@ var hasActiveSymbol = (tree) => {
|
|
|
934
984
|
};
|
|
935
985
|
var FormulaSheetValueTree = ({
|
|
936
986
|
sheet,
|
|
937
|
-
symbol
|
|
987
|
+
symbol,
|
|
988
|
+
symbolicOnly = false
|
|
938
989
|
}) => {
|
|
939
990
|
const showSymbolic = hasActiveSymbol(symbol.valueTree);
|
|
940
991
|
const terms = additionTerms(symbol.valueTree, symbol.valueTree.rootKey);
|
|
941
992
|
if (terms.length > 4) {
|
|
942
|
-
return /* @__PURE__ */ (0,
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
grouped && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("mo", { children: "(" }),
|
|
967
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
968
|
-
SymbolValueMathmlView,
|
|
993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "cso-long-formula", children: (symbolicOnly ? [false] : showSymbolic ? [false, true] : [true]).map(
|
|
994
|
+
(numerical) => (
|
|
995
|
+
// biome-ignore lint/a11y/useSemanticElements: This labels a formula group, not a fieldset of form controls.
|
|
996
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
997
|
+
"div",
|
|
998
|
+
{
|
|
999
|
+
className: "cso-formula-terms",
|
|
1000
|
+
role: "group",
|
|
1001
|
+
"aria-label": numerical ? "Substitution" : "Formula",
|
|
1002
|
+
children: terms.map((rootKey, index) => {
|
|
1003
|
+
const node = symbol.valueTree.nodes.find(
|
|
1004
|
+
(node2) => node2.key === rootKey
|
|
1005
|
+
);
|
|
1006
|
+
const operator = (node == null ? void 0 : node.kind) === "function" ? (0, import_core9.getFunctionBinaryOperatorById)(node.functionId) : void 0;
|
|
1007
|
+
const grouped = operator !== void 0 && (operator.priority < import_core9.SheetOperatorPriority.AddSubtract || index > 0 && operator.priority === import_core9.SheetOperatorPriority.AddSubtract) || node !== void 0 && requiresExplicitOperandGroup({
|
|
1008
|
+
sheet,
|
|
1009
|
+
node,
|
|
1010
|
+
numerical,
|
|
1011
|
+
literalsAsDrafts: true,
|
|
1012
|
+
parentFunctionId: "fg.add",
|
|
1013
|
+
argumentIndex: index === 0 ? 0 : 1
|
|
1014
|
+
});
|
|
1015
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1016
|
+
"span",
|
|
969
1017
|
{
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1018
|
+
className: "cso-formula-term",
|
|
1019
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("math", { display: "inline", children: [
|
|
1020
|
+
index === 0 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(AsciiMathView, { expression: symbol.glyph }),
|
|
1021
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("mo", { children: index === 0 ? "=" : "+" }),
|
|
1022
|
+
grouped && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("mo", { children: "(" }),
|
|
1023
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1024
|
+
SymbolValueMathmlView,
|
|
1025
|
+
{
|
|
1026
|
+
sheet,
|
|
1027
|
+
valueTree: __spreadProps(__spreadValues({}, symbol.valueTree), { rootKey }),
|
|
1028
|
+
noRootContainer: true,
|
|
1029
|
+
viewOptions: { numerical, literalsAsDrafts: true }
|
|
1030
|
+
}
|
|
1031
|
+
),
|
|
1032
|
+
grouped && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("mo", { children: ")" })
|
|
1033
|
+
] })
|
|
1034
|
+
},
|
|
1035
|
+
`${index}-${rootKey}`
|
|
1036
|
+
);
|
|
1037
|
+
})
|
|
1038
|
+
},
|
|
1039
|
+
String(numerical)
|
|
1040
|
+
)
|
|
981
1041
|
)
|
|
982
|
-
)
|
|
1042
|
+
) });
|
|
983
1043
|
}
|
|
984
|
-
return /* @__PURE__ */ (0,
|
|
1044
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
985
1045
|
SymbolValueMathBlock,
|
|
986
1046
|
{
|
|
987
1047
|
sheet,
|
|
988
1048
|
symbol,
|
|
989
1049
|
showGlyph: true,
|
|
990
|
-
showSymbolic,
|
|
991
|
-
showNumeric:
|
|
1050
|
+
showSymbolic: symbolicOnly || showSymbolic,
|
|
1051
|
+
showNumeric: !symbolicOnly
|
|
992
1052
|
}
|
|
993
1053
|
);
|
|
994
1054
|
};
|
|
995
1055
|
|
|
996
1056
|
// src/formula-sheet/FormulaSheetSymbolRow.tsx
|
|
997
|
-
var
|
|
1057
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1058
|
+
var bindingOrigin = ({
|
|
1059
|
+
sheet,
|
|
1060
|
+
symbol,
|
|
1061
|
+
label,
|
|
1062
|
+
computedReference = false
|
|
1063
|
+
}) => {
|
|
1064
|
+
const root = (0, import_core10.getValueNodeByKey)(symbol.valueTree, symbol.valueTree.rootKey);
|
|
1065
|
+
const source = root.kind === "symbol" ? sheet.symbols.find((item) => item.id === root.symbolId) : computedReference && root.kind === "function" ? symbol : void 0;
|
|
1066
|
+
if (root.kind === "symbol" && !source)
|
|
1067
|
+
throw new Error(`Missing binding origin '${root.symbolId}'`);
|
|
1068
|
+
if (source)
|
|
1069
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { "data-binding-origin": source.id, "data-binding-call": label, children: [
|
|
1070
|
+
label ? `${label}: ` : "",
|
|
1071
|
+
"From ",
|
|
1072
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(GlyphMathBlock, { glyph: source.glyph })
|
|
1073
|
+
] });
|
|
1074
|
+
if (root.kind === "literal" && root.value.kind === "number")
|
|
1075
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { "data-binding-origin": "literal", "data-binding-call": label, children: [
|
|
1076
|
+
label ? `${label}: ` : "",
|
|
1077
|
+
"Given",
|
|
1078
|
+
" ",
|
|
1079
|
+
root.draft || (Object.is(root.value.value, -0) ? "-0" : String(root.value.value))
|
|
1080
|
+
] });
|
|
1081
|
+
return void 0;
|
|
1082
|
+
};
|
|
998
1083
|
var FormulaSheetSymbolRow = ({
|
|
999
1084
|
sheet,
|
|
1000
1085
|
sheetItemIndex,
|
|
1001
|
-
item: symbol
|
|
1086
|
+
item: symbol,
|
|
1087
|
+
symbolicOnly = false,
|
|
1088
|
+
showFormula = true,
|
|
1089
|
+
numericKind,
|
|
1090
|
+
compactBinding = false,
|
|
1091
|
+
bindingOrigin: suppliedOrigin
|
|
1002
1092
|
}) => {
|
|
1003
1093
|
var _a, _b;
|
|
1004
1094
|
const { glyph: symbolGlyph } = symbol;
|
|
1005
1095
|
const symbolUnit = (_a = symbol.unit) != null ? _a : "";
|
|
1006
1096
|
const symbolDescription = symbol.description;
|
|
1007
1097
|
const symbolComment = (_b = symbol.comment) != null ? _b : "";
|
|
1008
|
-
const rootNode = (0,
|
|
1098
|
+
const rootNode = (0, import_core10.getValueNodeByKey)(
|
|
1009
1099
|
symbol.valueTree,
|
|
1010
1100
|
symbol.valueTree.rootKey
|
|
1011
1101
|
);
|
|
1012
1102
|
const symbolIsSolidLiteral = rootNode.kind === "literal";
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
/* @__PURE__ */ (0,
|
|
1017
|
-
|
|
1103
|
+
const origin = suppliedOrigin != null ? suppliedOrigin : compactBinding ? bindingOrigin({ sheet, symbol }) : void 0;
|
|
1104
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "cso-symbol-row flex min-w-0 flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "min-w-0", children: [
|
|
1105
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex min-w-0 border-t border-gray-300", children: [
|
|
1106
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FormulaSheetSpacerCell, {}),
|
|
1107
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FormulaSheetDescriptionCell, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("span", { children: [
|
|
1108
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FormulaSheetItemIndex, { index: sheetItemIndex }),
|
|
1018
1109
|
" ",
|
|
1019
1110
|
symbolDescription
|
|
1020
1111
|
] }) }),
|
|
1021
|
-
/* @__PURE__ */ (0,
|
|
1112
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FormulaSheetSymbolCell, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1022
1113
|
GlyphMathBlock,
|
|
1023
1114
|
{
|
|
1024
1115
|
glyph: symbolGlyph,
|
|
1025
1116
|
mathProps: { className: "shrink-0" }
|
|
1026
1117
|
}
|
|
1027
1118
|
) }),
|
|
1028
|
-
/* @__PURE__ */ (0,
|
|
1029
|
-
|
|
1030
|
-
|
|
1119
|
+
symbolicOnly ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FormulaSheetValueCell, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1120
|
+
"span",
|
|
1121
|
+
{
|
|
1122
|
+
className: "cso-symbolic-value",
|
|
1123
|
+
role: "img",
|
|
1124
|
+
"aria-label": "Value not yet defined",
|
|
1125
|
+
children: "\xD7"
|
|
1126
|
+
}
|
|
1127
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1128
|
+
FormulaSheetResultCell,
|
|
1129
|
+
{
|
|
1130
|
+
literal: symbol.valueTree.result,
|
|
1131
|
+
numericKind
|
|
1132
|
+
}
|
|
1133
|
+
),
|
|
1134
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FormulaSheetUnitCell, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(UnitMathBlock, { unit: symbolUnit, optional: true }) }),
|
|
1135
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(FormulaSheetCommentCell, { children: [
|
|
1136
|
+
origin ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { children: origin }) : null,
|
|
1137
|
+
symbolComment || " "
|
|
1138
|
+
] })
|
|
1031
1139
|
] }),
|
|
1032
|
-
!symbolIsSolidLiteral && /* @__PURE__ */ (0,
|
|
1033
|
-
/* @__PURE__ */ (0,
|
|
1034
|
-
/* @__PURE__ */ (0,
|
|
1140
|
+
showFormula && !origin && (!symbolIsSolidLiteral || symbolicOnly && rootNode.kind === "literal" && rootNode.value.kind !== "empty") && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "flex min-w-0", "data-derivation": "true", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "w-full min-w-0 overflow-visible border-t border-gray-300 text-[14px]", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "my-2 flex min-w-0", children: [
|
|
1141
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FormulaSheetSpacerCell, {}),
|
|
1142
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "min-w-0 max-w-full flex-1 overflow-visible", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1143
|
+
FormulaSheetValueTree,
|
|
1144
|
+
{
|
|
1145
|
+
sheet,
|
|
1146
|
+
symbol,
|
|
1147
|
+
symbolicOnly
|
|
1148
|
+
}
|
|
1149
|
+
) })
|
|
1035
1150
|
] }) }) })
|
|
1036
1151
|
] }) });
|
|
1037
1152
|
};
|
|
1038
1153
|
|
|
1039
1154
|
// src/formula-sheet/FormulaSheetItem.tsx
|
|
1040
|
-
var
|
|
1155
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1041
1156
|
var FormulaSheetItem = ({
|
|
1042
1157
|
sheet,
|
|
1043
1158
|
item,
|
|
1044
1159
|
sheetItemIndex
|
|
1045
1160
|
}) => {
|
|
1046
|
-
return /* @__PURE__ */ (0,
|
|
1047
|
-
item.kind === "section" && /* @__PURE__ */ (0,
|
|
1161
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "relative min-w-0", children: [
|
|
1162
|
+
item.kind === "section" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1048
1163
|
FormulaSheetSectionRow,
|
|
1049
1164
|
{
|
|
1050
1165
|
sheet,
|
|
@@ -1052,7 +1167,7 @@ var FormulaSheetItem = ({
|
|
|
1052
1167
|
item: item.section
|
|
1053
1168
|
}
|
|
1054
1169
|
),
|
|
1055
|
-
item.kind === "symbol" && /* @__PURE__ */ (0,
|
|
1170
|
+
item.kind === "symbol" && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1056
1171
|
FormulaSheetSymbolRow,
|
|
1057
1172
|
{
|
|
1058
1173
|
sheet,
|
|
@@ -1064,19 +1179,19 @@ var FormulaSheetItem = ({
|
|
|
1064
1179
|
};
|
|
1065
1180
|
|
|
1066
1181
|
// src/FormulaSheet.tsx
|
|
1067
|
-
var
|
|
1068
|
-
var
|
|
1182
|
+
var import_core11 = require("@cs-object/core");
|
|
1183
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1069
1184
|
var getFormulaSheetItemKey = (item, sheetItemIndex) => `${sheetItemIndex}-${item.kind}-${item.kind === "section" ? item.section.id : item.symbol.id}`;
|
|
1070
1185
|
var FormulaSheet = ({ sheet }) => {
|
|
1071
|
-
const sheetItems = (0,
|
|
1072
|
-
return /* @__PURE__ */ (0,
|
|
1186
|
+
const sheetItems = (0, import_core11.getRootSectionItems)(sheet);
|
|
1187
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
1073
1188
|
"article",
|
|
1074
1189
|
{
|
|
1075
1190
|
"data-formula-sheet": "true",
|
|
1076
1191
|
className: "flex min-h-[297mm] w-[210mm] min-w-[210mm] max-w-none flex-col items-stretch border border-gray-300 bg-white p-[5mm] [&_*:focus-visible]:outline-hidden",
|
|
1077
1192
|
children: [
|
|
1078
|
-
/* @__PURE__ */ (0,
|
|
1079
|
-
sheetItems.map((item, sheetItemIndex) => /* @__PURE__ */ (0,
|
|
1193
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(FormulaSheetHeader, {}),
|
|
1194
|
+
sheetItems.map((item, sheetItemIndex) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
1080
1195
|
FormulaSheetItem,
|
|
1081
1196
|
{
|
|
1082
1197
|
sheet,
|
|
@@ -1090,6 +1205,397 @@ var FormulaSheet = ({ sheet }) => {
|
|
|
1090
1205
|
);
|
|
1091
1206
|
};
|
|
1092
1207
|
|
|
1208
|
+
// src/formula-sheet/partition-comparisons.ts
|
|
1209
|
+
var FIT_TOLERANCE_PX = 2;
|
|
1210
|
+
function partitionColumnAxis(columnWidths, labelWidth, availableWidth, cap) {
|
|
1211
|
+
var _a;
|
|
1212
|
+
if (columnWidths.length === 0 || availableWidth <= 0) {
|
|
1213
|
+
return {
|
|
1214
|
+
groups: columnWidths.length ? [columnWidths.map((_, index) => index)] : []
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
const limit = cap && cap > 0 ? cap : Number.POSITIVE_INFINITY;
|
|
1218
|
+
const groups = [];
|
|
1219
|
+
let current = [];
|
|
1220
|
+
let used = labelWidth;
|
|
1221
|
+
for (let index = 0; index < columnWidths.length; index += 1) {
|
|
1222
|
+
const width = (_a = columnWidths[index]) != null ? _a : 0;
|
|
1223
|
+
const alone = labelWidth + width;
|
|
1224
|
+
if (alone > availableWidth + FIT_TOLERANCE_PX) {
|
|
1225
|
+
return {
|
|
1226
|
+
groups: [],
|
|
1227
|
+
unfit: { column: index, required: alone, available: availableWidth }
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
if (current.length > 0 && (current.length >= limit || used + width > availableWidth + FIT_TOLERANCE_PX)) {
|
|
1231
|
+
groups.push(current);
|
|
1232
|
+
current = [];
|
|
1233
|
+
used = labelWidth;
|
|
1234
|
+
}
|
|
1235
|
+
current.push(index);
|
|
1236
|
+
used += width;
|
|
1237
|
+
}
|
|
1238
|
+
if (current.length > 0) groups.push(current);
|
|
1239
|
+
return { groups };
|
|
1240
|
+
}
|
|
1241
|
+
function partitionRowAxis(rows, chromeHeight, availableHeight, firstAvailable = availableHeight) {
|
|
1242
|
+
var _a, _b, _c, _d;
|
|
1243
|
+
if (rows.length === 0 || availableHeight <= 0) {
|
|
1244
|
+
return { groups: rows.length ? [rows.map((_, index) => index)] : [] };
|
|
1245
|
+
}
|
|
1246
|
+
const groups = [];
|
|
1247
|
+
let current = [];
|
|
1248
|
+
let used = chromeHeight;
|
|
1249
|
+
let limit = firstAvailable > 0 ? firstAvailable : availableHeight;
|
|
1250
|
+
let banner = null;
|
|
1251
|
+
let bannerIncluded = false;
|
|
1252
|
+
for (let index = 0; index < rows.length; index += 1) {
|
|
1253
|
+
const row = rows[index];
|
|
1254
|
+
if (!row) continue;
|
|
1255
|
+
if (row.repeat) {
|
|
1256
|
+
banner = index;
|
|
1257
|
+
bannerIncluded = false;
|
|
1258
|
+
continue;
|
|
1259
|
+
}
|
|
1260
|
+
const bannerHeight = banner !== null && !bannerIncluded ? (_b = (_a = rows[banner]) == null ? void 0 : _a.height) != null ? _b : 0 : 0;
|
|
1261
|
+
const required = chromeHeight + bannerHeight + row.height;
|
|
1262
|
+
if (required > availableHeight + 2) {
|
|
1263
|
+
return {
|
|
1264
|
+
groups: [],
|
|
1265
|
+
unfit: { row: index, required, available: availableHeight }
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
if (current.length === 0 && required > limit + 2) {
|
|
1269
|
+
limit = availableHeight;
|
|
1270
|
+
}
|
|
1271
|
+
if (current.length > 0 && used + bannerHeight + row.height > limit + 2) {
|
|
1272
|
+
groups.push(current);
|
|
1273
|
+
current = [];
|
|
1274
|
+
used = chromeHeight;
|
|
1275
|
+
bannerIncluded = false;
|
|
1276
|
+
limit = availableHeight;
|
|
1277
|
+
}
|
|
1278
|
+
if (banner !== null && !bannerIncluded) {
|
|
1279
|
+
current.push(banner);
|
|
1280
|
+
used += (_d = (_c = rows[banner]) == null ? void 0 : _c.height) != null ? _d : 0;
|
|
1281
|
+
bannerIncluded = true;
|
|
1282
|
+
}
|
|
1283
|
+
current.push(index);
|
|
1284
|
+
used += row.height;
|
|
1285
|
+
}
|
|
1286
|
+
if (current.length > 0) groups.push(current);
|
|
1287
|
+
return { groups };
|
|
1288
|
+
}
|
|
1289
|
+
function planComparisonParts(measurements) {
|
|
1290
|
+
return measurements.map((measurement) => {
|
|
1291
|
+
const partitioned = partitionColumnAxis(
|
|
1292
|
+
measurement.columnWidths,
|
|
1293
|
+
measurement.labelWidth,
|
|
1294
|
+
measurement.availableWidth,
|
|
1295
|
+
measurement.cap
|
|
1296
|
+
);
|
|
1297
|
+
return __spreadValues(__spreadProps(__spreadValues({}, measurement), {
|
|
1298
|
+
groups: partitioned.groups
|
|
1299
|
+
}), partitioned.unfit ? { unfit: partitioned.unfit } : {});
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
function measureComparisons(root) {
|
|
1303
|
+
const scope = root != null ? root : document;
|
|
1304
|
+
const measurements = [];
|
|
1305
|
+
for (const comparison of scope.querySelectorAll(
|
|
1306
|
+
"[data-comparison-id]"
|
|
1307
|
+
)) {
|
|
1308
|
+
const table = comparison.querySelector(
|
|
1309
|
+
'table[data-comparison-table="screen"]'
|
|
1310
|
+
);
|
|
1311
|
+
const scroll = comparison.querySelector(
|
|
1312
|
+
"[data-comparison-scroll]"
|
|
1313
|
+
);
|
|
1314
|
+
if (!table || !scroll || typeof table.getBoundingClientRect !== "function") {
|
|
1315
|
+
continue;
|
|
1316
|
+
}
|
|
1317
|
+
const labelWidth = [
|
|
1318
|
+
...table.querySelectorAll("[data-comparison-label]")
|
|
1319
|
+
].reduce(
|
|
1320
|
+
(max, cell) => Math.max(max, cell.getBoundingClientRect().width),
|
|
1321
|
+
0
|
|
1322
|
+
);
|
|
1323
|
+
const columnWidths = [];
|
|
1324
|
+
for (const cell of table.querySelectorAll(
|
|
1325
|
+
"thead [data-comparison-column]"
|
|
1326
|
+
)) {
|
|
1327
|
+
const index = Number(cell.getAttribute("data-comparison-column"));
|
|
1328
|
+
if (!Number.isInteger(index) || columnWidths[index] !== void 0)
|
|
1329
|
+
continue;
|
|
1330
|
+
columnWidths[index] = cell.getBoundingClientRect().width;
|
|
1331
|
+
}
|
|
1332
|
+
const cap = Number(comparison.getAttribute("data-column-cap"));
|
|
1333
|
+
const measurement = {
|
|
1334
|
+
comparisonId: comparison.getAttribute("data-comparison-id") || "",
|
|
1335
|
+
sourcePlacementId: comparison.getAttribute("data-source-placement") || "",
|
|
1336
|
+
labelWidth,
|
|
1337
|
+
columnWidths,
|
|
1338
|
+
availableWidth: scroll.clientWidth
|
|
1339
|
+
};
|
|
1340
|
+
if (Number.isInteger(cap) && cap > 0) measurement.cap = cap;
|
|
1341
|
+
measurements.push(measurement);
|
|
1342
|
+
}
|
|
1343
|
+
return measurements;
|
|
1344
|
+
}
|
|
1345
|
+
function renderComparisonParts(plans, root, rowPartitioner = partitionRowAxis) {
|
|
1346
|
+
var _a;
|
|
1347
|
+
const noteMatches = (note, comparison, kept) => {
|
|
1348
|
+
if (comparison.getAttribute("data-cases-axis") === "rows") return true;
|
|
1349
|
+
const heading = note.getAttribute("data-case");
|
|
1350
|
+
if (!heading) return true;
|
|
1351
|
+
const header = [
|
|
1352
|
+
...comparison.querySelectorAll(
|
|
1353
|
+
"thead [data-case-heading][data-comparison-column]"
|
|
1354
|
+
)
|
|
1355
|
+
].find((cell) => cell.getAttribute("data-case-heading") === heading);
|
|
1356
|
+
if (!header) return true;
|
|
1357
|
+
return kept.has(Number(header.getAttribute("data-comparison-column")));
|
|
1358
|
+
};
|
|
1359
|
+
const keepColumn = (cell, kept) => {
|
|
1360
|
+
if (cell.hasAttribute("data-comparison-label")) return true;
|
|
1361
|
+
if (cell.hasAttribute("data-comparison-banner")) {
|
|
1362
|
+
cell.colSpan = kept.size + 1;
|
|
1363
|
+
return true;
|
|
1364
|
+
}
|
|
1365
|
+
const listed = cell.getAttribute("data-comparison-columns");
|
|
1366
|
+
if (listed !== null) {
|
|
1367
|
+
const next = listed.split(",").filter((value) => kept.has(Number(value)));
|
|
1368
|
+
if (next.length === 0) return false;
|
|
1369
|
+
cell.colSpan = next.length;
|
|
1370
|
+
cell.setAttribute("data-comparison-columns", next.join(","));
|
|
1371
|
+
return true;
|
|
1372
|
+
}
|
|
1373
|
+
const index = cell.getAttribute("data-comparison-column");
|
|
1374
|
+
return index === null || kept.has(Number(index));
|
|
1375
|
+
};
|
|
1376
|
+
const scope = root != null ? root : document;
|
|
1377
|
+
const diagnostics = [];
|
|
1378
|
+
for (const [comparisonIndex, plan] of plans.entries()) {
|
|
1379
|
+
const comparison = [
|
|
1380
|
+
...scope.querySelectorAll("[data-comparison-id]")
|
|
1381
|
+
].find(
|
|
1382
|
+
(element) => element.getAttribute("data-comparison-id") === plan.comparisonId
|
|
1383
|
+
);
|
|
1384
|
+
if (!comparison) continue;
|
|
1385
|
+
(_a = comparison.querySelector("[data-comparison-parts]")) == null ? void 0 : _a.remove();
|
|
1386
|
+
const selector = `[data-source-placement=${JSON.stringify(plan.sourcePlacementId)}]`;
|
|
1387
|
+
if (plan.unfit) {
|
|
1388
|
+
const overflowPx = Math.max(
|
|
1389
|
+
0,
|
|
1390
|
+
plan.unfit.required - plan.unfit.available
|
|
1391
|
+
);
|
|
1392
|
+
const layout = {
|
|
1393
|
+
media: "print",
|
|
1394
|
+
selector,
|
|
1395
|
+
left: 0,
|
|
1396
|
+
right: plan.unfit.required,
|
|
1397
|
+
containerLeft: 0,
|
|
1398
|
+
containerRight: plan.unfit.available,
|
|
1399
|
+
overflowPx
|
|
1400
|
+
};
|
|
1401
|
+
if (plan.sourcePlacementId) {
|
|
1402
|
+
layout.sourcePlacementId = plan.sourcePlacementId;
|
|
1403
|
+
}
|
|
1404
|
+
diagnostics.push({
|
|
1405
|
+
code: "DOCUMENT_LAYOUT_OVERFLOW",
|
|
1406
|
+
stage: "rendering",
|
|
1407
|
+
check: "rendering",
|
|
1408
|
+
message: `Comparison column ${plan.unfit.column + 1} cannot fit with its labels in print layout: ${selector}, required ${plan.unfit.required.toFixed(2)}px, available ${plan.unfit.available.toFixed(2)}px.`,
|
|
1409
|
+
layout
|
|
1410
|
+
});
|
|
1411
|
+
continue;
|
|
1412
|
+
}
|
|
1413
|
+
const table = comparison.querySelector(
|
|
1414
|
+
'table[data-comparison-table="screen"]'
|
|
1415
|
+
);
|
|
1416
|
+
if (!table || plan.groups.length === 0) continue;
|
|
1417
|
+
const parts = document.createElement("div");
|
|
1418
|
+
parts.setAttribute("data-comparison-parts", "");
|
|
1419
|
+
parts.className = "cso-comparison-parts";
|
|
1420
|
+
plan.groups.forEach((group, partIndex) => {
|
|
1421
|
+
var _a2, _b, _c, _d, _e, _f;
|
|
1422
|
+
const kept = new Set(group);
|
|
1423
|
+
const part = document.createElement("section");
|
|
1424
|
+
part.className = "cso-comparison-part";
|
|
1425
|
+
part.setAttribute("data-comparison-part", String(partIndex + 1));
|
|
1426
|
+
part.setAttribute("data-part-count", String(plan.groups.length));
|
|
1427
|
+
for (const note of comparison.querySelectorAll(
|
|
1428
|
+
":scope > p.cso-branch-note"
|
|
1429
|
+
)) {
|
|
1430
|
+
if (noteMatches(note, comparison, kept))
|
|
1431
|
+
part.appendChild(note.cloneNode(true));
|
|
1432
|
+
}
|
|
1433
|
+
const clone = table.cloneNode(true);
|
|
1434
|
+
clone.removeAttribute("data-comparison-table");
|
|
1435
|
+
clone.setAttribute("data-comparison-part-table", String(partIndex + 1));
|
|
1436
|
+
for (const row of clone.querySelectorAll("tr")) {
|
|
1437
|
+
for (const cell of [...row.children]) {
|
|
1438
|
+
if (!keepColumn(cell, kept)) cell.remove();
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
const columns = document.createElement("colgroup");
|
|
1442
|
+
const widths = [
|
|
1443
|
+
plan.labelWidth,
|
|
1444
|
+
...group.map((index) => plan.columnWidths[index] || 0)
|
|
1445
|
+
];
|
|
1446
|
+
const dataWidth = widths.slice(1).reduce((sum, width) => sum + width, 0);
|
|
1447
|
+
widths.forEach((width, index) => {
|
|
1448
|
+
const column = document.createElement("col");
|
|
1449
|
+
column.style.width = `${index === 0 ? width : dataWidth ? width / dataWidth * (plan.availableWidth - plan.labelWidth) : 0}px`;
|
|
1450
|
+
columns.appendChild(column);
|
|
1451
|
+
});
|
|
1452
|
+
clone.prepend(columns);
|
|
1453
|
+
clone.style.tableLayout = "fixed";
|
|
1454
|
+
const contextRow = document.createElement("tr");
|
|
1455
|
+
const context = document.createElement("th");
|
|
1456
|
+
context.colSpan = group.length + 1;
|
|
1457
|
+
context.setAttribute("data-comparison-context", "");
|
|
1458
|
+
const title = document.createElement("strong");
|
|
1459
|
+
title.textContent = ((_a2 = comparison.querySelector(":scope > h3")) == null ? void 0 : _a2.textContent) || "Comparison";
|
|
1460
|
+
if (plan.groups.length > 1)
|
|
1461
|
+
title.textContent += `. Part ${partIndex + 1} of ${plan.groups.length}`;
|
|
1462
|
+
context.appendChild(title);
|
|
1463
|
+
const methodReference = comparison.querySelector(
|
|
1464
|
+
":scope > [data-method-reference]"
|
|
1465
|
+
);
|
|
1466
|
+
if (methodReference) context.appendChild(methodReference.cloneNode(true));
|
|
1467
|
+
for (const limit of table.querySelectorAll(
|
|
1468
|
+
'th[data-outcome-kind="applicability"]'
|
|
1469
|
+
)) {
|
|
1470
|
+
const note = document.createElement("div");
|
|
1471
|
+
note.className = "cso-result-status";
|
|
1472
|
+
note.appendChild(document.createTextNode("Applicability limit "));
|
|
1473
|
+
note.appendChild(
|
|
1474
|
+
((_b = limit.firstElementChild) == null ? void 0 : _b.cloneNode(true)) || document.createTextNode("")
|
|
1475
|
+
);
|
|
1476
|
+
context.appendChild(note);
|
|
1477
|
+
}
|
|
1478
|
+
if (comparison.getAttribute("data-cases-axis") === "columns") {
|
|
1479
|
+
const labels = [];
|
|
1480
|
+
let group2 = "";
|
|
1481
|
+
let indexes = [];
|
|
1482
|
+
const save = () => {
|
|
1483
|
+
if (group2 && indexes.length)
|
|
1484
|
+
labels.push(
|
|
1485
|
+
`${group2} ${indexes[0]}-${indexes[indexes.length - 1]}`
|
|
1486
|
+
);
|
|
1487
|
+
};
|
|
1488
|
+
for (const row of ((_c = clone.tBodies[0]) == null ? void 0 : _c.rows) || []) {
|
|
1489
|
+
const banner = row.querySelector("[data-comparison-banner]");
|
|
1490
|
+
if (banner) {
|
|
1491
|
+
save();
|
|
1492
|
+
group2 = banner.textContent || "";
|
|
1493
|
+
indexes = [];
|
|
1494
|
+
} else {
|
|
1495
|
+
const index = (_e = (_d = row.querySelector("[data-formula-sheet-item-index]")) == null ? void 0 : _d.textContent) == null ? void 0 : _e.replace(".", "");
|
|
1496
|
+
if (index) indexes.push(index);
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
save();
|
|
1500
|
+
const key = document.createElement("div");
|
|
1501
|
+
key.className = "cso-result-status";
|
|
1502
|
+
key.textContent = labels.join(" \xB7 ");
|
|
1503
|
+
context.appendChild(key);
|
|
1504
|
+
}
|
|
1505
|
+
contextRow.appendChild(context);
|
|
1506
|
+
(_f = clone.tHead) == null ? void 0 : _f.prepend(contextRow);
|
|
1507
|
+
let rowNumber = 0;
|
|
1508
|
+
for (const row of clone.querySelectorAll("tr")) {
|
|
1509
|
+
const label = row.querySelector("[data-comparison-label]");
|
|
1510
|
+
if (!label) continue;
|
|
1511
|
+
const rowId = `cso-c${comparisonIndex}-p${partIndex}-r${rowNumber}`;
|
|
1512
|
+
rowNumber += 1;
|
|
1513
|
+
label.id = rowId;
|
|
1514
|
+
for (const cell of row.querySelectorAll(
|
|
1515
|
+
"[data-comparison-column]"
|
|
1516
|
+
)) {
|
|
1517
|
+
const column = cell.getAttribute("data-comparison-column");
|
|
1518
|
+
const header = clone.querySelector(
|
|
1519
|
+
`thead [data-comparison-column="${column}"]`
|
|
1520
|
+
);
|
|
1521
|
+
if (header && !header.id) {
|
|
1522
|
+
header.id = `cso-c${comparisonIndex}-p${partIndex}-c${column}`;
|
|
1523
|
+
}
|
|
1524
|
+
if (cell.tagName === "TD" && (header == null ? void 0 : header.id)) {
|
|
1525
|
+
cell.setAttribute("headers", `${rowId} ${header.id}`);
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
part.appendChild(clone);
|
|
1530
|
+
parts.appendChild(part);
|
|
1531
|
+
});
|
|
1532
|
+
const split = splitComparisonParts(parts);
|
|
1533
|
+
if (split) {
|
|
1534
|
+
const overflowPx = Math.max(0, split.required - split.available);
|
|
1535
|
+
const layout = {
|
|
1536
|
+
media: "print",
|
|
1537
|
+
selector,
|
|
1538
|
+
left: 0,
|
|
1539
|
+
right: split.required,
|
|
1540
|
+
containerLeft: 0,
|
|
1541
|
+
containerRight: split.available,
|
|
1542
|
+
overflowPx
|
|
1543
|
+
};
|
|
1544
|
+
if (plan.sourcePlacementId) {
|
|
1545
|
+
layout.sourcePlacementId = plan.sourcePlacementId;
|
|
1546
|
+
}
|
|
1547
|
+
diagnostics.push({
|
|
1548
|
+
code: "DOCUMENT_LAYOUT_OVERFLOW",
|
|
1549
|
+
stage: "rendering",
|
|
1550
|
+
check: "rendering",
|
|
1551
|
+
message: `Comparison row ${split.row + 1} cannot fit with its repeated headings in print layout: ${selector}, required ${split.required.toFixed(2)}px, available ${split.available.toFixed(2)}px.`,
|
|
1552
|
+
layout
|
|
1553
|
+
});
|
|
1554
|
+
continue;
|
|
1555
|
+
}
|
|
1556
|
+
comparison.appendChild(parts);
|
|
1557
|
+
}
|
|
1558
|
+
return diagnostics;
|
|
1559
|
+
function splitComparisonParts(parts) {
|
|
1560
|
+
var _a2;
|
|
1561
|
+
const frame = document.createElement("div");
|
|
1562
|
+
frame.className = "cso-comparison";
|
|
1563
|
+
Object.assign(frame.style, {
|
|
1564
|
+
position: "absolute",
|
|
1565
|
+
left: "0",
|
|
1566
|
+
top: "0",
|
|
1567
|
+
visibility: "hidden"
|
|
1568
|
+
});
|
|
1569
|
+
frame.style.width = getComputedStyle(document.documentElement).getPropertyValue("--cso-print-content-width").trim() || "190mm";
|
|
1570
|
+
const probe = document.createElement("div");
|
|
1571
|
+
probe.style.height = "calc(297mm - 24mm)";
|
|
1572
|
+
frame.appendChild(probe);
|
|
1573
|
+
(document.querySelector("[data-formula-sheet]") || document.body).appendChild(frame);
|
|
1574
|
+
frame.appendChild(parts);
|
|
1575
|
+
const available = probe.getBoundingClientRect().height;
|
|
1576
|
+
probe.remove();
|
|
1577
|
+
let unfit;
|
|
1578
|
+
for (const part of parts.querySelectorAll(
|
|
1579
|
+
":scope > section"
|
|
1580
|
+
)) {
|
|
1581
|
+
const table = part.querySelector("table");
|
|
1582
|
+
const body = table == null ? void 0 : table.tBodies[0];
|
|
1583
|
+
if (!table || !body) continue;
|
|
1584
|
+
const check = rowPartitioner(
|
|
1585
|
+
[...body.rows].map((row) => ({
|
|
1586
|
+
height: row.getBoundingClientRect().height,
|
|
1587
|
+
repeat: Boolean(row.querySelector("[data-comparison-banner]"))
|
|
1588
|
+
})),
|
|
1589
|
+
((_a2 = table.tHead) == null ? void 0 : _a2.getBoundingClientRect().height) || 0,
|
|
1590
|
+
available
|
|
1591
|
+
);
|
|
1592
|
+
if (check.unfit) unfit = check.unfit;
|
|
1593
|
+
}
|
|
1594
|
+
frame.remove();
|
|
1595
|
+
return unfit;
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1093
1599
|
// src/formula-sheet/print.ts
|
|
1094
1600
|
var DEFAULT_FORMULA_SHEET_SELECTOR = "[data-formula-sheet]";
|
|
1095
1601
|
var FORMULA_SHEET_PRINT_BODY_CLASS = "formula-sheet-printing";
|
|
@@ -1162,6 +1668,10 @@ var printFormulaSheet = (options = {}) => {
|
|
|
1162
1668
|
}
|
|
1163
1669
|
cleanupTimeout = browser.window.setTimeout(cleanup, PRINT_CLEANUP_DELAY_MS);
|
|
1164
1670
|
try {
|
|
1671
|
+
renderComparisonParts(
|
|
1672
|
+
planComparisonParts(measureComparisons(target)),
|
|
1673
|
+
printClone
|
|
1674
|
+
);
|
|
1165
1675
|
browser.window.print();
|
|
1166
1676
|
} catch (error) {
|
|
1167
1677
|
cleanup();
|
|
@@ -1200,35 +1710,36 @@ var printFormulaSheet = (options = {}) => {
|
|
|
1200
1710
|
};
|
|
1201
1711
|
|
|
1202
1712
|
// src/PreparedFormulaSheet.tsx
|
|
1203
|
-
var
|
|
1713
|
+
var import_core13 = require("@cs-object/core");
|
|
1714
|
+
var import_react2 = require("react");
|
|
1204
1715
|
|
|
1205
1716
|
// src/EngineeringMetadata.tsx
|
|
1206
|
-
var
|
|
1717
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1207
1718
|
var ContextValue = ({
|
|
1208
1719
|
value
|
|
1209
1720
|
}) => {
|
|
1210
1721
|
switch (value.kind) {
|
|
1211
1722
|
case "text":
|
|
1212
|
-
return /* @__PURE__ */ (0,
|
|
1723
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { "data-engineering-value": value.path, children: String(value.value) });
|
|
1213
1724
|
case "math":
|
|
1214
|
-
return /* @__PURE__ */ (0,
|
|
1725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1215
1726
|
"span",
|
|
1216
1727
|
{
|
|
1217
1728
|
"data-engineering-value": value.path,
|
|
1218
1729
|
"data-engineering-notation": "math",
|
|
1219
1730
|
"data-engineering-source": value.value,
|
|
1220
|
-
children: /* @__PURE__ */ (0,
|
|
1731
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(GlyphMathBlock, { glyph: value.value })
|
|
1221
1732
|
}
|
|
1222
1733
|
);
|
|
1223
1734
|
case "list":
|
|
1224
|
-
return /* @__PURE__ */ (0,
|
|
1735
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("ul", { children: value.items.map((item, index) => (
|
|
1225
1736
|
// biome-ignore lint/suspicious/noArrayIndexKey: prepared order identifies repeated entries
|
|
1226
|
-
/* @__PURE__ */ (0,
|
|
1737
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextValue, { value: item }) }, index)
|
|
1227
1738
|
)) });
|
|
1228
1739
|
case "record":
|
|
1229
|
-
return /* @__PURE__ */ (0,
|
|
1230
|
-
/* @__PURE__ */ (0,
|
|
1231
|
-
/* @__PURE__ */ (0,
|
|
1740
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("dl", { children: value.entries.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { children: [
|
|
1741
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("dt", { children: entry.label }),
|
|
1742
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextValue, { value: entry.value }) })
|
|
1232
1743
|
] }, entry.label)) });
|
|
1233
1744
|
default: {
|
|
1234
1745
|
const exhaustive = value;
|
|
@@ -1239,20 +1750,69 @@ var ContextValue = ({
|
|
|
1239
1750
|
var EngineeringMetadata = ({
|
|
1240
1751
|
entries,
|
|
1241
1752
|
subject
|
|
1242
|
-
}) => entries.length > 0 ? /* @__PURE__ */ (0,
|
|
1243
|
-
/* @__PURE__ */ (0,
|
|
1244
|
-
subject && /* @__PURE__ */ (0,
|
|
1753
|
+
}) => entries.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("dl", { className: "cso-engineering-context", children: entries.map(({ label, path, value }) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { "data-engineering-field": path, children: [
|
|
1754
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("dt", { children: [
|
|
1755
|
+
subject && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
1245
1756
|
subject,
|
|
1246
1757
|
": "
|
|
1247
1758
|
] }),
|
|
1248
1759
|
label
|
|
1249
1760
|
] }),
|
|
1250
|
-
/* @__PURE__ */ (0,
|
|
1761
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ContextValue, { value }) })
|
|
1251
1762
|
] }, path)) }) : null;
|
|
1252
1763
|
|
|
1764
|
+
// src/mathml/InlineFormulaMath.tsx
|
|
1765
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1766
|
+
var InlineFormulaMath = ({
|
|
1767
|
+
sheet,
|
|
1768
|
+
symbol,
|
|
1769
|
+
showGlyph = true
|
|
1770
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1771
|
+
"math",
|
|
1772
|
+
__spreadProps(__spreadValues({}, defaultMathBlockProps), {
|
|
1773
|
+
display: "inline",
|
|
1774
|
+
style: __spreadProps(__spreadValues({}, defaultMathBlockProps.style), { display: void 0 }),
|
|
1775
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("mrow", { children: [
|
|
1776
|
+
showGlyph ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
1777
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(AsciiMathView, { expression: symbol.glyph }),
|
|
1778
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("mo", { children: "=" })
|
|
1779
|
+
] }) : null,
|
|
1780
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1781
|
+
SymbolValueMathmlView,
|
|
1782
|
+
{
|
|
1783
|
+
sheet,
|
|
1784
|
+
valueTree: symbol.valueTree,
|
|
1785
|
+
noRootContainer: true,
|
|
1786
|
+
viewOptions: { literalsAsDrafts: true }
|
|
1787
|
+
}
|
|
1788
|
+
)
|
|
1789
|
+
] })
|
|
1790
|
+
})
|
|
1791
|
+
);
|
|
1792
|
+
|
|
1793
|
+
// src/table-case-notation.ts
|
|
1794
|
+
var import_core12 = require("@cs-object/core");
|
|
1795
|
+
var tableCaseQualifier = (invocationId, symbols) => {
|
|
1796
|
+
var _a, _b;
|
|
1797
|
+
for (const symbol of symbols) {
|
|
1798
|
+
const owner = (_a = symbol.metadata) == null ? void 0 : _a.invocationId;
|
|
1799
|
+
const scope = (_b = symbol.metadata) == null ? void 0 : _b.glyphScope;
|
|
1800
|
+
if (typeof owner !== "string" || typeof scope !== "string") continue;
|
|
1801
|
+
if (owner !== invocationId && !owner.startsWith(`${invocationId}/`))
|
|
1802
|
+
continue;
|
|
1803
|
+
const nestedDepth = owner === invocationId ? 0 : owner.slice(invocationId.length + 1).split("/").length;
|
|
1804
|
+
const bindings = scope.split(",");
|
|
1805
|
+
if (bindings.length <= nestedDepth) continue;
|
|
1806
|
+
return (0, import_core12.compactGlyphScope)(
|
|
1807
|
+
bindings.slice(0, bindings.length - nestedDepth).join(",")
|
|
1808
|
+
);
|
|
1809
|
+
}
|
|
1810
|
+
return void 0;
|
|
1811
|
+
};
|
|
1812
|
+
|
|
1253
1813
|
// src/PreparedFormulaSheet.tsx
|
|
1254
|
-
var
|
|
1255
|
-
var mathSheet = (document2) => (0,
|
|
1814
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1815
|
+
var mathSheet = (document2) => (0, import_core13.createSheetFromCalculationSourceObject)(
|
|
1256
1816
|
{
|
|
1257
1817
|
schemaVersion: "1.0.0",
|
|
1258
1818
|
title: document2.title,
|
|
@@ -1262,6 +1822,11 @@ var mathSheet = (document2) => (0, import_core11.createSheetFromCalculationSourc
|
|
|
1262
1822
|
id: section.id,
|
|
1263
1823
|
title: section.title,
|
|
1264
1824
|
items: section.items.flatMap((item) => {
|
|
1825
|
+
if (item.kind === "externalCall") {
|
|
1826
|
+
return [...item.call.inputs, ...item.call.outputs].map(
|
|
1827
|
+
(quantity) => ({ kind: "symbolRef", id: quantity.symbolId })
|
|
1828
|
+
);
|
|
1829
|
+
}
|
|
1265
1830
|
if (item.kind === "section") {
|
|
1266
1831
|
return [{ kind: "section", id: item.id }];
|
|
1267
1832
|
}
|
|
@@ -1283,16 +1848,118 @@ var mathSheet = (document2) => (0, import_core11.createSheetFromCalculationSourc
|
|
|
1283
1848
|
).sheet;
|
|
1284
1849
|
var requiredItem = (items, id) => {
|
|
1285
1850
|
const item = items.get(id);
|
|
1286
|
-
if (
|
|
1851
|
+
if (item === void 0) {
|
|
1287
1852
|
throw new Error(`Missing prepared item '${id}'`);
|
|
1288
1853
|
}
|
|
1289
1854
|
return item;
|
|
1290
1855
|
};
|
|
1856
|
+
var notationSheet = (id, symbols) => {
|
|
1857
|
+
const sheet = (0, import_core13.createSheetFromCalculationSourceObject)(
|
|
1858
|
+
{
|
|
1859
|
+
schemaVersion: "1.0.0",
|
|
1860
|
+
title: id,
|
|
1861
|
+
source: { id, metadata: {} },
|
|
1862
|
+
rootSectionIds: [id],
|
|
1863
|
+
sections: [
|
|
1864
|
+
{
|
|
1865
|
+
id,
|
|
1866
|
+
title: id,
|
|
1867
|
+
items: symbols.map((symbol) => ({ kind: "symbol", symbol }))
|
|
1868
|
+
}
|
|
1869
|
+
],
|
|
1870
|
+
detachedItems: []
|
|
1871
|
+
},
|
|
1872
|
+
{ id, label: id }
|
|
1873
|
+
).sheet;
|
|
1874
|
+
const byId = new Map(sheet.symbols.map((symbol) => [symbol.id, symbol]));
|
|
1875
|
+
const forwarded = new Set(
|
|
1876
|
+
symbols.filter((symbol) => {
|
|
1877
|
+
var _a;
|
|
1878
|
+
return ((_a = symbol.metadata) == null ? void 0 : _a.csoForwardedReturn) === true;
|
|
1879
|
+
}).map((symbol) => symbol.id)
|
|
1880
|
+
);
|
|
1881
|
+
return {
|
|
1882
|
+
row: (symbolId, index, options = {}) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
1883
|
+
FormulaSheetSymbolRow,
|
|
1884
|
+
{
|
|
1885
|
+
sheet,
|
|
1886
|
+
item: requiredItem(byId, symbolId),
|
|
1887
|
+
sheetItemIndex: index,
|
|
1888
|
+
symbolicOnly: true,
|
|
1889
|
+
compactBinding: options.compactBinding || forwarded.has(symbolId),
|
|
1890
|
+
bindingOrigin: options.bindingOrigin
|
|
1891
|
+
}
|
|
1892
|
+
),
|
|
1893
|
+
origin: (symbolId, label) => bindingOrigin({
|
|
1894
|
+
sheet,
|
|
1895
|
+
symbol: requiredItem(byId, symbolId),
|
|
1896
|
+
label,
|
|
1897
|
+
computedReference: true
|
|
1898
|
+
}),
|
|
1899
|
+
isConnection: (symbolId) => {
|
|
1900
|
+
const symbol = requiredItem(byId, symbolId);
|
|
1901
|
+
const root = (0, import_core13.getValueNodeByKey)(
|
|
1902
|
+
symbol.valueTree,
|
|
1903
|
+
symbol.valueTree.rootKey
|
|
1904
|
+
);
|
|
1905
|
+
return root.kind === "symbol" || root.kind === "literal";
|
|
1906
|
+
},
|
|
1907
|
+
description: (symbolId) => requiredItem(byId, symbolId).description,
|
|
1908
|
+
formula: (symbolId, showGlyph = true) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
1909
|
+
InlineFormulaMath,
|
|
1910
|
+
{
|
|
1911
|
+
sheet,
|
|
1912
|
+
symbol: requiredItem(byId, symbolId),
|
|
1913
|
+
showGlyph
|
|
1914
|
+
}
|
|
1915
|
+
)
|
|
1916
|
+
};
|
|
1917
|
+
};
|
|
1918
|
+
var readableName = (name) => name.replaceAll("_", " ").replace(/\b\w/u, (letter) => letter.toUpperCase());
|
|
1919
|
+
var SymbolicValueNote = () => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "cso-symbolic-note", children: "Reusable function for downstream use. Values are not defined yet." });
|
|
1920
|
+
var procedureAnchor = (id) => `cso-procedure-${id}`;
|
|
1921
|
+
var FunctionIdentity = ({
|
|
1922
|
+
identity
|
|
1923
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
1924
|
+
"p",
|
|
1925
|
+
{
|
|
1926
|
+
className: "cso-function-identity",
|
|
1927
|
+
"data-function-identity": `${identity.moduleId}::${identity.function}`,
|
|
1928
|
+
children: [
|
|
1929
|
+
"Function:",
|
|
1930
|
+
" ",
|
|
1931
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("code", { children: [
|
|
1932
|
+
identity.moduleId,
|
|
1933
|
+
"::",
|
|
1934
|
+
identity.function
|
|
1935
|
+
] })
|
|
1936
|
+
]
|
|
1937
|
+
}
|
|
1938
|
+
);
|
|
1939
|
+
var Procedure = ({
|
|
1940
|
+
title,
|
|
1941
|
+
children,
|
|
1942
|
+
heading: Heading,
|
|
1943
|
+
functionIdentity
|
|
1944
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("table", { className: "cso-procedure-table", children: [
|
|
1945
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("th", { children: [
|
|
1946
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Heading, { children: title }),
|
|
1947
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(FunctionIdentity, { identity: functionIdentity }),
|
|
1948
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(SymbolicValueNote, {})
|
|
1949
|
+
] }) }) }),
|
|
1950
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tbody", { children: children.map((child, index) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("td", { children: child }) }, index)) })
|
|
1951
|
+
] });
|
|
1291
1952
|
var PreparedFormulaSheet = ({
|
|
1292
1953
|
document: input,
|
|
1293
1954
|
showSourceDetails = true
|
|
1294
1955
|
}) => {
|
|
1295
|
-
|
|
1956
|
+
var _a, _b, _c, _d;
|
|
1957
|
+
const document2 = import_core13.PreparedDocumentSchema.parse(input);
|
|
1958
|
+
const procedures = new Map(
|
|
1959
|
+
document2.sections.flatMap(
|
|
1960
|
+
(section) => section.items.flatMap((item) => item.kind === "method" ? [item] : [])
|
|
1961
|
+
).map((method, index) => [method.id, `P${index + 1}`])
|
|
1962
|
+
);
|
|
1296
1963
|
const sheet = mathSheet(document2);
|
|
1297
1964
|
const sections = new Map(
|
|
1298
1965
|
document2.sections.map((section) => [section.id, section])
|
|
@@ -1301,165 +1968,1074 @@ var PreparedFormulaSheet = ({
|
|
|
1301
1968
|
document2.assets.map((asset) => [asset.asset.id, asset])
|
|
1302
1969
|
);
|
|
1303
1970
|
const symbols = new Map(sheet.symbols.map((symbol) => [symbol.id, symbol]));
|
|
1971
|
+
const capturedSymbols = [
|
|
1972
|
+
...document2.detachedSymbols,
|
|
1973
|
+
...document2.sections.flatMap(
|
|
1974
|
+
(section) => section.items.flatMap(
|
|
1975
|
+
(item) => item.kind === "symbol" ? [item.symbol] : []
|
|
1976
|
+
)
|
|
1977
|
+
)
|
|
1978
|
+
];
|
|
1304
1979
|
let symbolIndex = 0;
|
|
1305
|
-
const
|
|
1306
|
-
|
|
1307
|
-
{
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1980
|
+
const renderMethodContent = (content, helpers, notation, shown) => {
|
|
1981
|
+
const helperById = /* @__PURE__ */ new Map();
|
|
1982
|
+
const indexHelpers = (records) => {
|
|
1983
|
+
for (const helper of records) {
|
|
1984
|
+
helperById.set(helper.id, helper);
|
|
1985
|
+
indexHelpers(helper.helpers);
|
|
1986
|
+
}
|
|
1987
|
+
};
|
|
1988
|
+
indexHelpers(helpers);
|
|
1989
|
+
const origins = /* @__PURE__ */ new Map();
|
|
1990
|
+
const inputRows = (items) => items.flatMap(
|
|
1991
|
+
(item) => item.kind === "quantity" && item.role === "input" ? [item] : item.kind === "section" ? inputRows(item.content) : []
|
|
1992
|
+
);
|
|
1993
|
+
const collectOrigins = (items, path = [], active = /* @__PURE__ */ new Set()) => {
|
|
1994
|
+
var _a2;
|
|
1995
|
+
for (const item of items) {
|
|
1996
|
+
if (item.kind === "section") collectOrigins(item.content, path, active);
|
|
1997
|
+
if (item.kind !== "call") continue;
|
|
1998
|
+
const helper = requiredItem(helperById, item.helperId);
|
|
1999
|
+
if (active.has(helper.id))
|
|
2000
|
+
throw new Error(`Cyclic helper '${helper.id}'`);
|
|
2001
|
+
const callPath = [...path, item.binding];
|
|
2002
|
+
for (const input2 of item.inputs) {
|
|
2003
|
+
const quantity = inputRows(helper.content).find(
|
|
2004
|
+
(row) => row.selectionName === input2.name
|
|
2005
|
+
);
|
|
2006
|
+
if (!quantity)
|
|
2007
|
+
throw new Error(`Missing helper input '${input2.name}'`);
|
|
2008
|
+
const bindings = (_a2 = origins.get(quantity.symbolId)) != null ? _a2 : [];
|
|
2009
|
+
bindings.push({
|
|
2010
|
+
path: callPath.join(" / "),
|
|
2011
|
+
symbolId: input2.symbolId
|
|
2012
|
+
});
|
|
2013
|
+
origins.set(quantity.symbolId, bindings);
|
|
2014
|
+
}
|
|
2015
|
+
collectOrigins(
|
|
2016
|
+
helper.content,
|
|
2017
|
+
callPath,
|
|
2018
|
+
/* @__PURE__ */ new Set([...active, helper.id])
|
|
2019
|
+
);
|
|
2020
|
+
}
|
|
2021
|
+
};
|
|
2022
|
+
collectOrigins(content);
|
|
2023
|
+
const renderItems = (items) => items.map((item, index) => {
|
|
2024
|
+
var _a2, _b2, _c2;
|
|
2025
|
+
if (item.kind === "external") {
|
|
2026
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2027
|
+
"section",
|
|
1313
2028
|
{
|
|
1314
|
-
"
|
|
1315
|
-
|
|
1316
|
-
children:
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
2029
|
+
className: "cso-method-external cso-external-call",
|
|
2030
|
+
"data-method-external": item.binding,
|
|
2031
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("table", { children: [
|
|
2032
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("th", { colSpan: 2, children: [
|
|
2033
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("h4", { children: readableName(item.binding) }),
|
|
2034
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(SymbolicValueNote, {}),
|
|
2035
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("p", { children: [
|
|
2036
|
+
"External source: ",
|
|
2037
|
+
item.adapter.moduleId,
|
|
2038
|
+
",",
|
|
2039
|
+
" ",
|
|
2040
|
+
item.adapter.function
|
|
2041
|
+
] }),
|
|
2042
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { children: "CSO does not check the formulas inside this external calculation." })
|
|
2043
|
+
] }) }) }),
|
|
2044
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("tbody", { className: "cso-external-quantities", children: [
|
|
2045
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("th", { colSpan: 2, children: "Inputs" }) }),
|
|
2046
|
+
item.inputs.map((input2) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2047
|
+
"tr",
|
|
2048
|
+
{
|
|
2049
|
+
"data-external-method-input": input2.name,
|
|
2050
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("td", { colSpan: 2, className: "cso-external-quantity-cell", children: notation.row(input2.symbolId, symbolIndex++, {
|
|
2051
|
+
compactBinding: true
|
|
2052
|
+
}) })
|
|
2053
|
+
},
|
|
2054
|
+
input2.name
|
|
2055
|
+
))
|
|
2056
|
+
] }),
|
|
2057
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("tbody", { children: [
|
|
2058
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("th", { colSpan: 2, children: "Calculation procedure" }) }),
|
|
2059
|
+
item.declaration.interface.description.split(/\n\s*\n/u).map((paragraph, paragraphIndex) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("td", { colSpan: 2, children: paragraph }) }, `paragraph-${paragraphIndex}`))
|
|
2060
|
+
] }),
|
|
2061
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("tbody", { className: "cso-external-quantities", children: [
|
|
2062
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("th", { colSpan: 2, children: "Outputs" }) }),
|
|
2063
|
+
item.outputs.map((output) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2064
|
+
"tr",
|
|
2065
|
+
{
|
|
2066
|
+
"data-external-method-output": output.name,
|
|
2067
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("td", { colSpan: 2, className: "cso-external-quantity-cell", children: notation.row(output.symbolId, symbolIndex++) })
|
|
2068
|
+
},
|
|
2069
|
+
output.name
|
|
2070
|
+
))
|
|
2071
|
+
] })
|
|
2072
|
+
] })
|
|
2073
|
+
},
|
|
2074
|
+
`external-${item.binding}`
|
|
2075
|
+
);
|
|
2076
|
+
}
|
|
2077
|
+
if (item.kind === "boolean") {
|
|
2078
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2079
|
+
"p",
|
|
2080
|
+
{
|
|
2081
|
+
className: "cso-branch-note",
|
|
2082
|
+
"data-boolean": item.localId,
|
|
2083
|
+
"data-formula": item.predicateText,
|
|
2084
|
+
children: [
|
|
2085
|
+
item.description.replace(/[.!?:]$/u, ""),
|
|
2086
|
+
":",
|
|
2087
|
+
" ",
|
|
2088
|
+
item.predicateSymbolId ? notation.formula(item.predicateSymbolId, false) : item.predicateText
|
|
2089
|
+
]
|
|
2090
|
+
},
|
|
2091
|
+
`boolean-${item.localId}-${index}`
|
|
2092
|
+
);
|
|
2093
|
+
}
|
|
2094
|
+
if (item.kind === "check" || item.kind === "applicability") {
|
|
2095
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2096
|
+
"p",
|
|
2097
|
+
{
|
|
2098
|
+
className: "cso-branch-note",
|
|
2099
|
+
"data-check": item.kind === "check" ? item.localId : void 0,
|
|
2100
|
+
"data-applicability": item.kind === "applicability" ? item.localId : void 0,
|
|
2101
|
+
"data-formula": item.predicateText,
|
|
2102
|
+
children: [
|
|
2103
|
+
item.explanation.replace(/[.!?:]$/u, ""),
|
|
2104
|
+
":",
|
|
2105
|
+
" ",
|
|
2106
|
+
notation.formula(item.predicateSymbolId, false)
|
|
2107
|
+
]
|
|
2108
|
+
},
|
|
2109
|
+
`${item.kind}-${item.localId}-${index}`
|
|
2110
|
+
);
|
|
2111
|
+
}
|
|
2112
|
+
if (item.kind === "quantity") {
|
|
2113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2114
|
+
"div",
|
|
2115
|
+
{
|
|
2116
|
+
className: "cso-method-quantity",
|
|
2117
|
+
"data-quantity": item.selectionName,
|
|
2118
|
+
"data-formula": item.formulaText || void 0,
|
|
2119
|
+
children: notation.row(item.symbolId, symbolIndex++, {
|
|
2120
|
+
bindingOrigin: (_a2 = origins.get(item.symbolId)) == null ? void 0 : _a2.map((origin) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { children: notation.origin(
|
|
2121
|
+
origin.symbolId,
|
|
2122
|
+
readableName(origin.path)
|
|
2123
|
+
) }, origin.path))
|
|
2124
|
+
})
|
|
2125
|
+
},
|
|
2126
|
+
`quantity-${item.selectionName}-${index}`
|
|
2127
|
+
);
|
|
2128
|
+
}
|
|
2129
|
+
if (item.kind === "text") {
|
|
2130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2131
|
+
"p",
|
|
2132
|
+
{
|
|
2133
|
+
className: "cso-method-text",
|
|
2134
|
+
"data-method-text": item.localId,
|
|
2135
|
+
children: item.content
|
|
2136
|
+
},
|
|
2137
|
+
`text-${item.localId}`
|
|
2138
|
+
);
|
|
2139
|
+
}
|
|
2140
|
+
if (item.kind === "figure") {
|
|
2141
|
+
const asset = assets.get(item.assetId);
|
|
2142
|
+
if (!asset) {
|
|
2143
|
+
throw new Error(`Missing method asset '${item.assetId}'`);
|
|
2144
|
+
}
|
|
2145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2146
|
+
"figure",
|
|
2147
|
+
{
|
|
2148
|
+
className: "cso-figure",
|
|
2149
|
+
"data-method-figure": item.localId,
|
|
2150
|
+
children: [
|
|
2151
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("img", { src: asset.dataUrl, alt: item.alt }),
|
|
2152
|
+
item.caption ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("figcaption", { children: item.caption }) : null
|
|
2153
|
+
]
|
|
2154
|
+
},
|
|
2155
|
+
`figure-${item.localId}`
|
|
2156
|
+
);
|
|
2157
|
+
}
|
|
2158
|
+
if (item.kind === "section") {
|
|
2159
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2160
|
+
"section",
|
|
2161
|
+
{
|
|
2162
|
+
className: "cso-method-section",
|
|
2163
|
+
"data-method-section": item.localId,
|
|
2164
|
+
children: [
|
|
2165
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("h4", { children: item.title }),
|
|
2166
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(EngineeringMetadata, { entries: (_b2 = item.context) != null ? _b2 : [] }),
|
|
2167
|
+
renderItems(item.content)
|
|
2168
|
+
]
|
|
2169
|
+
},
|
|
2170
|
+
`section-${item.localId}`
|
|
2171
|
+
);
|
|
2172
|
+
}
|
|
2173
|
+
const helper = helperById.get(item.helperId);
|
|
2174
|
+
let explanation = null;
|
|
2175
|
+
if (helper && !shown.has(helper.id)) {
|
|
2176
|
+
shown.add(helper.id);
|
|
2177
|
+
explanation = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "cso-method-helper", "data-helper": helper.function, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2178
|
+
Procedure,
|
|
2179
|
+
{
|
|
2180
|
+
title: readableName(helper.function),
|
|
2181
|
+
heading: "h4",
|
|
2182
|
+
functionIdentity: helper.functionIdentity,
|
|
2183
|
+
children: [
|
|
2184
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2185
|
+
EngineeringMetadata,
|
|
1354
2186
|
{
|
|
1355
|
-
|
|
1356
|
-
"data-asset-sha256": asset.asset.sha256,
|
|
1357
|
-
className: "cso-figure",
|
|
1358
|
-
children: [
|
|
1359
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1360
|
-
"img",
|
|
1361
|
-
{
|
|
1362
|
-
src: asset.dataUrl,
|
|
1363
|
-
alt: item.figure.alt,
|
|
1364
|
-
style: item.figure.width === void 0 ? void 0 : { width: item.figure.width }
|
|
1365
|
-
}
|
|
1366
|
-
),
|
|
1367
|
-
item.figure.caption && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("figcaption", { children: item.figure.caption }),
|
|
1368
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(EngineeringMetadata, { entries: item.context })
|
|
1369
|
-
]
|
|
2187
|
+
entries: (_c2 = helper.context) != null ? _c2 : []
|
|
1370
2188
|
},
|
|
1371
|
-
|
|
1372
|
-
)
|
|
2189
|
+
"context"
|
|
2190
|
+
),
|
|
2191
|
+
...renderItems(helper.content)
|
|
2192
|
+
]
|
|
2193
|
+
}
|
|
2194
|
+
) });
|
|
2195
|
+
}
|
|
2196
|
+
const calculations = item.inputs.filter(
|
|
2197
|
+
(input2) => !notation.isConnection(input2.symbolId)
|
|
2198
|
+
);
|
|
2199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2200
|
+
"div",
|
|
2201
|
+
{
|
|
2202
|
+
className: explanation || calculations.length ? "cso-method-call" : void 0,
|
|
2203
|
+
"data-call": item.binding,
|
|
2204
|
+
children: [
|
|
2205
|
+
explanation,
|
|
2206
|
+
calculations.length ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "cso-formula-terms", children: calculations.map((input2) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2207
|
+
"span",
|
|
2208
|
+
{
|
|
2209
|
+
"data-formula": input2.formulaText,
|
|
2210
|
+
className: "cso-formula-term",
|
|
2211
|
+
children: notation.formula(input2.symbolId)
|
|
2212
|
+
},
|
|
2213
|
+
input2.name
|
|
2214
|
+
)) }) : null
|
|
2215
|
+
]
|
|
2216
|
+
},
|
|
2217
|
+
`call-${item.binding}`
|
|
2218
|
+
);
|
|
2219
|
+
});
|
|
2220
|
+
return renderItems(content);
|
|
2221
|
+
};
|
|
2222
|
+
const renderSection = (section) => {
|
|
2223
|
+
var _a2;
|
|
2224
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2225
|
+
"section",
|
|
2226
|
+
{
|
|
2227
|
+
"data-section-id": section.id,
|
|
2228
|
+
className: "cso-section",
|
|
2229
|
+
children: [
|
|
2230
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2231
|
+
"h2",
|
|
2232
|
+
{
|
|
2233
|
+
"data-source-placement": section.sourcePlacementId,
|
|
2234
|
+
className: "cso-section-heading",
|
|
2235
|
+
children: section.title
|
|
1373
2236
|
}
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
2237
|
+
),
|
|
2238
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(EngineeringMetadata, { entries: section.context }),
|
|
2239
|
+
(_a2 = section.engineeringChecks) == null ? void 0 : _a2.map((check) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2240
|
+
"p",
|
|
2241
|
+
{
|
|
2242
|
+
className: "cso-branch-note",
|
|
2243
|
+
"data-check": check.id,
|
|
2244
|
+
"data-check-result": check.reasons ? "not-applicable" : check.value ? "pass" : "fail",
|
|
2245
|
+
"data-formula": check.predicateText,
|
|
2246
|
+
children: check.reasons ? `Not applicable. ${check.reasons.join(" ")}` : `${check.value ? "Pass" : "Fail"}. ${check.explanation} ${check.predicateText}`
|
|
2247
|
+
},
|
|
2248
|
+
check.id
|
|
2249
|
+
)),
|
|
2250
|
+
section.items.map((item) => {
|
|
2251
|
+
var _a3, _b2, _c2, _d2, _e;
|
|
2252
|
+
switch (item.kind) {
|
|
2253
|
+
case "externalCall": {
|
|
2254
|
+
const outputLabel = (name) => {
|
|
2255
|
+
const output = item.call.outputs.find(
|
|
2256
|
+
(quantity) => quantity.name === name
|
|
2257
|
+
);
|
|
2258
|
+
return output ? requiredItem(symbols, output.symbolId).description : name;
|
|
2259
|
+
};
|
|
2260
|
+
const quantityRow = (quantity, role, index) => {
|
|
2261
|
+
var _a4;
|
|
2262
|
+
const symbol = requiredItem(symbols, quantity.symbolId);
|
|
2263
|
+
const qualification = (_a4 = item.qualifications) == null ? void 0 : _a4.find(
|
|
2264
|
+
(note) => note.symbolId === quantity.symbolId
|
|
2265
|
+
);
|
|
2266
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2267
|
+
"tr",
|
|
2268
|
+
{
|
|
2269
|
+
"data-external-quantity": quantity.name,
|
|
2270
|
+
"data-external-role": role,
|
|
2271
|
+
"data-external-index": index,
|
|
2272
|
+
"data-symbol-id": quantity.symbolId,
|
|
2273
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("td", { colSpan: 2, className: "cso-external-quantity-cell", children: [
|
|
2274
|
+
qualification ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2275
|
+
"p",
|
|
2276
|
+
{
|
|
2277
|
+
className: "cso-branch-note",
|
|
2278
|
+
"data-applicability": "not-applicable",
|
|
2279
|
+
children: [
|
|
2280
|
+
"Not applicable. ",
|
|
2281
|
+
qualification.reasons.join(" ")
|
|
2282
|
+
]
|
|
2283
|
+
}
|
|
2284
|
+
) : null,
|
|
2285
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2286
|
+
FormulaSheetSymbolRow,
|
|
2287
|
+
{
|
|
2288
|
+
sheet,
|
|
2289
|
+
item: symbol,
|
|
2290
|
+
sheetItemIndex: symbolIndex++,
|
|
2291
|
+
showFormula: false,
|
|
2292
|
+
numericKind: quantity.numericKind
|
|
2293
|
+
}
|
|
2294
|
+
)
|
|
2295
|
+
] })
|
|
2296
|
+
},
|
|
2297
|
+
`${role}-${quantity.name}`
|
|
2298
|
+
);
|
|
2299
|
+
};
|
|
2300
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2301
|
+
"section",
|
|
2302
|
+
{
|
|
2303
|
+
"data-source-placement": item.sourcePlacementId,
|
|
2304
|
+
"data-external-call": item.call.id,
|
|
2305
|
+
className: "cso-external-call",
|
|
2306
|
+
children: [
|
|
2307
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("table", { children: [
|
|
2308
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("th", { colSpan: 2, children: [
|
|
2309
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("h3", { children: readableName(item.title) }),
|
|
2310
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("p", { children: [
|
|
2311
|
+
"External source: ",
|
|
2312
|
+
item.call.adapter.moduleId,
|
|
2313
|
+
",",
|
|
2314
|
+
" ",
|
|
2315
|
+
item.call.adapter.function
|
|
2316
|
+
] }),
|
|
2317
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { children: "CSO does not check the formulas inside this external calculation." })
|
|
2318
|
+
] }) }) }),
|
|
2319
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("tbody", { className: "cso-external-quantities", children: [
|
|
2320
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("th", { colSpan: 2, children: "Inputs" }) }),
|
|
2321
|
+
item.call.inputs.map(
|
|
2322
|
+
(quantity, index) => quantityRow(quantity, "input", index)
|
|
2323
|
+
)
|
|
2324
|
+
] }),
|
|
2325
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("tbody", { children: [
|
|
2326
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("th", { colSpan: 2, children: "Calculation procedure" }) }),
|
|
2327
|
+
item.call.description.split(/\n\s*\n/u).map((paragraph, index) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("td", { colSpan: 2, children: paragraph }) }, `method-${index}`))
|
|
2328
|
+
] }),
|
|
2329
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("tbody", { className: "cso-external-quantities", children: [
|
|
2330
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("th", { colSpan: 2, children: "Outputs" }) }),
|
|
2331
|
+
item.call.outputs.map(
|
|
2332
|
+
(quantity, index) => quantityRow(quantity, "output", index)
|
|
2333
|
+
),
|
|
2334
|
+
item.call.warnings.map((warning, index) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("td", { colSpan: 2, children: warning }) }, `warning-${index}`)),
|
|
2335
|
+
((_a3 = document2.verification) == null ? void 0 : _a3.externalReferenceCoverage) ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2336
|
+
"td",
|
|
1396
2337
|
{
|
|
1397
|
-
|
|
2338
|
+
colSpan: 2,
|
|
2339
|
+
className: "cso-external-reference-coverage",
|
|
2340
|
+
children: [
|
|
2341
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("p", { children: [
|
|
2342
|
+
"Independent check coverage:",
|
|
2343
|
+
" ",
|
|
2344
|
+
document2.verification.externalReferenceCoverage.status,
|
|
2345
|
+
"."
|
|
2346
|
+
] }),
|
|
2347
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("p", { children: [
|
|
2348
|
+
"Independently checked:",
|
|
2349
|
+
" ",
|
|
2350
|
+
document2.verification.externalReferenceCoverage.checked.filter(
|
|
2351
|
+
(slot) => slot.externalCallId === item.call.id
|
|
2352
|
+
).map((slot) => outputLabel(slot.outputName)).join(", ") || "None",
|
|
2353
|
+
"."
|
|
2354
|
+
] }),
|
|
2355
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("p", { children: [
|
|
2356
|
+
"Without an independent check:",
|
|
2357
|
+
" ",
|
|
2358
|
+
document2.verification.externalReferenceCoverage.uncovered.filter(
|
|
2359
|
+
(slot) => slot.externalCallId === item.call.id
|
|
2360
|
+
).map((slot) => outputLabel(slot.outputName)).join(", ") || "None",
|
|
2361
|
+
"."
|
|
2362
|
+
] })
|
|
2363
|
+
]
|
|
1398
2364
|
}
|
|
1399
|
-
)
|
|
2365
|
+
) }) : null
|
|
1400
2366
|
] })
|
|
1401
|
-
},
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
2367
|
+
] }),
|
|
2368
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(EngineeringMetadata, { entries: item.context })
|
|
2369
|
+
]
|
|
2370
|
+
},
|
|
2371
|
+
item.sourcePlacementId
|
|
2372
|
+
);
|
|
2373
|
+
}
|
|
2374
|
+
case "section": {
|
|
2375
|
+
const child = requiredItem(sections, item.id);
|
|
2376
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2377
|
+
"div",
|
|
2378
|
+
{
|
|
2379
|
+
"data-source-placement": item.sourcePlacementId,
|
|
2380
|
+
children: [
|
|
2381
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(EngineeringMetadata, { entries: item.context }),
|
|
2382
|
+
renderSection(child)
|
|
2383
|
+
]
|
|
2384
|
+
},
|
|
2385
|
+
item.sourcePlacementId
|
|
2386
|
+
);
|
|
2387
|
+
}
|
|
2388
|
+
case "text": {
|
|
2389
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2390
|
+
"div",
|
|
2391
|
+
{
|
|
2392
|
+
"data-source-placement": item.sourcePlacementId,
|
|
2393
|
+
className: "cso-text",
|
|
2394
|
+
children: [
|
|
2395
|
+
item.text.content,
|
|
2396
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(EngineeringMetadata, { entries: item.context })
|
|
2397
|
+
]
|
|
2398
|
+
},
|
|
2399
|
+
item.sourcePlacementId
|
|
2400
|
+
);
|
|
2401
|
+
}
|
|
2402
|
+
case "figure": {
|
|
2403
|
+
const asset = requiredItem(assets, item.figure.assetId);
|
|
2404
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2405
|
+
"figure",
|
|
2406
|
+
{
|
|
2407
|
+
"data-source-placement": item.sourcePlacementId,
|
|
2408
|
+
"data-asset-sha256": asset.asset.sha256,
|
|
2409
|
+
className: "cso-figure",
|
|
2410
|
+
children: [
|
|
2411
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2412
|
+
"img",
|
|
2413
|
+
{
|
|
2414
|
+
src: asset.dataUrl,
|
|
2415
|
+
alt: item.figure.alt,
|
|
2416
|
+
style: item.figure.width === void 0 ? void 0 : { width: item.figure.width }
|
|
2417
|
+
}
|
|
2418
|
+
),
|
|
2419
|
+
item.figure.caption && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("figcaption", { children: item.figure.caption }),
|
|
2420
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(EngineeringMetadata, { entries: item.context })
|
|
2421
|
+
]
|
|
2422
|
+
},
|
|
2423
|
+
item.sourcePlacementId
|
|
2424
|
+
);
|
|
2425
|
+
}
|
|
2426
|
+
case "method": {
|
|
2427
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2428
|
+
"section",
|
|
2429
|
+
{
|
|
2430
|
+
"data-source-placement": item.sourcePlacementId,
|
|
2431
|
+
"data-method-id": item.id,
|
|
2432
|
+
id: procedureAnchor(requiredItem(procedures, item.id)),
|
|
2433
|
+
className: "cso-method",
|
|
2434
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2435
|
+
Procedure,
|
|
1406
2436
|
{
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
2437
|
+
title: `Procedure ${requiredItem(procedures, item.id)}: ${item.title}`,
|
|
2438
|
+
heading: "h3",
|
|
2439
|
+
functionIdentity: item.functionIdentity,
|
|
2440
|
+
children: [
|
|
2441
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2442
|
+
EngineeringMetadata,
|
|
2443
|
+
{
|
|
2444
|
+
entries: item.context
|
|
2445
|
+
},
|
|
2446
|
+
"context"
|
|
2447
|
+
),
|
|
2448
|
+
...renderMethodContent(
|
|
2449
|
+
item.content,
|
|
2450
|
+
item.helpers,
|
|
2451
|
+
notationSheet(item.id, item.symbols),
|
|
2452
|
+
/* @__PURE__ */ new Set()
|
|
2453
|
+
)
|
|
2454
|
+
]
|
|
1410
2455
|
}
|
|
1411
2456
|
)
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
2457
|
+
},
|
|
2458
|
+
item.sourcePlacementId
|
|
2459
|
+
);
|
|
2460
|
+
}
|
|
2461
|
+
case "table": {
|
|
2462
|
+
const caseHeading = (caseItem) => {
|
|
2463
|
+
const qualifier = tableCaseQualifier(
|
|
2464
|
+
caseItem.invocationId,
|
|
2465
|
+
capturedSymbols
|
|
2466
|
+
);
|
|
2467
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
2468
|
+
caseItem.heading,
|
|
2469
|
+
qualifier ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2470
|
+
"span",
|
|
2471
|
+
{
|
|
2472
|
+
className: "cso-comparison-case-qualifier",
|
|
2473
|
+
"data-case-qualifier": qualifier,
|
|
2474
|
+
children: [
|
|
2475
|
+
"Subscript: ",
|
|
2476
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(GlyphMathBlock, { glyph: qualifier })
|
|
2477
|
+
]
|
|
2478
|
+
}
|
|
2479
|
+
) : null
|
|
2480
|
+
] });
|
|
2481
|
+
};
|
|
2482
|
+
const outcomeRows = (_b2 = item.outcomeRows) != null ? _b2 : [];
|
|
2483
|
+
const rowIndices = /* @__PURE__ */ new Map();
|
|
2484
|
+
for (const group of item.groups)
|
|
2485
|
+
for (const row of group.rows)
|
|
2486
|
+
rowIndices.set(`${group.role}:${row.quantity}`, symbolIndex++);
|
|
2487
|
+
for (const row of outcomeRows)
|
|
2488
|
+
rowIndices.set(row.id, symbolIndex++);
|
|
2489
|
+
const quantityHeading = (quantity) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { className: "cso-comparison-quantity", children: [
|
|
2490
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { className: "cso-comparison-description", children: [
|
|
2491
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2492
|
+
FormulaSheetItemIndex,
|
|
2493
|
+
{
|
|
2494
|
+
index: requiredItem(
|
|
2495
|
+
rowIndices,
|
|
2496
|
+
`${quantity.role}:${quantity.quantity}`
|
|
2497
|
+
)
|
|
2498
|
+
}
|
|
2499
|
+
),
|
|
2500
|
+
" ",
|
|
2501
|
+
quantity.description
|
|
2502
|
+
] }),
|
|
2503
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { className: "cso-comparison-notation", children: [
|
|
2504
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(GlyphMathBlock, { glyph: quantity.glyph }),
|
|
2505
|
+
quantity.unit ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "cso-comparison-unit", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(UnitMathBlock, { unit: quantity.unit }) }) : null
|
|
2506
|
+
] })
|
|
2507
|
+
] });
|
|
2508
|
+
const shownCell = (cell) => cell.applicability ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { children: [
|
|
2509
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2510
|
+
NumericalValue,
|
|
2511
|
+
{
|
|
2512
|
+
value: cell.value,
|
|
2513
|
+
numericKind: cell.numericKind
|
|
2514
|
+
}
|
|
2515
|
+
),
|
|
2516
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2517
|
+
"span",
|
|
2518
|
+
{
|
|
2519
|
+
className: "cso-result-status",
|
|
2520
|
+
title: cell.applicability.reasons.join(" "),
|
|
2521
|
+
children: "Not applicable"
|
|
2522
|
+
}
|
|
2523
|
+
)
|
|
2524
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2525
|
+
NumericalValue,
|
|
2526
|
+
{
|
|
2527
|
+
value: cell.value,
|
|
2528
|
+
numericKind: cell.numericKind
|
|
2529
|
+
}
|
|
2530
|
+
);
|
|
2531
|
+
const notation = item.symbols ? notationSheet(item.id, item.symbols) : void 0;
|
|
2532
|
+
const outcomeHeading = (row) => {
|
|
2533
|
+
var _a4, _b3;
|
|
2534
|
+
const predicate = (_b3 = row.predicateSymbolId) != null ? _b3 : row.kind === "branch" ? (_a4 = row.cells.flatMap((cell) => cell.results)[0]) == null ? void 0 : _a4.conditionSymbolId : void 0;
|
|
2535
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { className: "cso-comparison-description", children: [
|
|
2536
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2537
|
+
FormulaSheetItemIndex,
|
|
2538
|
+
{
|
|
2539
|
+
index: requiredItem(rowIndices, row.id)
|
|
2540
|
+
}
|
|
2541
|
+
),
|
|
2542
|
+
" ",
|
|
2543
|
+
row.kind === "branch" ? `Rule used for ${row.label.toLowerCase()}` : row.label,
|
|
2544
|
+
predicate ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "cso-result-status", children: notation == null ? void 0 : notation.formula(predicate, false) }) : null
|
|
2545
|
+
] });
|
|
2546
|
+
};
|
|
2547
|
+
const outcomeCell = (row, heading) => {
|
|
2548
|
+
var _a4, _b3, _c3, _d3;
|
|
2549
|
+
if (row.kind === "branch") {
|
|
2550
|
+
const results2 = (_b3 = (_a4 = row.cells.find((cell) => cell.heading === heading)) == null ? void 0 : _a4.results) != null ? _b3 : [];
|
|
2551
|
+
return results2.length ? results2.map((result) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2552
|
+
"div",
|
|
2553
|
+
{
|
|
2554
|
+
"data-branch-note": heading,
|
|
2555
|
+
"data-case": heading,
|
|
2556
|
+
"data-symbol-id": result.symbolId,
|
|
2557
|
+
"data-node-key": result.nodeKey,
|
|
2558
|
+
"data-formula": result.value,
|
|
2559
|
+
children: [
|
|
2560
|
+
result.callPath ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "cso-result-status", children: readableName(result.callPath) }) : null,
|
|
2561
|
+
notation == null ? void 0 : notation.formula(result.branchSymbolId, false),
|
|
2562
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "cso-result-status", children: result.conditionHolds ? "Condition holds" : "Otherwise" })
|
|
2563
|
+
]
|
|
2564
|
+
},
|
|
2565
|
+
`${result.invocationId}:${result.nodeKey}`
|
|
2566
|
+
)) : "Not evaluated";
|
|
2567
|
+
}
|
|
2568
|
+
const results = (_d3 = (_c3 = row.cells.find((cell) => cell.heading === heading)) == null ? void 0 : _c3.results) != null ? _d3 : [];
|
|
2569
|
+
return results.length ? results.map((result) => {
|
|
2570
|
+
var _a5, _b4, _c4, _d4;
|
|
2571
|
+
const qualified = Boolean((_a5 = result.reasons) == null ? void 0 : _a5.length);
|
|
2572
|
+
const label = row.kind === "boolean" ? result.value ? "True" : "False" : qualified ? "Not applicable" : row.kind === "check" ? result.value ? "Pass" : "Fail" : result.value ? "Applicable" : "Not applicable";
|
|
2573
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2574
|
+
"div",
|
|
2575
|
+
{
|
|
2576
|
+
"data-case": heading,
|
|
2577
|
+
"data-invocation-id": result.invocationId,
|
|
2578
|
+
"data-boolean": row.kind === "boolean" ? row.id : void 0,
|
|
2579
|
+
"data-value": result.value,
|
|
2580
|
+
"data-check": row.kind === "check" ? (_b4 = row.localId) != null ? _b4 : row.id : void 0,
|
|
2581
|
+
"data-check-result": row.kind === "check" ? qualified ? "not-applicable" : result.value ? "pass" : "fail" : void 0,
|
|
2582
|
+
"data-applicability": row.kind === "applicability" ? (_c4 = row.localId) != null ? _c4 : row.id : void 0,
|
|
2583
|
+
"data-applicability-result": row.kind === "applicability" ? qualified || !result.value ? "not-applicable" : "applicable" : void 0,
|
|
2584
|
+
children: [
|
|
2585
|
+
result.callPath ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "cso-result-status", children: readableName(result.callPath) }) : null,
|
|
2586
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("strong", { children: label }),
|
|
2587
|
+
((_d4 = result.reasons) == null ? void 0 : _d4.length) ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "cso-result-status", children: result.reasons.filter((reason) => reason !== row.label).map((reason) => {
|
|
2588
|
+
const limit = outcomeRows.find(
|
|
2589
|
+
(candidate) => candidate.kind === "applicability" && candidate.label === reason
|
|
2590
|
+
);
|
|
2591
|
+
return limit ? `See limit ${requiredItem(rowIndices, limit.id)}.` : reason;
|
|
2592
|
+
}).join(" ") }) : null
|
|
2593
|
+
]
|
|
2594
|
+
},
|
|
2595
|
+
result.invocationId
|
|
2596
|
+
);
|
|
2597
|
+
}) : "Not evaluated";
|
|
2598
|
+
};
|
|
2599
|
+
const quantityColumn = /* @__PURE__ */ new Map();
|
|
2600
|
+
for (const group of item.groups) {
|
|
2601
|
+
for (const row of group.rows) {
|
|
2602
|
+
quantityColumn.set(
|
|
2603
|
+
`${group.role}:${row.quantity}`,
|
|
2604
|
+
quantityColumn.size
|
|
2605
|
+
);
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
const groupColumns = (group) => group.rows.map(
|
|
2609
|
+
(row) => quantityColumn.get(`${group.role}:${row.quantity}`)
|
|
2610
|
+
).join(",");
|
|
2611
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2612
|
+
"div",
|
|
2613
|
+
{
|
|
2614
|
+
"data-source-placement": item.sourcePlacementId,
|
|
2615
|
+
"data-comparison-id": item.id,
|
|
2616
|
+
"data-cases-axis": item.casesAxis,
|
|
2617
|
+
"data-column-cap": item.columnCap,
|
|
2618
|
+
className: "cso-comparison",
|
|
2619
|
+
children: [
|
|
2620
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("h3", { children: item.title }),
|
|
2621
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2622
|
+
"p",
|
|
2623
|
+
{
|
|
2624
|
+
className: "cso-function-identity",
|
|
2625
|
+
"data-method-reference": item.methodId,
|
|
2626
|
+
"data-function-identity": `${item.functionIdentity.moduleId}::${item.functionIdentity.function}`,
|
|
2627
|
+
children: [
|
|
2628
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2629
|
+
"a",
|
|
2630
|
+
{
|
|
2631
|
+
href: `#${procedureAnchor(requiredItem(procedures, item.methodId))}`,
|
|
2632
|
+
children: [
|
|
2633
|
+
"Uses procedure ",
|
|
2634
|
+
requiredItem(procedures, item.methodId)
|
|
2635
|
+
]
|
|
2636
|
+
}
|
|
2637
|
+
),
|
|
2638
|
+
": ",
|
|
2639
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("code", { children: [
|
|
2640
|
+
item.functionIdentity.moduleId,
|
|
2641
|
+
"::",
|
|
2642
|
+
item.functionIdentity.function
|
|
2643
|
+
] })
|
|
2644
|
+
]
|
|
2645
|
+
}
|
|
2646
|
+
),
|
|
2647
|
+
!item.outcomeRows && ((_c2 = item.engineeringChecks) == null ? void 0 : _c2.map(
|
|
2648
|
+
(check) => check.results.map((result) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2649
|
+
"p",
|
|
2650
|
+
{
|
|
2651
|
+
className: "cso-branch-note",
|
|
2652
|
+
"data-check": check.id,
|
|
2653
|
+
"data-check-result": result.reasons ? "not-applicable" : result.value ? "pass" : "fail",
|
|
2654
|
+
"data-case": result.heading,
|
|
2655
|
+
"data-formula": check.predicateText,
|
|
2656
|
+
children: [
|
|
2657
|
+
result.heading,
|
|
2658
|
+
result.callPath ? ` / ${result.callPath}` : "",
|
|
2659
|
+
":",
|
|
2660
|
+
" ",
|
|
2661
|
+
result.reasons ? `Not applicable. ${result.reasons.join(" ")}` : `${result.value ? "Pass" : "Fail"}. ${check.explanation}`
|
|
2662
|
+
]
|
|
2663
|
+
},
|
|
2664
|
+
`${check.id}-${result.invocationId}`
|
|
2665
|
+
))
|
|
2666
|
+
)),
|
|
2667
|
+
!item.outcomeRows && ((_d2 = item.applicabilityNotes) == null ? void 0 : _d2.map(
|
|
2668
|
+
(condition) => condition.results.map((result) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2669
|
+
"p",
|
|
2670
|
+
{
|
|
2671
|
+
className: "cso-branch-note",
|
|
2672
|
+
"data-applicability": condition.id,
|
|
2673
|
+
"data-applicability-result": result.value ? "applicable" : "not-applicable",
|
|
2674
|
+
"data-case": result.heading,
|
|
2675
|
+
"data-formula": condition.predicateText,
|
|
2676
|
+
children: [
|
|
2677
|
+
result.heading,
|
|
2678
|
+
result.callPath ? ` / ${result.callPath}` : "",
|
|
2679
|
+
":",
|
|
2680
|
+
" ",
|
|
2681
|
+
result.reasons ? `Not applicable. ${result.reasons.join(" ")}` : condition.explanation
|
|
2682
|
+
]
|
|
2683
|
+
},
|
|
2684
|
+
`${condition.id}-${result.invocationId}`
|
|
2685
|
+
))
|
|
2686
|
+
)),
|
|
2687
|
+
!item.outcomeRows && ((_e = item.branchNotes) == null ? void 0 : _e.map((note) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2688
|
+
"p",
|
|
2689
|
+
{
|
|
2690
|
+
className: "cso-branch-note",
|
|
2691
|
+
"data-branch-note": note.heading,
|
|
2692
|
+
"data-case": note.heading,
|
|
2693
|
+
"data-symbol-id": note.symbolId,
|
|
2694
|
+
"data-node-key": note.nodeKey,
|
|
2695
|
+
"data-formula": note.label,
|
|
2696
|
+
children: [
|
|
2697
|
+
note.heading,
|
|
2698
|
+
note.callPath ? ` / ${note.callPath}` : "",
|
|
2699
|
+
":",
|
|
2700
|
+
" ",
|
|
2701
|
+
notation == null ? void 0 : notation.description(note.branchSymbolId),
|
|
2702
|
+
" ",
|
|
2703
|
+
notation == null ? void 0 : notation.formula(note.branchSymbolId),
|
|
2704
|
+
", because",
|
|
2705
|
+
" ",
|
|
2706
|
+
notation == null ? void 0 : notation.formula(note.conditionSymbolId, false),
|
|
2707
|
+
" ",
|
|
2708
|
+
note.conditionHolds ? "holds" : "does not hold",
|
|
2709
|
+
"."
|
|
2710
|
+
]
|
|
2711
|
+
},
|
|
2712
|
+
`${note.invocationId}-${note.symbolId}-${note.nodeKey}`
|
|
2713
|
+
))),
|
|
2714
|
+
item.emptyState ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "cso-comparison-empty", children: item.emptyState }) : null,
|
|
2715
|
+
item.casesAxis === "rows" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2716
|
+
"div",
|
|
2717
|
+
{
|
|
2718
|
+
className: "cso-comparison-scroll",
|
|
2719
|
+
"data-comparison-scroll": "",
|
|
2720
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("table", { "data-comparison-table": "screen", children: [
|
|
2721
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("thead", { children: [
|
|
2722
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("tr", { children: [
|
|
2723
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("th", { scope: "col", "data-comparison-label": "", children: "Case" }),
|
|
2724
|
+
item.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2725
|
+
"th",
|
|
2726
|
+
{
|
|
2727
|
+
scope: "colgroup",
|
|
2728
|
+
colSpan: group.rows.length,
|
|
2729
|
+
"data-comparison-columns": groupColumns(group),
|
|
2730
|
+
children: group.label
|
|
2731
|
+
},
|
|
2732
|
+
group.role
|
|
2733
|
+
)),
|
|
2734
|
+
outcomeRows.length ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2735
|
+
"th",
|
|
2736
|
+
{
|
|
2737
|
+
scope: "colgroup",
|
|
2738
|
+
colSpan: outcomeRows.length,
|
|
2739
|
+
"data-comparison-columns": outcomeRows.map((_, index) => quantityColumn.size + index).join(","),
|
|
2740
|
+
children: "Checks and conditions"
|
|
2741
|
+
}
|
|
2742
|
+
) : null
|
|
2743
|
+
] }),
|
|
2744
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("tr", { children: [
|
|
2745
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("th", { scope: "col", "data-comparison-label": "", children: "Quantity" }),
|
|
2746
|
+
item.groups.flatMap(
|
|
2747
|
+
(group) => group.rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2748
|
+
"th",
|
|
2749
|
+
{
|
|
2750
|
+
scope: "col",
|
|
2751
|
+
"data-quantity": row.quantity,
|
|
2752
|
+
"data-comparison-column": quantityColumn.get(
|
|
2753
|
+
`${group.role}:${row.quantity}`
|
|
2754
|
+
),
|
|
2755
|
+
children: quantityHeading(row)
|
|
2756
|
+
},
|
|
2757
|
+
`${group.role}-${row.quantity}`
|
|
2758
|
+
))
|
|
2759
|
+
),
|
|
2760
|
+
outcomeRows.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2761
|
+
"th",
|
|
2762
|
+
{
|
|
2763
|
+
scope: "col",
|
|
2764
|
+
"data-outcome-kind": row.kind,
|
|
2765
|
+
"data-comparison-column": quantityColumn.size + index,
|
|
2766
|
+
children: outcomeHeading(row)
|
|
2767
|
+
},
|
|
2768
|
+
row.id
|
|
2769
|
+
))
|
|
2770
|
+
] })
|
|
2771
|
+
] }),
|
|
2772
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tbody", { children: item.cases.map((caseItem) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("tr", { children: [
|
|
2773
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2774
|
+
"th",
|
|
2775
|
+
{
|
|
2776
|
+
scope: "row",
|
|
2777
|
+
"data-comparison-label": "",
|
|
2778
|
+
"data-case-heading": caseItem.heading,
|
|
2779
|
+
children: caseHeading(caseItem)
|
|
2780
|
+
}
|
|
2781
|
+
),
|
|
2782
|
+
item.groups.flatMap(
|
|
2783
|
+
(group) => group.rows.map((row) => {
|
|
2784
|
+
const cell = row.cells.find(
|
|
2785
|
+
(candidate) => candidate.invocationId === caseItem.invocationId
|
|
2786
|
+
);
|
|
2787
|
+
if (!cell) {
|
|
2788
|
+
throw new Error(
|
|
2789
|
+
`Missing ${row.quantity} for ${caseItem.heading}`
|
|
2790
|
+
);
|
|
2791
|
+
}
|
|
2792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2793
|
+
"td",
|
|
2794
|
+
{
|
|
2795
|
+
"data-quantity": row.quantity,
|
|
2796
|
+
"data-case": caseItem.heading,
|
|
2797
|
+
"data-symbol-id": cell.symbolId,
|
|
2798
|
+
"data-value": cell.value,
|
|
2799
|
+
"data-comparison-column": quantityColumn.get(
|
|
2800
|
+
`${group.role}:${row.quantity}`
|
|
2801
|
+
),
|
|
2802
|
+
"data-applicability": cell.applicability ? "not-applicable" : void 0,
|
|
2803
|
+
children: shownCell(cell)
|
|
2804
|
+
},
|
|
2805
|
+
`${caseItem.invocationId}-${row.quantity}`
|
|
2806
|
+
);
|
|
2807
|
+
})
|
|
2808
|
+
),
|
|
2809
|
+
outcomeRows.map((row, index) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2810
|
+
"td",
|
|
2811
|
+
{
|
|
2812
|
+
"data-outcome-kind": row.kind,
|
|
2813
|
+
"data-comparison-column": quantityColumn.size + index,
|
|
2814
|
+
children: outcomeCell(row, caseItem.heading)
|
|
2815
|
+
},
|
|
2816
|
+
row.id
|
|
2817
|
+
))
|
|
2818
|
+
] }, caseItem.invocationId)) })
|
|
2819
|
+
] })
|
|
2820
|
+
}
|
|
2821
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2822
|
+
"div",
|
|
2823
|
+
{
|
|
2824
|
+
className: "cso-comparison-scroll",
|
|
2825
|
+
"data-comparison-scroll": "",
|
|
2826
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("table", { "data-comparison-table": "screen", children: [
|
|
2827
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("tr", { children: [
|
|
2828
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("th", { scope: "col", "data-comparison-label": "", children: "Quantity" }),
|
|
2829
|
+
item.cases.map((caseItem, index) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2830
|
+
"th",
|
|
2831
|
+
{
|
|
2832
|
+
scope: "col",
|
|
2833
|
+
"data-case-heading": caseItem.heading,
|
|
2834
|
+
"data-comparison-column": index,
|
|
2835
|
+
children: caseHeading(caseItem)
|
|
2836
|
+
},
|
|
2837
|
+
caseItem.invocationId
|
|
2838
|
+
))
|
|
2839
|
+
] }) }),
|
|
2840
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("tbody", { children: [
|
|
2841
|
+
item.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_react2.Fragment, { children: [
|
|
2842
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2843
|
+
"th",
|
|
2844
|
+
{
|
|
2845
|
+
scope: "colgroup",
|
|
2846
|
+
colSpan: item.cases.length + 1,
|
|
2847
|
+
"data-comparison-banner": "",
|
|
2848
|
+
children: group.label
|
|
2849
|
+
}
|
|
2850
|
+
) }),
|
|
2851
|
+
group.rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("tr", { children: [
|
|
2852
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2853
|
+
"th",
|
|
2854
|
+
{
|
|
2855
|
+
scope: "row",
|
|
2856
|
+
"data-quantity": row.quantity,
|
|
2857
|
+
"data-comparison-label": "",
|
|
2858
|
+
children: quantityHeading(row)
|
|
2859
|
+
}
|
|
2860
|
+
),
|
|
2861
|
+
row.cells.map((cell, index) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2862
|
+
"td",
|
|
2863
|
+
{
|
|
2864
|
+
"data-quantity": row.quantity,
|
|
2865
|
+
"data-case": cell.heading,
|
|
2866
|
+
"data-symbol-id": cell.symbolId,
|
|
2867
|
+
"data-value": cell.value,
|
|
2868
|
+
"data-comparison-column": index,
|
|
2869
|
+
"data-applicability": cell.applicability ? "not-applicable" : void 0,
|
|
2870
|
+
children: shownCell(cell)
|
|
2871
|
+
},
|
|
2872
|
+
cell.invocationId
|
|
2873
|
+
))
|
|
2874
|
+
] }, `${group.role}-${row.quantity}`))
|
|
2875
|
+
] }, group.role)),
|
|
2876
|
+
outcomeRows.length ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2877
|
+
"th",
|
|
2878
|
+
{
|
|
2879
|
+
scope: "colgroup",
|
|
2880
|
+
colSpan: item.cases.length + 1,
|
|
2881
|
+
"data-comparison-banner": "",
|
|
2882
|
+
children: "Checks and conditions"
|
|
2883
|
+
}
|
|
2884
|
+
) }) : null,
|
|
2885
|
+
outcomeRows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("tr", { children: [
|
|
2886
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2887
|
+
"th",
|
|
2888
|
+
{
|
|
2889
|
+
scope: "row",
|
|
2890
|
+
"data-comparison-label": "",
|
|
2891
|
+
"data-outcome-kind": row.kind,
|
|
2892
|
+
children: outcomeHeading(row)
|
|
2893
|
+
}
|
|
2894
|
+
),
|
|
2895
|
+
item.cases.map((caseItem, index) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2896
|
+
"td",
|
|
2897
|
+
{
|
|
2898
|
+
"data-outcome-kind": row.kind,
|
|
2899
|
+
"data-comparison-column": index,
|
|
2900
|
+
children: outcomeCell(row, caseItem.heading)
|
|
2901
|
+
},
|
|
2902
|
+
caseItem.invocationId
|
|
2903
|
+
))
|
|
2904
|
+
] }, row.id))
|
|
2905
|
+
] })
|
|
2906
|
+
] })
|
|
2907
|
+
}
|
|
2908
|
+
),
|
|
2909
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(EngineeringMetadata, { entries: item.context })
|
|
2910
|
+
]
|
|
2911
|
+
},
|
|
2912
|
+
item.sourcePlacementId
|
|
2913
|
+
);
|
|
2914
|
+
}
|
|
2915
|
+
case "symbol":
|
|
2916
|
+
case "symbolRef": {
|
|
2917
|
+
const symbolId = item.kind === "symbol" ? item.symbol.id : item.id;
|
|
2918
|
+
const symbol = requiredItem(symbols, symbolId);
|
|
2919
|
+
const index = symbolIndex++;
|
|
2920
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2921
|
+
"div",
|
|
2922
|
+
{
|
|
2923
|
+
"data-source-placement": item.sourcePlacementId,
|
|
2924
|
+
"data-symbol-id": symbolId,
|
|
2925
|
+
className: "cso-symbol-placement",
|
|
2926
|
+
children: [
|
|
2927
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(EngineeringMetadata, { entries: item.context }),
|
|
2928
|
+
"applicability" in item && item.applicability ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2929
|
+
"p",
|
|
2930
|
+
{
|
|
2931
|
+
className: "cso-branch-note",
|
|
2932
|
+
"data-applicability": "not-applicable",
|
|
2933
|
+
"data-symbol-id": symbolId,
|
|
2934
|
+
children: [
|
|
2935
|
+
"Not applicable. ",
|
|
2936
|
+
item.applicability.reasons.join(" ")
|
|
2937
|
+
]
|
|
2938
|
+
}
|
|
2939
|
+
) : null,
|
|
2940
|
+
item.operands.map(({ symbolId: id, context }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2941
|
+
EngineeringMetadata,
|
|
2942
|
+
{
|
|
2943
|
+
entries: context,
|
|
2944
|
+
subject: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
2945
|
+
"Operand",
|
|
2946
|
+
" ",
|
|
2947
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2948
|
+
GlyphMathBlock,
|
|
2949
|
+
{
|
|
2950
|
+
glyph: requiredItem(symbols, id).glyph
|
|
2951
|
+
}
|
|
2952
|
+
)
|
|
2953
|
+
] })
|
|
2954
|
+
},
|
|
2955
|
+
id
|
|
2956
|
+
)),
|
|
2957
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2958
|
+
FormulaSheetSymbolRow,
|
|
2959
|
+
{
|
|
2960
|
+
sheet,
|
|
2961
|
+
item: symbol,
|
|
2962
|
+
sheetItemIndex: index
|
|
2963
|
+
}
|
|
2964
|
+
)
|
|
2965
|
+
]
|
|
2966
|
+
},
|
|
2967
|
+
item.sourcePlacementId
|
|
2968
|
+
);
|
|
2969
|
+
}
|
|
2970
|
+
default: {
|
|
2971
|
+
const exhaustive = item;
|
|
2972
|
+
return exhaustive;
|
|
2973
|
+
}
|
|
1420
2974
|
}
|
|
1421
|
-
}
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
return /* @__PURE__ */ (0,
|
|
2975
|
+
})
|
|
2976
|
+
]
|
|
2977
|
+
},
|
|
2978
|
+
section.id
|
|
2979
|
+
);
|
|
2980
|
+
};
|
|
2981
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
1428
2982
|
"article",
|
|
1429
2983
|
{
|
|
1430
2984
|
"data-formula-sheet": "true",
|
|
1431
2985
|
"data-prepared-document": "true",
|
|
1432
2986
|
className: "cso-document",
|
|
1433
2987
|
children: [
|
|
1434
|
-
/* @__PURE__ */ (0,
|
|
1435
|
-
/* @__PURE__ */ (0,
|
|
1436
|
-
showSourceDetails && /* @__PURE__ */ (0,
|
|
1437
|
-
showSourceDetails && document2.source.kind === "execution" && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("p", { children: [
|
|
1438
|
-
"Function ",
|
|
1439
|
-
document2.source.function,
|
|
1440
|
-
". Inputs",
|
|
1441
|
-
" ",
|
|
1442
|
-
Object.entries(document2.source.resolvedInputs).map(
|
|
1443
|
-
([key, value]) => `${key} = ${Object.is(value, -0) ? "-0" : value}`
|
|
1444
|
-
).join(", "),
|
|
1445
|
-
"."
|
|
1446
|
-
] })
|
|
2988
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("header", { className: "cso-document-header", children: [
|
|
2989
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("h1", { children: document2.title }),
|
|
2990
|
+
showSourceDetails && document2.source.kind === "legacy" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { children: "Preview only. Numerical agreement has not been verified." }) : null
|
|
1447
2991
|
] }),
|
|
1448
|
-
/* @__PURE__ */ (0,
|
|
2992
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(EngineeringMetadata, { entries: document2.context }),
|
|
1449
2993
|
document2.rootSectionIds.map((id) => {
|
|
1450
2994
|
const section = sections.get(id);
|
|
1451
2995
|
if (!section) {
|
|
1452
2996
|
throw new Error(`Missing prepared root '${id}'`);
|
|
1453
2997
|
}
|
|
1454
2998
|
return renderSection(section);
|
|
1455
|
-
})
|
|
2999
|
+
}),
|
|
3000
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("footer", { className: "cso-evidence-note", children: [
|
|
3001
|
+
!document2.verification && document2.source.kind === "execution" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { children: "Numerical verification is reported separately." }) : null,
|
|
3002
|
+
showSourceDetails && document2.source.kind === "execution" ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("p", { children: [
|
|
3003
|
+
"Source calculation: ",
|
|
3004
|
+
readableName(document2.source.function),
|
|
3005
|
+
".",
|
|
3006
|
+
Object.keys(document2.source.resolvedInputs).length ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
3007
|
+
" ",
|
|
3008
|
+
"Supplied values:",
|
|
3009
|
+
" ",
|
|
3010
|
+
Object.entries(document2.source.resolvedInputs).map(
|
|
3011
|
+
([key, value]) => `${readableName(key)} = ${Object.is(value, -0) ? "-0" : value}`
|
|
3012
|
+
).join(", "),
|
|
3013
|
+
"."
|
|
3014
|
+
] }) : null
|
|
3015
|
+
] }) : null,
|
|
3016
|
+
((_a = document2.verification) == null ? void 0 : _a.externalCoverage) ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("p", { children: [
|
|
3017
|
+
"External-result consistency:",
|
|
3018
|
+
" ",
|
|
3019
|
+
(_b = document2.verification.checks.externalResultConsistency) == null ? void 0 : _b.status,
|
|
3020
|
+
". Formula checks:",
|
|
3021
|
+
" ",
|
|
3022
|
+
(_d = (_c = document2.verification.checks.formulaConsistency.counts) == null ? void 0 : _c.checked) != null ? _d : 0,
|
|
3023
|
+
". Captured external calls:",
|
|
3024
|
+
" ",
|
|
3025
|
+
document2.verification.externalCoverage.calls,
|
|
3026
|
+
". External results:",
|
|
3027
|
+
" ",
|
|
3028
|
+
document2.verification.externalCoverage.results,
|
|
3029
|
+
"."
|
|
3030
|
+
] }) : null
|
|
3031
|
+
] })
|
|
1456
3032
|
]
|
|
1457
3033
|
}
|
|
1458
3034
|
);
|
|
1459
3035
|
};
|
|
1460
3036
|
|
|
1461
3037
|
// src/prepare-document.ts
|
|
1462
|
-
var
|
|
3038
|
+
var import_core16 = require("@cs-object/core");
|
|
1463
3039
|
|
|
1464
3040
|
// src/active-symbols.ts
|
|
1465
3041
|
var activeSymbolIds = (initialIds, definitionsById) => {
|
|
@@ -1488,8 +3064,281 @@ var activeSymbolIds = (initialIds, definitionsById) => {
|
|
|
1488
3064
|
return reachableSymbolIds;
|
|
1489
3065
|
};
|
|
1490
3066
|
|
|
3067
|
+
// src/method-notation.ts
|
|
3068
|
+
var import_core14 = require("@cs-object/core");
|
|
3069
|
+
var notationId = (...parts) => JSON.stringify(parts);
|
|
3070
|
+
var emptyTree = {
|
|
3071
|
+
rootKey: "value",
|
|
3072
|
+
nodes: [{ key: "value", mode: "LITERAL", literal: { kind: "empty" } }]
|
|
3073
|
+
};
|
|
3074
|
+
var reachableNodes = (nodes, rootKey) => {
|
|
3075
|
+
const byKey = new Map(nodes.map((node) => [node.key, node]));
|
|
3076
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3077
|
+
const visit = (key) => {
|
|
3078
|
+
var _a, _b;
|
|
3079
|
+
if (seen.has(key)) return;
|
|
3080
|
+
seen.add(key);
|
|
3081
|
+
for (const argument of (_b = (_a = byKey.get(key)) == null ? void 0 : _a.funcArgs) != null ? _b : []) visit(argument.key);
|
|
3082
|
+
};
|
|
3083
|
+
visit(rootKey);
|
|
3084
|
+
return nodes.filter((node) => seen.has(node.key));
|
|
3085
|
+
};
|
|
3086
|
+
var calls = (content) => content.flatMap(
|
|
3087
|
+
(item) => item.kind === "call" || item.kind === "external" ? [item] : item.kind === "section" ? calls(item.content) : []
|
|
3088
|
+
);
|
|
3089
|
+
var isInput = (quantity) => {
|
|
3090
|
+
var _a;
|
|
3091
|
+
return quantity.nodes.length === 0 || ((_a = quantity.nodes[0]) == null ? void 0 : _a.mode) === "GIVEN_PARAMETER";
|
|
3092
|
+
};
|
|
3093
|
+
var methodNotation = (method, fail2) => {
|
|
3094
|
+
var _c, _d, _e, _f, _g, _h;
|
|
3095
|
+
const symbols = /* @__PURE__ */ new Map();
|
|
3096
|
+
const helpers = /* @__PURE__ */ new Map();
|
|
3097
|
+
const indexHelpers = (records) => {
|
|
3098
|
+
for (const helper of records) {
|
|
3099
|
+
helpers.set(helper.id, helper);
|
|
3100
|
+
indexHelpers(helper.helpers);
|
|
3101
|
+
}
|
|
3102
|
+
};
|
|
3103
|
+
indexHelpers(method.helpers);
|
|
3104
|
+
const add = (symbol) => {
|
|
3105
|
+
symbols.set(symbol.id, __spreadProps(__spreadValues({}, symbol), { notationScope: symbol.id }));
|
|
3106
|
+
return symbol.id;
|
|
3107
|
+
};
|
|
3108
|
+
const quantitySymbolId = (owner, variableName) => notationId(owner.id, variableName);
|
|
3109
|
+
const callHelper = (owner, binding) => {
|
|
3110
|
+
var _a;
|
|
3111
|
+
const call = calls(owner.content).find((item) => item.binding === binding);
|
|
3112
|
+
return (_a = helpers.get((call == null ? void 0 : call.kind) === "call" ? call.helperId : "")) != null ? _a : fail2(`Call '${binding}' has no helper in '${owner.id}'`);
|
|
3113
|
+
};
|
|
3114
|
+
const outputSymbolId = (owner, binding, output) => {
|
|
3115
|
+
var _a, _b, _c2, _d2;
|
|
3116
|
+
const id = notationId(owner.id, binding, "output", output);
|
|
3117
|
+
if (symbols.has(id)) return id;
|
|
3118
|
+
const external = calls(owner.content).find(
|
|
3119
|
+
(item) => item.kind === "external" && item.binding === binding
|
|
3120
|
+
);
|
|
3121
|
+
if ((external == null ? void 0 : external.kind) === "external") {
|
|
3122
|
+
const declared = (_b = (_a = external.declaration.interface.outputs.find(
|
|
3123
|
+
(item) => item[0] === output
|
|
3124
|
+
)) == null ? void 0 : _a[2]) != null ? _b : fail2(`Call '${binding}' has no external output '${output}'`);
|
|
3125
|
+
return add({
|
|
3126
|
+
id,
|
|
3127
|
+
glyph: (0, import_core14.scopedGlyph)(declared.glyph, binding),
|
|
3128
|
+
description: declared.description,
|
|
3129
|
+
unit: declared.unit,
|
|
3130
|
+
comment: (_c2 = declared.comment) != null ? _c2 : "",
|
|
3131
|
+
valueTree: emptyTree
|
|
3132
|
+
});
|
|
3133
|
+
}
|
|
3134
|
+
const quantity = (_d2 = callHelper(owner, binding).quantities.find(
|
|
3135
|
+
(candidate) => candidate.role === "output" && candidate.selectionName === output
|
|
3136
|
+
)) != null ? _d2 : fail2(`Call '${binding}' has no output '${output}'`);
|
|
3137
|
+
return add(__spreadProps(__spreadValues({
|
|
3138
|
+
id,
|
|
3139
|
+
glyph: (0, import_core14.scopedGlyph)(quantity.glyph, binding),
|
|
3140
|
+
description: quantity.description
|
|
3141
|
+
}, quantity.unit ? { unit: quantity.unit } : {}), {
|
|
3142
|
+
valueTree: emptyTree
|
|
3143
|
+
}));
|
|
3144
|
+
};
|
|
3145
|
+
const referencedId = (owner, node) => {
|
|
3146
|
+
var _a, _b, _c2, _d2, _e2, _f2;
|
|
3147
|
+
if (node.mode === "GIVEN_PARAMETER") {
|
|
3148
|
+
const quantity = (_a = owner.quantities.find(
|
|
3149
|
+
(candidate) => {
|
|
3150
|
+
var _a2;
|
|
3151
|
+
return ((_a2 = candidate.nodes[0]) == null ? void 0 : _a2.mode) === "GIVEN_PARAMETER" && candidate.nodes[0].parameter === node.parameter;
|
|
3152
|
+
}
|
|
3153
|
+
)) != null ? _a : fail2(`Given parameter '${node.parameter}' has no quantity`);
|
|
3154
|
+
return quantitySymbolId(owner, quantity.variableName);
|
|
3155
|
+
}
|
|
3156
|
+
if (((_b = node.ref) == null ? void 0 : _b.kind) === "output") {
|
|
3157
|
+
return outputSymbolId(owner, (_c2 = node.ref.call) != null ? _c2 : "", (_d2 = node.ref.output) != null ? _d2 : "");
|
|
3158
|
+
}
|
|
3159
|
+
const name = (_f2 = (_e2 = node.ref) == null ? void 0 : _e2.name) != null ? _f2 : "";
|
|
3160
|
+
if (!owner.quantities.some((quantity) => quantity.variableName === name)) {
|
|
3161
|
+
fail2(`Formula name '${name}' has no quantity in '${owner.id}'`);
|
|
3162
|
+
}
|
|
3163
|
+
return quantitySymbolId(owner, name);
|
|
3164
|
+
};
|
|
3165
|
+
const tree = (owner, nodes, rootKey = ((_b) => (_b = ((_a) => (_a = nodes[0]) == null ? void 0 : _a.key)()) != null ? _b : fail2("Empty formula"))()) => ({
|
|
3166
|
+
rootKey,
|
|
3167
|
+
nodes: reachableNodes(nodes, rootKey).map(
|
|
3168
|
+
(node) => {
|
|
3169
|
+
var _a2, _b2, _c2;
|
|
3170
|
+
const draft = node.draft === void 0 ? {} : { draft: node.draft };
|
|
3171
|
+
if (node.mode === "LITERAL") {
|
|
3172
|
+
const literal = (_a2 = node.literal) != null ? _a2 : fail2(`Literal '${node.key}' has no value`);
|
|
3173
|
+
return __spreadProps(__spreadValues({
|
|
3174
|
+
key: node.key,
|
|
3175
|
+
mode: "LITERAL"
|
|
3176
|
+
}, draft), {
|
|
3177
|
+
literal: {
|
|
3178
|
+
kind: "number",
|
|
3179
|
+
value: literal.value,
|
|
3180
|
+
numericKind: literal.numericKind
|
|
3181
|
+
}
|
|
3182
|
+
});
|
|
3183
|
+
}
|
|
3184
|
+
if (node.mode === "FUNCTION") {
|
|
3185
|
+
return __spreadProps(__spreadValues({
|
|
3186
|
+
key: node.key,
|
|
3187
|
+
mode: "FUNCTION"
|
|
3188
|
+
}, draft), {
|
|
3189
|
+
funcSpec: (_b2 = node.funcSpec) != null ? _b2 : fail2(`'${node.key}' has no function`),
|
|
3190
|
+
funcArgs: (_c2 = node.funcArgs) != null ? _c2 : []
|
|
3191
|
+
});
|
|
3192
|
+
}
|
|
3193
|
+
return __spreadProps(__spreadValues({
|
|
3194
|
+
key: node.key,
|
|
3195
|
+
mode: "SYMBOL"
|
|
3196
|
+
}, draft), {
|
|
3197
|
+
symbol: { id: referencedId(owner, node) }
|
|
3198
|
+
});
|
|
3199
|
+
}
|
|
3200
|
+
)
|
|
3201
|
+
});
|
|
3202
|
+
const ownerQuantity = (owner, variableName) => {
|
|
3203
|
+
var _a;
|
|
3204
|
+
return (_a = owner.quantities.find(
|
|
3205
|
+
(quantity) => quantity.variableName === variableName
|
|
3206
|
+
)) != null ? _a : fail2(`Quantity '${variableName}' is missing from '${owner.id}'`);
|
|
3207
|
+
};
|
|
3208
|
+
const symbolFor = (id, quantity, valueTree, glyph = quantity.glyph) => __spreadValues(__spreadProps(__spreadValues({
|
|
3209
|
+
id,
|
|
3210
|
+
glyph,
|
|
3211
|
+
description: quantity.description
|
|
3212
|
+
}, quantity.unit ? { unit: quantity.unit } : {}), {
|
|
3213
|
+
valueTree
|
|
3214
|
+
}), quantity.variableName.startsWith("__cso_return_") && quantity.role === "output" ? { metadata: { csoForwardedReturn: true } } : {});
|
|
3215
|
+
const owners = [method, ...helpers.values()];
|
|
3216
|
+
for (const owner of owners) {
|
|
3217
|
+
for (const quantity of owner.quantities) {
|
|
3218
|
+
add(
|
|
3219
|
+
symbolFor(
|
|
3220
|
+
quantitySymbolId(owner, quantity.variableName),
|
|
3221
|
+
quantity,
|
|
3222
|
+
isInput(quantity) ? emptyTree : tree(owner, quantity.nodes)
|
|
3223
|
+
)
|
|
3224
|
+
);
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
for (const owner of owners) {
|
|
3228
|
+
for (const call of calls(owner.content)) {
|
|
3229
|
+
if (call.kind === "external") {
|
|
3230
|
+
for (const [name, , declared] of call.declaration.interface.inputs) {
|
|
3231
|
+
const supplied = call.inputs.find((input) => input.name === name);
|
|
3232
|
+
const fallback = call.declaration.interface.defaults.find(
|
|
3233
|
+
(input) => input.name === name
|
|
3234
|
+
);
|
|
3235
|
+
const valueTree = supplied ? tree(owner, supplied.nodes) : fallback ? {
|
|
3236
|
+
rootKey: "value",
|
|
3237
|
+
nodes: [
|
|
3238
|
+
{
|
|
3239
|
+
key: "value",
|
|
3240
|
+
mode: "LITERAL",
|
|
3241
|
+
literal: {
|
|
3242
|
+
kind: "number",
|
|
3243
|
+
value: fallback.value,
|
|
3244
|
+
numericKind: fallback.numericKind
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
]
|
|
3248
|
+
} : emptyTree;
|
|
3249
|
+
add({
|
|
3250
|
+
id: notationId(owner.id, call.binding, "input", name),
|
|
3251
|
+
glyph: (0, import_core14.scopedGlyph)(declared.glyph, call.binding),
|
|
3252
|
+
description: declared.description,
|
|
3253
|
+
unit: declared.unit,
|
|
3254
|
+
comment: (_c = declared.comment) != null ? _c : "",
|
|
3255
|
+
valueTree
|
|
3256
|
+
});
|
|
3257
|
+
}
|
|
3258
|
+
for (const name of call.outputs)
|
|
3259
|
+
outputSymbolId(owner, call.binding, name);
|
|
3260
|
+
continue;
|
|
3261
|
+
}
|
|
3262
|
+
const helper = callHelper(owner, call.binding);
|
|
3263
|
+
for (const input of call.inputs) {
|
|
3264
|
+
const parameter = ownerQuantity(helper, input.name);
|
|
3265
|
+
add(
|
|
3266
|
+
symbolFor(
|
|
3267
|
+
notationId(owner.id, call.binding, "input", input.name),
|
|
3268
|
+
parameter,
|
|
3269
|
+
tree(owner, input.nodes),
|
|
3270
|
+
(0, import_core14.scopedGlyph)(parameter.glyph, call.binding)
|
|
3271
|
+
)
|
|
3272
|
+
);
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
for (const declaration of (_d = owner.booleans) != null ? _d : []) {
|
|
3276
|
+
if (declaration.expression.kind !== "predicate") continue;
|
|
3277
|
+
add({
|
|
3278
|
+
id: notationId(owner.id, "boolean", declaration.id),
|
|
3279
|
+
glyph: "b_{condition}",
|
|
3280
|
+
description: declaration.description,
|
|
3281
|
+
valueTree: tree(owner, declaration.expression.nodes)
|
|
3282
|
+
});
|
|
3283
|
+
}
|
|
3284
|
+
for (const condition of [
|
|
3285
|
+
...((_e = owner.checks) != null ? _e : []).map((condition2) => __spreadProps(__spreadValues({}, condition2), {
|
|
3286
|
+
kind: "check"
|
|
3287
|
+
})),
|
|
3288
|
+
...((_f = owner.applicability) != null ? _f : []).map((condition2) => __spreadProps(__spreadValues({}, condition2), {
|
|
3289
|
+
kind: "applicability"
|
|
3290
|
+
}))
|
|
3291
|
+
]) {
|
|
3292
|
+
const targetName = (_g = condition.targets[0]) != null ? _g : "";
|
|
3293
|
+
const target = (_h = owner.quantities.find(
|
|
3294
|
+
(quantity) => quantity.variableName === targetName || quantity.selectionName === targetName
|
|
3295
|
+
)) != null ? _h : fail2(`Condition '${condition.id}' has no target quantity`);
|
|
3296
|
+
add(
|
|
3297
|
+
symbolFor(
|
|
3298
|
+
notationId(owner.id, condition.kind, condition.id),
|
|
3299
|
+
target,
|
|
3300
|
+
tree(owner, condition.nodes)
|
|
3301
|
+
)
|
|
3302
|
+
);
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
return {
|
|
3306
|
+
quantityId: (owner, variableName) => quantitySymbolId(owner, variableName),
|
|
3307
|
+
callInputId: (owner, binding, name) => notationId(owner.id, binding, "input", name),
|
|
3308
|
+
callOutputId: (owner, binding, name) => outputSymbolId(owner, binding, name),
|
|
3309
|
+
conditionId: (owner, kind, id) => notationId(owner.id, kind, id),
|
|
3310
|
+
/** The branch a conditional chose and the test that chose it. */
|
|
3311
|
+
branch: (owner, variableName, nodeKey, chosenKey) => {
|
|
3312
|
+
var _a, _b;
|
|
3313
|
+
const quantity = ownerQuantity(owner, variableName);
|
|
3314
|
+
const conditional = (_a = quantity.nodes.find((node) => node.key === nodeKey)) != null ? _a : fail2(`Conditional '${nodeKey}' is missing from '${variableName}'`);
|
|
3315
|
+
const test = (_b = conditional.funcArgs) == null ? void 0 : _b[0];
|
|
3316
|
+
if (!test) fail2(`Conditional '${nodeKey}' is incomplete`);
|
|
3317
|
+
const base = quantitySymbolId(owner, variableName);
|
|
3318
|
+
return {
|
|
3319
|
+
quantitySymbolId: base,
|
|
3320
|
+
branchSymbolId: add(
|
|
3321
|
+
symbolFor(
|
|
3322
|
+
notationId(owner.id, variableName, nodeKey, "branch", chosenKey),
|
|
3323
|
+
quantity,
|
|
3324
|
+
tree(owner, quantity.nodes, chosenKey)
|
|
3325
|
+
)
|
|
3326
|
+
),
|
|
3327
|
+
conditionSymbolId: add(
|
|
3328
|
+
symbolFor(
|
|
3329
|
+
notationId(owner.id, variableName, nodeKey, "condition"),
|
|
3330
|
+
quantity,
|
|
3331
|
+
tree(owner, quantity.nodes, test.key)
|
|
3332
|
+
)
|
|
3333
|
+
)
|
|
3334
|
+
};
|
|
3335
|
+
},
|
|
3336
|
+
symbols: () => [...symbols.values()]
|
|
3337
|
+
};
|
|
3338
|
+
};
|
|
3339
|
+
|
|
1491
3340
|
// src/prepare-context.ts
|
|
1492
|
-
var
|
|
3341
|
+
var import_core15 = require("@cs-object/core");
|
|
1493
3342
|
var fields = /* @__PURE__ */ new Map([
|
|
1494
3343
|
["purpose", "Purpose"],
|
|
1495
3344
|
["explanation", "Explanation"],
|
|
@@ -1563,7 +3412,7 @@ var engineeringFields = (value, path) => {
|
|
|
1563
3412
|
if (value === void 0) {
|
|
1564
3413
|
return [];
|
|
1565
3414
|
}
|
|
1566
|
-
const object =
|
|
3415
|
+
const object = import_core15.HistoricalReviewSchema.shape.originalFields.parse(value);
|
|
1567
3416
|
return Object.entries(object).flatMap(([key, value2]) => {
|
|
1568
3417
|
const sourcePath = `${path}/${pointer(key)}`;
|
|
1569
3418
|
if (key === "additionalFields" && record(value2)) {
|
|
@@ -1574,7 +3423,30 @@ var engineeringFields = (value, path) => {
|
|
|
1574
3423
|
return label && selected ? [{ label, value: selected, path: sourcePath }] : [];
|
|
1575
3424
|
});
|
|
1576
3425
|
};
|
|
1577
|
-
var
|
|
3426
|
+
var placementContext = (source, path) => ["metadata", "contentMetadata", "additionalFields"].flatMap(
|
|
3427
|
+
(key) => engineeringFields(source == null ? void 0 : source[key], `${path}/${key}`)
|
|
3428
|
+
);
|
|
3429
|
+
var methodContentContext = (content, path) => content.map(
|
|
3430
|
+
(item, index) => item.kind !== "section" ? item : __spreadProps(__spreadValues({}, item), {
|
|
3431
|
+
context: placementContext(
|
|
3432
|
+
item.contextSource,
|
|
3433
|
+
`${path}/${index}/contextSource`
|
|
3434
|
+
),
|
|
3435
|
+
content: methodContentContext(
|
|
3436
|
+
item.content,
|
|
3437
|
+
`${path}/${index}/content`
|
|
3438
|
+
)
|
|
3439
|
+
})
|
|
3440
|
+
);
|
|
3441
|
+
var methodHelperContext = (helpers, path) => helpers.map((helper, index) => __spreadProps(__spreadValues({}, helper), {
|
|
3442
|
+
context: placementContext(
|
|
3443
|
+
helper.contextSource,
|
|
3444
|
+
`${path}/${index}/contextSource`
|
|
3445
|
+
),
|
|
3446
|
+
content: methodContentContext(helper.content, `${path}/${index}/content`),
|
|
3447
|
+
helpers: methodHelperContext(helper.helpers, `${path}/${index}/helpers`)
|
|
3448
|
+
}));
|
|
3449
|
+
var prepareDocumentContext = (document2, explained = /* @__PURE__ */ new Set()) => {
|
|
1578
3450
|
const definitions = new Map([
|
|
1579
3451
|
...document2.sections.flatMap(
|
|
1580
3452
|
(section, sectionIndex) => section.items.flatMap(
|
|
@@ -1596,7 +3468,9 @@ var prepareDocumentContext = (document2) => {
|
|
|
1596
3468
|
const placed = new Set(
|
|
1597
3469
|
document2.sections.flatMap(
|
|
1598
3470
|
(section) => section.items.flatMap(
|
|
1599
|
-
(item) => item.kind === "symbol" ? [item.symbol.id] : item.kind === "
|
|
3471
|
+
(item) => item.kind === "symbol" ? [item.symbol.id] : item.kind === "externalCall" ? [...item.call.inputs, ...item.call.outputs].map(
|
|
3472
|
+
(quantity) => quantity.symbolId
|
|
3473
|
+
) : item.kind === "symbolRef" ? [item.id] : []
|
|
1600
3474
|
)
|
|
1601
3475
|
)
|
|
1602
3476
|
);
|
|
@@ -1639,23 +3513,22 @@ var prepareDocumentContext = (document2) => {
|
|
|
1639
3513
|
),
|
|
1640
3514
|
items: section.items.map((item, itemIndex) => {
|
|
1641
3515
|
const path = `/sections/${sectionIndex}/items/${itemIndex}/contextSource`;
|
|
1642
|
-
const context =
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
);
|
|
3516
|
+
const context = placementContext(item.contextSource, path);
|
|
3517
|
+
if (item.kind === "method") {
|
|
3518
|
+
const itemPath = `/sections/${sectionIndex}/items/${itemIndex}`;
|
|
3519
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
3520
|
+
context,
|
|
3521
|
+
content: methodContentContext(item.content, `${itemPath}/content`),
|
|
3522
|
+
helpers: methodHelperContext(item.helpers, `${itemPath}/helpers`)
|
|
3523
|
+
});
|
|
3524
|
+
}
|
|
1652
3525
|
if (item.kind !== "symbol" && item.kind !== "symbolRef") {
|
|
1653
3526
|
return __spreadProps(__spreadValues({}, item), { context });
|
|
1654
3527
|
}
|
|
1655
3528
|
const id = item.kind === "symbol" ? item.symbol.id : item.id;
|
|
1656
3529
|
return __spreadProps(__spreadValues({}, item), {
|
|
1657
3530
|
context: [...symbolContext(id), ...context],
|
|
1658
|
-
operands: [...activeSymbolIds([id], symbols)].filter((id2) => !placed.has(id2)).map(operandContext)
|
|
3531
|
+
operands: [...activeSymbolIds([id], symbols)].filter((id2) => !placed.has(id2) && !explained.has(id2)).map(operandContext)
|
|
1659
3532
|
});
|
|
1660
3533
|
})
|
|
1661
3534
|
}))
|
|
@@ -1718,7 +3591,7 @@ var parseContent = (schema, value) => {
|
|
|
1718
3591
|
const parsed = schema.safeParse(value);
|
|
1719
3592
|
if (!parsed.success) {
|
|
1720
3593
|
throw new DocumentPreparationError(
|
|
1721
|
-
(0,
|
|
3594
|
+
(0, import_core16.contractIssuesToDiagnostics)(parsed.error.issues).map((diagnostic) => __spreadProps(__spreadValues({}, diagnostic), {
|
|
1722
3595
|
stage: "document"
|
|
1723
3596
|
}))
|
|
1724
3597
|
);
|
|
@@ -1727,9 +3600,9 @@ var parseContent = (schema, value) => {
|
|
|
1727
3600
|
};
|
|
1728
3601
|
var parseHistoricalReview = (value) => {
|
|
1729
3602
|
assertDocumentJson(value, "/historicalReview");
|
|
1730
|
-
return parseContent(
|
|
3603
|
+
return parseContent(import_core16.HistoricalReviewSchema, value);
|
|
1731
3604
|
};
|
|
1732
|
-
var parseDocument = (candidate) => parseContent(
|
|
3605
|
+
var parseDocument = (candidate) => parseContent(import_core16.PreparedDocumentSchema, candidate);
|
|
1733
3606
|
var reachableSections = (cso) => {
|
|
1734
3607
|
const sections = new Map(
|
|
1735
3608
|
cso.sections.map((section) => [section.id, section])
|
|
@@ -1961,9 +3834,481 @@ var resolveExecutionPlacementProvenance = (execution, item) => {
|
|
|
1961
3834
|
location: (_i = (_h = metadata == null ? void 0 : metadata.location) != null ? _h : targetCallSite) != null ? _i : definitionLocation
|
|
1962
3835
|
};
|
|
1963
3836
|
};
|
|
3837
|
+
var applicabilityField = (reasons) => reasons && reasons.length > 0 ? {
|
|
3838
|
+
applicability: {
|
|
3839
|
+
state: "not-applicable",
|
|
3840
|
+
reasons: [...reasons]
|
|
3841
|
+
}
|
|
3842
|
+
} : {};
|
|
3843
|
+
var sectionChecks = (execution, invocationId, derived) => {
|
|
3844
|
+
var _a;
|
|
3845
|
+
if (typeof invocationId !== "string") return {};
|
|
3846
|
+
const plans = ((_a = execution.methods) != null ? _a : []).flatMap(function walk(plan) {
|
|
3847
|
+
return [plan, ...plan.helpers.flatMap(walk)];
|
|
3848
|
+
});
|
|
3849
|
+
const engineeringChecks = plans.flatMap(
|
|
3850
|
+
(plan) => {
|
|
3851
|
+
var _a2;
|
|
3852
|
+
return ((_a2 = plan.checks) != null ? _a2 : []).flatMap((check) => {
|
|
3853
|
+
var _a3;
|
|
3854
|
+
const outcome = ((_a3 = execution.checkOutcomes) != null ? _a3 : []).find(
|
|
3855
|
+
(item) => item.methodId === plan.id && item.invocationId === invocationId && item.checkId === check.id
|
|
3856
|
+
);
|
|
3857
|
+
return outcome ? [
|
|
3858
|
+
__spreadValues({
|
|
3859
|
+
id: check.id,
|
|
3860
|
+
explanation: check.explanation,
|
|
3861
|
+
predicateText: check.predicateText,
|
|
3862
|
+
value: outcome.value
|
|
3863
|
+
}, (() => {
|
|
3864
|
+
const reasons = derived.reasonsByCheck.get(
|
|
3865
|
+
`${invocationId}|${check.id}`
|
|
3866
|
+
);
|
|
3867
|
+
return reasons ? { reasons: [...reasons] } : {};
|
|
3868
|
+
})())
|
|
3869
|
+
] : [];
|
|
3870
|
+
});
|
|
3871
|
+
}
|
|
3872
|
+
);
|
|
3873
|
+
return engineeringChecks.length > 0 ? { engineeringChecks } : {};
|
|
3874
|
+
};
|
|
3875
|
+
var groupedInvocationIds = (execution) => {
|
|
3876
|
+
var _a;
|
|
3877
|
+
return new Set(
|
|
3878
|
+
((_a = execution.tables) != null ? _a : []).flatMap(
|
|
3879
|
+
(table) => table.cases.map((item) => item.invocationId)
|
|
3880
|
+
)
|
|
3881
|
+
);
|
|
3882
|
+
};
|
|
3883
|
+
var replacesInvocation = (invocationId, grouped) => invocationId !== void 0 && [...grouped].some(
|
|
3884
|
+
(id) => invocationId === id || invocationId.startsWith(`${id}/`)
|
|
3885
|
+
);
|
|
3886
|
+
var presentedCell = (execution, cell, applicability) => {
|
|
3887
|
+
var _a, _b;
|
|
3888
|
+
if (cell.role === "input") {
|
|
3889
|
+
const invocation = execution.invocations.find(
|
|
3890
|
+
(item) => item.id === cell.caseInvocationId
|
|
3891
|
+
);
|
|
3892
|
+
const value = invocation == null ? void 0 : invocation.resolvedInputs[cell.quantity];
|
|
3893
|
+
const numericKind = (_a = invocation == null ? void 0 : invocation.resolvedInputKinds) == null ? void 0 : _a[cell.quantity];
|
|
3894
|
+
if (value === void 0 || numericKind !== "int" && numericKind !== "float") {
|
|
3895
|
+
fail("CELL_BINDING_MISMATCH", `Missing input '${cell.quantity}'`);
|
|
3896
|
+
}
|
|
3897
|
+
return __spreadValues({
|
|
3898
|
+
heading: cell.heading,
|
|
3899
|
+
invocationId: cell.caseInvocationId,
|
|
3900
|
+
symbolId: cell.symbolId,
|
|
3901
|
+
value,
|
|
3902
|
+
numericKind
|
|
3903
|
+
}, applicabilityField(applicability.reasonsBySymbolId.get(cell.symbolId)));
|
|
3904
|
+
}
|
|
3905
|
+
const output = (_b = execution.authoring) == null ? void 0 : _b.outputs.find(
|
|
3906
|
+
(item) => item.invocationId === cell.caseInvocationId && item.name === cell.quantity && item.symbolId === cell.symbolId
|
|
3907
|
+
);
|
|
3908
|
+
if (!output || output.numericKind !== "int" && output.numericKind !== "float") {
|
|
3909
|
+
fail("CELL_BINDING_MISMATCH", `Missing output '${cell.quantity}'`);
|
|
3910
|
+
}
|
|
3911
|
+
return __spreadValues({
|
|
3912
|
+
heading: cell.heading,
|
|
3913
|
+
invocationId: cell.caseInvocationId,
|
|
3914
|
+
symbolId: cell.symbolId,
|
|
3915
|
+
value: output.value,
|
|
3916
|
+
numericKind: output.numericKind
|
|
3917
|
+
}, applicabilityField(applicability.reasonsBySymbolId.get(cell.symbolId)));
|
|
3918
|
+
};
|
|
3919
|
+
var notationFor = (method) => methodNotation(method, (message) => fail("UNKNOWN_QUANTITY", message));
|
|
3920
|
+
var presentMethodQuantity = (owner, quantity, notation) => ({
|
|
3921
|
+
selectionName: quantity.selectionName,
|
|
3922
|
+
role: quantity.role,
|
|
3923
|
+
glyph: quantity.glyph,
|
|
3924
|
+
description: quantity.description,
|
|
3925
|
+
unit: quantity.unit,
|
|
3926
|
+
formulaText: quantity.formulaText,
|
|
3927
|
+
symbolId: notation.quantityId(owner, quantity.variableName)
|
|
3928
|
+
});
|
|
3929
|
+
var presentMethodContent = (owner, content, notation) => content.map((item) => {
|
|
3930
|
+
var _a, _b, _c;
|
|
3931
|
+
if (item.kind === "external") {
|
|
3932
|
+
return {
|
|
3933
|
+
kind: "external",
|
|
3934
|
+
binding: item.binding,
|
|
3935
|
+
declaration: item.declaration,
|
|
3936
|
+
adapter: item.adapter,
|
|
3937
|
+
inputs: item.declaration.interface.inputs.map(([name]) => {
|
|
3938
|
+
var _a2, _b2, _c2, _d;
|
|
3939
|
+
return {
|
|
3940
|
+
name,
|
|
3941
|
+
formulaText: (_d = (_a2 = item.inputs.find((input) => input.name === name)) == null ? void 0 : _a2.formulaText) != null ? _d : String(
|
|
3942
|
+
(_c2 = (_b2 = item.declaration.interface.defaults.find(
|
|
3943
|
+
(input) => input.name === name
|
|
3944
|
+
)) == null ? void 0 : _b2.value) != null ? _c2 : ""
|
|
3945
|
+
),
|
|
3946
|
+
symbolId: notation.callInputId(owner, item.binding, name)
|
|
3947
|
+
};
|
|
3948
|
+
}),
|
|
3949
|
+
outputs: item.outputs.map((name) => ({
|
|
3950
|
+
name,
|
|
3951
|
+
symbolId: notation.callOutputId(owner, item.binding, name)
|
|
3952
|
+
}))
|
|
3953
|
+
};
|
|
3954
|
+
}
|
|
3955
|
+
if (item.kind === "boolean") {
|
|
3956
|
+
const declared = (_a = owner.booleans) == null ? void 0 : _a.find(
|
|
3957
|
+
(candidate) => candidate.id === item.localId
|
|
3958
|
+
);
|
|
3959
|
+
if (!declared)
|
|
3960
|
+
fail("UNKNOWN_QUANTITY", `Boolean '${item.localId}' is missing`);
|
|
3961
|
+
return __spreadValues({
|
|
3962
|
+
kind: "boolean",
|
|
3963
|
+
localId: item.localId,
|
|
3964
|
+
description: declared.description,
|
|
3965
|
+
predicateText: declared.predicateText
|
|
3966
|
+
}, declared.expression.kind === "predicate" ? {
|
|
3967
|
+
predicateSymbolId: notation.conditionId(
|
|
3968
|
+
owner,
|
|
3969
|
+
"boolean",
|
|
3970
|
+
declared.id
|
|
3971
|
+
)
|
|
3972
|
+
} : {});
|
|
3973
|
+
}
|
|
3974
|
+
if (item.kind === "check" || item.kind === "applicability") {
|
|
3975
|
+
const declared = ((_b = item.kind === "check" ? owner.checks : owner.applicability) != null ? _b : []).find((candidate) => candidate.id === item.localId);
|
|
3976
|
+
if (!declared) {
|
|
3977
|
+
fail("UNKNOWN_QUANTITY", `Condition '${item.localId}' is missing`);
|
|
3978
|
+
}
|
|
3979
|
+
return {
|
|
3980
|
+
kind: item.kind,
|
|
3981
|
+
localId: item.localId,
|
|
3982
|
+
explanation: declared.explanation,
|
|
3983
|
+
predicateText: declared.predicateText,
|
|
3984
|
+
predicateSymbolId: notation.conditionId(owner, item.kind, declared.id)
|
|
3985
|
+
};
|
|
3986
|
+
}
|
|
3987
|
+
if (item.kind === "quantity") {
|
|
3988
|
+
const quantity = owner.quantities.find(
|
|
3989
|
+
(candidate) => candidate.variableName === item.variableName
|
|
3990
|
+
);
|
|
3991
|
+
if (!quantity) {
|
|
3992
|
+
fail("UNKNOWN_QUANTITY", `Quantity '${item.variableName}' is missing`);
|
|
3993
|
+
}
|
|
3994
|
+
return __spreadValues({
|
|
3995
|
+
kind: "quantity"
|
|
3996
|
+
}, presentMethodQuantity(owner, quantity, notation));
|
|
3997
|
+
}
|
|
3998
|
+
if (item.kind === "section") {
|
|
3999
|
+
return {
|
|
4000
|
+
kind: "section",
|
|
4001
|
+
localId: item.localId,
|
|
4002
|
+
title: item.title,
|
|
4003
|
+
contextSource: import_core16.HistoricalReviewSchema.shape.originalFields.parse({
|
|
4004
|
+
metadata: (_c = item.metadata) != null ? _c : {}
|
|
4005
|
+
}),
|
|
4006
|
+
content: presentMethodContent(owner, item.content, notation)
|
|
4007
|
+
};
|
|
4008
|
+
}
|
|
4009
|
+
if (item.kind === "call") {
|
|
4010
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
4011
|
+
inputs: item.inputs.map(({ name, formulaText }) => ({
|
|
4012
|
+
name,
|
|
4013
|
+
formulaText,
|
|
4014
|
+
symbolId: notation.callInputId(owner, item.binding, name)
|
|
4015
|
+
}))
|
|
4016
|
+
});
|
|
4017
|
+
}
|
|
4018
|
+
return item;
|
|
4019
|
+
});
|
|
4020
|
+
var presentMethodHelpers = (helpers, notation) => helpers.map((helper) => {
|
|
4021
|
+
var _a;
|
|
4022
|
+
return {
|
|
4023
|
+
id: helper.id,
|
|
4024
|
+
function: helper.function,
|
|
4025
|
+
functionIdentity: (0, import_core16.functionIdentityFrom)(helper),
|
|
4026
|
+
contextSource: import_core16.HistoricalReviewSchema.shape.originalFields.parse({
|
|
4027
|
+
metadata: (_a = helper.metadata) != null ? _a : {}
|
|
4028
|
+
}),
|
|
4029
|
+
content: presentMethodContent(helper, helper.content, notation),
|
|
4030
|
+
helpers: presentMethodHelpers(helper.helpers, notation)
|
|
4031
|
+
};
|
|
4032
|
+
});
|
|
4033
|
+
var presentedBranchNotes = (execution, table, method, notation, includeUniform = false) => {
|
|
4034
|
+
var _a, _b;
|
|
4035
|
+
const outcomes = (_a = execution.branchOutcomes) != null ? _a : [];
|
|
4036
|
+
const bound = table.cases.flatMap(
|
|
4037
|
+
(caseItem) => (0, import_core16.methodInvocationBindings)(execution, method, caseItem.invocationId).flatMap(
|
|
4038
|
+
({ plan, invocation, callPath }) => outcomes.filter((outcome) => outcome.invocationId === invocation.id).map((outcome) => {
|
|
4039
|
+
var _a2, _b2;
|
|
4040
|
+
const variable = (_a2 = invocation.symbols.find(
|
|
4041
|
+
(item) => item.symbolId === outcome.symbolId
|
|
4042
|
+
)) == null ? void 0 : _a2.variableName;
|
|
4043
|
+
const quantity = (_b2 = plan.quantities.find((item) => item.variableName === variable)) != null ? _b2 : fail(
|
|
4044
|
+
"UNKNOWN_QUANTITY",
|
|
4045
|
+
`Branch symbol '${outcome.symbolId}' is missing`
|
|
4046
|
+
);
|
|
4047
|
+
return { caseItem, plan, callPath, outcome, quantity };
|
|
4048
|
+
})
|
|
4049
|
+
)
|
|
4050
|
+
);
|
|
4051
|
+
const groupKey = (item) => JSON.stringify([
|
|
4052
|
+
item.plan.id,
|
|
4053
|
+
item.callPath,
|
|
4054
|
+
item.quantity.variableName,
|
|
4055
|
+
item.outcome.nodeKey
|
|
4056
|
+
]);
|
|
4057
|
+
const labels = /* @__PURE__ */ new Map();
|
|
4058
|
+
for (const item of bound) {
|
|
4059
|
+
const key = groupKey(item);
|
|
4060
|
+
const values = (_b = labels.get(key)) != null ? _b : /* @__PURE__ */ new Set();
|
|
4061
|
+
values.add(item.outcome.label);
|
|
4062
|
+
labels.set(key, values);
|
|
4063
|
+
}
|
|
4064
|
+
return bound.filter(
|
|
4065
|
+
(item) => {
|
|
4066
|
+
var _a2, _b2;
|
|
4067
|
+
return includeUniform || ((_b2 = (_a2 = labels.get(groupKey(item))) == null ? void 0 : _a2.size) != null ? _b2 : 0) > 1;
|
|
4068
|
+
}
|
|
4069
|
+
).map(({ caseItem, plan, callPath, outcome, quantity }) => {
|
|
4070
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
4071
|
+
const nodes = new Map(quantity.nodes.map((node) => [node.key, node]));
|
|
4072
|
+
let branch = outcome;
|
|
4073
|
+
let chosen;
|
|
4074
|
+
for (; ; ) {
|
|
4075
|
+
const arm = (_d = (_c = (_b2 = (_a2 = nodes.get(branch.nodeKey)) == null ? void 0 : _a2.funcArgs) == null ? void 0 : _b2[branch.value ? 1 : 2]) == null ? void 0 : _c.key) != null ? _d : fail(
|
|
4076
|
+
"UNKNOWN_QUANTITY",
|
|
4077
|
+
`Conditional '${branch.nodeKey}' is incomplete`
|
|
4078
|
+
);
|
|
4079
|
+
const inner = ((_f = (_e = nodes.get(arm)) == null ? void 0 : _e.funcSpec) == null ? void 0 : _f.id) === "fg.cnd" ? outcomes.find(
|
|
4080
|
+
(item) => item.invocationId === outcome.invocationId && item.symbolId === outcome.symbolId && item.nodeKey === arm
|
|
4081
|
+
) : void 0;
|
|
4082
|
+
if (!inner) {
|
|
4083
|
+
chosen = arm;
|
|
4084
|
+
break;
|
|
4085
|
+
}
|
|
4086
|
+
branch = inner;
|
|
4087
|
+
}
|
|
4088
|
+
return __spreadValues(__spreadProps(__spreadValues({
|
|
4089
|
+
heading: caseItem.heading
|
|
4090
|
+
}, callPath.length > 0 ? { callPath: callPath.join(" / ") } : {}), {
|
|
4091
|
+
invocationId: outcome.invocationId,
|
|
4092
|
+
symbolId: outcome.symbolId,
|
|
4093
|
+
nodeKey: outcome.nodeKey,
|
|
4094
|
+
label: outcome.label,
|
|
4095
|
+
conditionHolds: outcome.value
|
|
4096
|
+
}), notation.branch(
|
|
4097
|
+
plan,
|
|
4098
|
+
quantity.variableName,
|
|
4099
|
+
outcome.nodeKey,
|
|
4100
|
+
chosen
|
|
4101
|
+
));
|
|
4102
|
+
});
|
|
4103
|
+
};
|
|
4104
|
+
var comparisonPlacement = (execution, item, sectionId, index, applicability) => {
|
|
4105
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4106
|
+
if (item.kind !== "method" && item.kind !== "table") {
|
|
4107
|
+
fail("UNKNOWN_METHOD", "Expected a method or table placement");
|
|
4108
|
+
}
|
|
4109
|
+
const provenance = resolveExecutionPlacementProvenance(execution, item);
|
|
4110
|
+
const placement = __spreadValues(__spreadValues(__spreadValues({
|
|
4111
|
+
context: [],
|
|
4112
|
+
sourcePlacementId: placementId(sectionId, index)
|
|
4113
|
+
}, typeof provenance.localId === "string" ? { localId: provenance.localId } : {}), typeof provenance.invocationId === "string" ? { invocationId: provenance.invocationId } : {}), provenance.location ? { location: provenance.location } : {});
|
|
4114
|
+
if (item.kind === "method") {
|
|
4115
|
+
const method2 = (_a = execution.methods) == null ? void 0 : _a.find((record2) => record2.id === item.id);
|
|
4116
|
+
if (!method2) fail("UNKNOWN_METHOD", `Method '${item.id}' is missing`);
|
|
4117
|
+
const notation2 = notationFor(method2);
|
|
4118
|
+
return __spreadValues({
|
|
4119
|
+
kind: "method",
|
|
4120
|
+
id: item.id,
|
|
4121
|
+
title: method2.title,
|
|
4122
|
+
functionIdentity: (0, import_core16.functionIdentityFrom)(method2),
|
|
4123
|
+
contextSource: import_core16.HistoricalReviewSchema.shape.originalFields.parse({
|
|
4124
|
+
metadata: (_b = item.metadata) != null ? _b : {},
|
|
4125
|
+
contentMetadata: (_c = method2.metadata) != null ? _c : {}
|
|
4126
|
+
}),
|
|
4127
|
+
quantities: method2.quantities.map(
|
|
4128
|
+
(quantity) => presentMethodQuantity(method2, quantity, notation2)
|
|
4129
|
+
),
|
|
4130
|
+
content: presentMethodContent(method2, method2.content, notation2),
|
|
4131
|
+
helpers: presentMethodHelpers(method2.helpers, notation2),
|
|
4132
|
+
symbols: notation2.symbols()
|
|
4133
|
+
}, placement);
|
|
4134
|
+
}
|
|
4135
|
+
const table = (_d = execution.tables) == null ? void 0 : _d.find((record2) => record2.id === item.id);
|
|
4136
|
+
if (!table) fail("UNKNOWN_METHOD", `Table '${item.id}' is missing`);
|
|
4137
|
+
const method = (_e = execution.methods) == null ? void 0 : _e.find(
|
|
4138
|
+
(record2) => record2.id === table.methodId
|
|
4139
|
+
);
|
|
4140
|
+
if (!method) fail("UNKNOWN_METHOD", `Method '${table.methodId}' is missing`);
|
|
4141
|
+
const rows = (role, names) => names.map((name) => {
|
|
4142
|
+
const quantity = method.quantities.find(
|
|
4143
|
+
(candidate) => candidate.role === role && candidate.selectionName === name
|
|
4144
|
+
);
|
|
4145
|
+
if (!quantity) {
|
|
4146
|
+
fail(
|
|
4147
|
+
"UNKNOWN_QUANTITY",
|
|
4148
|
+
`Quantity '${name}' is missing from the method`
|
|
4149
|
+
);
|
|
4150
|
+
}
|
|
4151
|
+
return {
|
|
4152
|
+
quantity: name,
|
|
4153
|
+
role,
|
|
4154
|
+
glyph: quantity.glyph,
|
|
4155
|
+
description: quantity.description,
|
|
4156
|
+
unit: quantity.unit,
|
|
4157
|
+
cells: table.cases.map((caseItem) => {
|
|
4158
|
+
const cell = table.cells.find(
|
|
4159
|
+
(candidate) => candidate.caseInvocationId === caseItem.invocationId && candidate.quantity === name && candidate.role === role
|
|
4160
|
+
);
|
|
4161
|
+
if (!cell) {
|
|
4162
|
+
fail("CELL_BINDING_MISMATCH", `Missing cell for '${name}'`);
|
|
4163
|
+
}
|
|
4164
|
+
return presentedCell(execution, cell, applicability);
|
|
4165
|
+
})
|
|
4166
|
+
};
|
|
4167
|
+
});
|
|
4168
|
+
const notation = notationFor(method);
|
|
4169
|
+
const branchNotes = presentedBranchNotes(execution, table, method, notation);
|
|
4170
|
+
const bindings = table.cases.flatMap(
|
|
4171
|
+
(caseItem) => (0, import_core16.methodInvocationBindings)(execution, method, caseItem.invocationId).map(
|
|
4172
|
+
(binding) => __spreadProps(__spreadValues({}, binding), { heading: caseItem.heading })
|
|
4173
|
+
)
|
|
4174
|
+
);
|
|
4175
|
+
const checkPlans = new Map(bindings.map(({ plan }) => [plan.id, plan]));
|
|
4176
|
+
const engineeringChecks = [...checkPlans.values()].flatMap(
|
|
4177
|
+
(plan) => {
|
|
4178
|
+
var _a2;
|
|
4179
|
+
return ((_a2 = plan.checks) != null ? _a2 : []).flatMap((check) => {
|
|
4180
|
+
const results = bindings.filter((binding) => binding.plan.id === plan.id).flatMap(({ invocation, callPath, heading }) => {
|
|
4181
|
+
var _a3;
|
|
4182
|
+
const outcome = ((_a3 = execution.checkOutcomes) != null ? _a3 : []).find(
|
|
4183
|
+
(item2) => item2.methodId === plan.id && item2.invocationId === invocation.id && item2.checkId === check.id
|
|
4184
|
+
);
|
|
4185
|
+
if (!outcome) return [];
|
|
4186
|
+
const reasons = applicability.reasonsByCheck.get(
|
|
4187
|
+
`${invocation.id}|${check.id}`
|
|
4188
|
+
);
|
|
4189
|
+
return [
|
|
4190
|
+
__spreadValues(__spreadValues({
|
|
4191
|
+
heading,
|
|
4192
|
+
invocationId: invocation.id,
|
|
4193
|
+
value: outcome.value
|
|
4194
|
+
}, callPath.length > 0 ? { callPath: callPath.join(" / ") } : {}), reasons ? { reasons: [...reasons] } : {})
|
|
4195
|
+
];
|
|
4196
|
+
});
|
|
4197
|
+
return results.length > 0 ? [
|
|
4198
|
+
{
|
|
4199
|
+
id: plan.id === method.id ? check.id : JSON.stringify([plan.id, check.id]),
|
|
4200
|
+
explanation: check.explanation,
|
|
4201
|
+
predicateText: check.predicateText,
|
|
4202
|
+
results
|
|
4203
|
+
}
|
|
4204
|
+
] : [];
|
|
4205
|
+
});
|
|
4206
|
+
}
|
|
4207
|
+
);
|
|
4208
|
+
const applicabilityPlans = [
|
|
4209
|
+
method,
|
|
4210
|
+
...method.helpers.flatMap(function walk(helper) {
|
|
4211
|
+
return [helper, ...helper.helpers.flatMap(walk)];
|
|
4212
|
+
})
|
|
4213
|
+
];
|
|
4214
|
+
const applicabilityNotes = applicabilityPlans.flatMap(
|
|
4215
|
+
(plan) => {
|
|
4216
|
+
var _a2;
|
|
4217
|
+
return ((_a2 = plan.applicability) != null ? _a2 : []).flatMap((condition) => {
|
|
4218
|
+
const results = table.cases.flatMap(
|
|
4219
|
+
(caseItem) => {
|
|
4220
|
+
var _a3;
|
|
4221
|
+
return ((_a3 = execution.applicabilityOutcomes) != null ? _a3 : []).filter(
|
|
4222
|
+
(item2) => item2.methodId === plan.id && item2.applicabilityId === condition.id && (item2.invocationId === caseItem.invocationId || item2.invocationId.startsWith(`${caseItem.invocationId}/`))
|
|
4223
|
+
).map((outcome) => __spreadValues({
|
|
4224
|
+
heading: caseItem.heading,
|
|
4225
|
+
invocationId: outcome.invocationId,
|
|
4226
|
+
value: outcome.value
|
|
4227
|
+
}, outcome.value ? {} : { reasons: [condition.explanation] }));
|
|
4228
|
+
}
|
|
4229
|
+
);
|
|
4230
|
+
return results.length > 0 ? [
|
|
4231
|
+
{
|
|
4232
|
+
id: condition.id,
|
|
4233
|
+
explanation: condition.explanation,
|
|
4234
|
+
predicateText: condition.predicateText,
|
|
4235
|
+
results
|
|
4236
|
+
}
|
|
4237
|
+
] : [];
|
|
4238
|
+
});
|
|
4239
|
+
}
|
|
4240
|
+
);
|
|
4241
|
+
const outcomeRows = (0, import_core16.tableOutcomeRows)(execution, table);
|
|
4242
|
+
const allBranchNotes = presentedBranchNotes(
|
|
4243
|
+
execution,
|
|
4244
|
+
table,
|
|
4245
|
+
method,
|
|
4246
|
+
notation,
|
|
4247
|
+
true
|
|
4248
|
+
);
|
|
4249
|
+
const branchRows = /* @__PURE__ */ new Map();
|
|
4250
|
+
for (const note of allBranchNotes) {
|
|
4251
|
+
const id = JSON.stringify([note.quantitySymbolId, note.conditionSymbolId]);
|
|
4252
|
+
let row = branchRows.get(id);
|
|
4253
|
+
if (!row) {
|
|
4254
|
+
row = {
|
|
4255
|
+
kind: "branch",
|
|
4256
|
+
id,
|
|
4257
|
+
label: (_g = (_f = notation.symbols().find((symbol) => symbol.id === note.quantitySymbolId)) == null ? void 0 : _f.description) != null ? _g : "Selected rule",
|
|
4258
|
+
predicateText: "",
|
|
4259
|
+
cells: table.cases.map(({ heading }) => ({ heading, results: [] }))
|
|
4260
|
+
};
|
|
4261
|
+
branchRows.set(id, row);
|
|
4262
|
+
}
|
|
4263
|
+
const cell = row.cells.find((cell2) => cell2.heading === note.heading);
|
|
4264
|
+
if (cell) {
|
|
4265
|
+
const _h = note, { heading: _heading, label } = _h, evidence = __objRest(_h, ["heading", "label"]);
|
|
4266
|
+
cell.results.push(__spreadProps(__spreadValues({}, evidence), { value: label }));
|
|
4267
|
+
}
|
|
4268
|
+
}
|
|
4269
|
+
outcomeRows.push(...branchRows.values());
|
|
4270
|
+
return __spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
4271
|
+
kind: "table",
|
|
4272
|
+
id: item.id,
|
|
4273
|
+
title: table.title,
|
|
4274
|
+
methodId: method.id,
|
|
4275
|
+
functionIdentity: (0, import_core16.functionIdentityFrom)(method),
|
|
4276
|
+
casesAxis: table.casesAxis
|
|
4277
|
+
}, table.columnCap ? { columnCap: table.columnCap } : {}), branchNotes.length > 0 ? { branchNotes } : {}), outcomeRows.length > 0 ? { symbols: notation.symbols() } : {}), outcomeRows.length > 0 ? { outcomeRows } : {}), engineeringChecks.length > 0 ? { engineeringChecks } : {}), applicabilityNotes.length > 0 ? { applicabilityNotes } : {}), {
|
|
4278
|
+
cases: table.cases.map(({ heading, invocationId }) => ({
|
|
4279
|
+
heading,
|
|
4280
|
+
invocationId
|
|
4281
|
+
})),
|
|
4282
|
+
groups: [
|
|
4283
|
+
...table.inputs.length > 0 ? [
|
|
4284
|
+
{
|
|
4285
|
+
role: "input",
|
|
4286
|
+
label: "Inputs",
|
|
4287
|
+
rows: rows("input", table.inputs)
|
|
4288
|
+
}
|
|
4289
|
+
] : [],
|
|
4290
|
+
...table.outputs.length > 0 ? [
|
|
4291
|
+
{
|
|
4292
|
+
role: "output",
|
|
4293
|
+
label: "Outputs",
|
|
4294
|
+
rows: rows("output", table.outputs)
|
|
4295
|
+
}
|
|
4296
|
+
] : []
|
|
4297
|
+
]
|
|
4298
|
+
}), table.cases.length === 0 ? { emptyState: "No cases evaluated" } : {}), {
|
|
4299
|
+
replacedSections: table.cases.map((caseItem) => caseItem.sectionId)
|
|
4300
|
+
}), placement);
|
|
4301
|
+
};
|
|
1964
4302
|
var prepareExecutionDocument = (options) => {
|
|
1965
|
-
var _a,
|
|
1966
|
-
const execution = parseContent(
|
|
4303
|
+
var _a, _b, _d;
|
|
4304
|
+
const execution = parseContent(import_core16.ExecutionPayloadSchema, options.execution);
|
|
4305
|
+
const verification = options.verificationReport === void 0 ? void 0 : parseContent(import_core16.VerificationReportSchema, options.verificationReport);
|
|
4306
|
+
if (verification && execution.externalCalls && (!verification.executionBinding || (0, import_core16.executionBindingKey)(verification.executionBinding) !== (0, import_core16.executionBindingKey)((0, import_core16.executionBindingFrom)(execution)))) {
|
|
4307
|
+
fail(
|
|
4308
|
+
"DOCUMENT_VERIFICATION_BINDING_MISMATCH",
|
|
4309
|
+
"Verification must belong to the exact captured execution"
|
|
4310
|
+
);
|
|
4311
|
+
}
|
|
1967
4312
|
assertExtensionFields(options.execution.cso);
|
|
1968
4313
|
for (const review of (_a = options.historicalReviews) != null ? _a : [])
|
|
1969
4314
|
assertDocumentJson(review, "/historicalReview");
|
|
@@ -1971,22 +4316,71 @@ var prepareExecutionDocument = (options) => {
|
|
|
1971
4316
|
if (Object.hasOwn(cso.source, "metadata"))
|
|
1972
4317
|
assertDocumentJson(cso.source.metadata, "/source/metadata");
|
|
1973
4318
|
const assets = options.assets.map(
|
|
1974
|
-
(asset) => parseContent(
|
|
4319
|
+
(asset) => parseContent(import_core16.ResolvedAssetSchema, asset)
|
|
1975
4320
|
);
|
|
1976
4321
|
for (const resolved of assets) {
|
|
1977
4322
|
const declared = execution.assets.find(
|
|
1978
4323
|
(asset) => asset.id === resolved.asset.id
|
|
1979
4324
|
);
|
|
1980
|
-
if (!declared || JSON.stringify(
|
|
4325
|
+
if (!declared || JSON.stringify(import_core16.AssetRecordSchema.parse(declared)) !== JSON.stringify(resolved.asset)) {
|
|
1981
4326
|
fail(
|
|
1982
4327
|
"DOCUMENT_ASSET_BINDING_MISMATCH",
|
|
1983
4328
|
`Captured asset '${resolved.asset.id}' differs from the execution asset record`
|
|
1984
4329
|
);
|
|
1985
4330
|
}
|
|
1986
4331
|
}
|
|
1987
|
-
const
|
|
1988
|
-
|
|
1989
|
-
|
|
4332
|
+
const applicability = (0, import_core16.deriveApplicability)(execution);
|
|
4333
|
+
const grouped = groupedInvocationIds(execution);
|
|
4334
|
+
const sectionsById = new Map(
|
|
4335
|
+
cso.sections.map((section) => [section.id, section])
|
|
4336
|
+
);
|
|
4337
|
+
const externalByInvocation = new Map(
|
|
4338
|
+
((_b = execution.externalCalls) != null ? _b : []).map((call) => [call.id, call])
|
|
4339
|
+
);
|
|
4340
|
+
const externalPlacement = (call, sectionId, index, title = call.callBindingName, suffix = "") => ({
|
|
4341
|
+
kind: "externalCall",
|
|
4342
|
+
id: JSON.stringify([
|
|
4343
|
+
"externalCall",
|
|
4344
|
+
call.parentInvocationId,
|
|
4345
|
+
call.callBindingName
|
|
4346
|
+
]),
|
|
4347
|
+
title,
|
|
4348
|
+
call,
|
|
4349
|
+
qualifications: [
|
|
4350
|
+
...new Set(
|
|
4351
|
+
[...call.inputs, ...call.outputs].map((quantity) => quantity.symbolId)
|
|
4352
|
+
)
|
|
4353
|
+
].flatMap((symbolId) => {
|
|
4354
|
+
const reasons = applicability.reasonsBySymbolId.get(symbolId);
|
|
4355
|
+
return (reasons == null ? void 0 : reasons.length) ? [
|
|
4356
|
+
{
|
|
4357
|
+
symbolId,
|
|
4358
|
+
state: "not-applicable",
|
|
4359
|
+
reasons: [...reasons]
|
|
4360
|
+
}
|
|
4361
|
+
] : [];
|
|
4362
|
+
}),
|
|
4363
|
+
context: [],
|
|
4364
|
+
sourcePlacementId: placementId(sectionId, index) + suffix,
|
|
4365
|
+
localId: call.callBindingName,
|
|
4366
|
+
invocationId: call.parentInvocationId,
|
|
4367
|
+
location: call.callSite
|
|
4368
|
+
});
|
|
4369
|
+
const replaced = (section) => {
|
|
4370
|
+
var _a2;
|
|
4371
|
+
return replacesInvocation(
|
|
4372
|
+
typeof ((_a2 = section.metadata) == null ? void 0 : _a2.invocationId) === "string" ? section.metadata.invocationId : void 0,
|
|
4373
|
+
grouped
|
|
4374
|
+
);
|
|
4375
|
+
};
|
|
4376
|
+
const sections = reachableSections(cso).filter(
|
|
4377
|
+
(section) => {
|
|
4378
|
+
var _a2;
|
|
4379
|
+
return !replaced(section) && !externalByInvocation.has(String((_a2 = section.metadata) == null ? void 0 : _a2.invocationId));
|
|
4380
|
+
}
|
|
4381
|
+
).map((section) => {
|
|
4382
|
+
var _a2, _b2, _c2, _d2;
|
|
4383
|
+
return __spreadProps(__spreadValues({
|
|
1990
4384
|
id: section.id,
|
|
1991
4385
|
title: section.title,
|
|
1992
4386
|
sourcePlacementId: placementId(section.id, "heading"),
|
|
@@ -1994,15 +4388,64 @@ var prepareExecutionDocument = (options) => {
|
|
|
1994
4388
|
localId: (_a2 = section.metadata) == null ? void 0 : _a2.localId,
|
|
1995
4389
|
invocationId: (_b2 = section.metadata) == null ? void 0 : _b2.invocationId,
|
|
1996
4390
|
location: (_c2 = section.metadata) == null ? void 0 : _c2.location,
|
|
1997
|
-
metadata: retainedMetadata(section.metadata, true)
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
4391
|
+
metadata: retainedMetadata(section.metadata, true)
|
|
4392
|
+
}, sectionChecks(
|
|
4393
|
+
execution,
|
|
4394
|
+
(_d2 = section.metadata) == null ? void 0 : _d2.invocationId,
|
|
4395
|
+
applicability
|
|
4396
|
+
)), {
|
|
4397
|
+
items: section.items.flatMap((item, index) => {
|
|
4398
|
+
var _a3, _b3, _c3;
|
|
4399
|
+
if (item.kind === "section") {
|
|
4400
|
+
const target = sectionsById.get(item.id);
|
|
4401
|
+
const call = externalByInvocation.get(
|
|
4402
|
+
String((_a3 = target == null ? void 0 : target.metadata) == null ? void 0 : _a3.invocationId)
|
|
4403
|
+
);
|
|
4404
|
+
if (call) return [externalPlacement(call, section.id, index)];
|
|
4405
|
+
if (target && replaced(target)) return [];
|
|
4406
|
+
}
|
|
4407
|
+
if (item.kind === "method" || item.kind === "table") {
|
|
4408
|
+
const table = item.kind === "table" ? (_b3 = execution.tables) == null ? void 0 : _b3.find((table2) => table2.id === item.id) : void 0;
|
|
4409
|
+
const retained = (_c3 = table == null ? void 0 : table.cases.flatMap(
|
|
4410
|
+
(caseItem) => {
|
|
4411
|
+
var _a4;
|
|
4412
|
+
return ((_a4 = execution.externalCalls) != null ? _a4 : []).filter(
|
|
4413
|
+
(call) => call.id.startsWith(`${caseItem.invocationId}/`)
|
|
4414
|
+
).map(
|
|
4415
|
+
(call) => externalPlacement(
|
|
4416
|
+
call,
|
|
4417
|
+
section.id,
|
|
4418
|
+
index,
|
|
4419
|
+
`${caseItem.heading} / ${call.id.slice(caseItem.invocationId.length + 1).split("/").join(" / ")}`,
|
|
4420
|
+
`:external:${encodeURIComponent(call.id)}`
|
|
4421
|
+
)
|
|
4422
|
+
);
|
|
4423
|
+
}
|
|
4424
|
+
)) != null ? _c3 : [];
|
|
4425
|
+
return [
|
|
4426
|
+
comparisonPlacement(
|
|
4427
|
+
execution,
|
|
4428
|
+
item,
|
|
4429
|
+
section.id,
|
|
4430
|
+
index,
|
|
4431
|
+
applicability
|
|
4432
|
+
),
|
|
4433
|
+
...retained
|
|
4434
|
+
];
|
|
4435
|
+
}
|
|
4436
|
+
return [
|
|
4437
|
+
__spreadValues(__spreadProps(__spreadValues(__spreadValues({}, itemFields(item)), applicabilityField(
|
|
4438
|
+
item.kind === "symbol" || item.kind === "symbolRef" ? applicability.reasonsBySymbolId.get(
|
|
4439
|
+
item.kind === "symbol" ? item.symbol.id : item.id
|
|
4440
|
+
) : void 0
|
|
4441
|
+
)), {
|
|
4442
|
+
context: [],
|
|
4443
|
+
contextSource: retainItemContextSource(item, true),
|
|
4444
|
+
sourcePlacementId: placementId(section.id, index)
|
|
4445
|
+
}), resolveExecutionPlacementProvenance(execution, item))
|
|
4446
|
+
];
|
|
2004
4447
|
})
|
|
2005
|
-
};
|
|
4448
|
+
});
|
|
2006
4449
|
});
|
|
2007
4450
|
const displayed = new Set(
|
|
2008
4451
|
sections.flatMap(
|
|
@@ -2019,13 +4462,18 @@ var prepareExecutionDocument = (options) => {
|
|
|
2019
4462
|
const placementHistory = itemHistory.filter(
|
|
2020
4463
|
(item) => item.kind !== "text" && item.kind !== "figure"
|
|
2021
4464
|
);
|
|
2022
|
-
const
|
|
2023
|
-
const document2 = parseDocument({
|
|
2024
|
-
documentVersion:
|
|
2025
|
-
|
|
4465
|
+
const _c = cso.source, { metadata: _sourceMetadata } = _c, sourceProvenance = __objRest(_c, ["metadata"]);
|
|
4466
|
+
const document2 = parseDocument(__spreadProps(__spreadValues({
|
|
4467
|
+
documentVersion: sections.some(
|
|
4468
|
+
(section) => section.items.some(
|
|
4469
|
+
(item) => item.kind === "method" || item.kind === "table"
|
|
4470
|
+
)
|
|
4471
|
+
) ? "6" : execution.externalCalls ? "4" : "2",
|
|
4472
|
+
context: []
|
|
4473
|
+
}, verification ? { verification } : {}), {
|
|
2026
4474
|
source: __spreadValues({
|
|
2027
4475
|
kind: "execution"
|
|
2028
|
-
}, (0,
|
|
4476
|
+
}, (0, import_core16.executionBindingFrom)(execution)),
|
|
2029
4477
|
sourceMetadata: cso.source.metadata,
|
|
2030
4478
|
title: cso.title,
|
|
2031
4479
|
rootSectionIds: cso.rootSectionIds,
|
|
@@ -2051,12 +4499,19 @@ var prepareExecutionDocument = (options) => {
|
|
|
2051
4499
|
return sections2.length > 0 ? { sections: sections2 } : {};
|
|
2052
4500
|
})()), symbolHistory.length > 0 ? { symbols: symbolHistory } : {}), referencedSymbolHistory.length > 0 ? { referencedSymbols: referencedSymbolHistory } : {}), contentHistory.length > 0 ? { content: contentHistory } : {}), placementHistory.length > 0 ? { placements: placementHistory } : {})
|
|
2053
4501
|
}),
|
|
2054
|
-
...(
|
|
4502
|
+
...(_d = options.historicalReviews) != null ? _d : []
|
|
2055
4503
|
]
|
|
2056
|
-
});
|
|
2057
|
-
return parseContent(
|
|
4504
|
+
}));
|
|
4505
|
+
return parseContent(import_core16.BoundPreparedDocumentSchema, {
|
|
2058
4506
|
execution,
|
|
2059
|
-
document: prepareDocumentContext(
|
|
4507
|
+
document: prepareDocumentContext(
|
|
4508
|
+
document2,
|
|
4509
|
+
new Set(
|
|
4510
|
+
execution.invocations.filter((invocation) => replacesInvocation(invocation.id, grouped)).flatMap(
|
|
4511
|
+
(invocation) => invocation.symbols.map((symbol) => symbol.symbolId)
|
|
4512
|
+
)
|
|
4513
|
+
)
|
|
4514
|
+
)
|
|
2060
4515
|
}).document;
|
|
2061
4516
|
};
|
|
2062
4517
|
var legacyFigure = (options, manifest, item, sourcePlacementId) => {
|
|
@@ -2085,7 +4540,7 @@ var legacyFigure = (options, manifest, item, sourcePlacementId) => {
|
|
|
2085
4540
|
`Original figure '${item.id}' captured bytes are missing`
|
|
2086
4541
|
);
|
|
2087
4542
|
}
|
|
2088
|
-
return parseContent(
|
|
4543
|
+
return parseContent(import_core16.PreparedDocumentItemSchema, {
|
|
2089
4544
|
kind: "figure",
|
|
2090
4545
|
id: item.id,
|
|
2091
4546
|
sourcePlacementId,
|
|
@@ -2101,15 +4556,15 @@ var legacyFigure = (options, manifest, item, sourcePlacementId) => {
|
|
|
2101
4556
|
var prepareLegacyDocument = (options) => {
|
|
2102
4557
|
var _a, _b, _c, _d;
|
|
2103
4558
|
const cso = restoreContentFields(
|
|
2104
|
-
parseContent(
|
|
4559
|
+
parseContent(import_core16.CalculationSourceObjectSchema, options.cso),
|
|
2105
4560
|
options.cso
|
|
2106
4561
|
);
|
|
2107
4562
|
assertExtensionFields(options.cso);
|
|
2108
4563
|
for (const review of (_a = options.historicalReviews) != null ? _a : [])
|
|
2109
4564
|
assertDocumentJson(review, "/historicalReview");
|
|
2110
|
-
const manifest = parseContent(
|
|
4565
|
+
const manifest = parseContent(import_core16.LegacyAssetManifestSchema, options.manifest);
|
|
2111
4566
|
const sections = reachableSections(cso).map(
|
|
2112
|
-
(section) => parseContent(
|
|
4567
|
+
(section) => parseContent(import_core16.PreparedDocumentSectionSchema, {
|
|
2113
4568
|
id: section.id,
|
|
2114
4569
|
title: section.title,
|
|
2115
4570
|
sourcePlacementId: placementId(section.id, "heading"),
|
|
@@ -2120,7 +4575,7 @@ var prepareLegacyDocument = (options) => {
|
|
|
2120
4575
|
if (item.kind === "figure") {
|
|
2121
4576
|
return legacyFigure(options, manifest, item, sourcePlacementId);
|
|
2122
4577
|
}
|
|
2123
|
-
return parseContent(
|
|
4578
|
+
return parseContent(import_core16.PreparedDocumentItemSchema, __spreadProps(__spreadValues({}, itemFields(item)), {
|
|
2124
4579
|
sourcePlacementId,
|
|
2125
4580
|
context: [],
|
|
2126
4581
|
contextSource: retainItemContextSource(item)
|
|
@@ -2183,7 +4638,11 @@ var prepareLegacyDocument = (options) => {
|
|
|
2183
4638
|
DocumentPreparationError,
|
|
2184
4639
|
FormulaSheet,
|
|
2185
4640
|
PreparedFormulaSheet,
|
|
4641
|
+
measureComparisons,
|
|
4642
|
+
partitionRowAxis,
|
|
4643
|
+
planComparisonParts,
|
|
2186
4644
|
prepareExecutionDocument,
|
|
2187
4645
|
prepareLegacyDocument,
|
|
2188
|
-
printFormulaSheet
|
|
4646
|
+
printFormulaSheet,
|
|
4647
|
+
renderComparisonParts
|
|
2189
4648
|
});
|