@magmonium/cli 0.8.20 → 0.8.21

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.
Files changed (2) hide show
  1. package/codegen/index.js +1806 -627
  2. package/package.json +1 -1
package/codegen/index.js CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // libs/codegen/src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ ACTION_NAME_READER: () => ACTION_NAME_READER,
23
24
  ALL_VARIANT: () => ALL_VARIANT,
24
25
  API_SEGMENT: () => API_SEGMENT,
25
26
  APP_CONFIG_SOURCE: () => APP_CONFIG_SOURCE,
@@ -123,6 +124,7 @@ __export(index_exports, {
123
124
  EMPTY_STORE_HOOK: () => EMPTY_STORE_HOOK,
124
125
  EMPTY_STORE_METHODS: () => EMPTY_STORE_METHODS,
125
126
  EMPTY_WC_CONFIG: () => EMPTY_WC_CONFIG,
127
+ ENUM_VALUE_READER: () => ENUM_VALUE_READER,
126
128
  ENVIRONMENT_PRESETS: () => ENVIRONMENT_PRESETS,
127
129
  FALLBACK_APP_COLOR: () => FALLBACK_APP_COLOR,
128
130
  FALLBACK_SLOTS: () => FALLBACK_SLOTS,
@@ -221,6 +223,11 @@ __export(index_exports, {
221
223
  NO_ROOT_PREFIX: () => NO_ROOT_PREFIX,
222
224
  NO_TRANSLATE_CONFIG_KEY: () => NO_TRANSLATE_CONFIG_KEY,
223
225
  ONE_CONFIG_SOURCE: () => ONE_CONFIG_SOURCE,
226
+ ONE_FUNCTIONS: () => ONE_FUNCTIONS,
227
+ ONE_FUNCTION_CATALOG: () => ONE_FUNCTION_CATALOG,
228
+ ONE_FUNCTION_ID_PARAM: () => ONE_FUNCTION_ID_PARAM,
229
+ ONE_FUNCTION_MAP_PARAM: () => ONE_FUNCTION_MAP_PARAM,
230
+ ONE_FUNCTION_PREFIX: () => ONE_FUNCTION_PREFIX,
224
231
  ONE_IMPORT_MODULE: () => ONE_IMPORT_MODULE,
225
232
  ONE_PACKAGE_VERSION: () => ONE_PACKAGE_VERSION,
226
233
  OPEN_SCREEN_INPUT_SOURCES: () => OPEN_SCREEN_INPUT_SOURCES,
@@ -290,12 +297,18 @@ __export(index_exports, {
290
297
  SEARCH_TEXT_INPUT: () => SEARCH_TEXT_INPUT,
291
298
  SECTION_TABLE_COLUMNS_KEY: () => SECTION_TABLE_COLUMNS_KEY,
292
299
  SECTION_TABLE_SEED_COLUMNS: () => SECTION_TABLE_SEED_COLUMNS,
300
+ SECTION_TABLE_SORT_DIRECTION: () => SECTION_TABLE_SORT_DIRECTION,
301
+ SECTION_TABLE_SORT_ID: () => SECTION_TABLE_SORT_ID,
302
+ SECTION_TABLE_SORT_OUTPUT: () => SECTION_TABLE_SORT_OUTPUT,
293
303
  SHARDED_FOLDERS: () => SHARDED_FOLDERS,
294
304
  SHARED_FUNCTIONS: () => SHARED_FUNCTIONS,
295
305
  SHARED_LIB_ROOT: () => SHARED_LIB_ROOT,
296
306
  SHARED_SHAPES: () => SHARED_SHAPES,
297
307
  SHARED_SHAPE_ID_PREFIX: () => SHARED_SHAPE_ID_PREFIX,
298
308
  SHIPPED_SHELL_PATHS: () => SHIPPED_SHELL_PATHS,
309
+ SORT_DIRECTION_ENUM: () => SORT_DIRECTION_ENUM,
310
+ SORT_DIRECTION_ENUM_ID: () => SORT_DIRECTION_ENUM_ID,
311
+ SORT_DIRECTION_VALUES: () => SORT_DIRECTION_VALUES,
299
312
  SOURCE_LANG: () => SOURCE_LANG,
300
313
  STARTER_GROUP: () => STARTER_GROUP,
301
314
  STAT_TEXT_SOURCES: () => STAT_TEXT_SOURCES,
@@ -334,6 +347,7 @@ __export(index_exports, {
334
347
  acceptsPatterns: () => acceptsPatterns,
335
348
  actionButtonEntries: () => actionButtonEntries,
336
349
  actionButtonOverrides: () => actionButtonOverrides,
350
+ actionEnumFile: () => actionEnumFile,
337
351
  actionEnumValues: () => actionEnumValues,
338
352
  actionEnums: () => actionEnums,
339
353
  actionRenderIds: () => actionRenderIds,
@@ -527,6 +541,7 @@ __export(index_exports, {
527
541
  computedRootIds: () => computedRootIds,
528
542
  conditionCheckType: () => conditionCheckType,
529
543
  conditionError: () => conditionError,
544
+ conditionFunction: () => conditionFunction,
530
545
  conditionId: () => conditionId,
531
546
  conditionKind: () => conditionKind,
532
547
  configurableResponses: () => configurableResponses,
@@ -538,6 +553,8 @@ __export(index_exports, {
538
553
  contentTemplateTag: () => contentTemplateTag,
539
554
  contrastRatio: () => contrastRatio,
540
555
  controlDrawsDenial: () => controlDrawsDenial,
556
+ controlEnumValues: () => controlEnumValues,
557
+ controlEnums: () => controlEnums,
541
558
  controlMapReadsState: () => controlMapReadsState,
542
559
  controlMapStateRootIds: () => controlMapStateRootIds,
543
560
  controlMapUsesAuth: () => controlMapUsesAuth,
@@ -626,6 +643,7 @@ __export(index_exports, {
626
643
  embedShapeBlocked: () => embedShapeBlocked,
627
644
  embeddedRefOf: () => embeddedRefOf,
628
645
  emissionShapeLookup: () => emissionShapeLookup,
646
+ emitEnumFile: () => emitEnumFile,
629
647
  emitFullAppFiles: () => emitFullAppFiles,
630
648
  emitGeneratedFiles: () => emitGeneratedFiles,
631
649
  emitOverlayFiles: () => emitOverlayFiles,
@@ -643,6 +661,16 @@ __export(index_exports, {
643
661
  encodeRoot: () => encodeRoot,
644
662
  endWithNewline: () => endWithNewline,
645
663
  ensureWritable: () => ensureWritable,
664
+ enumEventStateWrites: () => enumEventStateWrites,
665
+ enumEventWrites: () => enumEventWrites,
666
+ enumFileBase: () => enumFileBase,
667
+ enumIdOf: () => enumIdOf,
668
+ enumLabels: () => enumLabels,
669
+ enumMemberLabel: () => enumMemberLabel,
670
+ enumMemberName: () => enumMemberName,
671
+ enumModule: () => enumModule,
672
+ enumNameOf: () => enumNameOf,
673
+ enumValuesOf: () => enumValuesOf,
646
674
  evaluateVariantGate: () => evaluateVariantGate,
647
675
  eventPayloadTsType: () => eventPayloadTsType,
648
676
  everyFormReset: () => everyFormReset,
@@ -850,6 +878,7 @@ __export(index_exports, {
850
878
  isCompleteVisibilitySource: () => isCompleteVisibilitySource,
851
879
  isCompositionKind: () => isCompositionKind,
852
880
  isComputedEligible: () => isComputedEligible,
881
+ isControlEnum: () => isControlEnum,
853
882
  isControlVisible: () => isControlVisible,
854
883
  isCountdown: () => isCountdown,
855
884
  isCustomPath: () => isCustomPath,
@@ -897,6 +926,7 @@ __export(index_exports, {
897
926
  isNavRowShape: () => isNavRowShape,
898
927
  isNavVisibilityFunction: () => isNavVisibilityFunction,
899
928
  isOnChange: () => isOnChange,
929
+ isOneFunctionComputed: () => isOneFunctionComputed,
900
930
  isOptionRowShape: () => isOptionRowShape,
901
931
  isOrderingMenuActionOperator: () => isOrderingMenuActionOperator,
902
932
  isOrderingOutputArmOperator: () => isOrderingOutputArmOperator,
@@ -985,6 +1015,9 @@ __export(index_exports, {
985
1015
  landsUnconditionally: () => landsUnconditionally,
986
1016
  levelStateComputeds: () => levelStateComputeds,
987
1017
  libImportsFrom: () => libImportsFrom,
1018
+ liftToList: () => liftToList,
1019
+ liftToListInTemplate: () => liftToListInTemplate,
1020
+ liftsToList: () => liftsToList,
988
1021
  linkDrift: () => linkDrift,
989
1022
  linkTargetKind: () => linkTargetKind,
990
1023
  linkedVariableReaders: () => linkedVariableReaders,
@@ -994,6 +1027,7 @@ __export(index_exports, {
994
1027
  listFeatures: () => listFeatures,
995
1028
  listFilesUnder: () => listFilesUnder,
996
1029
  listFunctions: () => listFunctions,
1030
+ listOneFunctions: () => listOneFunctions,
997
1031
  listScreenComputeds: () => listScreenComputeds,
998
1032
  listScreenInputs: () => listScreenInputs,
999
1033
  listScreenOutputs: () => listScreenOutputs,
@@ -1102,6 +1136,7 @@ __export(index_exports, {
1102
1136
  navRowMiss: () => navRowMiss,
1103
1137
  navRowSourceBindings: () => navRowSourceBindings,
1104
1138
  navRowSourceOptions: () => navRowSourceOptions,
1139
+ navRowStoreOptions: () => navRowStoreOptions,
1105
1140
  navSegmentId: () => navSegmentId,
1106
1141
  navTailPathsOf: () => navTailPathsOf,
1107
1142
  navVariantNavIds: () => navVariantNavIds,
@@ -1149,6 +1184,13 @@ __export(index_exports, {
1149
1184
  normalizeTranslationKey: () => normalizeTranslationKey,
1150
1185
  normalizeVariantName: () => normalizeVariantName,
1151
1186
  offersOutputArms: () => offersOutputArms,
1187
+ oneFunctionArgFits: () => oneFunctionArgFits,
1188
+ oneFunctionFromPickValue: () => oneFunctionFromPickValue,
1189
+ oneFunctionOf: () => oneFunctionOf,
1190
+ oneFunctionPickValue: () => oneFunctionPickValue,
1191
+ oneFunctionReturns: () => oneFunctionReturns,
1192
+ oneFunctionSignature: () => oneFunctionSignature,
1193
+ oneFunctionSignatureText: () => oneFunctionSignatureText,
1152
1194
  openError: () => openError,
1153
1195
  openId: () => openId,
1154
1196
  openInputAnswered: () => openInputAnswered,
@@ -1405,6 +1447,7 @@ __export(index_exports, {
1405
1447
  sanitizeControlGroups: () => sanitizeControlGroups,
1406
1448
  sanitizeControlVariants: () => sanitizeControlVariants,
1407
1449
  sanitizeDistinct: () => sanitizeDistinct,
1450
+ sanitizeEnums: () => sanitizeEnums,
1408
1451
  sanitizeMemberPath: () => sanitizeMemberPath,
1409
1452
  sanitizeNavMap: () => sanitizeNavMap,
1410
1453
  sanitizeNpmAllowlist: () => sanitizeNpmAllowlist,
@@ -1435,6 +1478,7 @@ __export(index_exports, {
1435
1478
  screenControlAttrs: () => screenControlAttrs,
1436
1479
  screenControlHasRequiredInputBindings: () => screenControlHasRequiredInputBindings,
1437
1480
  screenControlInputGuards: () => screenControlInputGuards,
1481
+ screenControlLiftsInput: () => screenControlLiftsInput,
1438
1482
  screenEmbedGapReason: () => screenEmbedGapReason,
1439
1483
  screenEmitBindingTargets: () => screenEmitBindingTargets,
1440
1484
  screenEmitConstTargets: () => screenEmitConstTargets,
@@ -1468,6 +1512,10 @@ __export(index_exports, {
1468
1512
  screenPropertiesWithComputeds: () => screenPropertiesWithComputeds,
1469
1513
  screenTest: () => screenTest,
1470
1514
  screenVariableActionEnumIds: () => screenVariableActionEnumIds,
1515
+ screenVariableDataType: () => screenVariableDataType,
1516
+ screenVariableEnumId: () => screenVariableEnumId,
1517
+ screenVariableEnumIds: () => screenVariableEnumIds,
1518
+ screenVariableEnums: () => screenVariableEnums,
1471
1519
  screenVariableInitialAllowed: () => screenVariableInitialAllowed,
1472
1520
  screenVariableInitialIssue: () => screenVariableInitialIssue,
1473
1521
  screenVariableSourceType: () => screenVariableSourceType,
@@ -1493,6 +1541,8 @@ __export(index_exports, {
1493
1541
  sectionTableEmissions: () => sectionTableEmissions,
1494
1542
  sectionTableRef: () => sectionTableRef,
1495
1543
  sectionTableRows: () => sectionTableRows,
1544
+ sectionTableSortEnums: () => sectionTableSortEnums,
1545
+ sectionTableSortIds: () => sectionTableSortIds,
1496
1546
  seedColumn: () => seedColumn,
1497
1547
  seedColumns: () => seedColumns,
1498
1548
  seedInstanceArgs: () => seedInstanceArgs,
@@ -1526,6 +1576,7 @@ __export(index_exports, {
1526
1576
  shapesInReach: () => shapesInReach,
1527
1577
  sharedShapeHolders: () => sharedShapeHolders,
1528
1578
  signatureChanged: () => signatureChanged,
1579
+ signatureEnums: () => signatureEnums,
1529
1580
  signatureFormIds: () => signatureFormIds,
1530
1581
  signatureNamesOptionRow: () => signatureNamesOptionRow,
1531
1582
  signatureShapeIds: () => signatureShapeIds,
@@ -1533,9 +1584,11 @@ __export(index_exports, {
1533
1584
  slug: () => slug,
1534
1585
  slugifyComponentName: () => slugifyComponentName,
1535
1586
  slugifyMessage: () => slugifyMessage,
1587
+ sortRowEnumId: () => sortRowEnumId,
1536
1588
  sourceCarriesTrackKey: () => sourceCarriesTrackKey,
1537
1589
  staleCases: () => staleCases,
1538
1590
  staleMenuActionItems: () => staleMenuActionItems,
1591
+ stampStatePropertyEnums: () => stampStatePropertyEnums,
1539
1592
  standardMenuConfigs: () => standardMenuConfigs,
1540
1593
  starterFunction: () => starterFunction,
1541
1594
  stateComputedArgExpression: () => stateComputedArgExpression,
@@ -1563,6 +1616,8 @@ __export(index_exports, {
1563
1616
  storeAppOptions: () => storeAppOptions,
1564
1617
  storeHookCallError: () => storeHookCallError,
1565
1618
  storeNameScope: () => storeNameScope,
1619
+ storeOwnerOfValue: () => storeOwnerOfValue,
1620
+ storeOwnerValue: () => storeOwnerValue,
1566
1621
  storeReaders: () => storeReaders,
1567
1622
  storeTest: () => storeTest,
1568
1623
  storesOf: () => storesOf,
@@ -1698,7 +1753,9 @@ __export(index_exports, {
1698
1753
  withEmittedTests: () => withEmittedTests,
1699
1754
  withFormShapes: () => withFormShapes,
1700
1755
  withListRowShape: () => withListRowShape,
1756
+ withScreenEnums: () => withScreenEnums,
1701
1757
  withScreenMethodCallSites: () => withScreenMethodCallSites,
1758
+ withVariableEnums: () => withVariableEnums,
1702
1759
  wouldComputedCycle: () => wouldComputedCycle,
1703
1760
  wouldCycle: () => wouldCycle,
1704
1761
  wouldScreenComputedCycle: () => wouldScreenComputedCycle,
@@ -1747,6 +1804,8 @@ var ControlType = /* @__PURE__ */ ((ControlType2) => {
1747
1804
  ControlType2["STAT_VALUE"] = "stat_value";
1748
1805
  ControlType2["STAT_CORNER"] = "stat_corner";
1749
1806
  ControlType2["HEAT_SWATCH"] = "heat_swatch";
1807
+ ControlType2["SCORE_SET"] = "score_set";
1808
+ ControlType2["SCORE_SET_ITEM"] = "score_set_item";
1750
1809
  ControlType2["FORM"] = "form";
1751
1810
  ControlType2["FIELD"] = "field";
1752
1811
  ControlType2["SECTION_BUTTON_GROUP"] = "section_button_group";
@@ -1840,6 +1899,19 @@ var OPTION_ROW_TYPE_NAME = "DropdownOption";
1840
1899
  var OPTION_ROW_TYPE_PACKAGE = "@magmonium/one";
1841
1900
  var AUDIENCE_TYPE_NAME = "Audience";
1842
1901
  var AUDIENCE_TYPE_PACKAGE = "@magmonium/one";
1902
+ var SORT_DIRECTION_ENUM_ID = "section-table-sort-direction";
1903
+ function screenVariableDataType(variable) {
1904
+ return {
1905
+ type: variable.dataType,
1906
+ ...variable.actionEnumId ? { actionEnumId: variable.actionEnumId } : {},
1907
+ ...variable.sortEnumId ? { sortEnumId: variable.sortEnumId } : {}
1908
+ };
1909
+ }
1910
+ var enumIdOf = (dataType) => dataType?.actionEnumId ?? dataType?.sortEnumId;
1911
+ var isControlEnum = (dataType) => {
1912
+ const id = enumIdOf(dataType);
1913
+ return !!id && id !== SORT_DIRECTION_ENUM_ID;
1914
+ };
1843
1915
  var isMapCardinality = (cardinality) => cardinality === "map" || cardinality === "map-many";
1844
1916
  var SHARED_SHAPE_ID_PREFIX = "shared-";
1845
1917
  var isSharedShapeId = (id) => !!id && id.startsWith(SHARED_SHAPE_ID_PREFIX);
@@ -2088,6 +2160,9 @@ var featureShapeIds = (fn) => signatureShapeIds(fn).filter((id) => !isSharedShap
2088
2160
  var returnCardinalityOf = (fn) => fn.returnCardinality ?? "one";
2089
2161
  function tierOf(fn) {
2090
2162
  if (featureShapeIds(fn).length > 0) return "feature";
2163
+ if (fn.params.some((param) => isControlEnum(param.dataType)) || isControlEnum(fn.returnType)) {
2164
+ return "feature";
2165
+ }
2091
2166
  return fn.tier === "feature" ? "feature" : "app";
2092
2167
  }
2093
2168
  var isAppTier = (fn) => tierOf(fn) === "app";
@@ -2314,8 +2389,8 @@ var elementMismatch = (source, sourceShapes, target, targetShapes, seen, at, mis
2314
2389
  return void 0;
2315
2390
  };
2316
2391
  function dataTypeFits(source, sourceShapes, target, targetShapes, keyed = false) {
2317
- const cardinalityFits = source.cardinality === target.cardinality || keyed && source.cardinality === "many" && isMapCardinality(target.cardinality);
2318
- if (!cardinalityFits) return false;
2392
+ const cardinalityFits2 = source.cardinality === target.cardinality || keyed && source.cardinality === "many" && isMapCardinality(target.cardinality);
2393
+ if (!cardinalityFits2) return false;
2319
2394
  return elementFits(
2320
2395
  source.dataType,
2321
2396
  sourceShapes,
@@ -2325,8 +2400,8 @@ function dataTypeFits(source, sourceShapes, target, targetShapes, keyed = false)
2325
2400
  );
2326
2401
  }
2327
2402
  function dataTypeMismatch(source, sourceShapes, target, targetShapes, keyed = false, label = "value", missingFrom = "the response") {
2328
- const cardinalityFits = source.cardinality === target.cardinality || keyed && source.cardinality === "many" && isMapCardinality(target.cardinality);
2329
- if (!cardinalityFits) {
2403
+ const cardinalityFits2 = source.cardinality === target.cardinality || keyed && source.cardinality === "many" && isMapCardinality(target.cardinality);
2404
+ if (!cardinalityFits2) {
2330
2405
  return `${label} \u2014 ${target.cardinality} expected, ${source.cardinality} arrives`;
2331
2406
  }
2332
2407
  return elementMismatch(
@@ -2569,7 +2644,8 @@ var formFileBase = (formName) => `${formName.replace(/_/g, "-")}-form`;
2569
2644
  function tsTypeExpression(shapes, dataType, cardinality, actionEnumName = () => void 0) {
2570
2645
  const shapeKey = shapeKeyOf(dataType);
2571
2646
  const interfaceNameOf = dataType?.type === "form" ? formInterfaceName : shapeInterfaceName;
2572
- const enumName = dataType?.actionEnumId ? actionEnumName(dataType.actionEnumId) : void 0;
2647
+ const enumId = dataType?.actionEnumId ?? dataType?.sortEnumId;
2648
+ const enumName = enumId ? actionEnumName(enumId) : void 0;
2573
2649
  const element = shapeKey !== void 0 ? interfaceNameOf(shapes[shapeKey]?.name ?? "") : enumName ?? (dataType?.type === "file" ? "File" : dataType?.type === "option" ? OPTION_ROW_TYPE_NAME : dataType?.type === "audience" ? AUDIENCE_TYPE_NAME : dataType?.type) ?? "string";
2574
2650
  const named = element || "unknown";
2575
2651
  if (cardinality === "many") return `${named}[]`;
@@ -3176,6 +3252,9 @@ var contentTemplateTag = (host) => {
3176
3252
  var contentOf = (node) => (node.childrens ?? []).find((child) => child.type === "content" /* CONTENT */);
3177
3253
  var hasContent = (node) => (node.childrens ?? []).some((child) => child.type === "content" /* CONTENT */);
3178
3254
 
3255
+ // libs/codegen/src/model/one-import-module.ts
3256
+ var ONE_IMPORT_MODULE = "@magmonium/one";
3257
+
3179
3258
  // libs/codegen/src/model/control-const.ts
3180
3259
  var CONTROL_RELATIONSHIPS = {
3181
3260
  ["section" /* SECTION */]: [
@@ -3279,6 +3358,7 @@ var CONTROL_RELATIONSHIPS = {
3279
3358
  "user" /* USER */,
3280
3359
  "stat" /* STAT */,
3281
3360
  "heat_swatch" /* HEAT_SWATCH */,
3361
+ "score_set" /* SCORE_SET */,
3282
3362
  "flex" /* FLEX */,
3283
3363
  "card" /* CARD */,
3284
3364
  "chat_bubble" /* CHAT_BUBBLE */,
@@ -3343,6 +3423,7 @@ var CONTROL_RELATIONSHIPS = {
3343
3423
  "user" /* USER */,
3344
3424
  "stat" /* STAT */,
3345
3425
  "heat_swatch" /* HEAT_SWATCH */,
3426
+ "score_set" /* SCORE_SET */,
3346
3427
  "flex" /* FLEX */,
3347
3428
  "card" /* CARD */,
3348
3429
  "chat_bubble" /* CHAT_BUBBLE */,
@@ -3368,6 +3449,7 @@ var CONTROL_RELATIONSHIPS = {
3368
3449
  "user" /* USER */,
3369
3450
  "stat" /* STAT */,
3370
3451
  "heat_swatch" /* HEAT_SWATCH */,
3452
+ "score_set" /* SCORE_SET */,
3371
3453
  "flex" /* FLEX */,
3372
3454
  "card" /* CARD */,
3373
3455
  "chat_bubble" /* CHAT_BUBBLE */,
@@ -3401,6 +3483,7 @@ var CONTROL_RELATIONSHIPS = {
3401
3483
  "user" /* USER */,
3402
3484
  "stat" /* STAT */,
3403
3485
  "heat_swatch" /* HEAT_SWATCH */,
3486
+ "score_set" /* SCORE_SET */,
3404
3487
  "flex" /* FLEX */,
3405
3488
  "card" /* CARD */,
3406
3489
  "chat_bubble" /* CHAT_BUBBLE */,
@@ -3438,6 +3521,7 @@ var CONTROL_RELATIONSHIPS = {
3438
3521
  "user" /* USER */,
3439
3522
  "stat" /* STAT */,
3440
3523
  "heat_swatch" /* HEAT_SWATCH */,
3524
+ "score_set" /* SCORE_SET */,
3441
3525
  "card" /* CARD */,
3442
3526
  "chat_bubble" /* CHAT_BUBBLE */,
3443
3527
  "section_carousel" /* SECTION_CAROUSEL */,
@@ -3471,6 +3555,7 @@ var CONTROL_RELATIONSHIPS = {
3471
3555
  "user" /* USER */,
3472
3556
  "stat" /* STAT */,
3473
3557
  "heat_swatch" /* HEAT_SWATCH */,
3558
+ "score_set" /* SCORE_SET */,
3474
3559
  "card" /* CARD */,
3475
3560
  "chat_bubble" /* CHAT_BUBBLE */,
3476
3561
  "section_carousel" /* SECTION_CAROUSEL */,
@@ -3536,6 +3621,7 @@ var CONTROL_RELATIONSHIPS = {
3536
3621
  "plugin" /* PLUGIN */,
3537
3622
  "user" /* USER */,
3538
3623
  "heat_swatch" /* HEAT_SWATCH */,
3624
+ "score_set" /* SCORE_SET */,
3539
3625
  "button" /* BUTTON */,
3540
3626
  "context_menu" /* CONTEXT_MENU */,
3541
3627
  "audience_picker" /* AUDIENCE_PICKER */,
@@ -3615,6 +3701,12 @@ var CONTROL_RELATIONSHIPS = {
3615
3701
  // A leaf: a block of colour holds nothing, and the figure it stands for is a
3616
3702
  // text laid beside it by the Flex that holds both.
3617
3703
  ["heat_swatch" /* HEAT_SWATCH */]: [],
3704
+ // Its Scores and nothing else — a headline is an attribute, and what the set
3705
+ // draws is read off its items, never projected markup (libs/one GLOSSARY.md
3706
+ // ScoreSet). Seeded with three, the first primary, so a fresh drop draws.
3707
+ ["score_set" /* SCORE_SET */]: ["score_set_item" /* SCORE_SET_ITEM */],
3708
+ // A leaf: an item renders nothing of its own.
3709
+ ["score_set_item" /* SCORE_SET_ITEM */]: [],
3618
3710
  // Content like a Logo, but the one content Control that is not a leaf: what
3619
3711
  // `m-user` projects beneath the name is a ContentControl, the same single
3620
3712
  // child a card Field takes and gated the same way, through `contentSlotOf`.
@@ -3856,6 +3948,8 @@ var OWN_DIRECTIVES = {
3856
3948
  ["stat_value" /* STAT_VALUE */]: ["routerLink"],
3857
3949
  ["stat_corner" /* STAT_CORNER */]: ["routerLink"],
3858
3950
  ["heat_swatch" /* HEAT_SWATCH */]: ["routerLink"],
3951
+ ["score_set" /* SCORE_SET */]: [],
3952
+ ["score_set_item" /* SCORE_SET_ITEM */]: [],
3859
3953
  ["form" /* FORM */]: ["routerLink"],
3860
3954
  ["field" /* FIELD */]: ["mOptions", "routerLink"],
3861
3955
  // Nothing to attach: a ContentControl emits an `ng-template` — where a
@@ -4025,6 +4119,8 @@ var CONTROL_LABEL = {
4025
4119
  ["stat_value" /* STAT_VALUE */]: "stat-value",
4026
4120
  ["stat_corner" /* STAT_CORNER */]: "stat-corner",
4027
4121
  ["heat_swatch" /* HEAT_SWATCH */]: "heat-swatch",
4122
+ ["score_set" /* SCORE_SET */]: "score-set-control",
4123
+ ["score_set_item" /* SCORE_SET_ITEM */]: "score-set-item-control",
4028
4124
  ["nav_header" /* NAV_HEADER */]: "nav-header",
4029
4125
  ["form" /* FORM */]: "form",
4030
4126
  ["field" /* FIELD */]: "field",
@@ -4094,6 +4190,9 @@ var CONTROL_ICON = {
4094
4190
  ["stat_corner" /* STAT_CORNER */]: "control_stat_corner",
4095
4191
  // Reuse the Stat glyph until swatch artwork joins the shared set.
4096
4192
  ["heat_swatch" /* HEAT_SWATCH */]: "control_stat",
4193
+ // Reuse the Stat glyph until score artwork joins the shared set.
4194
+ ["score_set" /* SCORE_SET */]: "control_stat",
4195
+ ["score_set_item" /* SCORE_SET_ITEM */]: "control_stat_value",
4097
4196
  ["nav_header" /* NAV_HEADER */]: "control_nav_header",
4098
4197
  ["form" /* FORM */]: "control_form",
4099
4198
  ["field" /* FIELD */]: "control_field",
@@ -4141,7 +4240,6 @@ var DIRECTIVE_CODEGEN = {
4141
4240
  mPadding: "PaddingDirective",
4142
4241
  mMargin: "MarginDirective"
4143
4242
  };
4144
- var ONE_IMPORT_MODULE = "@magmonium/one";
4145
4243
  var CONTROL_CODEGEN = {
4146
4244
  ["section" /* SECTION */]: {
4147
4245
  tag: "m-section",
@@ -4361,6 +4459,16 @@ var CONTROL_CODEGEN = {
4361
4459
  tag: "m-heat-swatch",
4362
4460
  component: "HeatSwatchComponent"
4363
4461
  },
4462
+ // Folderless for the Stat's reason: no list, no artwork, every setting a
4463
+ // scalar on the tag (libs/one GLOSSARY.md ScoreSet).
4464
+ ["score_set" /* SCORE_SET */]: {
4465
+ tag: "m-score-set",
4466
+ component: "ScoreSetComponent"
4467
+ },
4468
+ ["score_set_item" /* SCORE_SET_ITEM */]: {
4469
+ tag: "m-score-set-item",
4470
+ component: "ScoreSetItemComponent"
4471
+ },
4364
4472
  // Navigation header with back button and breadcrumb trail.
4365
4473
  // Folderless as it uses NavStore internally and takes no config.
4366
4474
  ["nav_header" /* NAV_HEADER */]: {
@@ -4740,6 +4848,159 @@ var screenMethodCalls = (method) => method ? [
4740
4848
  ...method.calls ?? []
4741
4849
  ] : [];
4742
4850
 
4851
+ // libs/codegen/src/model/one-function-catalog.ts
4852
+ var ONE_FUNCTION_ID_PARAM = "id";
4853
+ var ONE_FUNCTION_MAP_PARAM = "map";
4854
+ var ONE_FUNCTION_PREFIX = "one:";
4855
+ var ONE_FUNCTIONS = [
4856
+ {
4857
+ // `getFromMap<T>(id, map: Record<string, T>): T | undefined` — the row a
4858
+ // `map` holds under an id, typically a ScreenInput a Page was handed.
4859
+ name: "getFromMap",
4860
+ importFrom: ONE_IMPORT_MODULE,
4861
+ reach: ["screen-computed"],
4862
+ returnsRow: true,
4863
+ params: [
4864
+ { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
4865
+ { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
4866
+ ],
4867
+ rowParamId: ONE_FUNCTION_MAP_PARAM,
4868
+ rowCardinality: "map",
4869
+ signature: (row) => ({
4870
+ params: [
4871
+ {
4872
+ id: ONE_FUNCTION_ID_PARAM,
4873
+ name: "id",
4874
+ dataType: { type: "string" },
4875
+ cardinality: "one",
4876
+ acceptsUndefined: true
4877
+ },
4878
+ {
4879
+ id: ONE_FUNCTION_MAP_PARAM,
4880
+ name: "map",
4881
+ dataType: row,
4882
+ cardinality: "map",
4883
+ acceptsUndefined: true
4884
+ }
4885
+ ],
4886
+ returnType: row,
4887
+ returnCardinality: "one",
4888
+ returnUndefined: true
4889
+ })
4890
+ },
4891
+ {
4892
+ // `existsInMap(id, map: Record<string, unknown>): boolean` — whether a
4893
+ // `map` holds anything under an id (ADR 0202). `false` rather than
4894
+ // `undefined` while either is, so a gate on an unloaded store reads "not
4895
+ // there yet" and a computed over it never needs `?.`.
4896
+ name: "existsInMap",
4897
+ importFrom: ONE_IMPORT_MODULE,
4898
+ reach: ["screen-computed", "call-condition"],
4899
+ returnsRow: false,
4900
+ params: [
4901
+ { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
4902
+ { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
4903
+ ],
4904
+ rowParamId: ONE_FUNCTION_MAP_PARAM,
4905
+ rowCardinality: "map",
4906
+ signature: (row) => ({
4907
+ params: [
4908
+ {
4909
+ id: ONE_FUNCTION_ID_PARAM,
4910
+ name: "id",
4911
+ dataType: { type: "string" },
4912
+ cardinality: "one",
4913
+ acceptsUndefined: true
4914
+ },
4915
+ {
4916
+ id: ONE_FUNCTION_MAP_PARAM,
4917
+ name: "map",
4918
+ dataType: row,
4919
+ cardinality: "map",
4920
+ acceptsUndefined: true
4921
+ }
4922
+ ],
4923
+ returnType: { type: "boolean" },
4924
+ returnCardinality: "one"
4925
+ })
4926
+ },
4927
+ {
4928
+ // `notExistsInMap(id, map: Record<string, unknown>): boolean` — the
4929
+ // named inverse, offered on CallConditions (ADR 0202).
4930
+ name: "notExistsInMap",
4931
+ importFrom: ONE_IMPORT_MODULE,
4932
+ reach: ["call-condition"],
4933
+ returnsRow: false,
4934
+ params: [
4935
+ { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
4936
+ { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
4937
+ ],
4938
+ rowParamId: ONE_FUNCTION_MAP_PARAM,
4939
+ rowCardinality: "map",
4940
+ signature: (row) => ({
4941
+ params: [
4942
+ {
4943
+ id: ONE_FUNCTION_ID_PARAM,
4944
+ name: "id",
4945
+ dataType: { type: "string" },
4946
+ cardinality: "one",
4947
+ acceptsUndefined: true
4948
+ },
4949
+ {
4950
+ id: ONE_FUNCTION_MAP_PARAM,
4951
+ name: "map",
4952
+ dataType: row,
4953
+ cardinality: "map",
4954
+ acceptsUndefined: true
4955
+ }
4956
+ ],
4957
+ returnType: { type: "boolean" },
4958
+ returnCardinality: "one"
4959
+ })
4960
+ }
4961
+ ];
4962
+ var ONE_FUNCTION_CATALOG = Object.fromEntries(ONE_FUNCTIONS.map((entry2) => [entry2.name, entry2]));
4963
+ var oneFunctionOf = (name3) => name3 ? ONE_FUNCTIONS.find((entry2) => entry2.name === name3) : void 0;
4964
+ var listOneFunctions = (reach = "screen-computed") => ONE_FUNCTIONS.filter((entry2) => entry2.reach.includes(reach)).sort(
4965
+ (a, b) => a.name.localeCompare(b.name)
4966
+ );
4967
+ var oneFunctionPickValue = (name3) => `${ONE_FUNCTION_PREFIX}${name3}`;
4968
+ var oneFunctionFromPickValue = (value) => value?.startsWith(ONE_FUNCTION_PREFIX) ? oneFunctionOf(value.slice(ONE_FUNCTION_PREFIX.length)) : void 0;
4969
+ function oneFunctionArgFits(param, held, fromPath) {
4970
+ if (!held) return false;
4971
+ if (param.rule === "string-one")
4972
+ return held.dataType.type === "string" && held.cardinality === "one";
4973
+ return fromPath && held.cardinality === "map";
4974
+ }
4975
+ function oneFunctionReturns(entry2, row) {
4976
+ const signature = entry2.signature(row);
4977
+ return {
4978
+ dataType: signature.returnType,
4979
+ cardinality: signature.returnCardinality,
4980
+ ...signature.returnUndefined ? { optional: true } : {}
4981
+ };
4982
+ }
4983
+ function oneFunctionSignature(entry2, returns) {
4984
+ return {
4985
+ id: "",
4986
+ name: entry2.name,
4987
+ // An entry answering a fixed type stores that type, not the row: its
4988
+ // `map` is spelled `Record<string, unknown>` by the library, so the stand-in
4989
+ // over the stored type reads the same at every reader.
4990
+ ...entry2.signature(returns.dataType),
4991
+ body: ""
4992
+ };
4993
+ }
4994
+ function oneFunctionSignatureText(entry2, rowLabel) {
4995
+ const generic = entry2.returnsRow && !rowLabel;
4996
+ const t = entry2.returnsRow ? rowLabel ?? "T" : "unknown";
4997
+ const params = entry2.params.map(
4998
+ (param) => param.rule === "string-one" ? `${param.name}: string` : `${param.name}: Record<string, ${t}>`
4999
+ ).join(", ");
5000
+ const returns = entry2.returnsRow ? `${t} | undefined` : "boolean";
5001
+ return `${entry2.name}${generic ? "<T>" : ""}(${params}): ${returns}`;
5002
+ }
5003
+
4743
5004
  // libs/codegen/src/lib/pure-function-helper.ts
4744
5005
  function normalizeFunctionName(raw) {
4745
5006
  const cleaned = raw.trim().replace(
@@ -4774,35 +5035,62 @@ function listFunctions(functions) {
4774
5035
  (a, b) => a.name.localeCompare(b.name)
4775
5036
  );
4776
5037
  }
4777
- function paramTypeText(shapes, param) {
4778
- const type = tsTypeExpression(shapes, param.dataType, param.cardinality);
5038
+ var enumNameIn = (enums) => (id) => enums?.find((entry2) => entry2.id === id)?.name;
5039
+ function paramTypeText(shapes, param, enums) {
5040
+ const type = tsTypeExpression(
5041
+ shapes,
5042
+ param.dataType,
5043
+ param.cardinality,
5044
+ enumNameIn(enums)
5045
+ );
4779
5046
  return param.acceptsUndefined ? `${type} | undefined` : type;
4780
5047
  }
4781
- function paramListText(shapes, params) {
4782
- return params.map((param) => `${param.name}: ${paramTypeText(shapes, param)}`).join(", ");
5048
+ function paramListText(shapes, params, enums) {
5049
+ return params.map((param) => `${param.name}: ${paramTypeText(shapes, param, enums)}`).join(", ");
4783
5050
  }
4784
- function returnTypeText(shapes, fn) {
4785
- const type = tsTypeExpression(shapes, fn.returnType, fn.returnCardinality);
5051
+ function returnTypeText(shapes, fn, enums) {
5052
+ const type = tsTypeExpression(
5053
+ shapes,
5054
+ fn.returnType,
5055
+ fn.returnCardinality,
5056
+ enumNameIn(enums)
5057
+ );
4786
5058
  const widened = fn.returnUndefined ? `${type} | undefined` : type;
4787
5059
  return fn.returnAsync ? `Promise<${widened}>` : widened;
4788
5060
  }
4789
- function signatureText(shapes, fn) {
5061
+ function signatureText(shapes, fn, enums) {
4790
5062
  return `export const ${fn.name} = ${fn.returnAsync ? "async " : ""}(${paramListText(
4791
5063
  shapes,
4792
- fn.params
4793
- )}): ${returnTypeText(shapes, fn)} => {`;
5064
+ fn.params,
5065
+ enums
5066
+ )}): ${returnTypeText(shapes, fn, enums)} => {`;
5067
+ }
5068
+ function signatureEnums(fn, enums) {
5069
+ const ids = [
5070
+ ...fn.params.map((param) => enumIdOf(param.dataType)),
5071
+ enumIdOf(fn.returnType)
5072
+ ].filter((id) => !!id);
5073
+ const named = [...new Set(ids)].map((id) => enums?.find((entry2) => entry2.id === id)).filter((entry2) => !!entry2);
5074
+ const seen = new Set(named.map((entry2) => entry2.name));
5075
+ const read = (enums ?? []).filter((entry2) => {
5076
+ if (seen.has(entry2.name)) return false;
5077
+ if (!new RegExp(`\\b${entry2.name}\\b`).test(fn.body ?? "")) return false;
5078
+ seen.add(entry2.name);
5079
+ return true;
5080
+ });
5081
+ return [...named, ...read];
4794
5082
  }
4795
- function functionJsDoc(shapes, fn) {
5083
+ function functionJsDoc(shapes, fn, enums) {
4796
5084
  const summary = (fn.description ?? "").trim();
4797
5085
  if (!summary) return "";
4798
5086
  const summaryLines = summary.split(/\n+/).map((line) => line.trim()).filter(Boolean).map((line) => ` * ${line}`);
4799
5087
  const paramLines = fn.params.map(
4800
- (param) => ` * @param ${param.name} - ${paramTypeText(shapes, param)}`
5088
+ (param) => ` * @param ${param.name} - ${paramTypeText(shapes, param, enums)}`
4801
5089
  );
4802
- const returns = ` * @returns ${returnTypeText(shapes, fn)}`;
5090
+ const returns = ` * @returns ${returnTypeText(shapes, fn, enums)}`;
4803
5091
  return ["/**", ...summaryLines, ...paramLines, returns, " */"].join("\n");
4804
5092
  }
4805
- function generateFunctionFile(shapes, fn) {
5093
+ function generateFunctionFile(shapes, fn, enums) {
4806
5094
  const npmImports = (fn.imports ?? []).map((entry2) => {
4807
5095
  const names = entry2.names.join(", ");
4808
5096
  return names ? `import { ${names} } from '${entry2.package}';` : "";
@@ -4820,15 +5108,18 @@ function generateFunctionFile(shapes, fn) {
4820
5108
  )}';`
4821
5109
  ).join("\n");
4822
5110
  const optionImport = signatureNamesOptionRow(fn) ? `import { ${OPTION_ROW_TYPE_NAME} } from '${OPTION_ROW_TYPE_PACKAGE}';` : "";
4823
- const imports = [npmImports, optionImport, shapeImports, formImports].filter(Boolean).join("\n");
4824
- const doc = functionJsDoc(shapes, fn);
5111
+ const enumImports = signatureEnums(fn, enums).map(
5112
+ (entry2) => entry2.library ? `import { ${entry2.name} } from '@magmonium/one';` : `import { ${entry2.name} } from '../type/${entry2.fileName.replace(/\.ts$/, "")}';`
5113
+ ).join("\n");
5114
+ const imports = [npmImports, optionImport, enumImports, shapeImports, formImports].filter(Boolean).join("\n");
5115
+ const doc = functionJsDoc(shapes, fn, enums);
4825
5116
  const head = [imports, doc].filter(Boolean).join("\n\n");
4826
5117
  const prefix = head ? `${head}
4827
5118
 
4828
5119
  ` : "";
4829
5120
  const body = fn.body.trim();
4830
5121
  const indented = body ? body.split("\n").map((line) => line.trim() ? ` ${line}` : line).join("\n") : "";
4831
- return `${prefix}${signatureText(shapes, fn)}
5122
+ return `${prefix}${signatureText(shapes, fn, enums)}
4832
5123
  ${indented}
4833
5124
  };
4834
5125
  `;
@@ -4898,7 +5189,11 @@ function screenComputedRootIds(computed) {
4898
5189
  function screenComputedFunction(computed, functions) {
4899
5190
  if (computed.functionId) return functions[computed.functionId];
4900
5191
  if (!computed.returns) return void 0;
4901
- const { dataType, cardinality } = computed.returns;
5192
+ const { dataType, cardinality, optional } = computed.returns;
5193
+ if (computed.oneFunction) {
5194
+ const entry2 = oneFunctionOf(computed.oneFunction);
5195
+ return entry2 ? oneFunctionSignature(entry2, computed.returns) : void 0;
5196
+ }
4902
5197
  return {
4903
5198
  id: "",
4904
5199
  name: "",
@@ -4907,10 +5202,12 @@ function screenComputedFunction(computed, functions) {
4907
5202
  ],
4908
5203
  returnType: dataType,
4909
5204
  returnCardinality: cardinality,
5205
+ ...optional ? { returnUndefined: true } : {},
4910
5206
  body: `return ${PASSTHROUGH_PARAM_ID};`
4911
5207
  };
4912
5208
  }
4913
- var isPassthroughComputed = (computed) => !computed.functionId;
5209
+ var isPassthroughComputed = (computed) => !computed.functionId && !computed.oneFunction;
5210
+ var isOneFunctionComputed = (computed) => !computed.functionId && !!computed.oneFunction;
4914
5211
  function screenComputedNavIds(computed) {
4915
5212
  return Object.values(computed.args).flatMap(
4916
5213
  (arg) => arg.source === "nav" && arg.navId ? [arg.navId] : []
@@ -4968,7 +5265,7 @@ function wouldScreenComputedCycle(computeds, hostId, targetId) {
4968
5265
  };
4969
5266
  return walk(targetId);
4970
5267
  }
4971
- var sameType = (a, b) => a.type === "shape" ? b.type === "shape" && a.shapeId === b.shapeId : a.type === b.type;
5268
+ var sameType = (held, param) => held.type === "shape" ? param.type === "shape" && held.shapeId === param.shapeId : held.type === param.type && (!enumIdOf(param) || enumIdOf(held) === enumIdOf(param));
4972
5269
  function argPathOptions(roots, shapes, param, computeds = {}) {
4973
5270
  return readablePaths(roots, shapes, computeds).filter((option2) => argAnswersParam(option2.held, param, shapes)).map(({ path, label }) => ({ path, label }));
4974
5271
  }
@@ -5044,7 +5341,7 @@ function screenComputedArgHeldType(arg, inputs, siblings, functions, scope = {})
5044
5341
  if (arg.source === "variable") {
5045
5342
  const variable = scope.variables?.[arg.variableId];
5046
5343
  return variable ? {
5047
- dataType: { type: variable.dataType },
5344
+ dataType: screenVariableDataType(variable),
5048
5345
  cardinality: variable.cardinality
5049
5346
  } : void 0;
5050
5347
  }
@@ -5134,7 +5431,7 @@ function screenPropertiesWithComputeds(properties, computeds = {}, functions = {
5134
5431
  result[variable.id] = {
5135
5432
  id: variable.id,
5136
5433
  name: variable.name,
5137
- dataType: { type: variable.dataType },
5434
+ dataType: screenVariableDataType(variable),
5138
5435
  cardinality: variable.cardinality
5139
5436
  };
5140
5437
  }
@@ -6818,7 +7115,11 @@ var BINDING_SLOT = {
6818
7115
  // A [HeatSwatch]'s figure, named for the `m-heat-swatch` input it lands on.
6819
7116
  // Content by the `total` test: what the block paints *is* the datum, one per
6820
7117
  // row inside a Repeat.
6821
- value: "value"
7118
+ value: "value",
7119
+ // A [ScoreSet]'s Score Date, named for the `m-score-set` input it lands on.
7120
+ // Content by the `total` test: whether the set reads stale *is* the datum's
7121
+ // age, read off the same record its Scores are.
7122
+ scoreDate: "scoreDate"
6822
7123
  };
6823
7124
  var USER_VALUE_SLOTS = [
6824
7125
  BINDING_SLOT.id,
@@ -6987,7 +7288,7 @@ var bindingDataType = (source, ctx) => {
6987
7288
  dataType = computed ? screenComputedFunction(computed, ctx.functions ?? {})?.returnType : void 0;
6988
7289
  } else if (root.kind === "screen_variable") {
6989
7290
  const variable = ctx.variables?.[root.id];
6990
- dataType = variable ? { type: variable.dataType } : void 0;
7291
+ dataType = variable ? screenVariableDataType(variable) : void 0;
6991
7292
  } else if (root.kind === "form_model") {
6992
7293
  const model = ctx.formModels?.[root.id];
6993
7294
  dataType = model ? { type: "form", formId: model.formId } : void 0;
@@ -8177,7 +8478,7 @@ var bindingCardinality = (binding, scope, seen = /* @__PURE__ */ new Set()) => {
8177
8478
  }
8178
8479
  case "screen_variable": {
8179
8480
  const variable = scope.screenVariables?.[root.id];
8180
- dataType = variable ? { type: variable.dataType } : void 0;
8481
+ dataType = variable ? screenVariableDataType(variable) : void 0;
8181
8482
  cardinality = variable?.cardinality;
8182
8483
  break;
8183
8484
  }
@@ -8715,7 +9016,7 @@ var screenRoots = (scope) => [
8715
9016
  ...Object.values(scope.screenVariables ?? {}).map((variable) => ({
8716
9017
  root: { kind: "screen_variable", id: variable.id },
8717
9018
  name: variable.name,
8718
- dataType: { type: variable.dataType },
9019
+ dataType: screenVariableDataType(variable),
8719
9020
  cardinality: variable.cardinality
8720
9021
  })),
8721
9022
  // A FormModel is the one Screen-owned root walked into rather than read
@@ -9062,7 +9363,15 @@ var sameType4 = (a, b) => {
9062
9363
  }
9063
9364
  return true;
9064
9365
  };
9065
- var bindingFits = (option2, target) => option2.cardinality === target.cardinality && option2.dataType?.type === target.dataType?.type && (option2.dataType?.type !== "shape" || target.dataType?.type !== "shape" || option2.dataType.shapeId === target.dataType.shapeId);
9366
+ var stringEnumFits = (read, target, enums) => {
9367
+ if (read.cardinality !== target.cardinality) return false;
9368
+ if (target.dataType?.type !== "string" || read.dataType?.type !== "enum") {
9369
+ return false;
9370
+ }
9371
+ const appEnum = enums?.[read.dataType.enumId];
9372
+ return !!appEnum?.hasValue && appEnum.valueType === "string";
9373
+ };
9374
+ var bindingFits = (option2, target, enums) => stringEnumFits(option2, target, enums) || option2.cardinality === target.cardinality && option2.dataType?.type === target.dataType?.type && (option2.dataType?.type !== "shape" || target.dataType?.type !== "shape" || option2.dataType.shapeId === target.dataType.shapeId);
9066
9375
  var eventMemberType = (row, scope) => {
9067
9376
  const path = row.event ?? [];
9068
9377
  if (row.source !== "event" || path.length !== 1) return void 0;
@@ -9071,7 +9380,7 @@ var eventMemberType = (row, scope) => {
9071
9380
  function callArgEventMismatch(row, target, scope) {
9072
9381
  if (!target?.dataType || row.transform) return false;
9073
9382
  const member = eventMemberType(row, scope);
9074
- return !!member && !sameType4(target, member);
9383
+ return !!member && !sameType4(target, member) && !stringEnumFits(member, target, scope.bindings?.enums);
9075
9384
  }
9076
9385
  var AUTO_CASTS = {
9077
9386
  string: { number: "Number", boolean: "Boolean" },
@@ -9083,6 +9392,7 @@ function callArgTypeMismatch(row, target, scope) {
9083
9392
  if (row.source !== "binding" && row.source !== "event") return void 0;
9084
9393
  const read = bindingPipeType(row, target, scope);
9085
9394
  if (!read || sameType4(target, read)) return void 0;
9395
+ if (stringEnumFits(read, target, scope.bindings?.enums)) return void 0;
9086
9396
  const expected = {
9087
9397
  dataType: target.dataType,
9088
9398
  cardinality: target.cardinality
@@ -9134,7 +9444,7 @@ var rowComplete = (row, target, payload, fieldNames, constants, functions, scope
9134
9444
  (option2) => option2.value === value
9135
9445
  );
9136
9446
  if (!picked) return "call-arg-unknown-binding";
9137
- if (!bindingFits(picked, target) && !row.transform) {
9447
+ if (!bindingFits(picked, target, scope.bindings?.enums) && !row.transform) {
9138
9448
  return "call-arg-type-mismatch";
9139
9449
  }
9140
9450
  } else if (row.source === "storage") {
@@ -9724,7 +10034,9 @@ var inputPrimitive = (input) => input.dataType.type === "shape" || input.dataTyp
9724
10034
  // boundary (ADR 0038) — so it is no ScreenInput's type either. An `audience`
9725
10035
  // joins it: a picker's value is held and bound as a whole, not narrowed to a
9726
10036
  // primitive here (ADR 0187).
9727
- input.dataType.type === "option" || input.dataType.type === "audience" ? void 0 : input.dataType.type;
10037
+ input.dataType.type === "option" || input.dataType.type === "audience" || // An AppTarget Enum (ADR 0204): matched by enumId in the source picker, not
10038
+ // by primitive type. A static literal cannot name a member identity.
10039
+ input.dataType.type === "enum" ? void 0 : input.dataType.type;
9728
10040
  function mergeScreenInputs(declared = {}, inferred = []) {
9729
10041
  const byName = /* @__PURE__ */ new Map();
9730
10042
  for (const input of listScreenInputs(declared)) {
@@ -9806,6 +10118,7 @@ function screenInputExpression(binding, target, wires, renderBinding = () => voi
9806
10118
  case "variable":
9807
10119
  case "constant":
9808
10120
  case "computed":
10121
+ case "enum-member":
9809
10122
  return void 0;
9810
10123
  // resolved by the caller, which knows this Screen's names
9811
10124
  case "output": {
@@ -9839,10 +10152,27 @@ function screenMemberExpression(binding, ctx) {
9839
10152
  const name3 = ctx.constants?.[binding.constantId]?.name;
9840
10153
  return name3 ?? void 0;
9841
10154
  }
10155
+ case "enum-member": {
10156
+ const appEnum = ctx.appEnums?.[binding.enumId];
10157
+ const member = appEnum?.members.find((m) => m.id === binding.memberId);
10158
+ return appEnum && member ? `${appEnum.name}.${member.key}` : void 0;
10159
+ }
9842
10160
  default:
9843
10161
  return void 0;
9844
10162
  }
9845
10163
  }
10164
+ var liftsToList = (target, source) => target.cardinality === "many" && source.cardinality === "one";
10165
+ var liftToList = (expression, present) => present ? `[${expression}]` : `${expression} !== undefined ? [${expression}] : []`;
10166
+ var liftToListInTemplate = (expression) => `${expression} | toList`;
10167
+ function screenControlLiftsInput(node, ctx, readSource) {
10168
+ if (node.type !== "screen" /* SCREEN */) return false;
10169
+ const ref = embeddedRefOf(node, ctx);
10170
+ if (!ref) return false;
10171
+ return Object.entries(ref.inputs).some(([inputId, target]) => {
10172
+ const binding = node.screenInputs?.[inputId];
10173
+ return !!binding && liftsToList(target, readSource(binding));
10174
+ });
10175
+ }
9846
10176
  function screenControlInputGuards(node, ctx, renderBinding = () => void 0, bindingPresent = () => true, computedPresent = () => true) {
9847
10177
  if (node.type !== "screen" /* SCREEN */) return [];
9848
10178
  const ref = embeddedRefOf(node, ctx);
@@ -9875,7 +10205,10 @@ function screenControlInputGuards(node, ctx, renderBinding = () => void 0, bindi
9875
10205
  }
9876
10206
  return [...guards.values()];
9877
10207
  }
9878
- function screenControlAttrs(node, ctx, wires, renderMethodCall, renderStateWrite = () => void 0, renderScreenWrites = () => [], renderScreenEmits = () => [], renderBinding = () => void 0, inputAliases = /* @__PURE__ */ new Map()) {
10208
+ function screenControlAttrs(node, ctx, wires, renderMethodCall, renderStateWrite = () => void 0, renderScreenWrites = () => [], renderScreenEmits = () => [], renderBinding = () => void 0, inputAliases = /* @__PURE__ */ new Map(), readSource = () => ({
10209
+ cardinality: void 0,
10210
+ present: true
10211
+ })) {
9879
10212
  if (node.type !== "screen" /* SCREEN */) return "";
9880
10213
  const ref = embeddedRefOf(node, ctx);
9881
10214
  if (!ref) return "";
@@ -9884,7 +10217,8 @@ function screenControlAttrs(node, ctx, wires, renderMethodCall, renderStateWrite
9884
10217
  const binding = node.screenInputs?.[inputId];
9885
10218
  if (!binding) return "";
9886
10219
  const read = screenMemberExpression(binding, ctx) ?? screenInputExpression(binding, target, wires, renderBinding);
9887
- const expr = read === void 0 ? void 0 : inputAliases.get(read) ?? read;
10220
+ const alias = read === void 0 ? void 0 : inputAliases.get(read);
10221
+ const expr = read === void 0 ? void 0 : liftsToList(target, readSource(binding)) ? liftToListInTemplate(alias ?? read) : alias ?? read;
9888
10222
  if (target.required && expr === void 0) return void 0;
9889
10223
  return expr === void 0 ? "" : ` [${target.name}]="${expr}"`;
9890
10224
  });
@@ -9979,6 +10313,8 @@ var unresolvedInputLeg = (binding, describeBinding) => {
9979
10313
  return "reads a ScreenConstant that is gone";
9980
10314
  case "computed":
9981
10315
  return "reads a ScreenComputed that is gone";
10316
+ case "enum-member":
10317
+ return "reads an Enum member that is gone";
9982
10318
  case "output":
9983
10319
  return "reads an output whose wire is gone";
9984
10320
  case "data":
@@ -9986,226 +10322,151 @@ var unresolvedInputLeg = (binding, describeBinding) => {
9986
10322
  }
9987
10323
  };
9988
10324
 
9989
- // libs/codegen/src/lib/state-write-helper.ts
9990
- var VALUE_KINDS = [
9991
- "fixed",
9992
- "const",
9993
- "clear",
9994
- "toggle",
9995
- "event",
9996
- "input"
9997
- ];
9998
- var isStateWrite = (value) => typeof value === "object" && value !== null && "propertyId" in value && typeof value.propertyId === "string" && "value" in value && typeof value.value === "object" && value.value !== null && VALUE_KINDS.includes(value.value?.kind);
9999
- function stateWriteRows(writes, output) {
10000
- const rows = writes?.[output];
10001
- if (Array.isArray(rows)) return rows.filter(isStateWrite);
10002
- if (isStateWrite(rows)) return [rows];
10003
- return [];
10004
- }
10005
- function stateWriteTargets(properties) {
10006
- return listDataProperties(properties).map((property) => ({
10007
- property,
10008
- label: `${typeSigil(property.dataType, property.cardinality)} - ${property.name}`
10009
- }));
10010
- }
10011
- function findStateWriteProperty(properties, propertyId) {
10012
- return listDataProperties(properties).find((p2) => p2.id === propertyId);
10013
- }
10014
- function stateWriteFixedAllowed(property) {
10015
- return property.cardinality === "one" && property.dataType.type !== "shape";
10016
- }
10017
- function stateWriteToggleAllowed(property) {
10018
- return property.cardinality === "one" && property.dataType.type === "boolean";
10019
- }
10020
- function stateWriteEventAllowed(payload) {
10021
- return payload !== "void";
10022
- }
10023
- function stateWriteInputTargets(inputs, property) {
10024
- if (property.dataType.type === "shape") return [];
10025
- return Object.values(inputs).filter(
10026
- (input) => inputPrimitive(input) === property.dataType.type && input.cardinality === property.cardinality
10027
- ).sort((a, b) => a.name.localeCompare(b.name));
10028
- }
10029
- function stateWriteConstTargets(constants, property) {
10030
- if (property.dataType.type === "shape" || property.cardinality !== "one") {
10031
- return [];
10032
- }
10033
- return Object.values(constants).filter((constant) => constant.dataType === property.dataType.type).sort((a, b) => a.name.localeCompare(b.name));
10034
- }
10035
- function stateWriteValueKinds(property, payload, inputs, constants = {}) {
10036
- const kinds = [];
10037
- if (stateWriteFixedAllowed(property)) kinds.push("fixed");
10038
- if (stateWriteConstTargets(constants, property).length) kinds.push("const");
10039
- kinds.push("clear");
10040
- if (stateWriteToggleAllowed(property)) kinds.push("toggle");
10041
- if (stateWriteEventAllowed(payload)) kinds.push("event");
10042
- if (stateWriteInputTargets(inputs, property).length) kinds.push("input");
10043
- return kinds;
10044
- }
10045
- function defaultStateWriteValue(property, payload, inputs, constants = {}) {
10046
- const [kind] = stateWriteValueKinds(property, payload, inputs, constants);
10047
- return buildStateWriteValue(kind ?? "clear", property, inputs, constants);
10048
- }
10049
- function buildStateWriteValue(kind, property, inputs, constants = {}) {
10050
- if (kind === "fixed") return { kind: "fixed", value: "" };
10051
- if (kind === "toggle") return { kind: "toggle" };
10052
- if (kind === "event") return { kind: "event" };
10053
- if (kind === "const") {
10054
- const [only] = stateWriteConstTargets(constants, property);
10055
- return { kind: "const", constantId: only?.id ?? "" };
10056
- }
10057
- if (kind === "input") {
10058
- const [only] = stateWriteInputTargets(inputs, property);
10059
- return { kind: "input", inputId: only?.id ?? "" };
10060
- }
10061
- return { kind: "clear" };
10062
- }
10063
- function nextStateWriteRow(properties, rows, payload, inputs, constants = {}) {
10064
- const taken = new Set(rows.map((row) => row.propertyId));
10065
- const free = stateWriteTargets(properties).find(
10066
- (target) => !taken.has(target.property.id)
10067
- );
10068
- if (!free) return void 0;
10069
- return {
10070
- propertyId: free.property.id,
10071
- value: defaultStateWriteValue(free.property, payload, inputs, constants)
10072
- };
10073
- }
10074
- function validateStateWrites(properties, rows, payload, fieldNames, inputs, constants = {}) {
10075
- const seen = /* @__PURE__ */ new Set();
10076
- for (const row of rows) {
10077
- if (seen.has(row.propertyId)) return "state-write-duplicate";
10078
- seen.add(row.propertyId);
10079
- const property = findStateWriteProperty(properties, row.propertyId);
10080
- if (!property) return "state-write-unknown-property";
10081
- const value = row.value;
10082
- if (!stateWriteValueKinds(property, payload, inputs, constants).includes(
10083
- value.kind
10084
- )) {
10085
- return "state-write-value-not-allowed";
10086
- }
10087
- if (value.kind === "fixed" && !String(value.value ?? "").trim()) {
10088
- return "state-write-incomplete";
10089
- }
10090
- if (value.kind === "const") {
10091
- if (!value.constantId) return "state-write-incomplete";
10092
- if (!stateWriteConstTargets(constants, property).some(
10093
- (c) => c.id === value.constantId
10094
- )) {
10095
- return "state-write-unknown-const";
10096
- }
10325
+ // libs/codegen/src/lib/section-table-helper.ts
10326
+ var SECTION_TABLE_COLUMNS_KEY = "columns";
10327
+ var SECTION_TABLE_SEED_COLUMNS = 3;
10328
+ var ALIGNS = ["left", "center", "right"];
10329
+ var DATA_TYPES = ["text", "number", "date"];
10330
+ var seedColumn = (index) => ({
10331
+ label: `column-${index + 1}`
10332
+ });
10333
+ var seedColumns = (count = SECTION_TABLE_SEED_COLUMNS) => Array.from({ length: count }, (_, i) => seedColumn(i));
10334
+ var text = (value) => {
10335
+ const trimmed = typeof value === "string" ? value.trim() : "";
10336
+ return trimmed || void 0;
10337
+ };
10338
+ function toSectionTableColumns(value) {
10339
+ if (!Array.isArray(value)) return [];
10340
+ return value.filter((raw) => !!raw && typeof raw === "object").map((raw) => {
10341
+ const column = {};
10342
+ const id = text(raw["id"]);
10343
+ if (id) column.id = id;
10344
+ const label = text(raw["label"]);
10345
+ if (label) column.label = label;
10346
+ if (ALIGNS.includes(raw["align"])) {
10347
+ column.align = raw["align"];
10097
10348
  }
10098
- if (value.kind === "input") {
10099
- if (!value.inputId) return "state-write-incomplete";
10100
- if (!stateWriteInputTargets(inputs, property).some(
10101
- (i) => i.id === value.inputId
10102
- )) {
10103
- return "state-write-unknown-input";
10104
- }
10349
+ const span = Number(raw["span"]);
10350
+ if (raw["span"] != null && raw["span"] !== "" && Number.isFinite(span)) {
10351
+ column.span = Math.min(12, Math.max(1, Math.round(span)));
10105
10352
  }
10106
- if (value.kind === "event" && value.path?.length && fieldNames.length && !value.path.every((name3) => fieldNames.includes(name3))) {
10107
- return "state-write-incomplete";
10353
+ if (raw["sortable"] === true) column.sortable = true;
10354
+ if (DATA_TYPES.includes(raw["dataType"])) {
10355
+ column.dataType = raw["dataType"];
10108
10356
  }
10109
- }
10110
- return void 0;
10357
+ if (raw["defaultSort"] === true) column.defaultSort = true;
10358
+ if (raw["ascending"] === true) column.ascending = true;
10359
+ if (raw["freeze"] === true) column.freeze = true;
10360
+ if (raw["squeeze"] === true) column.squeeze = true;
10361
+ return column;
10362
+ });
10111
10363
  }
10112
- var IDENTIFIER2 = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
10113
- var memberAccess4 = (segment) => IDENTIFIER2.test(segment) ? `.${segment}` : `['${segment}']`;
10114
- var valueExpression = (value, property, payload, storeProp, inputs, constants, eventRoot, self = "", eventMember) => {
10115
- if (value.kind === "clear") return "undefined";
10116
- if (value.kind === "toggle") return `!${storeProp}.${property.name}()`;
10117
- if (value.kind === "fixed") {
10118
- return literalExpression(value.value, property.dataType);
10119
- }
10120
- if (value.kind === "const") {
10121
- const constant = constants[value.constantId];
10122
- return constant ? `${self}${constant.name}` : void 0;
10123
- }
10124
- if (value.kind === "input") {
10125
- const input = inputs[value.inputId];
10126
- return input ? `${self}${input.name}()` : void 0;
10127
- }
10128
- if (payload !== "record" || !value.path?.length) return eventRoot;
10129
- const read = `$event${value.path.map(memberAccess4).join("")}`;
10130
- return eventMember ? eventMember(
10131
- value.path,
10132
- read,
10133
- "$event",
10134
- property.cardinality,
10135
- property.dataType
10136
- ) : read;
10364
+ var columnNeedsId = (column) => (!!column.sortable || !!column.defaultSort) && !column.id;
10365
+ var sectionTableSortIds = (columns) => [
10366
+ ...new Set(
10367
+ columns.filter((column) => column.sortable || column.defaultSort).map((column) => column.id).filter((id) => !!id)
10368
+ )
10369
+ ];
10370
+ var putSectionTableColumn = (columns, index, column) => {
10371
+ const next = index >= columns.length ? [...columns, column] : columns.map((current, i) => i === index ? column : current);
10372
+ if (!column.defaultSort) return next;
10373
+ return next.map((current, i) => {
10374
+ if (i === index || !current.defaultSort) return current;
10375
+ const { defaultSort: _defaultSort, ascending: _ascending, ...rest } = current;
10376
+ return rest;
10377
+ });
10137
10378
  };
10138
- function stateWritePatchExpression(properties, rows, payload, fieldNames, inputs, storeProp, constants = {}, eventRoot = "$event", scope = "template", eventMember) {
10139
- if (!rows.length) return void 0;
10140
- if (validateStateWrites(
10141
- properties,
10142
- rows,
10143
- payload,
10144
- fieldNames,
10145
- inputs,
10146
- constants
10147
- )) {
10148
- return void 0;
10149
- }
10150
- const members = [];
10151
- for (const row of rows) {
10152
- const property = findStateWriteProperty(properties, row.propertyId);
10153
- if (!property) return void 0;
10154
- const expr = valueExpression(
10155
- row.value,
10156
- property,
10157
- payload,
10158
- storeProp,
10159
- inputs,
10160
- constants,
10161
- eventRoot,
10162
- scope === "class" ? "this." : "",
10163
- eventMember
10164
- );
10165
- if (expr === void 0) return void 0;
10166
- members.push({ name: property.name, text: `${property.name}: ${expr}` });
10379
+ var enclosingSectionTable = (control, controlMap) => {
10380
+ const seen = /* @__PURE__ */ new Set();
10381
+ let current = control?.parentId ? controlMap[control.parentId] : void 0;
10382
+ while (current && isTaglessFamily(current.type) && !seen.has(current.id)) {
10383
+ seen.add(current.id);
10384
+ current = current.parentId ? controlMap[current.parentId] : void 0;
10167
10385
  }
10168
- members.sort((a, b) => a.name.localeCompare(b.name));
10169
- return `${storeProp}.patch({ ${members.map((m) => m.text).join(", ")} })`;
10170
- }
10171
- function stateWriteInputIds(control) {
10172
- return everyStateWrite(control).map((row) => row.value.kind === "input" ? row.value.inputId : "").filter(Boolean);
10173
- }
10174
- function everyStateWrite(control) {
10175
- const from = (map) => Object.keys(map ?? {}).flatMap((key2) => stateWriteRows(map, key2));
10176
- return [
10177
- ...from(control.outputWrites),
10178
- ...from(control.screenOutputWrites),
10179
- ...armStateWrites(control)
10180
- ];
10181
- }
10182
- function armStateWrites(control) {
10183
- return [
10184
- ...[
10185
- ...Object.values(control.outputOutcomes ?? {}),
10186
- ...Object.values(control.screenOutputOutcomes ?? {})
10187
- ].flatMap((outcome) => [
10188
- ...outcome.success?.writes ?? [],
10189
- ...outcome.denied?.writes ?? [],
10190
- ...outcome.failure?.writes ?? []
10191
- ]),
10192
- // An OverlayAnswer's rows are the same rows one moment later — what this
10193
- // call site does with what the overlay it opened handed back (ADR 0131) —
10194
- // so every guard reading this sweep reaches them without being taught.
10195
- ...Object.values(control.outputOpens ?? {}).flatMap(
10196
- (open) => open.answer?.writes ?? []
10197
- )
10198
- ];
10386
+ return current?.type === "section_table" /* SECTION_TABLE */ ? current : void 0;
10387
+ };
10388
+ var sectionTableRows = (tableId, controlMap) => {
10389
+ const rows = [];
10390
+ const walk = (ids) => ids.forEach((id) => {
10391
+ const control = controlMap[id];
10392
+ if (!control) return;
10393
+ if (control.type === "section_table_row" /* SECTION_TABLE_ROW */) rows.push(control);
10394
+ else if (isTaglessFamily(control.type)) walk(control.childrens ?? []);
10395
+ });
10396
+ walk(controlMap[tableId]?.childrens ?? []);
10397
+ return rows;
10398
+ };
10399
+ var tableHasRepeat = (tableId, controlMap) => {
10400
+ const walk = (ids) => ids.some((id) => {
10401
+ const control = controlMap[id];
10402
+ if (!control || !isTaglessFamily(control.type)) return false;
10403
+ return control.type === "repeat" /* REPEAT */ || walk(control.childrens ?? []);
10404
+ });
10405
+ return walk(controlMap[tableId]?.childrens ?? []);
10406
+ };
10407
+ var sectionTableRef = (id) => `sectionTable_${id.replace(/[^a-zA-Z0-9_]/g, "_")}`;
10408
+ var newCell = (id, parentId) => ({
10409
+ id,
10410
+ type: "section_table_cell" /* SECTION_TABLE_CELL */,
10411
+ parentId,
10412
+ configs: {},
10413
+ childrens: []
10414
+ });
10415
+ var descendants = (id, controlMap) => (controlMap[id]?.childrens ?? []).flatMap((child) => [
10416
+ child,
10417
+ ...descendants(child, controlMap)
10418
+ ]);
10419
+ function syncSectionTableCells(controlMap, tableId, change, genId2) {
10420
+ const next = { ...controlMap };
10421
+ sectionTableRows(tableId, controlMap).forEach((row) => {
10422
+ const cells = [...row.childrens];
10423
+ const pad2 = (length) => {
10424
+ while (cells.length < length) {
10425
+ const id = genId2();
10426
+ next[id] = newCell(id, row.id);
10427
+ cells.push(id);
10428
+ }
10429
+ };
10430
+ if (change.kind === "add") {
10431
+ pad2(change.index);
10432
+ const id = genId2();
10433
+ next[id] = newCell(id, row.id);
10434
+ cells.splice(change.index, 0, id);
10435
+ } else if (change.kind === "remove") {
10436
+ const [removed] = cells.splice(change.index, 1);
10437
+ if (removed) {
10438
+ [removed, ...descendants(removed, controlMap)].forEach(
10439
+ (id) => delete next[id]
10440
+ );
10441
+ }
10442
+ } else {
10443
+ pad2(Math.max(change.from, change.to) + 1);
10444
+ const [moved] = cells.splice(change.from, 1);
10445
+ cells.splice(change.to, 0, moved);
10446
+ }
10447
+ next[row.id] = { ...row, childrens: cells };
10448
+ });
10449
+ return next;
10199
10450
  }
10200
- function countStateWriteReferences(controls, propertyId) {
10201
- return Object.values(controls).reduce(
10202
- (total, control) => total + everyStateWrite(control).filter((row) => row.propertyId === propertyId).length,
10203
- 0
10451
+ function seedSectionTableRow(rowId, parentId, cellCount, genId2) {
10452
+ const cells = Array.from(
10453
+ { length: Math.max(1, cellCount) },
10454
+ () => newCell(genId2(), rowId)
10204
10455
  );
10456
+ return {
10457
+ [rowId]: {
10458
+ id: rowId,
10459
+ type: "section_table_row" /* SECTION_TABLE_ROW */,
10460
+ parentId,
10461
+ configs: {},
10462
+ childrens: cells.map((cell) => cell.id)
10463
+ },
10464
+ ...Object.fromEntries(cells.map((cell) => [cell.id, cell]))
10465
+ };
10205
10466
  }
10206
10467
 
10207
10468
  // libs/codegen/src/lib/screen-write-helper.ts
10208
- var VALUE_KINDS2 = [
10469
+ var VALUE_KINDS = [
10209
10470
  "fixed",
10210
10471
  "const",
10211
10472
  "clear",
@@ -10213,17 +10474,17 @@ var VALUE_KINDS2 = [
10213
10474
  "event",
10214
10475
  "input"
10215
10476
  ];
10216
- var isScreenWrite = (value) => typeof value === "object" && value !== null && "variableId" in value && typeof value.variableId === "string" && "value" in value && typeof value.value === "object" && value.value !== null && VALUE_KINDS2.includes(value.value?.kind);
10477
+ var isScreenWrite = (value) => typeof value === "object" && value !== null && "variableId" in value && typeof value.variableId === "string" && "value" in value && typeof value.value === "object" && value.value !== null && VALUE_KINDS.includes(value.value?.kind);
10217
10478
  function screenWriteRows(writes, output) {
10218
10479
  const rows = writes?.[output];
10219
10480
  if (Array.isArray(rows)) return rows.filter(isScreenWrite);
10220
10481
  if (isScreenWrite(rows)) return [rows];
10221
10482
  return [];
10222
10483
  }
10223
- function screenWriteTargets(variables) {
10484
+ function screenWriteTargets(variables, enumName = () => void 0) {
10224
10485
  return Object.values(variables).sort((a, b) => a.name.localeCompare(b.name)).map((variable) => ({
10225
10486
  variable,
10226
- label: `${typeSigil({ type: variable.dataType }, variable.cardinality)} - ${variable.name}`
10487
+ label: `${enumName(variable) ?? typeSigil({ type: variable.dataType }, variable.cardinality)} - ${variable.name}`
10227
10488
  }));
10228
10489
  }
10229
10490
  function findScreenVariable(variables, variableId) {
@@ -10324,9 +10585,9 @@ function validateScreenWrites(variables, rows, payload, fieldNames, inputs, cons
10324
10585
  }
10325
10586
  return void 0;
10326
10587
  }
10327
- var IDENTIFIER3 = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
10328
- var memberAccess5 = (segment) => IDENTIFIER3.test(segment) ? `.${segment}` : `['${segment}']`;
10329
- var valueExpression2 = (value, variable, payload, inputs, constants, eventRoot, self = "", eventMember) => {
10588
+ var IDENTIFIER2 = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
10589
+ var memberAccess4 = (segment) => IDENTIFIER2.test(segment) ? `.${segment}` : `['${segment}']`;
10590
+ var valueExpression = (value, variable, payload, inputs, constants, eventRoot, self = "", eventMember) => {
10330
10591
  if (value.kind === "clear") return "undefined";
10331
10592
  if (value.kind === "toggle") return `!${self}${variable.name}()`;
10332
10593
  if (value.kind === "fixed") {
@@ -10340,8 +10601,10 @@ var valueExpression2 = (value, variable, payload, inputs, constants, eventRoot,
10340
10601
  const input = inputs[value.inputId];
10341
10602
  return input ? `${self}${input.name}()` : void 0;
10342
10603
  }
10343
- if (payload !== "record" || !value.path?.length) return eventRoot;
10344
- const read = `$event${value.path.map(memberAccess5).join("")}`;
10604
+ if (payload !== "record" || !value.path?.length) {
10605
+ return typeof eventRoot === "string" ? eventRoot : eventRoot(variable);
10606
+ }
10607
+ const read = `$event${value.path.map(memberAccess4).join("")}`;
10345
10608
  return eventMember ? eventMember(
10346
10609
  value.path,
10347
10610
  read,
@@ -10350,7 +10613,7 @@ var valueExpression2 = (value, variable, payload, inputs, constants, eventRoot,
10350
10613
  variable.dataType
10351
10614
  ) : read;
10352
10615
  };
10353
- function screenWriteStatements(variables, rows, payload, fieldNames, inputs, constants = {}, eventRoot = "$event", scope = "template", eventMember) {
10616
+ function screenWriteStatements(variables, rows, payload, fieldNames, inputs, constants = {}, eventRoot = "$event", scope = "template", eventMember, narrow) {
10354
10617
  if (!rows.length) return [];
10355
10618
  if (validateScreenWrites(
10356
10619
  variables,
@@ -10367,7 +10630,7 @@ function screenWriteStatements(variables, rows, payload, fieldNames, inputs, con
10367
10630
  const variable = findScreenVariable(variables, row.variableId);
10368
10631
  if (!variable) return [];
10369
10632
  const self = scope === "class" ? "this." : "";
10370
- const expr = valueExpression2(
10633
+ const expr = valueExpression(
10371
10634
  row.value,
10372
10635
  variable,
10373
10636
  payload,
@@ -10378,9 +10641,10 @@ function screenWriteStatements(variables, rows, payload, fieldNames, inputs, con
10378
10641
  eventMember
10379
10642
  );
10380
10643
  if (expr === void 0) return [];
10644
+ const narrowed = narrow ? narrow(variable, row.value, expr) : expr;
10381
10645
  statements.push({
10382
10646
  name: variable.name,
10383
- text: `${self}${variable.name}.set(${expr})`
10647
+ text: `${self}${variable.name}.set(${narrowed})`
10384
10648
  });
10385
10649
  }
10386
10650
  return statements.sort((a, b) => a.name.localeCompare(b.name)).map((statement) => statement.text);
@@ -10420,15 +10684,95 @@ function screenVariableActionEnumIds(controls, variableId) {
10420
10684
  )
10421
10685
  ).map((control) => control.id);
10422
10686
  }
10687
+ var SECTION_TABLE_SORT_OUTPUT = "sortChange";
10688
+ var SECTION_TABLE_SORT_ID = "id";
10689
+ var SECTION_TABLE_SORT_DIRECTION = "direction";
10690
+ var SORT_DIRECTION_VALUES = ["asc", "desc"];
10691
+ var sortRowEnumId = (tableId, path) => {
10692
+ if (path?.length !== 1) return void 0;
10693
+ if (path[0] === SECTION_TABLE_SORT_ID) return tableId;
10694
+ return path[0] === SECTION_TABLE_SORT_DIRECTION ? SORT_DIRECTION_ENUM_ID : void 0;
10695
+ };
10696
+ function enumEventWrites(control) {
10697
+ if (control.type === "section_action" /* SECTION_ACTION */) {
10698
+ return everyScreenWrite(control).filter((row) => row.value.kind === "event").map((row) => ({ row, enumId: control.id }));
10699
+ }
10700
+ if (control.type !== "section_table" /* SECTION_TABLE */) return [];
10701
+ return Object.keys(control.outputScreenWrites ?? {}).filter((output) => baseOutputName(output) === SECTION_TABLE_SORT_OUTPUT).flatMap((output) => screenWriteRows(control.outputScreenWrites, output)).flatMap((row) => {
10702
+ const enumId = row.value.kind === "event" ? sortRowEnumId(control.id, row.value.path) : void 0;
10703
+ return enumId ? [{ row, enumId }] : [];
10704
+ });
10705
+ }
10706
+ function controlEnumValues(node) {
10707
+ if (node.type === "section_action" /* SECTION_ACTION */) return actionEnumValues(node);
10708
+ if (node.type !== "section_table" /* SECTION_TABLE */) return [];
10709
+ return sectionTableSortIds(
10710
+ toSectionTableColumns(node.configs?.[SECTION_TABLE_COLUMNS_KEY])
10711
+ );
10712
+ }
10713
+ function screenVariableEnumIds(controls, variableId) {
10714
+ return [
10715
+ ...new Set(
10716
+ Object.values(controls).flatMap(enumEventWrites).filter(({ row }) => row.variableId === variableId).map(({ enumId }) => enumId)
10717
+ )
10718
+ ];
10719
+ }
10720
+ function enumValuesOf(enumId, tree) {
10721
+ if (enumId === SORT_DIRECTION_ENUM_ID) return [...SORT_DIRECTION_VALUES];
10722
+ const find = (nodes) => {
10723
+ for (const node2 of nodes) {
10724
+ if (node2.id === enumId) return node2;
10725
+ const child = find(node2.childrens);
10726
+ if (child) return child;
10727
+ }
10728
+ return void 0;
10729
+ };
10730
+ const node = find(tree);
10731
+ return node ? controlEnumValues(node) : [];
10732
+ }
10733
+ function screenVariableEnumId(controls, variable) {
10734
+ if (variable.dataType !== "string" || variable.cardinality !== "one") {
10735
+ return void 0;
10736
+ }
10737
+ const ids = screenVariableEnumIds(controls, variable.id);
10738
+ return ids.length === 1 ? ids[0] : void 0;
10739
+ }
10740
+ function withVariableEnums(variables, controls) {
10741
+ let changed = false;
10742
+ const next = Object.fromEntries(
10743
+ Object.entries(variables).map(([id, variable]) => {
10744
+ const enumId = screenVariableEnumId(controls, variable);
10745
+ const action = !!enumId && controls[enumId]?.type === "section_action" /* SECTION_ACTION */;
10746
+ const actionEnumId = enumId && action ? enumId : void 0;
10747
+ const sortEnumId = enumId && !action ? enumId : void 0;
10748
+ if (variable.actionEnumId === actionEnumId && variable.sortEnumId === sortEnumId) {
10749
+ return [id, variable];
10750
+ }
10751
+ changed = true;
10752
+ const {
10753
+ actionEnumId: _action,
10754
+ sortEnumId: _sort,
10755
+ ...rest
10756
+ } = variable;
10757
+ return [
10758
+ id,
10759
+ {
10760
+ ...rest,
10761
+ ...actionEnumId ? { actionEnumId } : {},
10762
+ ...sortEnumId ? { sortEnumId } : {}
10763
+ }
10764
+ ];
10765
+ })
10766
+ );
10767
+ return changed ? next : variables;
10768
+ }
10423
10769
  function hasScreenVariableActionEnumConflict(controls) {
10424
- const actionEnumIdsByVariable = /* @__PURE__ */ new Map();
10770
+ const enumIdsByVariable = /* @__PURE__ */ new Map();
10425
10771
  for (const control of Object.values(controls)) {
10426
- if (control.type !== "section_action" /* SECTION_ACTION */) continue;
10427
- for (const row of everyScreenWrite(control)) {
10428
- if (row.value.kind !== "event") continue;
10429
- const ids = actionEnumIdsByVariable.get(row.variableId) ?? /* @__PURE__ */ new Set();
10430
- ids.add(control.id);
10431
- actionEnumIdsByVariable.set(row.variableId, ids);
10772
+ for (const { row, enumId } of enumEventWrites(control)) {
10773
+ const ids = enumIdsByVariable.get(row.variableId) ?? /* @__PURE__ */ new Set();
10774
+ ids.add(enumId);
10775
+ enumIdsByVariable.set(row.variableId, ids);
10432
10776
  if (ids.size > 1) return true;
10433
10777
  }
10434
10778
  }
@@ -10441,6 +10785,270 @@ function countScreenWriteReferences(controls, variableId) {
10441
10785
  );
10442
10786
  }
10443
10787
 
10788
+ // libs/codegen/src/lib/state-write-helper.ts
10789
+ var VALUE_KINDS2 = [
10790
+ "fixed",
10791
+ "const",
10792
+ "clear",
10793
+ "toggle",
10794
+ "event",
10795
+ "input"
10796
+ ];
10797
+ var isStateWrite = (value) => typeof value === "object" && value !== null && "propertyId" in value && typeof value.propertyId === "string" && "value" in value && typeof value.value === "object" && value.value !== null && VALUE_KINDS2.includes(value.value?.kind);
10798
+ function stateWriteRows(writes, output) {
10799
+ const rows = writes?.[output];
10800
+ if (Array.isArray(rows)) return rows.filter(isStateWrite);
10801
+ if (isStateWrite(rows)) return [rows];
10802
+ return [];
10803
+ }
10804
+ function stateWriteTargets(properties, enumName = () => void 0) {
10805
+ return listDataProperties(properties).map((property) => ({
10806
+ property,
10807
+ label: `${enumName(property) ?? typeSigil(property.dataType, property.cardinality)} - ${property.name}`
10808
+ }));
10809
+ }
10810
+ function findStateWriteProperty(properties, propertyId) {
10811
+ return listDataProperties(properties).find((p2) => p2.id === propertyId);
10812
+ }
10813
+ function stateWriteFixedAllowed(property) {
10814
+ return property.cardinality === "one" && property.dataType.type !== "shape";
10815
+ }
10816
+ function stateWriteToggleAllowed(property) {
10817
+ return property.cardinality === "one" && property.dataType.type === "boolean";
10818
+ }
10819
+ function stateWriteEventAllowed(payload) {
10820
+ return payload !== "void";
10821
+ }
10822
+ function stateWriteInputTargets(inputs, property) {
10823
+ if (property.dataType.type === "shape") return [];
10824
+ return Object.values(inputs).filter(
10825
+ (input) => inputPrimitive(input) === property.dataType.type && input.cardinality === property.cardinality
10826
+ ).sort((a, b) => a.name.localeCompare(b.name));
10827
+ }
10828
+ function stateWriteConstTargets(constants, property) {
10829
+ if (property.dataType.type === "shape" || property.cardinality !== "one") {
10830
+ return [];
10831
+ }
10832
+ return Object.values(constants).filter((constant) => constant.dataType === property.dataType.type).sort((a, b) => a.name.localeCompare(b.name));
10833
+ }
10834
+ function stateWriteValueKinds(property, payload, inputs, constants = {}) {
10835
+ const kinds = [];
10836
+ if (stateWriteFixedAllowed(property)) kinds.push("fixed");
10837
+ if (stateWriteConstTargets(constants, property).length) kinds.push("const");
10838
+ kinds.push("clear");
10839
+ if (stateWriteToggleAllowed(property)) kinds.push("toggle");
10840
+ if (stateWriteEventAllowed(payload)) kinds.push("event");
10841
+ if (stateWriteInputTargets(inputs, property).length) kinds.push("input");
10842
+ return kinds;
10843
+ }
10844
+ function defaultStateWriteValue(property, payload, inputs, constants = {}) {
10845
+ const [kind] = stateWriteValueKinds(property, payload, inputs, constants);
10846
+ return buildStateWriteValue(kind ?? "clear", property, inputs, constants);
10847
+ }
10848
+ function buildStateWriteValue(kind, property, inputs, constants = {}) {
10849
+ if (kind === "fixed") return { kind: "fixed", value: "" };
10850
+ if (kind === "toggle") return { kind: "toggle" };
10851
+ if (kind === "event") return { kind: "event" };
10852
+ if (kind === "const") {
10853
+ const [only] = stateWriteConstTargets(constants, property);
10854
+ return { kind: "const", constantId: only?.id ?? "" };
10855
+ }
10856
+ if (kind === "input") {
10857
+ const [only] = stateWriteInputTargets(inputs, property);
10858
+ return { kind: "input", inputId: only?.id ?? "" };
10859
+ }
10860
+ return { kind: "clear" };
10861
+ }
10862
+ function nextStateWriteRow(properties, rows, payload, inputs, constants = {}) {
10863
+ const taken = new Set(rows.map((row) => row.propertyId));
10864
+ const free = stateWriteTargets(properties).find(
10865
+ (target) => !taken.has(target.property.id)
10866
+ );
10867
+ if (!free) return void 0;
10868
+ return {
10869
+ propertyId: free.property.id,
10870
+ value: defaultStateWriteValue(free.property, payload, inputs, constants)
10871
+ };
10872
+ }
10873
+ function validateStateWrites(properties, rows, payload, fieldNames, inputs, constants = {}) {
10874
+ const seen = /* @__PURE__ */ new Set();
10875
+ for (const row of rows) {
10876
+ if (seen.has(row.propertyId)) return "state-write-duplicate";
10877
+ seen.add(row.propertyId);
10878
+ const property = findStateWriteProperty(properties, row.propertyId);
10879
+ if (!property) return "state-write-unknown-property";
10880
+ const value = row.value;
10881
+ if (!stateWriteValueKinds(property, payload, inputs, constants).includes(
10882
+ value.kind
10883
+ )) {
10884
+ return "state-write-value-not-allowed";
10885
+ }
10886
+ if (value.kind === "fixed" && !String(value.value ?? "").trim()) {
10887
+ return "state-write-incomplete";
10888
+ }
10889
+ if (value.kind === "const") {
10890
+ if (!value.constantId) return "state-write-incomplete";
10891
+ if (!stateWriteConstTargets(constants, property).some(
10892
+ (c) => c.id === value.constantId
10893
+ )) {
10894
+ return "state-write-unknown-const";
10895
+ }
10896
+ }
10897
+ if (value.kind === "input") {
10898
+ if (!value.inputId) return "state-write-incomplete";
10899
+ if (!stateWriteInputTargets(inputs, property).some(
10900
+ (i) => i.id === value.inputId
10901
+ )) {
10902
+ return "state-write-unknown-input";
10903
+ }
10904
+ }
10905
+ if (value.kind === "event" && value.path?.length && fieldNames.length && !value.path.every((name3) => fieldNames.includes(name3))) {
10906
+ return "state-write-incomplete";
10907
+ }
10908
+ }
10909
+ return void 0;
10910
+ }
10911
+ var IDENTIFIER3 = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
10912
+ var memberAccess5 = (segment) => IDENTIFIER3.test(segment) ? `.${segment}` : `['${segment}']`;
10913
+ var valueExpression2 = (value, property, payload, storeProp, inputs, constants, eventRoot, self = "", eventMember) => {
10914
+ if (value.kind === "clear") return "undefined";
10915
+ if (value.kind === "toggle") return `!${storeProp}.${property.name}()`;
10916
+ if (value.kind === "fixed") {
10917
+ return literalExpression(value.value, property.dataType);
10918
+ }
10919
+ if (value.kind === "const") {
10920
+ const constant = constants[value.constantId];
10921
+ return constant ? `${self}${constant.name}` : void 0;
10922
+ }
10923
+ if (value.kind === "input") {
10924
+ const input = inputs[value.inputId];
10925
+ return input ? `${self}${input.name}()` : void 0;
10926
+ }
10927
+ if (payload !== "record" || !value.path?.length) {
10928
+ return typeof eventRoot === "string" ? eventRoot : eventRoot(property);
10929
+ }
10930
+ const read = `$event${value.path.map(memberAccess5).join("")}`;
10931
+ return eventMember ? eventMember(
10932
+ value.path,
10933
+ read,
10934
+ "$event",
10935
+ property.cardinality,
10936
+ property.dataType
10937
+ ) : read;
10938
+ };
10939
+ function stateWritePatchExpression(properties, rows, payload, fieldNames, inputs, storeProp, constants = {}, eventRoot = "$event", scope = "template", eventMember, narrow) {
10940
+ if (!rows.length) return void 0;
10941
+ if (validateStateWrites(
10942
+ properties,
10943
+ rows,
10944
+ payload,
10945
+ fieldNames,
10946
+ inputs,
10947
+ constants
10948
+ )) {
10949
+ return void 0;
10950
+ }
10951
+ const members = [];
10952
+ for (const row of rows) {
10953
+ const property = findStateWriteProperty(properties, row.propertyId);
10954
+ if (!property) return void 0;
10955
+ const expr = valueExpression2(
10956
+ row.value,
10957
+ property,
10958
+ payload,
10959
+ storeProp,
10960
+ inputs,
10961
+ constants,
10962
+ eventRoot,
10963
+ scope === "class" ? "this." : "",
10964
+ eventMember
10965
+ );
10966
+ if (expr === void 0) return void 0;
10967
+ const narrowed = narrow ? narrow(property, row.value, expr) : expr;
10968
+ members.push({
10969
+ name: property.name,
10970
+ text: `${property.name}: ${narrowed}`
10971
+ });
10972
+ }
10973
+ members.sort((a, b) => a.name.localeCompare(b.name));
10974
+ return `${storeProp}.patch({ ${members.map((m) => m.text).join(", ")} })`;
10975
+ }
10976
+ function stateWriteInputIds(control) {
10977
+ return everyStateWrite(control).map((row) => row.value.kind === "input" ? row.value.inputId : "").filter(Boolean);
10978
+ }
10979
+ function everyStateWrite(control) {
10980
+ const from = (map) => Object.keys(map ?? {}).flatMap((key2) => stateWriteRows(map, key2));
10981
+ return [
10982
+ ...from(control.outputWrites),
10983
+ ...from(control.screenOutputWrites),
10984
+ ...armStateWrites(control)
10985
+ ];
10986
+ }
10987
+ function armStateWrites(control) {
10988
+ return [
10989
+ ...[
10990
+ ...Object.values(control.outputOutcomes ?? {}),
10991
+ ...Object.values(control.screenOutputOutcomes ?? {})
10992
+ ].flatMap((outcome) => [
10993
+ ...outcome.success?.writes ?? [],
10994
+ ...outcome.denied?.writes ?? [],
10995
+ ...outcome.failure?.writes ?? []
10996
+ ]),
10997
+ // An OverlayAnswer's rows are the same rows one moment later — what this
10998
+ // call site does with what the overlay it opened handed back (ADR 0131) —
10999
+ // so every guard reading this sweep reaches them without being taught.
11000
+ ...Object.values(control.outputOpens ?? {}).flatMap(
11001
+ (open) => open.answer?.writes ?? []
11002
+ )
11003
+ ];
11004
+ }
11005
+ function countStateWriteReferences(controls, propertyId) {
11006
+ return Object.values(controls).reduce(
11007
+ (total, control) => total + everyStateWrite(control).filter((row) => row.propertyId === propertyId).length,
11008
+ 0
11009
+ );
11010
+ }
11011
+ function enumEventStateWrites(control) {
11012
+ if (control.type === "section_action" /* SECTION_ACTION */) {
11013
+ return everyStateWrite(control).filter((row) => row.value.kind === "event" && !row.value.path?.length).map((row) => ({ row, enumId: control.id }));
11014
+ }
11015
+ if (control.type !== "section_table" /* SECTION_TABLE */) return [];
11016
+ return Object.keys(control.outputWrites ?? {}).filter((output) => baseOutputName(output) === SECTION_TABLE_SORT_OUTPUT).flatMap((output) => stateWriteRows(control.outputWrites, output)).flatMap((row) => {
11017
+ const enumId = row.value.kind === "event" ? sortRowEnumId(control.id, row.value.path) : void 0;
11018
+ return enumId ? [{ row, enumId }] : [];
11019
+ });
11020
+ }
11021
+ function stampStatePropertyEnums(properties, controlMaps) {
11022
+ const sources = /* @__PURE__ */ new Map();
11023
+ controlMaps.forEach(
11024
+ (controls) => Object.values(controls).forEach(
11025
+ (control) => enumEventStateWrites(control).forEach(({ row, enumId }) => {
11026
+ const enums = sources.get(row.propertyId) ?? /* @__PURE__ */ new Map();
11027
+ enums.set(enumId, control);
11028
+ sources.set(row.propertyId, enums);
11029
+ })
11030
+ )
11031
+ );
11032
+ let changed = false;
11033
+ const next = { ...properties };
11034
+ sources.forEach((enums, propertyId) => {
11035
+ const property = properties[propertyId];
11036
+ const [[enumId, control]] = [...enums];
11037
+ if (!property || enums.size !== 1 || property.dataType.type !== "string" || property.cardinality !== "one" || property.dataType.actionEnumId || property.dataType.sortEnumId) {
11038
+ return;
11039
+ }
11040
+ changed = true;
11041
+ next[propertyId] = {
11042
+ ...property,
11043
+ dataType: {
11044
+ ...property.dataType,
11045
+ ...control.type === "section_action" /* SECTION_ACTION */ ? { actionEnumId: enumId } : { sortEnumId: enumId }
11046
+ }
11047
+ };
11048
+ });
11049
+ return changed ? next : properties;
11050
+ }
11051
+
10444
11052
  // libs/codegen/src/lib/output-arm-helper.ts
10445
11053
  var OUTPUT_ARM_SEPARATOR = "|arm:";
10446
11054
  var outputArmKey = (output, armId) => `${output}${OUTPUT_ARM_SEPARATOR}${armId.trim()}`;
@@ -12046,7 +12654,7 @@ var OUTPUT_PAYLOADS_BY_CONTROL = {
12046
12654
  ["section_pagination" /* SECTION_PAGINATION */]: { paginationChange: "record" },
12047
12655
  // libs/one SectionTableSort — the column's id and the direction.
12048
12656
  ["section_table" /* SECTION_TABLE */]: { sortChange: "record" },
12049
- ["section_table_row" /* SECTION_TABLE_ROW */]: { rowClick: "void" },
12657
+ ["section_table_row" /* SECTION_TABLE_ROW */]: { rowClick: "record" },
12050
12658
  // libs/one SectionChart: the preset id picked (or `custom` once the window
12051
12659
  // was dragged), and the window itself as `{from, to}` ISO text — what an
12052
12660
  // ApiOperation's date params take (GLOSSARY.md SectionChartWindow).
@@ -12065,6 +12673,8 @@ var OUTPUT_PAYLOADS_BY_CONTROL = {
12065
12673
  var FIELD_STRING_READER = "fieldString";
12066
12674
  var FIELD_NUMBER_READER = "fieldNumber";
12067
12675
  var FIELD_BOOLEAN_READER = "fieldBoolean";
12676
+ var ACTION_NAME_READER = "actionName";
12677
+ var ENUM_VALUE_READER = "enumValue";
12068
12678
  var OUTPUT_PAYLOAD_MEMBERS = {
12069
12679
  ["section_action" /* SECTION_ACTION */]: { clicked: { name: "S" } },
12070
12680
  ["context_menu" /* CONTEXT_MENU */]: {
@@ -12329,6 +12939,7 @@ function shadowedShapes(ops, shapes) {
12329
12939
  out.set(twin.id, {
12330
12940
  name: shapeInterfaceName(twin.name),
12331
12941
  shapeId: twin.id,
12942
+ specShapeId: spec.id,
12332
12943
  details
12333
12944
  });
12334
12945
  }
@@ -12552,8 +13163,9 @@ function importShapes(dataType, from, existing, mintId, overwriteExisting = fals
12552
13163
  (candidate) => sameOrigin(candidate.origin, source.origin)
12553
13164
  )?.id : void 0;
12554
13165
  const sameSchema = (candidate) => !source.origin || !candidate.origin || candidate.name === source.name;
13166
+ const sameLayout = (candidate) => !!candidate.positional === !!source.positional;
12555
13167
  const structural = Object.values(candidates).find(
12556
- (candidate) => sameSchema(candidate) && dataTypeFits(
13168
+ (candidate) => sameSchema(candidate) && sameLayout(candidate) && dataTypeFits(
12557
13169
  { dataType: { type: "shape", shapeId }, cardinality: "one" },
12558
13170
  from,
12559
13171
  {
@@ -12580,6 +13192,8 @@ function importShapes(dataType, from, existing, mintId, overwriteExisting = fals
12580
13192
  id: id2,
12581
13193
  name: source.name,
12582
13194
  keys: [],
13195
+ // A tuple stays a tuple: the spec's layout, not the held one (ADR 0196).
13196
+ ...source.positional ? { positional: true } : {},
12583
13197
  ...source.origin ? { origin: source.origin } : shapes[id2]?.origin ? { origin: shapes[id2].origin } : {}
12584
13198
  };
12585
13199
  shapes[id2] = shape;
@@ -12767,6 +13381,8 @@ var cacheMethodReads = (method) => method.cache?.propertyId ? [method.cache.prop
12767
13381
  // libs/codegen/src/lib/store-ownership.ts
12768
13382
  var MAIN_STORE_OWNER = { kind: "main" };
12769
13383
  var MAIN_STORE_VALUE = "main";
13384
+ var storeOwnerValue = (owner) => owner.kind === "main" ? MAIN_STORE_VALUE : owner.subStoreId;
13385
+ var storeOwnerOfValue = (value) => value && value !== MAIN_STORE_VALUE ? { kind: "sub", subStoreId: value } : MAIN_STORE_OWNER;
12770
13386
  var subStoresOf = (feature) => Object.values(feature.subStores ?? {});
12771
13387
  function storesOf(feature) {
12772
13388
  const main2 = {
@@ -14293,6 +14909,13 @@ var createCondition = () => ({
14293
14909
  check: { source: "store", operator: "not_exists" }
14294
14910
  });
14295
14911
  var conditionKind = (condition) => condition.kind ?? "function";
14912
+ function conditionFunction(condition, functions) {
14913
+ if (condition.oneFunction) {
14914
+ const entry2 = oneFunctionOf(condition.oneFunction);
14915
+ return entry2?.reach.includes("call-condition") ? oneFunctionSignature(entry2, { dataType: { type: "string" } }) : void 0;
14916
+ }
14917
+ return functions[condition.functionId];
14918
+ }
14296
14919
  var answersBoolean = (fn) => fn.returnType.type === "boolean" && fn.returnCardinality === "one";
14297
14920
  function conditionCheckType(check, args, properties, shapes) {
14298
14921
  const read = check.source === "args" ? check.arg ? argValue2({ source: "args", arg: check.arg }, args, properties, shapes) : void 0 : check.path?.length ? argValue2(
@@ -14320,6 +14943,26 @@ function conditionError(condition, args, functions, properties, shapes) {
14320
14943
  if (conditionKind(condition) === "check") {
14321
14944
  return checkError2(condition.check, args, properties, shapes);
14322
14945
  }
14946
+ const entry2 = condition.oneFunction ? oneFunctionOf(condition.oneFunction) : void 0;
14947
+ if (condition.oneFunction) {
14948
+ if (!entry2?.reach.includes("call-condition"))
14949
+ return "condition-no-function";
14950
+ for (const param of entry2.params) {
14951
+ const binding = condition.args[param.id];
14952
+ if (!binding) return "condition-args";
14953
+ if (binding.source === "fixed") {
14954
+ if (param.rule !== "string-one" || typeof binding.value !== "string")
14955
+ return "condition-type";
14956
+ continue;
14957
+ }
14958
+ const read = argValue2(binding, args, properties, shapes);
14959
+ if (!read) return "condition-args";
14960
+ const held = read.value.dataType ? { dataType: read.value.dataType, cardinality: read.value.cardinality } : void 0;
14961
+ if (!oneFunctionArgFits(param, held, binding.source === "store"))
14962
+ return "condition-type";
14963
+ }
14964
+ return void 0;
14965
+ }
14323
14966
  const fn = functions[condition.functionId];
14324
14967
  if (!fn) return "condition-no-function";
14325
14968
  if (!answersBoolean(fn)) return "condition-not-boolean";
@@ -15878,6 +16521,7 @@ function generateStoreMethods(methods, operationOf, properties, shapes, function
15878
16521
  const calls = [];
15879
16522
  const errorTypeAliases = [];
15880
16523
  const argShapes = /* @__PURE__ */ new Set();
16524
+ const oneFunctionNames = /* @__PURE__ */ new Set();
15881
16525
  for (const method of list) {
15882
16526
  if (isCacheMethod(method)) continue;
15883
16527
  const op = operationOf(method);
@@ -16195,7 +16839,8 @@ ${failureArms.map(
16195
16839
  true
16196
16840
  );
16197
16841
  }
16198
- const fn = functions[condition.functionId];
16842
+ const fn = conditionFunction(condition, functions);
16843
+ if (condition.oneFunction && fn) oneFunctionNames.add(fn.name);
16199
16844
  const waits = [];
16200
16845
  const callArgs2 = (fn?.params ?? []).map((param) => {
16201
16846
  const binding = condition.args[param.id];
@@ -16225,9 +16870,10 @@ ${failureArms.map(
16225
16870
  waits.push(`${read} !== undefined`);
16226
16871
  return statePathExpression(binding.path, roots, shapes, true, receiverOf);
16227
16872
  });
16873
+ const negate = condition.oneFunction && condition.negate ? "!" : "";
16228
16874
  return [
16229
16875
  ...Array.from(new Set(waits)),
16230
- `${fn?.name}(${callArgs2.join(", ")})`
16876
+ `${negate}${fn?.name}(${callArgs2.join(", ")})`
16231
16877
  ].join(" && ");
16232
16878
  });
16233
16879
  const conditionBlock = conditions.length ? `
@@ -16503,7 +17149,8 @@ ${beforePersists.map((line) => ` ${line}`).join("\n")}
16503
17149
  // A CallCompute's and a CallCondition's PureFunction are spelled in
16504
17150
  // the store's own pipe, so they are imported the same way.
16505
17151
  ...(method.computes ?? []).map((compute) => compute.functionId).filter((id) => !!id && !!functions[id]),
16506
- ...(method.conditions ?? []).filter((condition) => conditionKind(condition) === "function").map((condition) => condition.functionId).filter((id) => !!id && !!functions[id]),
17152
+ // A OneFunction is the library's, imported by `oneFunctions`.
17153
+ ...(method.conditions ?? []).filter((condition) => conditionKind(condition) === "function").filter((condition) => !condition.oneFunction).map((condition) => condition.functionId).filter((id) => !!id && !!functions[id]),
16507
17154
  ...templateTransformRefs(
16508
17155
  method.inputs.map((mapping) => mapping.transform),
16509
17156
  functions
@@ -16512,7 +17159,8 @@ ${beforePersists.map((line) => ` ${line}`).join("\n")}
16512
17159
  )
16513
17160
  ).sort();
16514
17161
  return functionIds.length ? { functionIds } : {};
16515
- })()
17162
+ })(),
17163
+ ...oneFunctionNames.size ? { oneFunctions: [...oneFunctionNames].sort() } : {}
16516
17164
  };
16517
17165
  }
16518
17166
  function generateCacheMethods(methods, operationOf, properties, shapes, roots = properties, receiverOf = OWN_STORE, callable = methods) {
@@ -17193,18 +17841,190 @@ function pruneOutputLinkArgs(control, drop) {
17193
17841
  return dropped;
17194
17842
  }
17195
17843
 
17844
+ // libs/codegen/src/lib/tree-helper.ts
17845
+ function buildTree(controlMap, rootControlIds, selection) {
17846
+ const state = (id) => selection ? variantRenderState(id, controlMap, selection) : "solid";
17847
+ const resolveDirectives = (ctrl) => {
17848
+ if (!ctrl.directives) return void 0;
17849
+ const resolved = {};
17850
+ for (const [name3, directive] of Object.entries(ctrl.directives)) {
17851
+ if (directive.overlayId) {
17852
+ const overlay = controlMap[directive.overlayId];
17853
+ if (overlay) {
17854
+ resolved[name3] = {
17855
+ overlayId: directive.overlayId,
17856
+ type: overlay.type,
17857
+ configs: overlay.configs
17858
+ };
17859
+ }
17860
+ } else {
17861
+ resolved[name3] = { configs: directive.configs ?? {} };
17862
+ }
17863
+ }
17864
+ return Object.keys(resolved).length > 0 ? resolved : void 0;
17865
+ };
17866
+ const toNode = (ctrl) => {
17867
+ const childrens = getChildren(ctrl.id);
17868
+ const fullyFaded = state(ctrl.id) === "faded" && childrens.every((child) => child.faded);
17869
+ return {
17870
+ type: ctrl.type,
17871
+ id: ctrl.id,
17872
+ configs: ctrl.configs,
17873
+ childrens,
17874
+ directives: resolveDirectives(ctrl),
17875
+ ...ctrl.source ? { source: ctrl.source } : {},
17876
+ ...ctrl.variants?.length ? { variants: ctrl.variants } : {},
17877
+ // Carried through so renderBranch can order the `@else` last and spell it
17878
+ // without reaching back into ControlMap mid-walk (GLOSSARY.md DefaultArm).
17879
+ ...ctrl.armKind ? { armKind: ctrl.armKind } : {},
17880
+ ...ctrl.variantKind ? { variantKind: ctrl.variantKind } : {},
17881
+ ...ctrl.outputs && Object.keys(ctrl.outputs).length ? { outputs: ctrl.outputs } : {},
17882
+ ...ctrl.outputArgs && Object.keys(ctrl.outputArgs).length ? { outputArgs: ctrl.outputArgs } : {},
17883
+ ...ctrl.outputWrites && Object.keys(ctrl.outputWrites).length ? { outputWrites: ctrl.outputWrites } : {},
17884
+ ...ctrl.outputEmits && Object.keys(ctrl.outputEmits).length ? { outputEmits: ctrl.outputEmits } : {},
17885
+ ...ctrl.outputScreenWrites && Object.keys(ctrl.outputScreenWrites).length ? { outputScreenWrites: ctrl.outputScreenWrites } : {},
17886
+ ...ctrl.outputOpens && Object.keys(ctrl.outputOpens).length ? { outputOpens: ctrl.outputOpens } : {},
17887
+ ...ctrl.outputNavs && Object.keys(ctrl.outputNavs).length ? { outputNavs: ctrl.outputNavs } : {},
17888
+ ...ctrl.outputNewTabs && Object.keys(ctrl.outputNewTabs).length ? { outputNewTabs: ctrl.outputNewTabs } : {},
17889
+ ...ctrl.outputOutcomes && Object.keys(ctrl.outputOutcomes).length ? { outputOutcomes: ctrl.outputOutcomes } : {},
17890
+ // Without this the codegen walk reads `outputArms` off a Tree that never
17891
+ // carried it, every gated output falls back to ungated, and its groups —
17892
+ // filed under `<output>|arm:<armId>` — are skipped as qualified keys. The
17893
+ // output emits nothing at all (GLOSSARY.md OutputArm).
17894
+ ...ctrl.outputArms && Object.keys(ctrl.outputArms).length ? { outputArms: ctrl.outputArms } : {},
17895
+ // Without this every group fires its first call alone: the rest are
17896
+ // filed under `<group>|call:<callId>` and read in the order this holds
17897
+ // (GLOSSARY.md OutputCall).
17898
+ ...ctrl.outputCalls && Object.keys(ctrl.outputCalls).length ? { outputCalls: ctrl.outputCalls } : {},
17899
+ ...ctrl.outputScreenMethods && Object.keys(ctrl.outputScreenMethods).length ? { outputScreenMethods: ctrl.outputScreenMethods } : {},
17900
+ ...ctrl.menuActions?.length ? { menuActions: ctrl.menuActions } : {},
17901
+ ...ctrl.screenId ? { screenId: ctrl.screenId } : {},
17902
+ // The other answer to what a ScreenControl mounts (ADR 0088). Carried
17903
+ // for `screenId`'s reason: the Canvas labels its placeholder from it and
17904
+ // codegen emits its tag.
17905
+ ...ctrl.handRef ? { handRef: ctrl.handRef } : {},
17906
+ ...ctrl.screenInputs && Object.keys(ctrl.screenInputs).length ? { screenInputs: ctrl.screenInputs } : {},
17907
+ // Carried for `screenId`'s reason: the Canvas draws the embed's box at
17908
+ // it and codegen emits it on the tag.
17909
+ ...ctrl.maxWidth ? { maxWidth: ctrl.maxWidth } : {},
17910
+ ...ctrl.screenOutputs && Object.keys(ctrl.screenOutputs).length ? { screenOutputs: ctrl.screenOutputs } : {},
17911
+ ...ctrl.screenOutputCalls && Object.keys(ctrl.screenOutputCalls).length ? { screenOutputCalls: ctrl.screenOutputCalls } : {},
17912
+ ...ctrl.screenOutputWrites && Object.keys(ctrl.screenOutputWrites).length ? { screenOutputWrites: ctrl.screenOutputWrites } : {},
17913
+ ...ctrl.screenOutputEmits && Object.keys(ctrl.screenOutputEmits).length ? { screenOutputEmits: ctrl.screenOutputEmits } : {},
17914
+ ...ctrl.screenOutputScreenWrites && Object.keys(ctrl.screenOutputScreenWrites).length ? { screenOutputScreenWrites: ctrl.screenOutputScreenWrites } : {},
17915
+ ...ctrl.checks?.length ? { checks: ctrl.checks } : {},
17916
+ ...ctrl.formatPipes?.length ? { formatPipes: ctrl.formatPipes } : {},
17917
+ ...ctrl.cards ? { cards: ctrl.cards } : {},
17918
+ ...ctrl.search ? { search: ctrl.search } : {},
17919
+ // A Repeat's row count, carried for `cards`' reason: the Canvas draws
17920
+ // its sample rows from the Tree alone. Nothing else reads it — codegen
17921
+ // never emits a count (GLOSSARY.md SampleValue).
17922
+ ...ctrl.repeat?.sampleRows !== void 0 ? { sampleRows: ctrl.repeat.sampleRows } : {},
17923
+ ...fullyFaded ? { faded: true } : {}
17924
+ };
17925
+ };
17926
+ const getChildren = (parentId) => {
17927
+ const parent = controlMap[parentId];
17928
+ if (!parent || !parent.childrens) return [];
17929
+ return parent.childrens.map((childId) => controlMap[childId]).filter(Boolean).filter((ctrl) => state(ctrl.id) !== "hidden").map(toNode);
17930
+ };
17931
+ const tree = rootControlIds.map((id) => controlMap[id]).filter(Boolean).filter((ctrl) => state(ctrl.id) !== "hidden").map(toNode);
17932
+ return selection ? markFadedRoots(tree) : tree;
17933
+ }
17934
+ function markFadedRoots(nodes, underFaded = false) {
17935
+ return nodes.map((node) => {
17936
+ const faded = !underFaded && node.faded;
17937
+ const next = {
17938
+ ...node,
17939
+ childrens: markFadedRoots(node.childrens, underFaded || !!node.faded)
17940
+ };
17941
+ if (faded) {
17942
+ next.faded = true;
17943
+ } else {
17944
+ delete next.faded;
17945
+ }
17946
+ return next;
17947
+ });
17948
+ }
17949
+
17950
+ // libs/codegen/src/lib/enum-label-helper.ts
17951
+ function enumLabels(controlMap, rootControlIds, properties = {}) {
17952
+ const names = new Map(
17953
+ controlEnums([
17954
+ { tree: buildTree(controlMap, rootControlIds), controlMap }
17955
+ ]).map((entry2) => [entry2.id, entry2.name])
17956
+ );
17957
+ const stamped = stampStatePropertyEnums(properties, [controlMap]);
17958
+ const control = (controlId) => names.get(controlId);
17959
+ return {
17960
+ control,
17961
+ variable: (variable) => {
17962
+ const id = screenVariableEnumId(controlMap, variable);
17963
+ return id ? control(id) : void 0;
17964
+ },
17965
+ property: (property) => {
17966
+ const dataType = (stamped[property.id] ?? property).dataType;
17967
+ const id = dataType.actionEnumId ?? dataType.sortEnumId;
17968
+ return id ? control(id) : void 0;
17969
+ }
17970
+ };
17971
+ }
17972
+ function enumMemberLabel(key2) {
17973
+ if (!key2) return "";
17974
+ return key2.split("_").map(
17975
+ (word, i) => i === 0 ? word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() : word.toLowerCase()
17976
+ ).join(" ");
17977
+ }
17978
+ function enumNameOf(seed) {
17979
+ return seed.replace(/^[^A-Za-z]+/, "").replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
17980
+ }
17981
+ function enumFileBase(name3) {
17982
+ return name3.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
17983
+ }
17984
+ function emitEnumFile(appEnum) {
17985
+ const asString2 = appEnum.hasValue && appEnum.valueType === "string";
17986
+ const members = appEnum.members.map((m, index) => {
17987
+ if (asString2) {
17988
+ const text2 = typeof m.value === "string" ? m.value : m.key;
17989
+ const quoted = `'${text2.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
17990
+ return ` ${m.key} = ${quoted},`;
17991
+ }
17992
+ const own = appEnum.hasValue && typeof m.value === "number";
17993
+ return ` ${m.key} = ${own ? m.value : index},`;
17994
+ }).join("\n");
17995
+ const fileName = `shared/type/${appEnum.fileName}.ts`;
17996
+ return {
17997
+ path: `src/app/${fileName}`,
17998
+ fileName,
17999
+ contents: `export enum ${appEnum.name} {
18000
+ ${members}
18001
+ }
18002
+ `
18003
+ };
18004
+ }
18005
+
17196
18006
  // libs/codegen/src/lib/screen-input-source-helper.ts
17197
18007
  var SCREEN_SOURCE_SEP = "::";
17198
18008
  var encode = (kind, id) => `${kind}${SCREEN_SOURCE_SEP}${id}`;
18009
+ var cardinalityFits = (source, target) => source === target || target === "many" && source === "one";
17199
18010
  function screenInputSourceOptions(scope, want) {
17200
18011
  const { dataType, cardinality, required } = want;
17201
18012
  const byName = (rows) => [...rows].sort((a, b) => a.name.localeCompare(b.name));
18013
+ if (want.declared?.type === "enum") {
18014
+ return enumSourceOptions(
18015
+ scope,
18016
+ want.declared.enumId,
18017
+ cardinality,
18018
+ !!required,
18019
+ byName
18020
+ );
18021
+ }
17202
18022
  const members = dataType ? screenMemberOptions(scope, dataType, cardinality, !!required, byName) : [];
17203
18023
  return [...members, ...dataOptions(scope, want)];
17204
18024
  }
17205
18025
  function screenMemberOptions(scope, dataType, cardinality, required, byName) {
17206
18026
  const inputs = byName(Object.values(scope.inputs ?? {})).filter(
17207
- (input) => inputPrimitive(input) === dataType && input.cardinality === cardinality
18027
+ (input) => inputPrimitive(input) === dataType && cardinalityFits(input.cardinality, cardinality)
17208
18028
  ).map((input) => ({
17209
18029
  value: encode("input", input.id),
17210
18030
  label: input.name,
@@ -17212,7 +18032,7 @@ function screenMemberOptions(scope, dataType, cardinality, required, byName) {
17212
18032
  ...required && !input.required ? { optional: true } : {}
17213
18033
  }));
17214
18034
  const variables = byName(Object.values(scope.variables ?? {})).filter(
17215
- (variable) => variable.dataType === dataType && variable.cardinality === cardinality
18035
+ (variable) => variable.dataType === dataType && cardinalityFits(variable.cardinality, cardinality)
17216
18036
  ).map((variable) => ({
17217
18037
  value: encode("variable", variable.id),
17218
18038
  label: variable.name,
@@ -17223,17 +18043,17 @@ function screenMemberOptions(scope, dataType, cardinality, required, byName) {
17223
18043
  // Always `signal<T | undefined>`, whatever it is seeded with.
17224
18044
  ...required ? { optional: true } : {}
17225
18045
  }));
17226
- const constants = cardinality === "one" ? byName(Object.values(scope.constants ?? {})).filter((constant) => constant.dataType === dataType).map((constant) => ({
18046
+ const constants = byName(Object.values(scope.constants ?? {})).filter((constant) => constant.dataType === dataType).map((constant) => ({
17227
18047
  value: encode("constant", constant.id),
17228
18048
  label: constant.name,
17229
18049
  binding: {
17230
18050
  kind: "constant",
17231
18051
  constantId: constant.id
17232
18052
  }
17233
- })) : [];
18053
+ }));
17234
18054
  const computeds = byName(Object.values(scope.computeds ?? {})).filter((computed) => {
17235
18055
  const fn = screenComputedFunction(computed, scope.functions ?? {});
17236
- return !!fn && fn.returnType.type === dataType && fn.returnCardinality === cardinality;
18056
+ return !!fn && fn.returnType.type === dataType && cardinalityFits(returnCardinalityOf(fn), cardinality);
17237
18057
  }).map((computed) => ({
17238
18058
  value: encode("computed", computed.id),
17239
18059
  label: computed.name,
@@ -17251,6 +18071,30 @@ function screenMemberOptions(scope, dataType, cardinality, required, byName) {
17251
18071
  }));
17252
18072
  return [...inputs, ...variables, ...constants, ...computeds];
17253
18073
  }
18074
+ function enumSourceOptions(scope, enumId, cardinality, required, byName) {
18075
+ const inputs = byName(Object.values(scope.inputs ?? {})).filter(
18076
+ (input) => input.dataType.type === "enum" && input.dataType.enumId === enumId && cardinalityFits(input.cardinality, cardinality)
18077
+ ).map((input) => ({
18078
+ value: encode("input", input.id),
18079
+ label: input.name,
18080
+ binding: { kind: "input", inputId: input.id },
18081
+ ...required && !input.required ? { optional: true } : {}
18082
+ }));
18083
+ const appEnum = scope.enums?.[enumId];
18084
+ const members = appEnum ? [...appEnum.members].sort((a, b) => a.key.localeCompare(b.key)).map((member) => ({
18085
+ value: encode(
18086
+ "enum-member",
18087
+ `${enumId}${SCREEN_SOURCE_SEP}${member.id}`
18088
+ ),
18089
+ label: enumMemberLabel(member.key),
18090
+ binding: {
18091
+ kind: "enum-member",
18092
+ enumId,
18093
+ memberId: member.id
18094
+ }
18095
+ })) : [];
18096
+ return [...inputs, ...members];
18097
+ }
17254
18098
  var sameType6 = (candidate, declared) => {
17255
18099
  if (candidate?.type !== declared.type) return false;
17256
18100
  return declared.type === "shape" ? candidate.type === "shape" && candidate.shapeId === declared.shapeId : true;
@@ -17263,7 +18107,7 @@ function dataOptions(scope, want) {
17263
18107
  const listedAsMember = !!want.dataType;
17264
18108
  return bindingOptions(
17265
18109
  data,
17266
- (candidate, rowCardinality) => rowCardinality === cardinality && sameType6(candidate, declared)
18110
+ (candidate, rowCardinality) => cardinalityFits(rowCardinality, cardinality) && sameType6(candidate, declared)
17267
18111
  ).filter(
17268
18112
  ({ binding }) => !(listedAsMember && binding.path.length === 0 && memberRoots.has(binding.root.kind))
17269
18113
  ).map(({ value, label, binding }) => ({
@@ -17283,6 +18127,11 @@ function screenInputSourceValue(binding) {
17283
18127
  return encode("constant", binding.constantId);
17284
18128
  case "computed":
17285
18129
  return encode("computed", binding.computedId);
18130
+ case "enum-member":
18131
+ return encode(
18132
+ "enum-member",
18133
+ `${binding.enumId}${SCREEN_SOURCE_SEP}${binding.memberId}`
18134
+ );
17286
18135
  case "data":
17287
18136
  return encode("data", encodeBinding(binding.binding));
17288
18137
  default:
@@ -17430,10 +18279,13 @@ function validateOutputOpen(open, screens, payload, hostInputs, constants = {},
17430
18279
  }
17431
18280
  var IDENTIFIER5 = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
17432
18281
  var memberAccess6 = (segment) => IDENTIFIER5.test(segment) ? `.${segment}` : `['${segment}']`;
17433
- function valueExpression3(value, input, payload, hostInputs, constants, eventRoot, self, eventMember, renderMember = () => void 0, renderBinding = () => void 0) {
18282
+ function valueExpression3(value, input, payload, hostInputs, constants, eventRoot, self, eventMember, renderMember = () => void 0, renderBinding = () => void 0, readSource) {
17434
18283
  if (value.kind === "clear") return "undefined";
17435
- if (value.kind === "screen")
17436
- return value.binding.kind === "data" ? renderBinding(value.binding.binding) : renderMember(value.binding);
18284
+ if (value.kind === "screen") {
18285
+ const read2 = value.binding.kind === "data" ? renderBinding(value.binding.binding) : renderMember(value.binding);
18286
+ const source = readSource?.(value.binding);
18287
+ return read2 !== void 0 && source && liftsToList(input, source) ? liftToList(read2, source.present) : read2;
18288
+ }
17437
18289
  if (value.kind === "fixed")
17438
18290
  return literalExpression(value.value, input.dataType);
17439
18291
  if (value.kind === "const") {
@@ -17451,7 +18303,7 @@ function valueExpression3(value, input, payload, hostInputs, constants, eventRoo
17451
18303
  return eventMember ? eventMember(value.path, read, "$event", input.cardinality, input.dataType) : read;
17452
18304
  }
17453
18305
  var outputOpenReadsEvent = (open) => !!open && outputOpenInputs(open).some((row) => row.value.kind === "event");
17454
- function outputOpenInputEntries(open, declared, payload, hostInputs, constants, eventRoot, self, eventMember, renderMember, renderBinding) {
18306
+ function outputOpenInputEntries(open, declared, payload, hostInputs, constants, eventRoot, self, eventMember, renderMember, renderBinding, readSource) {
17455
18307
  const byId = new Map(declared.map((input) => [input.id, input]));
17456
18308
  const entries = [];
17457
18309
  for (const row of outputOpenInputs(open)) {
@@ -17467,7 +18319,8 @@ function outputOpenInputEntries(open, declared, payload, hostInputs, constants,
17467
18319
  self,
17468
18320
  eventMember,
17469
18321
  renderMember,
17470
- renderBinding
18322
+ renderBinding,
18323
+ readSource
17471
18324
  );
17472
18325
  if (expr === void 0) return void 0;
17473
18326
  entries.push(`${input.name}: ${expr}`);
@@ -18608,144 +19461,6 @@ var acceptedRemoteLink = (typed) => {
18608
19461
  return link === "" || LINK_SLUG.test(link) ? link : void 0;
18609
19462
  };
18610
19463
 
18611
- // libs/codegen/src/lib/section-table-helper.ts
18612
- var SECTION_TABLE_COLUMNS_KEY = "columns";
18613
- var SECTION_TABLE_SEED_COLUMNS = 3;
18614
- var ALIGNS = ["left", "center", "right"];
18615
- var DATA_TYPES = ["text", "number", "date"];
18616
- var seedColumn = (index) => ({
18617
- label: `column-${index + 1}`
18618
- });
18619
- var seedColumns = (count = SECTION_TABLE_SEED_COLUMNS) => Array.from({ length: count }, (_, i) => seedColumn(i));
18620
- var text = (value) => {
18621
- const trimmed = typeof value === "string" ? value.trim() : "";
18622
- return trimmed || void 0;
18623
- };
18624
- function toSectionTableColumns(value) {
18625
- if (!Array.isArray(value)) return [];
18626
- return value.filter((raw) => !!raw && typeof raw === "object").map((raw) => {
18627
- const column = {};
18628
- const id = text(raw["id"]);
18629
- if (id) column.id = id;
18630
- const label = text(raw["label"]);
18631
- if (label) column.label = label;
18632
- if (ALIGNS.includes(raw["align"])) {
18633
- column.align = raw["align"];
18634
- }
18635
- const span = Number(raw["span"]);
18636
- if (raw["span"] != null && raw["span"] !== "" && Number.isFinite(span)) {
18637
- column.span = Math.min(12, Math.max(1, Math.round(span)));
18638
- }
18639
- if (raw["sortable"] === true) column.sortable = true;
18640
- if (DATA_TYPES.includes(raw["dataType"])) {
18641
- column.dataType = raw["dataType"];
18642
- }
18643
- if (raw["defaultSort"] === true) column.defaultSort = true;
18644
- if (raw["ascending"] === true) column.ascending = true;
18645
- if (raw["freeze"] === true) column.freeze = true;
18646
- if (raw["squeeze"] === true) column.squeeze = true;
18647
- return column;
18648
- });
18649
- }
18650
- var columnNeedsId = (column) => (!!column.sortable || !!column.defaultSort) && !column.id;
18651
- var putSectionTableColumn = (columns, index, column) => {
18652
- const next = index >= columns.length ? [...columns, column] : columns.map((current, i) => i === index ? column : current);
18653
- if (!column.defaultSort) return next;
18654
- return next.map((current, i) => {
18655
- if (i === index || !current.defaultSort) return current;
18656
- const { defaultSort: _defaultSort, ascending: _ascending, ...rest } = current;
18657
- return rest;
18658
- });
18659
- };
18660
- var enclosingSectionTable = (control, controlMap) => {
18661
- const seen = /* @__PURE__ */ new Set();
18662
- let current = control?.parentId ? controlMap[control.parentId] : void 0;
18663
- while (current && isTaglessFamily(current.type) && !seen.has(current.id)) {
18664
- seen.add(current.id);
18665
- current = current.parentId ? controlMap[current.parentId] : void 0;
18666
- }
18667
- return current?.type === "section_table" /* SECTION_TABLE */ ? current : void 0;
18668
- };
18669
- var sectionTableRows = (tableId, controlMap) => {
18670
- const rows = [];
18671
- const walk = (ids) => ids.forEach((id) => {
18672
- const control = controlMap[id];
18673
- if (!control) return;
18674
- if (control.type === "section_table_row" /* SECTION_TABLE_ROW */) rows.push(control);
18675
- else if (isTaglessFamily(control.type)) walk(control.childrens ?? []);
18676
- });
18677
- walk(controlMap[tableId]?.childrens ?? []);
18678
- return rows;
18679
- };
18680
- var tableHasRepeat = (tableId, controlMap) => {
18681
- const walk = (ids) => ids.some((id) => {
18682
- const control = controlMap[id];
18683
- if (!control || !isTaglessFamily(control.type)) return false;
18684
- return control.type === "repeat" /* REPEAT */ || walk(control.childrens ?? []);
18685
- });
18686
- return walk(controlMap[tableId]?.childrens ?? []);
18687
- };
18688
- var sectionTableRef = (id) => `sectionTable_${id.replace(/[^a-zA-Z0-9_]/g, "_")}`;
18689
- var newCell = (id, parentId) => ({
18690
- id,
18691
- type: "section_table_cell" /* SECTION_TABLE_CELL */,
18692
- parentId,
18693
- configs: {},
18694
- childrens: []
18695
- });
18696
- var descendants = (id, controlMap) => (controlMap[id]?.childrens ?? []).flatMap((child) => [
18697
- child,
18698
- ...descendants(child, controlMap)
18699
- ]);
18700
- function syncSectionTableCells(controlMap, tableId, change, genId2) {
18701
- const next = { ...controlMap };
18702
- sectionTableRows(tableId, controlMap).forEach((row) => {
18703
- const cells = [...row.childrens];
18704
- const pad2 = (length) => {
18705
- while (cells.length < length) {
18706
- const id = genId2();
18707
- next[id] = newCell(id, row.id);
18708
- cells.push(id);
18709
- }
18710
- };
18711
- if (change.kind === "add") {
18712
- pad2(change.index);
18713
- const id = genId2();
18714
- next[id] = newCell(id, row.id);
18715
- cells.splice(change.index, 0, id);
18716
- } else if (change.kind === "remove") {
18717
- const [removed] = cells.splice(change.index, 1);
18718
- if (removed) {
18719
- [removed, ...descendants(removed, controlMap)].forEach(
18720
- (id) => delete next[id]
18721
- );
18722
- }
18723
- } else {
18724
- pad2(Math.max(change.from, change.to) + 1);
18725
- const [moved] = cells.splice(change.from, 1);
18726
- cells.splice(change.to, 0, moved);
18727
- }
18728
- next[row.id] = { ...row, childrens: cells };
18729
- });
18730
- return next;
18731
- }
18732
- function seedSectionTableRow(rowId, parentId, cellCount, genId2) {
18733
- const cells = Array.from(
18734
- { length: Math.max(1, cellCount) },
18735
- () => newCell(genId2(), rowId)
18736
- );
18737
- return {
18738
- [rowId]: {
18739
- id: rowId,
18740
- type: "section_table_row" /* SECTION_TABLE_ROW */,
18741
- parentId,
18742
- configs: {},
18743
- childrens: cells.map((cell) => cell.id)
18744
- },
18745
- ...Object.fromEntries(cells.map((cell) => [cell.id, cell]))
18746
- };
18747
- }
18748
-
18749
19464
  // libs/codegen/src/lib/search-codegen.ts
18750
19465
  var searchMemberName = (component) => {
18751
19466
  const stem = component.replace(/Component$/, "") || component;
@@ -19451,7 +20166,7 @@ function formModelShapeKeys(controlMap, formId) {
19451
20166
  return buildFormShape(controlMap, formId)?.keys ?? [];
19452
20167
  }
19453
20168
  function formModelKeyType(key2) {
19454
- if (key2.dataType.type === "shape" || key2.dataType.type === "form" || key2.dataType.type === "option" || key2.dataType.type === "audience") {
20169
+ if (key2.dataType.type === "shape" || key2.dataType.type === "form" || key2.dataType.type === "option" || key2.dataType.type === "audience" || key2.dataType.type === "enum") {
19455
20170
  return void 0;
19456
20171
  }
19457
20172
  if (!isKeyCardinality(key2.cardinality)) return void 0;
@@ -19499,7 +20214,7 @@ function formModelSourceType(source, scope) {
19499
20214
  input.cardinality
19500
20215
  );
19501
20216
  }
19502
- if (input.dataType.type === "form" || input.dataType.type === "option" || input.dataType.type === "audience") {
20217
+ if (input.dataType.type === "form" || input.dataType.type === "option" || input.dataType.type === "audience" || input.dataType.type === "enum") {
19503
20218
  return void 0;
19504
20219
  }
19505
20220
  if (source.member?.length) return void 0;
@@ -19518,7 +20233,7 @@ function formModelSourceType(source, scope) {
19518
20233
  fn.returnCardinality
19519
20234
  );
19520
20235
  }
19521
- if (fn.returnType.type === "form" || fn.returnType.type === "option" || fn.returnType.type === "audience") {
20236
+ if (fn.returnType.type === "form" || fn.returnType.type === "option" || fn.returnType.type === "audience" || fn.returnType.type === "enum") {
19522
20237
  return void 0;
19523
20238
  }
19524
20239
  if (source.member?.length) return void 0;
@@ -19740,7 +20455,7 @@ function screenVariableSourceType(source, scope) {
19740
20455
  const input = scope.inputs[source.inputId];
19741
20456
  if (!input || input.dataType.type === "shape") return void 0;
19742
20457
  if (input.dataType.type === "form") return void 0;
19743
- if (input.dataType.type === "file" || input.dataType.type === "option" || input.dataType.type === "audience") {
20458
+ if (input.dataType.type === "file" || input.dataType.type === "option" || input.dataType.type === "audience" || input.dataType.type === "enum") {
19744
20459
  return void 0;
19745
20460
  }
19746
20461
  if (!isVariableCardinality(input.cardinality)) return void 0;
@@ -19749,7 +20464,7 @@ function screenVariableSourceType(source, scope) {
19749
20464
  if (source.source === "computed") {
19750
20465
  const computed = scope.computeds[source.computedId];
19751
20466
  const fn = computed ? screenComputedFunction(computed, scope.functions) : void 0;
19752
- if (!fn || fn.returnType.type === "shape" || fn.returnType.type === "form" || fn.returnType.type === "file" || fn.returnType.type === "option" || fn.returnType.type === "audience") {
20467
+ if (!fn || fn.returnType.type === "shape" || fn.returnType.type === "form" || fn.returnType.type === "file" || fn.returnType.type === "option" || fn.returnType.type === "audience" || fn.returnType.type === "enum") {
19753
20468
  return void 0;
19754
20469
  }
19755
20470
  if (!isVariableCardinality(fn.returnCardinality)) return void 0;
@@ -19816,6 +20531,15 @@ function linkedVariableReaders(variables, source) {
19816
20531
  }
19817
20532
 
19818
20533
  // libs/codegen/src/lib/codegen-helper.ts
20534
+ var SORT_DIRECTION_ENUM = {
20535
+ id: SORT_DIRECTION_ENUM_ID,
20536
+ name: "SectionTableSortDirection",
20537
+ fileName: "",
20538
+ values: [...SORT_DIRECTION_VALUES],
20539
+ members: ["Asc", "Desc"],
20540
+ library: true
20541
+ };
20542
+ var enumImportLine = (entry2, fromTypeDir) => entry2.library ? `import { ${entry2.name} } from '@magmonium/one';` : `import { ${entry2.name} } from '${fromTypeDir}${enumModule(entry2)}';`;
19819
20543
  function variantGuard(node, names, storeProp) {
19820
20544
  const held = (node.variants ?? []).map((entry2) => {
19821
20545
  const name3 = names.get(entry2.id);
@@ -20177,6 +20901,11 @@ var NUMBER_ONLY_KEYS = /* @__PURE__ */ new Set(["xs", "sm", "md", "lg", "xl", "x
20177
20901
  var IMG_NUMBER_ONLY_KEYS = /* @__PURE__ */ new Set([...NUMBER_ONLY_KEYS, "width", "height"]);
20178
20902
  var FILTER_BOUND_SLOTS = [BINDING_SLOT.min, BINDING_SLOT.max];
20179
20903
  var FILTER_NUMBER_ONLY_KEYS = /* @__PURE__ */ new Set([...NUMBER_ONLY_KEYS, "min", "max"]);
20904
+ var SCORE_ITEM_NUMBER_ONLY_KEYS = /* @__PURE__ */ new Set([...NUMBER_ONLY_KEYS, "value"]);
20905
+ var SCORE_SET_NUMBER_ONLY_KEYS = /* @__PURE__ */ new Set([
20906
+ ...NUMBER_ONLY_KEYS,
20907
+ "staleAfterDays"
20908
+ ]);
20180
20909
  var SECTION_TABLE_INPUTS = /* @__PURE__ */ new Set([
20181
20910
  "sticky",
20182
20911
  "margin",
@@ -20353,13 +21082,82 @@ function actionEnums(tree) {
20353
21082
  walk(tree);
20354
21083
  return out;
20355
21084
  }
21085
+ var enumMemberName = (entry2, index) => entry2.members?.[index] ?? toPascalCase(entry2.values[index] ?? "");
20356
21086
  var actionEnumFile = (entry2) => ({
20357
21087
  fileName: `${TYPE_SEGMENT}/${entry2.fileName}`,
20358
21088
  contents: `export enum ${entry2.name} {
20359
- ${entry2.values.map((value) => ` ${toPascalCase(value)} = '${value}',`).join("\n")}
21089
+ ${entry2.values.map((value, i) => ` ${enumMemberName(entry2, i)} = '${value}',`).join("\n")}
20360
21090
  }
20361
21091
  `
20362
21092
  });
21093
+ var enumModule = (entry2) => entry2.fileName.replace(/\.ts$/, "");
21094
+ var sortMemberNames = (values) => {
21095
+ const taken = /* @__PURE__ */ new Set();
21096
+ return values.map((value) => {
21097
+ const pascal4 = toPascalCase(value.replace(/[^A-Za-z0-9]+/g, "-")) || "Column";
21098
+ const base = /^[0-9]/.test(pascal4) ? `_${pascal4}` : pascal4;
21099
+ let name3 = base;
21100
+ for (let n = 2; taken.has(name3); n += 1) name3 = `${base}${n}`;
21101
+ taken.add(name3);
21102
+ return name3;
21103
+ });
21104
+ };
21105
+ function sectionTableSortEnums(controlMap, taken = /* @__PURE__ */ new Set()) {
21106
+ return sectionTableEmissions(controlMap).flatMap((emission) => {
21107
+ const values = sectionTableSortIds(emission.columns);
21108
+ if (!values.length) return [];
21109
+ const base = `${toPascalCase(
21110
+ emission.memberName.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)
21111
+ )}SortColumn`;
21112
+ let name3 = base;
21113
+ for (let n = 2; taken.has(name3); n += 1) name3 = `${base}${n}`;
21114
+ taken.add(name3);
21115
+ return [
21116
+ {
21117
+ id: emission.id,
21118
+ name: name3,
21119
+ fileName: `${name3.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`).replace(/^-/, "")}.ts`,
21120
+ values,
21121
+ members: sortMemberNames(values)
21122
+ }
21123
+ ];
21124
+ });
21125
+ }
21126
+ function controlEnums(screens) {
21127
+ const actions = actionEnums(screens.flatMap((screen) => screen.tree));
21128
+ const taken = /* @__PURE__ */ new Set([...actions.map((entry2) => entry2.name), SORT_DIRECTION_ENUM.name]);
21129
+ const hasTable = screens.some(
21130
+ (screen) => Object.values(screen.controlMap).some(
21131
+ (control) => control.type === "section_table" /* SECTION_TABLE */
21132
+ )
21133
+ );
21134
+ return [
21135
+ ...actions,
21136
+ ...screens.flatMap(
21137
+ (screen) => sectionTableSortEnums(screen.controlMap, taken)
21138
+ ),
21139
+ ...hasTable ? [SORT_DIRECTION_ENUM] : []
21140
+ ];
21141
+ }
21142
+ var withScreenEnums = (ctx, tree) => {
21143
+ const variables = ctx.variables ? withVariableEnums(ctx.variables, ctx.controlMap ?? {}) : void 0;
21144
+ if (ctx.enums && variables === ctx.variables) return ctx;
21145
+ return {
21146
+ ...ctx,
21147
+ ...variables ? { variables } : {},
21148
+ enums: ctx.enums ?? controlEnums([{ tree, controlMap: ctx.controlMap ?? {} }])
21149
+ };
21150
+ };
21151
+ function screenVariableEnums(ctx) {
21152
+ const out = /* @__PURE__ */ new Map();
21153
+ const controls = ctx.controlMap ?? {};
21154
+ Object.values(withVariableEnums(ctx.variables ?? {}, controls)).forEach((variable) => {
21155
+ const id = variable.actionEnumId ?? variable.sortEnumId;
21156
+ const entry2 = id ? ctx.enums?.find((candidate) => candidate.id === id) : void 0;
21157
+ if (entry2) out.set(variable.id, entry2);
21158
+ });
21159
+ return out;
21160
+ }
20363
21161
  function sectionTableEmissions(controlMap) {
20364
21162
  const used = /* @__PURE__ */ new Set();
20365
21163
  return Object.values(controlMap).filter((control) => control.type === "section_table" /* SECTION_TABLE */).map((control) => ({
@@ -20378,25 +21176,44 @@ function sectionTableEmissions(controlMap) {
20378
21176
  });
20379
21177
  }
20380
21178
  var sectionTablesFileBase = (fileBase) => `${fileBase}-tables`;
20381
- function sectionTableFiles(emissions, fileBase) {
21179
+ function sectionTableFiles(emissions, fileBase, enums) {
20382
21180
  if (!emissions.length) return [];
20383
- const consts = emissions.map(
20384
- (emission) => `export const ${emission.memberName}: SectionTableConfig = {
20385
- columns: ${JSON.stringify(
20386
- emission.columns,
20387
- null,
20388
- 2
20389
- ).split("\n").join("\n ")},
21181
+ const enumOf = (id) => enums.find((entry2) => entry2.id === id);
21182
+ const columnsLiteral = (emission) => {
21183
+ const entry2 = enumOf(emission.id);
21184
+ if (!entry2) return JSON.stringify(emission.columns, null, 2);
21185
+ const member = (id) => `${entry2.name}.${enumMemberName(entry2, entry2.values.indexOf(id))}`;
21186
+ const columns = emission.columns.map((column) => {
21187
+ const { id, ...rest } = column;
21188
+ return id && entry2.values.includes(id) ? { id: `\0${member(id)}\0`, ...rest } : rest;
21189
+ });
21190
+ return JSON.stringify(columns, null, 2).replace(
21191
+ /"\\u0000([^"\\]+)\\u0000"/g,
21192
+ "$1"
21193
+ );
21194
+ };
21195
+ const consts = emissions.map((emission) => {
21196
+ const entry2 = enumOf(emission.id);
21197
+ return `export const ${emission.memberName}: SectionTableConfig${entry2 ? `<${entry2.name}>` : ""} = {
21198
+ columns: ${columnsLiteral(emission).split("\n").join("\n ")},
20390
21199
  };
21200
+ `;
21201
+ }).join("\n");
21202
+ const enumImports = emissions.map((emission) => enumOf(emission.id)).filter((entry2) => !!entry2).map(
21203
+ (entry2) => `import { ${entry2.name} } from './${enumModule(entry2)}';
20391
21204
  `
20392
- ).join("\n");
21205
+ ).join("");
20393
21206
  return [
20394
21207
  {
20395
21208
  fileName: `${TYPE_SEGMENT}/${sectionTablesFileBase(fileBase)}.ts`,
20396
21209
  contents: `import type { SectionTableConfig } from '@magmonium/one';
20397
-
21210
+ ${enumImports}
20398
21211
  ${consts}`
20399
- }
21212
+ },
21213
+ // The enums themselves, beside the const that names them. A Feature emits
21214
+ // its own once more among its type files; the path and the text are the
21215
+ // same, and the second write is dropped (emit-app-files `written`).
21216
+ ...emissions.map((emission) => enumOf(emission.id)).filter((entry2) => !!entry2).map(actionEnumFile)
20400
21217
  ];
20401
21218
  }
20402
21219
  function actionButtonsAttr(node, names) {
@@ -20409,6 +21226,8 @@ function inlineAttrs(node) {
20409
21226
  var numberOnlyKeysOf = (type) => {
20410
21227
  if (type === "img" /* IMG */) return IMG_NUMBER_ONLY_KEYS;
20411
21228
  if (type === "section_filter" /* SECTION_FILTER */) return FILTER_NUMBER_ONLY_KEYS;
21229
+ if (type === "score_set_item" /* SCORE_SET_ITEM */) return SCORE_ITEM_NUMBER_ONLY_KEYS;
21230
+ if (type === "score_set" /* SCORE_SET */) return SCORE_SET_NUMBER_ONLY_KEYS;
20412
21231
  return NUMBER_ONLY_KEYS;
20413
21232
  };
20414
21233
  function wrapInGuard(markup, guard, pad2) {
@@ -20662,6 +21481,8 @@ var attrBindingSlots = (type) => {
20662
21481
  if (type === "app_logo" /* APP_LOGO */) return APP_LOGO_VALUE_SLOTS;
20663
21482
  if (type === "section_pagination" /* SECTION_PAGINATION */) return [BINDING_SLOT.total];
20664
21483
  if (type === "heat_swatch" /* HEAT_SWATCH */) return [BINDING_SLOT.value];
21484
+ if (type === "score_set_item" /* SCORE_SET_ITEM */) return [BINDING_SLOT.value];
21485
+ if (type === "score_set" /* SCORE_SET */) return [BINDING_SLOT.scoreDate];
20665
21486
  if (type === "section_chart_series" /* SECTION_CHART_SERIES */)
20666
21487
  return [BINDING_SLOT.data, BINDING_SLOT.label];
20667
21488
  return hasTextSource(type) ? [BINDING_SLOT.label] : [];
@@ -20724,6 +21545,47 @@ var bindingScope = (ctx, storeProp) => ({
20724
21545
  // would spell a member on an object the class never injected (ADR 0040).
20725
21546
  storeProp: ctx.hasStore ? storeProp : void 0
20726
21547
  });
21548
+ var screenComputedPresentIn = (ctx, computedId) => {
21549
+ const computed = ctx.screenComputeds?.[computedId];
21550
+ return !!computed && !screenComputedIsOptional(
21551
+ computed,
21552
+ screenComputedFunction(computed, ctx.functions ?? {}),
21553
+ ctx.inputs ?? {},
21554
+ ctx.screenComputeds ?? {},
21555
+ ctx.functions ?? {}
21556
+ );
21557
+ };
21558
+ var screenSourceReader = (ctx, scope) => (binding) => {
21559
+ switch (binding.kind) {
21560
+ case "input": {
21561
+ const input = ctx.inputs?.[binding.inputId];
21562
+ return { cardinality: input?.cardinality, present: !!input?.required };
21563
+ }
21564
+ case "variable":
21565
+ return {
21566
+ cardinality: ctx.variables?.[binding.variableId]?.cardinality,
21567
+ present: false
21568
+ };
21569
+ case "constant":
21570
+ case "enum-member":
21571
+ return { cardinality: "one", present: true };
21572
+ case "computed": {
21573
+ const computed = ctx.screenComputeds?.[binding.computedId];
21574
+ const fn = computed ? screenComputedFunction(computed, ctx.functions ?? {}) : void 0;
21575
+ return {
21576
+ cardinality: fn ? returnCardinalityOf(fn) : void 0,
21577
+ present: screenComputedPresentIn(ctx, binding.computedId)
21578
+ };
21579
+ }
21580
+ case "data":
21581
+ return {
21582
+ cardinality: bindingCardinality(binding.binding, scope),
21583
+ present: bindingAlwaysPresent(binding.binding, scope)
21584
+ };
21585
+ default:
21586
+ return { cardinality: void 0, present: true };
21587
+ }
21588
+ };
20727
21589
  var callArgBindings = (ctx, storeProp, where = {}) => ({
20728
21590
  bindingScope: {
20729
21591
  ...bindingScope(ctx, storeProp),
@@ -20743,6 +21605,7 @@ var callArgBindings = (ctx, storeProp, where = {}) => ({
20743
21605
  screenComputeds: ctx.screenComputeds,
20744
21606
  screenVariables: ctx.variables,
20745
21607
  functions: ctx.functions,
21608
+ enums: ctx.appEnums,
20746
21609
  allowAlias: !where.memberPrefix
20747
21610
  }
20748
21611
  });
@@ -20791,7 +21654,7 @@ var boundCardinality = (binding, ctx) => {
20791
21654
  }
20792
21655
  case "screen_variable": {
20793
21656
  const variable = ctx.variables?.[binding.root.id];
20794
- dataType = variable ? { type: variable.dataType } : void 0;
21657
+ dataType = variable ? screenVariableDataType(variable) : void 0;
20795
21658
  cardinality = variable?.cardinality;
20796
21659
  break;
20797
21660
  }
@@ -20896,6 +21759,14 @@ function boundAttrs(node, ctx, storeProp) {
20896
21759
  const expr = bindingExpression(bindings[BINDING_SLOT.value], scope);
20897
21760
  if (expr) parts.push(` [value]="${expr}"`);
20898
21761
  }
21762
+ if (node.type === "score_set_item" /* SCORE_SET_ITEM */ && bindings?.[BINDING_SLOT.value]) {
21763
+ const expr = bindingExpression(bindings[BINDING_SLOT.value], scope);
21764
+ if (expr) parts.push(` [value]="${expr}"`);
21765
+ }
21766
+ if (node.type === "score_set" /* SCORE_SET */ && bindings?.[BINDING_SLOT.scoreDate]) {
21767
+ const expr = bindingExpression(bindings[BINDING_SLOT.scoreDate], scope);
21768
+ if (expr) parts.push(` [scoreDate]="${expr}"`);
21769
+ }
20899
21770
  if (node.type === "section_chart_series" /* SECTION_CHART_SERIES */ && bindings?.[BINDING_SLOT.data]) {
20900
21771
  const expr = bindingExpression(bindings[BINDING_SLOT.data], scope);
20901
21772
  if (expr) parts.push(` [data]="${expr}"`);
@@ -21067,6 +21938,12 @@ function tagAttrs(node, ctx, storeProp) {
21067
21938
  delete configs2[BINDING_SLOT.value];
21068
21939
  return `${inlineAttrs({ ...node, configs: configs2 })}${boundAttrs(node, ctx, storeProp)}`;
21069
21940
  }
21941
+ const scoreSlot = node.type === "score_set_item" /* SCORE_SET_ITEM */ ? BINDING_SLOT.value : node.type === "score_set" /* SCORE_SET */ ? BINDING_SLOT.scoreDate : void 0;
21942
+ if (scoreSlot && ctx.controlMap?.[node.id]?.bindings?.[scoreSlot]) {
21943
+ const configs2 = { ...node.configs ?? {} };
21944
+ delete configs2[scoreSlot];
21945
+ return `${inlineAttrs({ ...node, configs: configs2 })}${boundAttrs(node, ctx, storeProp)}`;
21946
+ }
21070
21947
  if (node.type === "section_filter" /* SECTION_FILTER */) {
21071
21948
  const bindings = ctx.controlMap?.[node.id]?.bindings;
21072
21949
  const configs2 = { ...node.configs ?? {} };
@@ -21405,6 +22282,13 @@ function statePatchFor(node, output, payload, storeProp, ctx, writes = node.outp
21405
22282
  if (!properties) return void 0;
21406
22283
  const rows = stateWriteRows(writes, output);
21407
22284
  if (!rows.length) return void 0;
22285
+ const enumById = new Map((ctx.enums ?? []).map((entry2) => [entry2.id, entry2]));
22286
+ const enumOf = ({ id }) => {
22287
+ const dataType = properties[id]?.dataType;
22288
+ const enumId = dataType?.actionEnumId ?? dataType?.sortEnumId;
22289
+ return enumId ? enumById.get(enumId) : void 0;
22290
+ };
22291
+ const root = actionEventRoot(node, eventRoot, enumOf);
21408
22292
  return stateWritePatchExpression(
21409
22293
  properties,
21410
22294
  rows,
@@ -21420,13 +22304,14 @@ function statePatchFor(node, output, payload, storeProp, ctx, writes = node.outp
21420
22304
  // resolve was a row the panel called complete and codegen dropped in
21421
22305
  // silence, taking every other row on the output with it (ADR 0043).
21422
22306
  ctx.constants ?? {},
21423
- eventRoot,
22307
+ root,
21424
22308
  scope,
21425
22309
  // A FilterGroup's payload is keyed by its Filters and its value type is the
21426
22310
  // union of what any of them carries, so a member read is cast down to that
21427
22311
  // Filter's own shape (libs/one ADR 0026). Undefined for every other
21428
22312
  // Control, whose members are already typed.
21429
- filterGroupEventMember(node)
22313
+ filterGroupEventMember(node),
22314
+ enumNarrow(node, output, enumOf)
21430
22315
  );
21431
22316
  }
21432
22317
  function screenWritesFor(node, output, payload, ctx, writes = node.outputScreenWrites, eventRoot = "$event", scope = "template") {
@@ -21434,6 +22319,9 @@ function screenWritesFor(node, output, payload, ctx, writes = node.outputScreenW
21434
22319
  if (!variables) return [];
21435
22320
  const rows = screenWriteRows(writes, output);
21436
22321
  if (!rows.length) return [];
22322
+ const enums = screenVariableEnums(ctx);
22323
+ const enumOf = ({ id }) => enums.get(id);
22324
+ const root = actionEventRoot(node, eventRoot, enumOf);
21437
22325
  return screenWriteStatements(
21438
22326
  variables,
21439
22327
  rows,
@@ -21443,11 +22331,38 @@ function screenWritesFor(node, output, payload, ctx, writes = node.outputScreenW
21443
22331
  [],
21444
22332
  ctx.inputs ?? {},
21445
22333
  ctx.constants ?? {},
21446
- eventRoot,
22334
+ root,
21447
22335
  scope,
21448
- filterGroupEventMember(node)
22336
+ filterGroupEventMember(node),
22337
+ enumNarrow(node, output, enumOf)
21449
22338
  );
21450
22339
  }
22340
+ function enumNarrow(node, output, enumOf) {
22341
+ return (target, value, expr) => {
22342
+ const entry2 = enumOf(target);
22343
+ if (!entry2 || value.kind === "clear") return expr;
22344
+ if (value.kind === "event") {
22345
+ if (node.type === "section_action" /* SECTION_ACTION */ && !value.path?.length) {
22346
+ return expr;
22347
+ }
22348
+ const sorted = node.type === "section_table" /* SECTION_TABLE */ && baseOutputName(output) === SECTION_TABLE_SORT_OUTPUT && sortRowEnumId(node.id, value.path) === entry2.id;
22349
+ if (sorted) return expr;
22350
+ }
22351
+ if (value.kind === "fixed") {
22352
+ const index = entry2.values.indexOf(value.value);
22353
+ if (index >= 0) return `${entry2.name}.${enumMemberName(entry2, index)}`;
22354
+ }
22355
+ return `${ENUM_VALUE_READER}(${expr}, ${entry2.name})`;
22356
+ };
22357
+ }
22358
+ function actionEventRoot(node, eventRoot, enumOf) {
22359
+ const bare = /^(.+)\?\.name \?\? ''$/.exec(eventRoot);
22360
+ if (node.type !== "section_action" /* SECTION_ACTION */ || !bare) return eventRoot;
22361
+ return (target) => {
22362
+ const entry2 = enumOf(target);
22363
+ return entry2 ? `${ACTION_NAME_READER}(${bare[1]}, ${entry2.name})` : eventRoot;
22364
+ };
22365
+ }
21451
22366
  function screenEmitsFor(node, trigger, payload, ctx, emits = node.outputEmits, eventRoot = "$event", scope = "template", storeProp = "") {
21452
22367
  const outputs = ctx.outputs;
21453
22368
  if (!outputs) return [];
@@ -21554,6 +22469,20 @@ function payloadAttr(node, payloads) {
21554
22469
  const prop = payloads.get(payloadPropKey(node));
21555
22470
  return prop && !prop.modeled ? ` [data]="${prop.name}!"` : "";
21556
22471
  }
22472
+ function sectionTableRowItemAttr(node, controlMap) {
22473
+ if (node.type !== "section_table_row" /* SECTION_TABLE_ROW */ || !controlMap) return "";
22474
+ const seen = /* @__PURE__ */ new Set();
22475
+ let current = controlMap[node.id];
22476
+ while (current?.parentId && !seen.has(current.id)) {
22477
+ seen.add(current.id);
22478
+ current = controlMap[current.parentId];
22479
+ if (current?.type === "repeat" /* REPEAT */) {
22480
+ return ` [item]="${repeatSpec(current).itemAlias}"`;
22481
+ }
22482
+ if (current?.type === "section_table" /* SECTION_TABLE */) return "";
22483
+ }
22484
+ return "";
22485
+ }
21557
22486
  function renderTag(node, indent2, names, methods, operationOf, storeProp, ctx, wires, payloads) {
21558
22487
  const pad2 = " ".repeat(indent2);
21559
22488
  if (node.type === "screen" /* SCREEN */) {
@@ -21563,16 +22492,7 @@ function renderTag(node, indent2, names, methods, operationOf, storeProp, ctx, w
21563
22492
  ctx,
21564
22493
  (binding) => bindingExpression(binding, guardScope),
21565
22494
  (binding) => bindingAlwaysPresent(binding, guardScope),
21566
- (computedId) => {
21567
- const computed = ctx.screenComputeds?.[computedId];
21568
- return !!computed && !screenComputedIsOptional(
21569
- computed,
21570
- screenComputedFunction(computed, ctx.functions ?? {}),
21571
- ctx.inputs ?? {},
21572
- ctx.screenComputeds ?? {},
21573
- ctx.functions ?? {}
21574
- );
21575
- }
22495
+ (computedId) => screenComputedPresentIn(ctx, computedId)
21576
22496
  );
21577
22497
  const inputAliases = new Map(
21578
22498
  guards.map((guard) => [guard.expression, guard.alias])
@@ -21632,7 +22552,8 @@ function renderTag(node, indent2, names, methods, operationOf, storeProp, ctx, w
21632
22552
  // sits in, a StateProperty — emits through the same walk every other
21633
22553
  // bound slot does (GLOSSARY.md DataBinding).
21634
22554
  (binding) => bindingExpression(binding, bindingScope(ctx, storeProp)),
21635
- inputAliases
22555
+ inputAliases,
22556
+ screenSourceReader(ctx, guardScope)
21636
22557
  );
21637
22558
  if (bound === void 0) {
21638
22559
  const name3 = node.handRef ?? node.screenId ?? "an embedded Screen";
@@ -21680,7 +22601,7 @@ ${" ".repeat(indent2 + index)}}`,
21680
22601
  ctx.overlayNames,
21681
22602
  bindingScope(ctx, storeProp),
21682
22603
  ctx.controlMap?.[node.id]?.bindings
21683
- )}${outputAttrs(node, methods, operationOf, storeProp, ctx)}`;
22604
+ )}${sectionTableRowItemAttr(node, ctx.controlMap)}${outputAttrs(node, methods, operationOf, storeProp, ctx)}`;
21684
22605
  if (node.type === "section_action" /* SECTION_ACTION */) {
21685
22606
  return `${pad2}<${tag}${attrs}${actionButtonsAttr(node, ctx.actionButtonNames)} />`;
21686
22607
  }
@@ -21768,6 +22689,7 @@ ${pad2}</${tag}>` : `${pad2}<${tag}${attrs} />`;
21768
22689
  }
21769
22690
  function planScreenEmit(tree, variants = {}, featureName = "feature", ctx = {}) {
21770
22691
  const writtenTags = /* @__PURE__ */ new Set();
22692
+ ctx = withScreenEnums(ctx, tree);
21771
22693
  return {
21772
22694
  ctx: {
21773
22695
  ...ctx,
@@ -21788,7 +22710,7 @@ function planScreenEmit(tree, variants = {}, featureName = "feature", ctx = {})
21788
22710
  }
21789
22711
  function generateHtml(tree, variants = {}, methods = {}, operationOf = () => void 0, featureName = "feature", ctx = {}, plan) {
21790
22712
  const codegenCtx = plan?.ctx ?? {
21791
- ...ctx,
22713
+ ...withScreenEnums(ctx, tree),
21792
22714
  translateParamsMember: ctx.translateParamsMember ?? `${toCamelCase(slugifyComponentName(featureName))}TranslateParams`,
21793
22715
  // Assigned here rather than per node: a name is unique across the Screen or
21794
22716
  // it is not unique at all, and the class assigns the same names from the
@@ -21931,6 +22853,18 @@ function collectPayloadReaders(tree, methods, operationOf, storeProp, ctx) {
21931
22853
  walk(tree);
21932
22854
  return [...used].sort();
21933
22855
  }
22856
+ function everyOutputAttrs(tree, methods, operationOf, storeProp, ctx) {
22857
+ const out = [];
22858
+ const walk = (nodes) => nodes.forEach((node) => {
22859
+ out.push(outputAttrs(node, methods, operationOf, storeProp, ctx));
22860
+ walk(node.childrens);
22861
+ });
22862
+ walk(tree);
22863
+ return out.join("\n");
22864
+ }
22865
+ var ENUM_READERS = [ACTION_NAME_READER, ENUM_VALUE_READER];
22866
+ var enumReadersIn = (text2) => ENUM_READERS.filter((reader) => text2.includes(`${reader}(`));
22867
+ var enumsNamedIn = (text2, enums) => enums.filter((entry2) => new RegExp(`\\b${entry2.name}\\b`).test(text2));
21934
22868
  function hasStateWrite(tree, ctx) {
21935
22869
  if (!ctx.properties) return false;
21936
22870
  return tree.some(
@@ -22056,12 +22990,36 @@ var transformMembersBlock = (refs, functions) => {
22056
22990
  return decls.length ? `
22057
22991
  ${decls.map((d) => d.line).join("")}` : "";
22058
22992
  };
22059
- var inputDeclsBlock = (inputs, lookup) => {
22993
+ var enumMemberEnums = (controls, appEnums = {}) => {
22994
+ const ids = /* @__PURE__ */ new Set();
22995
+ const add = (binding) => {
22996
+ if (binding.kind === "enum-member") ids.add(binding.enumId);
22997
+ };
22998
+ Object.values(controls).forEach((control) => {
22999
+ Object.values(control.screenInputs ?? {}).forEach(add);
23000
+ Object.keys(control.outputOpens ?? {}).forEach((output) => {
23001
+ const open = outputOpenOf(control.outputOpens, output);
23002
+ if (!open) return;
23003
+ outputOpenInputs(open).forEach((row) => {
23004
+ if (row.value.kind === "screen") add(row.value.binding);
23005
+ });
23006
+ });
23007
+ });
23008
+ return [...ids].map((id) => appEnums[id]).filter((appEnum) => !!appEnum).sort((a, b) => a.name.localeCompare(b.name));
23009
+ };
23010
+ var inputDeclsBlock = (inputs, lookup, appEnums) => {
22060
23011
  if (!inputs.length) return "";
22061
- return "\n" + inputs.map(
22062
- ({ decl, required }) => ` readonly ${decl.name} = input${required ? ".required" : ""}<${componentInputTsType(decl, lookup)}>();
22063
- `
22064
- ).join("");
23012
+ return "\n" + inputs.map(({ decl, required }) => {
23013
+ let tsType;
23014
+ if (decl.dataType?.type === "enum") {
23015
+ const appEnum = appEnums?.[decl.dataType.enumId];
23016
+ tsType = appEnum ? appEnum.name : "string";
23017
+ } else {
23018
+ tsType = componentInputTsType(decl, lookup);
23019
+ }
23020
+ return ` readonly ${decl.name} = input${required ? ".required" : ""}<${tsType}>();
23021
+ `;
23022
+ }).join("");
22065
23023
  };
22066
23024
  var constantDeclsBlock = (constants) => {
22067
23025
  if (!constants.length) return "";
@@ -22179,18 +23137,17 @@ var variableDeclsBlock = (variables, scope) => {
22179
23137
  );
22180
23138
  };
22181
23139
  return "\n" + [...variables].sort((a, b) => a.name.localeCompare(b.name)).map((variable) => {
22182
- const type = tsTypeExpression(
22183
- {},
22184
- { type: variable.dataType },
22185
- variable.cardinality
22186
- );
23140
+ const entry2 = scope.enums?.get(variable.id);
23141
+ const type = entry2 ? entry2.name : tsTypeExpression({}, { type: variable.dataType }, variable.cardinality);
22187
23142
  const read = sourceRead(variable);
22188
23143
  if (read) {
22189
- return ` protected readonly ${variable.name} = linkedSignal<${type} | undefined>(() => ${read});
23144
+ const narrowed = entry2 ? `${ENUM_VALUE_READER}(${read}, ${entry2.name})` : read;
23145
+ return ` protected readonly ${variable.name} = linkedSignal<${type} | undefined>(() => ${narrowed});
22190
23146
  `;
22191
23147
  }
22192
23148
  const seed = screenVariableInitialAllowed(variable) ? (variable.initial ?? "").trim() : "";
22193
- const start = seed ? literalExpression(seed, { type: variable.dataType }) : "undefined";
23149
+ const member = entry2 ? entry2.values.indexOf(seed) : -1;
23150
+ const start = !seed ? "undefined" : entry2 ? member >= 0 ? `${entry2.name}.${enumMemberName(entry2, member)}` : "undefined" : literalExpression(seed, { type: variable.dataType });
22194
23151
  return ` protected readonly ${variable.name} = signal<${type} | undefined>(${start});
22195
23152
  `;
22196
23153
  }).join("");
@@ -22425,7 +23382,8 @@ function outputOpenEmit(node, output, ctx, storeProp, indent2 = " ", methods
22425
23382
  (binding) => bindingExpression(binding, {
22426
23383
  ...bindingScope(ctx, storeProp),
22427
23384
  memberPrefix: "this."
22428
- })
23385
+ }),
23386
+ screenSourceReader(ctx, bindingScope(ctx, storeProp))
22429
23387
  );
22430
23388
  if (!entries) return void 0;
22431
23389
  return {
@@ -23792,9 +24750,18 @@ ${read.map(([expr, local]) => ` const ${local} = ${expr};`).join("\n")}` :
23792
24750
  return emitted.length ? `
23793
24751
  ${emitted.join("")}` : "";
23794
24752
  }
23795
- var componentInputTypeImports = (inputs, lookup, shapes, featureName) => {
24753
+ var componentInputTypeImports = (inputs, lookup, shapes, featureName, appEnums) => {
23796
24754
  const roots = inputs.flatMap(componentInputShapeIds);
23797
- if (!roots.length) return "";
24755
+ const enumImports = [
24756
+ ...new Set(
24757
+ inputs.filter((input) => input.dataType?.type === "enum").map((input) => {
24758
+ const enumId = input.dataType.enumId;
24759
+ const appEnum = appEnums?.[enumId];
24760
+ return appEnum ? `import { ${appEnum.name} } from '../../../shared/type/${appEnum.fileName}';` : void 0;
24761
+ }).filter((line) => !!line)
24762
+ )
24763
+ ].sort();
24764
+ if (!roots.length && !enumImports.length) return "";
23798
24765
  const drawnPool = {
23799
24766
  ...Object.fromEntries(
23800
24767
  Object.entries(lookup).filter(([id]) => isSharedShapeId(id))
@@ -23815,7 +24782,7 @@ ${spec.map((shape) => ` ${shapeInterfaceName(shape.name)},`).sort().join(
23815
24782
  )}
23816
24783
  } from '../${TYPE_SEGMENT}/${apiTypesModule(featureName)}';`
23817
24784
  ] : [];
23818
- return [...drawnImports, ...specImports].join("\n") + "\n";
24785
+ return [...enumImports, ...drawnImports, ...specImports].join("\n") + "\n";
23819
24786
  };
23820
24787
  var variantNameMap = (variants) => new Map(
23821
24788
  listSelectableVariants(variants).map((variant) => [
@@ -23835,6 +24802,13 @@ function collectComponentImportEntries(tree, ctx = {}) {
23835
24802
  from: ref.importFrom,
23836
24803
  tag: ref.tag
23837
24804
  });
24805
+ if (screenControlLiftsInput(
24806
+ node,
24807
+ ctx,
24808
+ screenSourceReader(ctx, bindingScope(ctx, ""))
24809
+ )) {
24810
+ entries.push({ component: "ToListPipe", from: ONE_IMPORT_MODULE });
24811
+ }
23838
24812
  }
23839
24813
  } else {
23840
24814
  const codegen = codegenFor(node.type);
@@ -23948,9 +24922,9 @@ function generateStateType(featureName, properties, shapes = {}, enums = [], ini
23948
24922
  const enumById = new Map(enums.map((entry2) => [entry2.id, entry2]));
23949
24923
  const enumImports = Array.from(
23950
24924
  new Set(
23951
- dataProperties.map((property) => property.dataType.actionEnumId).map((id) => id ? enumById.get(id) : void 0).filter((entry2) => !!entry2).map(
23952
- (entry2) => `import { ${entry2.name} } from './${entry2.fileName.replace(/\.ts$/, "")}';`
23953
- )
24925
+ dataProperties.map(
24926
+ (property) => property.dataType.actionEnumId ?? property.dataType.sortEnumId
24927
+ ).map((id) => id ? enumById.get(id) : void 0).filter((entry2) => !!entry2).map((entry2) => enumImportLine(entry2, "./"))
23954
24928
  )
23955
24929
  ).join("\n");
23956
24930
  const members = dataProperties.map(
@@ -24204,6 +25178,8 @@ ${lines.join("\n")}
24204
25178
  ...drawn.needsModal ? [MODAL_STORE] : [],
24205
25179
  // A `denied` arm's refusal is claimed off the library (api ADR 0005).
24206
25180
  ...drawn.needsDenial ? ["claimDenial"] : [],
25181
+ // A CallCondition asking a OneFunction (ADR 0202).
25182
+ ...drawn.oneFunctions ?? [],
24207
25183
  ...hooks.needsStorage || drawn.needsStorage || storageMethods.needsStorage ? [STORAGE_SERVICE] : [],
24208
25184
  // What the host's search box is read through, drawn per row the way every
24209
25185
  // other source's import is (ADR 0184).
@@ -24522,6 +25498,7 @@ function screenTouchedSubStores(ctx, tree, methods, operationOf, constants, clas
24522
25498
  );
24523
25499
  }
24524
25500
  function generateTs(tree, naming, featureName, variants = {}, methods = {}, operationOf = () => void 0, shapes = {}, ctx = {}, html, plan) {
25501
+ ctx = withScreenEnums(ctx, tree);
24525
25502
  const components = collectUsedComponents(
24526
25503
  tree,
24527
25504
  ctx,
@@ -24792,7 +25769,8 @@ ${tables.map(
24792
25769
  inputs.map((i) => i.decl),
24793
25770
  lookup,
24794
25771
  shapes,
24795
- featureName
25772
+ featureName,
25773
+ ctx.appEnums
24796
25774
  );
24797
25775
  const screenComputedsBody = screenComputedsBlock(
24798
25776
  screenComputeds,
@@ -24820,7 +25798,11 @@ ${tables.map(
24820
25798
  } : {},
24821
25799
  // Every CompositionKind: a `computed` arg walking into a sibling's shape
24822
25800
  // return needs the keys named whether or not a store is injected.
24823
- shapes
25801
+ shapes,
25802
+ // The Screen's own variables, which a `variable` arg reads as
25803
+ // `this.<name>()`. Missing here, every such arg emitted `undefined` and
25804
+ // the computed answered nothing however the variable moved.
25805
+ variables: ctx.variables ?? {}
24824
25806
  }
24825
25807
  );
24826
25808
  const menuConditionScreenRoots = screenPropertiesWithComputeds(
@@ -24992,11 +25974,28 @@ ${tables.map(
24992
25974
  storeProp,
24993
25975
  ctx
24994
25976
  );
24995
- const payloadReaderImport = payloadReaders.length ? `import { ${payloadReaders.join(", ")} } from '@magmonium/one';
25977
+ const templateText = html ?? everyOutputAttrs(tree, methods, operationOf, storeProp, ctx);
25978
+ const templateReaders = enumReadersIn(templateText);
25979
+ const templateEnums = enumsNamedIn(templateText, ctx.enums ?? []).map(
25980
+ (entry2) => entry2.name
25981
+ );
25982
+ const templateMembers = [
25983
+ .../* @__PURE__ */ new Set([...payloadReaders, ...templateReaders])
25984
+ ].sort();
25985
+ const payloadReaderImport = templateMembers.length ? `import { ${templateMembers.join(", ")} } from '@magmonium/one';
24996
25986
  ` : "";
24997
- const payloadReadersBody = payloadReaders.length ? "\n" + payloadReaders.map((reader) => ` protected readonly ${reader} = ${reader};
25987
+ const payloadReadersBody = templateMembers.length || templateEnums.length ? "\n" + [...templateMembers, ...templateEnums.sort()].map((reader) => ` protected readonly ${reader} = ${reader};
24998
25988
  `).join("") : "";
24999
- const assetOptionsImport = screenComputedsBody.includes("assetOptions(") ? `import { assetOptions } from '@magmonium/one';
25989
+ const oneFunctionImports = [
25990
+ ...new Set(
25991
+ Object.values(screenComputeds).filter((computed) => isOneFunctionComputed(computed)).map((computed) => computed.oneFunction).filter((name3) => screenComputedsBody.includes(`${name3}(`))
25992
+ )
25993
+ ];
25994
+ const libraryImports = [
25995
+ ...screenComputedsBody.includes("assetOptions(") ? ["assetOptions"] : [],
25996
+ ...oneFunctionImports
25997
+ ].sort();
25998
+ const assetOptionsImport = libraryImports.length ? `import { ${libraryImports.join(", ")} } from '@magmonium/one';
25000
25999
  ` : "";
25001
26000
  const busyImport = busyOnClass ? `import { ${BUSY_SIGNAL} } from '@magmonium/one';
25002
26001
  ` : "";
@@ -25017,14 +26016,16 @@ ${tables.map(
25017
26016
  protected readonly ${GLOBAL_METHOD_STORES[store].prop} = inject(${GLOBAL_METHOD_STORES[store].className});
25018
26017
  `
25019
26018
  ).join("");
25020
- const inputsBody = inputDeclsBlock(inputs, lookup);
26019
+ const inputsBody = inputDeclsBlock(inputs, lookup, ctx.appEnums);
25021
26020
  const constantsBody = constantDeclsBlock(Object.values(constants));
26021
+ const variableEnums = screenVariableEnums(ctx);
25022
26022
  const variablesBody = variableDeclsBlock(variables, {
25023
26023
  inputs: ctx.inputs ?? {},
25024
26024
  computeds: screenComputeds,
25025
26025
  ...needsStore ? { storeProp: featureStoreProp(featureName) } : {},
25026
26026
  properties: ctx.properties ?? {},
25027
- shapes
26027
+ shapes,
26028
+ enums: variableEnums
25028
26029
  });
25029
26030
  const formModels = Object.values(ctx.formModels ?? {});
25030
26031
  const formModelsBody = formModelDeclsBlock(formModels, {
@@ -25113,8 +26114,31 @@ ${tables.map(
25113
26114
  templateRefs,
25114
26115
  ctx.functions ?? {}
25115
26116
  );
26117
+ const memberEnums = enumMemberEnums(ctx.controlMap ?? {}, ctx.appEnums);
26118
+ const memberEnumImports = memberEnums.map(
26119
+ (appEnum) => `import { ${appEnum.name} } from '../../../shared/type/${appEnum.fileName}';`
26120
+ ).filter((line) => !inputTypeImports.includes(line)).map((line) => `${line}
26121
+ `).join("");
26122
+ const memberEnumsBody = memberEnums.length ? `
26123
+ ${memberEnums.map(
26124
+ (appEnum) => ` protected readonly ${appEnum.name} = ${appEnum.name};
26125
+ `
26126
+ ).join("")}` : "";
26127
+ const classText = `${variablesBody}${screenMethodsBody}${outcomeHandlersBody}${menuActionHandlersBody}${outputArmHandlersBody}${wiresBody}`;
26128
+ const enumNames = /* @__PURE__ */ new Set([
26129
+ ...[...variableEnums.values()].map((entry2) => entry2.name),
26130
+ ...templateEnums,
26131
+ ...enumsNamedIn(classText, ctx.enums ?? []).map((entry2) => entry2.name)
26132
+ ]);
26133
+ const enumImports = (ctx.enums ?? []).filter((entry2) => enumNames.has(entry2.name)).sort((a, b) => a.name.localeCompare(b.name)).map((entry2) => `${enumImportLine(entry2, `../${TYPE_SEGMENT}/`)}
26134
+ `).join("");
26135
+ const classReaders = enumReadersIn(classText).filter(
26136
+ (reader) => !templateMembers.includes(reader)
26137
+ );
26138
+ const classReaderImport = classReaders.length ? `import { ${classReaders.join(", ")} } from '@magmonium/one';
26139
+ ` : "";
25116
26140
  return `${angularImports}
25117
- ${`${outcomeHandlersBody}${menuActionHandlersBody}`.includes("$event: MenuItem") ? "import type { MenuItem } from '@magmonium/one';\n" : ""}${contextMenuConfigBody ? "import type { ContextMenu } from '@magmonium/one';\n" : ""}${audiencePickerConfigBody ? "import type { AudiencePicker } from '@magmonium/one';\n" : ""}${environmentImport}${inputTypeImports}${importsBlock}${validationImports}${sectionTableImport}${formModelImports}${storeImport}${busyImport}${authImport}${globalStoreImports}${modalImport}${overlayRefImport}${navRefImport}${navRouterImport}${assetOptionsImport}${payloadReaderImport}${screenFunctionImport}
26141
+ ${`${outcomeHandlersBody}${menuActionHandlersBody}`.includes("$event: MenuItem") ? "import type { MenuItem } from '@magmonium/one';\n" : ""}${contextMenuConfigBody ? "import type { ContextMenu } from '@magmonium/one';\n" : ""}${audiencePickerConfigBody ? "import type { AudiencePicker } from '@magmonium/one';\n" : ""}${environmentImport}${inputTypeImports}${memberEnumImports}${importsBlock}${validationImports}${sectionTableImport}${formModelImports}${storeImport}${busyImport}${authImport}${globalStoreImports}${modalImport}${overlayRefImport}${navRefImport}${navRouterImport}${assetOptionsImport}${payloadReaderImport}${classReaderImport}${enumImports}${screenFunctionImport}
25118
26142
  @Component({
25119
26143
  selector: '${naming.selector}',
25120
26144
  changeDetection: ChangeDetectionStrategy.OnPush,
@@ -25134,7 +26158,7 @@ ${`${outcomeHandlersBody}${menuActionHandlersBody}`.includes("$event: MenuItem")
25134
26158
  width: 100%
25135
26159
  \`,
25136
26160
  })
25137
- export class ${naming.className} {${storeBody}${busyBody}${authBody}${globalStoreBody}${modalBody}${overlayRefBody}${navRefBody}${navRouterBody}${imgApiOriginBody}${inputsBody}${constantsBody}${screenComputedsBody}${variablesBody}${formModelsBody}${screenVariantsBody}${cardsBody}${searchBody}${messageParamsBody}${outputsBody}${wiresBody}${overlayProps}${contextMenuConfigBody}${audiencePickerConfigBody}${payloadsBody}${transformMembersBody}${payloadReadersBody}${sectionTablesBody}${checksBody}${screenMethodsBody}${outputOpenBody}${outputLinkBody}${outcomeHandlersBody}${menuActionHandlersBody}${menuConditionBody}${outputArmHandlersBody}${autoCallsBody}}
26161
+ export class ${naming.className} {${storeBody}${busyBody}${authBody}${globalStoreBody}${modalBody}${overlayRefBody}${navRefBody}${navRouterBody}${imgApiOriginBody}${inputsBody}${constantsBody}${screenComputedsBody}${variablesBody}${formModelsBody}${screenVariantsBody}${cardsBody}${searchBody}${messageParamsBody}${outputsBody}${wiresBody}${overlayProps}${contextMenuConfigBody}${audiencePickerConfigBody}${payloadsBody}${transformMembersBody}${memberEnumsBody}${payloadReadersBody}${sectionTablesBody}${checksBody}${screenMethodsBody}${outputOpenBody}${outputLinkBody}${outcomeHandlersBody}${menuActionHandlersBody}${menuConditionBody}${outputArmHandlersBody}${autoCallsBody}}
25138
26162
  `;
25139
26163
  }
25140
26164
  function assetName(node) {
@@ -25249,7 +26273,8 @@ function generateCode(tree, featureName, screenName, properties = {}, variants =
25249
26273
  // that wanted it was dropped.
25250
26274
  properties: ctx.properties ?? properties,
25251
26275
  shapes: ctx.shapes ?? shapes,
25252
- translateParamsMember: ctx.translateParamsMember ?? `${toCamelCase(naming.fileBase)}TranslateParams`
26276
+ translateParamsMember: ctx.translateParamsMember ?? `${toCamelCase(naming.fileBase)}TranslateParams`,
26277
+ enums: withScreenEnums(ctx, tree).enums
25253
26278
  };
25254
26279
  const apiMethods = Object.values(ctx.subStores ?? {}).reduce(
25255
26280
  (acc, sub) => ({ ...acc, ...sub.methods }),
@@ -25276,7 +26301,9 @@ function generateCode(tree, featureName, screenName, properties = {}, variants =
25276
26301
  operationOf,
25277
26302
  shapes,
25278
26303
  codegenCtx,
25279
- void 0,
26304
+ // The template, which the class reads for the enum reads it declares
26305
+ // members for (ADR 0203); the tags it prunes by still come from `plan`.
26306
+ html,
25280
26307
  plan
25281
26308
  ),
25282
26309
  assets: collectControlAssets(tree, codegenCtx.controlMap),
@@ -25294,7 +26321,8 @@ function generateCode(tree, featureName, screenName, properties = {}, variants =
25294
26321
  ),
25295
26322
  sectionTableFiles: sectionTableFiles(
25296
26323
  sectionTableEmissions(ctx.controlMap ?? {}),
25297
- naming.fileBase
26324
+ naming.fileBase,
26325
+ codegenCtx.enums ?? []
25298
26326
  ),
25299
26327
  screenFacts: {
25300
26328
  className: naming.className,
@@ -25404,7 +26432,7 @@ function generateFeatureCode(feature, context) {
25404
26432
  // per store: each `withState` reads its own interface (ADR 0093).
25405
26433
  typeFiles: [
25406
26434
  ...generateShapeFiles(feature.shapes),
25407
- ...context.actionEnums.map(actionEnumFile),
26435
+ ...context.actionEnums.filter((entry2) => !entry2.library).map(actionEnumFile),
25408
26436
  ...apiTypes ? [{ fileName: apiTypesFile(feature.name), contents: apiTypes }] : [],
25409
26437
  ...stores.stateFiles
25410
26438
  ]
@@ -25466,7 +26494,7 @@ __export(package_exports, {
25466
26494
  version: () => version
25467
26495
  });
25468
26496
  var name = "@magmonium/one";
25469
- var version = "0.4.68";
26497
+ var version = "0.4.79";
25470
26498
  var description = "Magmonium One \u2014 Angular design-system primitives for mm Apps";
25471
26499
  var author = "magmonium";
25472
26500
  var license = "MIT";
@@ -25534,7 +26562,7 @@ __export(package_exports2, {
25534
26562
  version: () => version2
25535
26563
  });
25536
26564
  var name2 = "@magmonium/cli";
25537
- var version2 = "0.8.20";
26565
+ var version2 = "0.8.21";
25538
26566
  var description2 = "A powerful and extensible asset compilation tool that can be shared across multiple projects";
25539
26567
  var bin = {
25540
26568
  "mag-cli": "bin/cli.js"
@@ -25861,14 +26889,24 @@ function findNavRowShapeId(shapes) {
25861
26889
  )?.id;
25862
26890
  }
25863
26891
  var NEW_COMPUTED = "__new_computed__";
25864
- var navRowFeatureOptions = (features) => features.filter((feature) => navRowSourceOptions(feature).length > 0).map((feature) => ({ value: feature.id, label: feature.name }));
26892
+ var navRowFeatureOptions = (features, canAuthor = () => false) => features.filter(
26893
+ (feature) => canAuthor(feature.id) || navRowSourceOptions(feature).length > 0
26894
+ ).map((feature) => ({ value: feature.id, label: feature.name }));
26895
+ var navRowStoreOptions = (feature) => feature ? [
26896
+ { value: MAIN_STORE_VALUE, label: feature.name },
26897
+ ...subStoresOf(feature).map((subStore) => ({
26898
+ value: subStore.id,
26899
+ label: subStoreFullName(feature.name, subStore.name)
26900
+ }))
26901
+ ] : [];
25865
26902
  var newComputedOption = () => ({
25866
26903
  value: NEW_COMPUTED,
25867
26904
  label: "create-computed"
25868
26905
  });
25869
- function navRowSourceOptions(feature) {
26906
+ function navRowSourceOptions(feature, owner) {
25870
26907
  if (!feature) return [];
25871
- return storesOf(feature).flatMap(
26908
+ const value = owner && storeOwnerValue(owner);
26909
+ return storesOf(feature).filter((store) => !value || storeOwnerValue(store.owner) === value).flatMap(
25872
26910
  (store) => Object.values(store.computeds).filter((computed) => {
25873
26911
  const fn = feature.functions?.[computed.functionId];
25874
26912
  return !!fn && isNavRowShape(fn.returnType, fn.returnCardinality, feature.shapes);
@@ -27502,7 +28540,15 @@ function sanitizeDataType(value, shapes) {
27502
28540
  return typeof formId === "string" && formId ? { type: "form", formId } : fallback;
27503
28541
  }
27504
28542
  if (dataType.type === "option") return { type: "option" };
27505
- return dataType.type === "number" || dataType.type === "boolean" ? { type: dataType.type } : fallback;
28543
+ if (dataType.type === "number" || dataType.type === "boolean") {
28544
+ return { type: dataType.type };
28545
+ }
28546
+ const { actionEnumId, sortEnumId } = dataType;
28547
+ return {
28548
+ type: "string",
28549
+ ...typeof actionEnumId === "string" && actionEnumId ? { actionEnumId } : {},
28550
+ ...typeof sortEnumId === "string" && sortEnumId ? { sortEnumId } : {}
28551
+ };
27506
28552
  }
27507
28553
  function sanitizeCardinality(value) {
27508
28554
  const holder = value;
@@ -27846,7 +28892,12 @@ function sanitizeMethods(methods, properties, functions = {}) {
27846
28892
  const debounce = rawDebounce && typeof rawDebounce.id === "string" && !!rawDebounce.id && typeof rawDebounce.seconds === "number" && rawDebounce.seconds > 0 ? { id: rawDebounce.id, seconds: rawDebounce.seconds } : void 0;
27847
28893
  const functionCondition = (condition) => ({
27848
28894
  id: condition.id,
27849
- functionId: condition.functionId,
28895
+ // A OneFunction is held by name and keeps no register id (ADR 0202).
28896
+ functionId: condition.oneFunction ? "" : condition.functionId,
28897
+ ...condition.oneFunction ? {
28898
+ oneFunction: condition.oneFunction,
28899
+ ...condition.negate === true ? { negate: true } : {}
28900
+ } : {},
27850
28901
  args: Object.fromEntries(
27851
28902
  Object.entries(condition.args).filter(([, binding]) => {
27852
28903
  if (!binding) return false;
@@ -27857,7 +28908,7 @@ function sanitizeMethods(methods, properties, functions = {}) {
27857
28908
  )
27858
28909
  });
27859
28910
  const conditions = (Array.isArray(method.conditions) ? method.conditions : []).filter(
27860
- (condition) => !!condition && typeof condition.id === "string" && !!condition.id && (condition.kind === "check" ? !!condition.check && (condition.check.source === "store" || condition.check.source === "args") && RULE_OPERATORS.includes(condition.check.operator) : typeof condition.functionId === "string" && !!functions[condition.functionId] && !!condition.args && typeof condition.args === "object")
28911
+ (condition) => !!condition && typeof condition.id === "string" && !!condition.id && (condition.kind === "check" ? !!condition.check && (condition.check.source === "store" || condition.check.source === "args") && RULE_OPERATORS.includes(condition.check.operator) : (typeof condition.oneFunction === "string" ? !!condition.oneFunction : typeof condition.functionId === "string" && !!functions[condition.functionId]) && !!condition.args && typeof condition.args === "object")
27861
28912
  ).map((condition) => {
27862
28913
  const check = condition.check;
27863
28914
  if (condition.kind !== "check" || !check)
@@ -28245,8 +29296,18 @@ function sanitizeStateComputeds(value, functions, reservedNames) {
28245
29296
  var PRIMITIVE_TYPES = ["string", "number", "boolean"];
28246
29297
  var dataTypeName = (value) => value && typeof value === "object" ? value.type : value;
28247
29298
  var sanitizePrimitive = (value) => PRIMITIVE_TYPES.includes(value) ? value : "string";
28248
- var sanitizeInputDataType = (value, shapes) => value && typeof value === "object" && value.type === "shape" ? sanitizeDataType(value, shapes) : { type: sanitizePrimitive(dataTypeName(value)) };
28249
- function sanitizeScreenInputs(inputs, shapes) {
29299
+ var sanitizeInputDataType = (value, shapes, enums) => {
29300
+ if (value && typeof value === "object") {
29301
+ const type = value.type;
29302
+ if (type === "shape") return sanitizeDataType(value, shapes);
29303
+ if (type === "enum") {
29304
+ const enumId = value.enumId;
29305
+ return typeof enumId === "string" && enumId && enums[enumId] ? { type: "enum", enumId } : { type: "string" };
29306
+ }
29307
+ }
29308
+ return { type: sanitizePrimitive(dataTypeName(value)) };
29309
+ };
29310
+ function sanitizeScreenInputs(inputs, shapes, enums) {
28250
29311
  if (!inputs || typeof inputs !== "object") return {};
28251
29312
  const result = {};
28252
29313
  const takenNames = /* @__PURE__ */ new Set();
@@ -28260,7 +29321,7 @@ function sanitizeScreenInputs(inputs, shapes) {
28260
29321
  result[id] = {
28261
29322
  id,
28262
29323
  name: input.name,
28263
- dataType: sanitizeInputDataType(input.dataType, shapes),
29324
+ dataType: sanitizeInputDataType(input.dataType, shapes, enums),
28264
29325
  cardinality: sanitizeCardinality(input),
28265
29326
  ...input.required ? { required: true } : {},
28266
29327
  ...input.origin === "card" ? { origin: "card" } : {},
@@ -28656,8 +29717,26 @@ function sanitizeScreenComputeds(value, functions, inputs, constants, variables,
28656
29717
  continue;
28657
29718
  }
28658
29719
  const returns = computed.functionId ? void 0 : sanitizeComputedReturns(computed.returns);
29720
+ const oneFunction = !computed.functionId && typeof computed.oneFunction === "string" ? computed.oneFunction : void 0;
29721
+ if (oneFunction && returns && !oneFunctionOf(oneFunction)) {
29722
+ taken.add(computed.name);
29723
+ result[id] = {
29724
+ id,
29725
+ name: computed.name,
29726
+ oneFunction,
29727
+ args: computed.args ?? {},
29728
+ returns
29729
+ };
29730
+ continue;
29731
+ }
28659
29732
  const fn = computed.functionId ? functions[computed.functionId] : returns ? screenComputedFunction(
28660
- { id, name: computed.name, args: {}, returns },
29733
+ {
29734
+ id,
29735
+ name: computed.name,
29736
+ args: {},
29737
+ returns,
29738
+ ...oneFunction ? { oneFunction } : {}
29739
+ },
28661
29740
  {}
28662
29741
  ) : void 0;
28663
29742
  if (!fn) continue;
@@ -28679,7 +29758,13 @@ function sanitizeScreenComputeds(value, functions, inputs, constants, variables,
28679
29758
  fn.params.filter((param) => answers(stored[param.id])).map((param) => [param.id, stored[param.id]])
28680
29759
  );
28681
29760
  taken.add(computed.name);
28682
- result[id] = returns ? { id, name: computed.name, args, returns } : { id, name: computed.name, functionId: fn.id, args };
29761
+ result[id] = returns ? {
29762
+ id,
29763
+ name: computed.name,
29764
+ ...oneFunction ? { oneFunction } : {},
29765
+ args,
29766
+ returns
29767
+ } : { id, name: computed.name, functionId: fn.id, args };
28683
29768
  }
28684
29769
  return result;
28685
29770
  }
@@ -28687,16 +29772,25 @@ function sanitizeComputedReturns(value) {
28687
29772
  if (!value || typeof value !== "object") return void 0;
28688
29773
  const raw = value.dataType;
28689
29774
  const cardinality = sanitizeCardinality(value);
29775
+ const optional = value.optional === true ? { optional: true } : {};
28690
29776
  if (!raw || typeof raw !== "object") return void 0;
28691
29777
  if (raw.type === "shape" && typeof raw.shapeId === "string" && raw.shapeId)
28692
- return { dataType: { type: "shape", shapeId: raw.shapeId }, cardinality };
29778
+ return {
29779
+ dataType: { type: "shape", shapeId: raw.shapeId },
29780
+ cardinality,
29781
+ ...optional
29782
+ };
28693
29783
  if (raw.type === "form" && typeof raw.formId === "string" && raw.formId)
28694
- return { dataType: { type: "form", formId: raw.formId }, cardinality };
29784
+ return {
29785
+ dataType: { type: "form", formId: raw.formId },
29786
+ cardinality,
29787
+ ...optional
29788
+ };
28695
29789
  if (raw.type === "string" || raw.type === "number" || raw.type === "boolean" || raw.type === "option")
28696
- return { dataType: { type: raw.type }, cardinality };
29790
+ return { dataType: { type: raw.type }, cardinality, ...optional };
28697
29791
  return void 0;
28698
29792
  }
28699
- function sanitizeScreens(screens, features, appFunctions, sharedShapes = {}) {
29793
+ function sanitizeScreens(screens, features, appFunctions, sharedShapes = {}, enums = {}) {
28700
29794
  if (!Array.isArray(screens)) return [];
28701
29795
  const result = [];
28702
29796
  const seenIds = /* @__PURE__ */ new Set();
@@ -28721,10 +29815,14 @@ function sanitizeScreens(screens, features, appFunctions, sharedShapes = {}) {
28721
29815
  } else {
28722
29816
  meta = { id: screen.id, name: screen.name, kind };
28723
29817
  }
28724
- const inputs = sanitizeScreenInputs(screen.inputs, {
28725
- ...sharedShapes,
28726
- ...kind === "feature" && features[screen.featureId]?.shapes || {}
28727
- });
29818
+ const inputs = sanitizeScreenInputs(
29819
+ screen.inputs,
29820
+ {
29821
+ ...sharedShapes,
29822
+ ...kind === "feature" && features[screen.featureId]?.shapes || {}
29823
+ },
29824
+ enums
29825
+ );
28728
29826
  if (Object.keys(inputs).length) meta.inputs = inputs;
28729
29827
  const variants = sanitizeVariants(screen.variants);
28730
29828
  if (Object.keys(variants).length) meta.variants = variants;
@@ -28997,6 +30095,70 @@ function sanitizeDistinct(raw) {
28997
30095
  return [{ kind, ids: a < b ? [a, b] : [b, a] }];
28998
30096
  });
28999
30097
  }
30098
+ var ENUM_NAME = /^[A-Z][A-Za-z0-9]*$/;
30099
+ var ENUM_MEMBER_KEY = /^[A-Z][A-Z0-9_]*$/;
30100
+ function sanitizeEnums(raw) {
30101
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
30102
+ const result = {};
30103
+ const takenNames = /* @__PURE__ */ new Set();
30104
+ for (const [id, value] of Object.entries(raw)) {
30105
+ if (!value || typeof value !== "object") continue;
30106
+ const stored = value;
30107
+ if (typeof stored.name !== "string" || !ENUM_NAME.test(stored.name)) continue;
30108
+ if (takenNames.has(stored.name)) continue;
30109
+ const hasValue = stored.hasValue === true;
30110
+ const valueType = stored.valueType === "string" ? "string" : "number";
30111
+ const members = sanitizeEnumMembers(stored.members, hasValue, valueType);
30112
+ if (!members.length) continue;
30113
+ takenNames.add(stored.name);
30114
+ result[id] = {
30115
+ id,
30116
+ name: stored.name,
30117
+ // Derived rather than trusted, so a rename cannot leave the emitted path
30118
+ // disagreeing with the name beside it.
30119
+ fileName: enumFileBase(stored.name),
30120
+ members,
30121
+ hasValue,
30122
+ ...valueType === "string" ? { valueType } : {}
30123
+ };
30124
+ }
30125
+ return result;
30126
+ }
30127
+ var sanitizeEnumMembers = (raw, hasValue, valueType) => {
30128
+ if (!Array.isArray(raw)) return [];
30129
+ const members = [];
30130
+ const takenKeys = /* @__PURE__ */ new Set();
30131
+ const takenValues = /* @__PURE__ */ new Set();
30132
+ const takenTexts = /* @__PURE__ */ new Set();
30133
+ for (const entry2 of raw) {
30134
+ if (!entry2 || typeof entry2 !== "object") continue;
30135
+ const stored = entry2;
30136
+ if (typeof stored.key !== "string" || !ENUM_MEMBER_KEY.test(stored.key)) {
30137
+ continue;
30138
+ }
30139
+ if (takenKeys.has(stored.key)) continue;
30140
+ let value;
30141
+ if (hasValue && valueType === "string") {
30142
+ const given = typeof stored.value === "string" && stored.value.trim() ? stored.value : stored.key;
30143
+ let text2 = takenTexts.has(given) ? stored.key : given;
30144
+ for (let n = 2; takenTexts.has(text2); n++) text2 = `${stored.key}_${n}`;
30145
+ takenTexts.add(text2);
30146
+ value = text2;
30147
+ } else if (hasValue) {
30148
+ const given = typeof stored.value === "number" && Number.isFinite(stored.value) ? Math.trunc(stored.value) : void 0;
30149
+ value = given !== void 0 && !takenValues.has(given) ? given : 0;
30150
+ while (takenValues.has(value)) value += 1;
30151
+ takenValues.add(value);
30152
+ }
30153
+ takenKeys.add(stored.key);
30154
+ members.push({
30155
+ id: typeof stored.id === "string" && stored.id ? stored.id : stored.key,
30156
+ key: stored.key,
30157
+ ...value !== void 0 ? { value } : {}
30158
+ });
30159
+ }
30160
+ return members;
30161
+ };
29000
30162
  function relocateShapeTypedFunctions(appFunctions, features) {
29001
30163
  const misfiled = Object.values(appFunctions).filter(
29002
30164
  (fn) => featureShapeIds(fn).length > 0
@@ -29024,6 +30186,7 @@ function relocateShapeTypedFunctions(appFunctions, features) {
29024
30186
  }
29025
30187
  function decodeWorkspace(stored, docs) {
29026
30188
  const sharedShapes = sanitizeShapes(stored.sharedShapes, {}, "shared");
30189
+ const enums = sanitizeEnums(stored.enums);
29027
30190
  const appFunctions = sanitizePureFunctions(
29028
30191
  stored.functions,
29029
30192
  everyStoredShape(stored.features, sharedShapes)
@@ -29037,7 +30200,8 @@ function decodeWorkspace(stored, docs) {
29037
30200
  stored.screens,
29038
30201
  features,
29039
30202
  appFunctions,
29040
- sharedShapes
30203
+ sharedShapes,
30204
+ enums
29041
30205
  );
29042
30206
  const usedFeatures = new Set(
29043
30207
  screens.filter((screen) => screen.kind === "feature" && screen.featureId).map((screen) => screen.featureId)
@@ -29084,6 +30248,7 @@ function decodeWorkspace(stored, docs) {
29084
30248
  // it was found in.
29085
30249
  functions: refiled.functions,
29086
30250
  sharedShapes,
30251
+ enums,
29087
30252
  distinct: sanitizeDistinct(stored.distinct)
29088
30253
  },
29089
30254
  currentScreenId,
@@ -29294,6 +30459,7 @@ function buildDesignSource(ws, operations = drawnOperations(ws)) {
29294
30459
  screens: ws.screens.map(({ meta }) => meta),
29295
30460
  functions: ws.functions,
29296
30461
  sharedShapes: ws.sharedShapes ?? {},
30462
+ enums: ws.enums ?? {},
29297
30463
  distinct: ws.distinct ?? [],
29298
30464
  // Travels though GLOSSARY.md files it beside AiProvider: that grouping is
29299
30465
  // Reset Project's scope, not disk. This is a list of package names and
@@ -29436,6 +30602,7 @@ function readDesignSource(files3) {
29436
30602
  screens,
29437
30603
  functions: workspace.functions,
29438
30604
  sharedShapes: workspace.sharedShapes ?? {},
30605
+ enums: workspace.enums ?? {},
29439
30606
  distinct: workspace.distinct ?? [],
29440
30607
  npmAllowlist: sanitizeNpmAllowlist(stored.npmAllowlist),
29441
30608
  icons: workspace.icons,
@@ -29478,112 +30645,6 @@ var designSourceEmitted = (ws) => Object.entries(buildDesignSource(ws)).map(([pa
29478
30645
  contents
29479
30646
  }));
29480
30647
 
29481
- // libs/codegen/src/lib/tree-helper.ts
29482
- function buildTree(controlMap, rootControlIds, selection) {
29483
- const state = (id) => selection ? variantRenderState(id, controlMap, selection) : "solid";
29484
- const resolveDirectives = (ctrl) => {
29485
- if (!ctrl.directives) return void 0;
29486
- const resolved = {};
29487
- for (const [name3, directive] of Object.entries(ctrl.directives)) {
29488
- if (directive.overlayId) {
29489
- const overlay = controlMap[directive.overlayId];
29490
- if (overlay) {
29491
- resolved[name3] = {
29492
- overlayId: directive.overlayId,
29493
- type: overlay.type,
29494
- configs: overlay.configs
29495
- };
29496
- }
29497
- } else {
29498
- resolved[name3] = { configs: directive.configs ?? {} };
29499
- }
29500
- }
29501
- return Object.keys(resolved).length > 0 ? resolved : void 0;
29502
- };
29503
- const toNode = (ctrl) => {
29504
- const childrens = getChildren(ctrl.id);
29505
- const fullyFaded = state(ctrl.id) === "faded" && childrens.every((child) => child.faded);
29506
- return {
29507
- type: ctrl.type,
29508
- id: ctrl.id,
29509
- configs: ctrl.configs,
29510
- childrens,
29511
- directives: resolveDirectives(ctrl),
29512
- ...ctrl.source ? { source: ctrl.source } : {},
29513
- ...ctrl.variants?.length ? { variants: ctrl.variants } : {},
29514
- // Carried through so renderBranch can order the `@else` last and spell it
29515
- // without reaching back into ControlMap mid-walk (GLOSSARY.md DefaultArm).
29516
- ...ctrl.armKind ? { armKind: ctrl.armKind } : {},
29517
- ...ctrl.variantKind ? { variantKind: ctrl.variantKind } : {},
29518
- ...ctrl.outputs && Object.keys(ctrl.outputs).length ? { outputs: ctrl.outputs } : {},
29519
- ...ctrl.outputArgs && Object.keys(ctrl.outputArgs).length ? { outputArgs: ctrl.outputArgs } : {},
29520
- ...ctrl.outputWrites && Object.keys(ctrl.outputWrites).length ? { outputWrites: ctrl.outputWrites } : {},
29521
- ...ctrl.outputEmits && Object.keys(ctrl.outputEmits).length ? { outputEmits: ctrl.outputEmits } : {},
29522
- ...ctrl.outputScreenWrites && Object.keys(ctrl.outputScreenWrites).length ? { outputScreenWrites: ctrl.outputScreenWrites } : {},
29523
- ...ctrl.outputOpens && Object.keys(ctrl.outputOpens).length ? { outputOpens: ctrl.outputOpens } : {},
29524
- ...ctrl.outputNavs && Object.keys(ctrl.outputNavs).length ? { outputNavs: ctrl.outputNavs } : {},
29525
- ...ctrl.outputNewTabs && Object.keys(ctrl.outputNewTabs).length ? { outputNewTabs: ctrl.outputNewTabs } : {},
29526
- ...ctrl.outputOutcomes && Object.keys(ctrl.outputOutcomes).length ? { outputOutcomes: ctrl.outputOutcomes } : {},
29527
- // Without this the codegen walk reads `outputArms` off a Tree that never
29528
- // carried it, every gated output falls back to ungated, and its groups —
29529
- // filed under `<output>|arm:<armId>` — are skipped as qualified keys. The
29530
- // output emits nothing at all (GLOSSARY.md OutputArm).
29531
- ...ctrl.outputArms && Object.keys(ctrl.outputArms).length ? { outputArms: ctrl.outputArms } : {},
29532
- // Without this every group fires its first call alone: the rest are
29533
- // filed under `<group>|call:<callId>` and read in the order this holds
29534
- // (GLOSSARY.md OutputCall).
29535
- ...ctrl.outputCalls && Object.keys(ctrl.outputCalls).length ? { outputCalls: ctrl.outputCalls } : {},
29536
- ...ctrl.outputScreenMethods && Object.keys(ctrl.outputScreenMethods).length ? { outputScreenMethods: ctrl.outputScreenMethods } : {},
29537
- ...ctrl.menuActions?.length ? { menuActions: ctrl.menuActions } : {},
29538
- ...ctrl.screenId ? { screenId: ctrl.screenId } : {},
29539
- // The other answer to what a ScreenControl mounts (ADR 0088). Carried
29540
- // for `screenId`'s reason: the Canvas labels its placeholder from it and
29541
- // codegen emits its tag.
29542
- ...ctrl.handRef ? { handRef: ctrl.handRef } : {},
29543
- ...ctrl.screenInputs && Object.keys(ctrl.screenInputs).length ? { screenInputs: ctrl.screenInputs } : {},
29544
- // Carried for `screenId`'s reason: the Canvas draws the embed's box at
29545
- // it and codegen emits it on the tag.
29546
- ...ctrl.maxWidth ? { maxWidth: ctrl.maxWidth } : {},
29547
- ...ctrl.screenOutputs && Object.keys(ctrl.screenOutputs).length ? { screenOutputs: ctrl.screenOutputs } : {},
29548
- ...ctrl.screenOutputCalls && Object.keys(ctrl.screenOutputCalls).length ? { screenOutputCalls: ctrl.screenOutputCalls } : {},
29549
- ...ctrl.screenOutputWrites && Object.keys(ctrl.screenOutputWrites).length ? { screenOutputWrites: ctrl.screenOutputWrites } : {},
29550
- ...ctrl.screenOutputEmits && Object.keys(ctrl.screenOutputEmits).length ? { screenOutputEmits: ctrl.screenOutputEmits } : {},
29551
- ...ctrl.screenOutputScreenWrites && Object.keys(ctrl.screenOutputScreenWrites).length ? { screenOutputScreenWrites: ctrl.screenOutputScreenWrites } : {},
29552
- ...ctrl.checks?.length ? { checks: ctrl.checks } : {},
29553
- ...ctrl.formatPipes?.length ? { formatPipes: ctrl.formatPipes } : {},
29554
- ...ctrl.cards ? { cards: ctrl.cards } : {},
29555
- ...ctrl.search ? { search: ctrl.search } : {},
29556
- // A Repeat's row count, carried for `cards`' reason: the Canvas draws
29557
- // its sample rows from the Tree alone. Nothing else reads it — codegen
29558
- // never emits a count (GLOSSARY.md SampleValue).
29559
- ...ctrl.repeat?.sampleRows !== void 0 ? { sampleRows: ctrl.repeat.sampleRows } : {},
29560
- ...fullyFaded ? { faded: true } : {}
29561
- };
29562
- };
29563
- const getChildren = (parentId) => {
29564
- const parent = controlMap[parentId];
29565
- if (!parent || !parent.childrens) return [];
29566
- return parent.childrens.map((childId) => controlMap[childId]).filter(Boolean).filter((ctrl) => state(ctrl.id) !== "hidden").map(toNode);
29567
- };
29568
- const tree = rootControlIds.map((id) => controlMap[id]).filter(Boolean).filter((ctrl) => state(ctrl.id) !== "hidden").map(toNode);
29569
- return selection ? markFadedRoots(tree) : tree;
29570
- }
29571
- function markFadedRoots(nodes, underFaded = false) {
29572
- return nodes.map((node) => {
29573
- const faded = !underFaded && node.faded;
29574
- const next = {
29575
- ...node,
29576
- childrens: markFadedRoots(node.childrens, underFaded || !!node.faded)
29577
- };
29578
- if (faded) {
29579
- next.faded = true;
29580
- } else {
29581
- delete next.faded;
29582
- }
29583
- return next;
29584
- });
29585
- }
29586
-
29587
30648
  // libs/codegen/src/lib/overlay-widgets-helper.ts
29588
30649
  var overlayWidgetScreenIds = (maps) => {
29589
30650
  const ids = /* @__PURE__ */ new Set();
@@ -31760,7 +32821,11 @@ var pureFunctionTest = (path, fn, shapes) => ({
31760
32821
  (entry2) => block(
31761
32822
  entry2.name,
31762
32823
  [
31763
- `expect(await ${fn.name}(${entry2.args.join(", ")})).toEqual(${entry2.expected});`
32824
+ // A case is authored as literals, and a literal is no member
32825
+ // of an enum a parameter names: called the way the smoke test
32826
+ // above is, so `'total'` reaches it as the string it is at
32827
+ // runtime (ADR 0203).
32828
+ `expect(await ${namesEnum(fn) ? `(${fn.name} as (...args: unknown[]) => unknown)` : fn.name}(${entry2.args.join(", ")})).toEqual(${entry2.expected});`
31764
32829
  ],
31765
32830
  true
31766
32831
  )
@@ -31768,6 +32833,7 @@ var pureFunctionTest = (path, fn, shapes) => ({
31768
32833
  ]
31769
32834
  )
31770
32835
  });
32836
+ var namesEnum = (fn) => fn.params.some((param) => !!enumIdOf(param.dataType));
31771
32837
  var URL_HELPERS = [
31772
32838
  `const ANY_SEGMENT = '__segment__';`,
31773
32839
  `const urlPattern = (urls: HttpService, domain: string, segments: string[], version?: 'v2'): RegExp =>`,
@@ -32868,23 +33934,33 @@ var screenCtxOf = (ws, meta, controlMap) => {
32868
33934
  // holds no StateProperty and no StateComputed, so every other Feature-owned
32869
33935
  // field here is empty and could not tell a Feature Screen from a Page
32870
33936
  // (ADR 0063).
32871
- hasStore: !!feature
33937
+ hasStore: !!feature,
33938
+ // A Feature Screen names its enums as the Feature's state file does, the
33939
+ // list being drawn across every Screen of it; a storeless one derives its
33940
+ // own from itself (ADR 0203).
33941
+ ...feature ? { enums: featureEnums(ws, feature.id) } : {},
33942
+ // AppTarget-owned Enums an input may name, so the class imports the one
33943
+ // shared type and declares `input<Status>()` (ADR 0204).
33944
+ appEnums: ws.enums ?? {}
32872
33945
  };
32873
33946
  };
33947
+ var featureEnums = (ws, featureId) => controlEnums(
33948
+ ws.screens.filter(
33949
+ (screen) => screen.meta.kind === "feature" && screen.meta.featureId === featureId
33950
+ ).map((screen) => ({
33951
+ tree: buildTree(screen.state.controlMap, screen.state.rootControlIds),
33952
+ controlMap: screen.state.controlMap
33953
+ }))
33954
+ );
32874
33955
  var featureContextOf = (ws, feature) => ({
32875
33956
  operationOf: ws.operationOf,
32876
33957
  // App-tier first, the Feature's own over the top: the narrower scope, and a
32877
33958
  // name collision between them is already refused (ADR 0045).
32878
33959
  functions: { ...ws.functions, ...feature.functions ?? {} },
32879
33960
  // Derived from every Screen before the Feature's shared state file is
32880
- // emitted, so a property may name an action bar drawn on a sibling Screen.
32881
- actionEnums: actionEnums(
32882
- ws.screens.filter(
32883
- (screen) => screen.meta.kind === "feature" && screen.meta.featureId === feature.id
32884
- ).flatMap(
32885
- (screen) => buildTree(screen.state.controlMap, screen.state.rootControlIds)
32886
- )
32887
- ),
33961
+ // emitted, so a property may name an action bar or a sorting table drawn on
33962
+ // a sibling Screen.
33963
+ actionEnums: featureEnums(ws, feature.id),
32888
33964
  usesBusy: featureUsesBusy(ws, feature.id),
32889
33965
  armed: featureMethodArms(ws, feature.id),
32890
33966
  // The Screen a StoreMethod opens once it has landed (GLOSSARY.md OpenScreen).
@@ -32919,14 +33995,23 @@ var emitFunctionFiles = (ws) => {
32919
33995
  listFunctions(ws.functions).forEach((fn) => {
32920
33996
  const path = `${SHARED_LIB_ROOT}/${functionFileBase(fn.name)}.ts`;
32921
33997
  const shapes = { ...ws.sharedShapes ?? {}, ...forms };
32922
- push({ path, contents: generateFunctionFile(shapes, fn) });
33998
+ push({
33999
+ path,
34000
+ contents: generateFunctionFile(shapes, fn, [SORT_DIRECTION_ENUM])
34001
+ });
32923
34002
  push(pureFunctionTest(path, fn, shapes));
32924
34003
  });
32925
34004
  Object.values(ws.features).forEach((feature) => {
32926
34005
  listFunctions(feature.functions ?? {}).forEach((fn) => {
32927
34006
  const path = functionFilePath(fn, feature.name);
32928
34007
  const shapes = { ...feature.shapes, ...forms };
32929
- push({ path, contents: generateFunctionFile(shapes, fn) });
34008
+ push({
34009
+ path,
34010
+ contents: generateFunctionFile(shapes, fn, [
34011
+ ...featureEnums(ws, feature.id),
34012
+ SORT_DIRECTION_ENUM
34013
+ ])
34014
+ });
32930
34015
  push(pureFunctionTest(path, fn, shapes));
32931
34016
  });
32932
34017
  });
@@ -32939,7 +34024,40 @@ var emitSharedShapeFiles = (ws) => {
32939
34024
  contents: generateShapeInterface(shared, shape)
32940
34025
  }));
32941
34026
  };
32942
- var inReach = (ws) => ws.sharedShapes ? { ...ws, features: featuresInReach(ws.features, ws.sharedShapes) } : ws;
34027
+ var emitEnumFiles = (ws) => {
34028
+ const enums = ws.enums ?? {};
34029
+ return Object.values(enums).map((appEnum) => emitEnumFile(appEnum));
34030
+ };
34031
+ var inReach = (ws) => withPropertyEnums(
34032
+ ws.sharedShapes ? { ...ws, features: featuresInReach(ws.features, ws.sharedShapes) } : ws
34033
+ );
34034
+ var withPropertyEnums = (ws) => {
34035
+ const features = Object.fromEntries(
34036
+ Object.entries(ws.features).map(([id, feature]) => {
34037
+ const controlMaps = ws.screens.filter(
34038
+ (screen) => screen.meta.kind === "feature" && screen.meta.featureId === id
34039
+ ).map((screen) => screen.state.controlMap);
34040
+ const subStores = feature.subStores ? Object.fromEntries(
34041
+ Object.entries(feature.subStores).map(([subId, sub]) => [
34042
+ subId,
34043
+ {
34044
+ ...sub,
34045
+ properties: stampStatePropertyEnums(sub.properties, controlMaps)
34046
+ }
34047
+ ])
34048
+ ) : void 0;
34049
+ return [
34050
+ id,
34051
+ {
34052
+ ...feature,
34053
+ properties: stampStatePropertyEnums(feature.properties, controlMaps),
34054
+ ...subStores ? { subStores } : {}
34055
+ }
34056
+ ];
34057
+ })
34058
+ );
34059
+ return { ...ws, features };
34060
+ };
32943
34061
  var emitFormShapeFiles = (ws) => {
32944
34062
  const functions = { ...ws.functions };
32945
34063
  Object.values(ws.features).forEach((feature) => {
@@ -33223,6 +34341,7 @@ var emitFullAppFiles = (authored, stringify) => {
33223
34341
  files3.push(...emitFunctionFiles(ws));
33224
34342
  files3.push(...emitFormShapeFiles(ws));
33225
34343
  files3.push(...emitSharedShapeFiles(ws));
34344
+ files3.push(...emitEnumFiles(ws));
33226
34345
  files3.push(...navGeneratedFiles(ws));
33227
34346
  if (ws.appAssetTree) {
33228
34347
  Object.entries(ws.appAssetTree).forEach(([folder, folderFiles]) => {
@@ -33294,6 +34413,7 @@ var emitOverlayFiles = (authored, stringify) => {
33294
34413
  files3.push(...emitFunctionFiles(ws));
33295
34414
  files3.push(...emitFormShapeFiles(ws));
33296
34415
  files3.push(...emitSharedShapeFiles(ws));
34416
+ files3.push(...emitEnumFiles(ws));
33297
34417
  files3.push(...navGeneratedFiles(ws));
33298
34418
  if (ws.appAssetTree) {
33299
34419
  Object.entries(ws.appAssetTree).forEach(([folder, folderFiles]) => {
@@ -33413,6 +34533,7 @@ var HISTORY_LABELS = [
33413
34533
  "edit-binding",
33414
34534
  "edit-variant",
33415
34535
  "edit-shape",
34536
+ "edit-enum",
33416
34537
  "edit-method",
33417
34538
  "edit-store",
33418
34539
  "edit-timer",
@@ -33451,6 +34572,7 @@ var HISTORY_AUTHORED_KEYS = [
33451
34572
  "navMap",
33452
34573
  "functions",
33453
34574
  "sharedShapes",
34575
+ "enums",
33454
34576
  "distinct",
33455
34577
  "wcConfig"
33456
34578
  ];
@@ -33461,6 +34583,7 @@ var HISTORY_SELECTION_KEYS = [
33461
34583
  ];
33462
34584
  // Annotate the CommonJS export names for ESM import in node:
33463
34585
  0 && (module.exports = {
34586
+ ACTION_NAME_READER,
33464
34587
  ALL_VARIANT,
33465
34588
  API_SEGMENT,
33466
34589
  APP_CONFIG_SOURCE,
@@ -33564,6 +34687,7 @@ var HISTORY_SELECTION_KEYS = [
33564
34687
  EMPTY_STORE_HOOK,
33565
34688
  EMPTY_STORE_METHODS,
33566
34689
  EMPTY_WC_CONFIG,
34690
+ ENUM_VALUE_READER,
33567
34691
  ENVIRONMENT_PRESETS,
33568
34692
  FALLBACK_APP_COLOR,
33569
34693
  FALLBACK_SLOTS,
@@ -33662,6 +34786,11 @@ var HISTORY_SELECTION_KEYS = [
33662
34786
  NO_ROOT_PREFIX,
33663
34787
  NO_TRANSLATE_CONFIG_KEY,
33664
34788
  ONE_CONFIG_SOURCE,
34789
+ ONE_FUNCTIONS,
34790
+ ONE_FUNCTION_CATALOG,
34791
+ ONE_FUNCTION_ID_PARAM,
34792
+ ONE_FUNCTION_MAP_PARAM,
34793
+ ONE_FUNCTION_PREFIX,
33665
34794
  ONE_IMPORT_MODULE,
33666
34795
  ONE_PACKAGE_VERSION,
33667
34796
  OPEN_SCREEN_INPUT_SOURCES,
@@ -33731,12 +34860,18 @@ var HISTORY_SELECTION_KEYS = [
33731
34860
  SEARCH_TEXT_INPUT,
33732
34861
  SECTION_TABLE_COLUMNS_KEY,
33733
34862
  SECTION_TABLE_SEED_COLUMNS,
34863
+ SECTION_TABLE_SORT_DIRECTION,
34864
+ SECTION_TABLE_SORT_ID,
34865
+ SECTION_TABLE_SORT_OUTPUT,
33734
34866
  SHARDED_FOLDERS,
33735
34867
  SHARED_FUNCTIONS,
33736
34868
  SHARED_LIB_ROOT,
33737
34869
  SHARED_SHAPES,
33738
34870
  SHARED_SHAPE_ID_PREFIX,
33739
34871
  SHIPPED_SHELL_PATHS,
34872
+ SORT_DIRECTION_ENUM,
34873
+ SORT_DIRECTION_ENUM_ID,
34874
+ SORT_DIRECTION_VALUES,
33740
34875
  SOURCE_LANG,
33741
34876
  STARTER_GROUP,
33742
34877
  STAT_TEXT_SOURCES,
@@ -33775,6 +34910,7 @@ var HISTORY_SELECTION_KEYS = [
33775
34910
  acceptsPatterns,
33776
34911
  actionButtonEntries,
33777
34912
  actionButtonOverrides,
34913
+ actionEnumFile,
33778
34914
  actionEnumValues,
33779
34915
  actionEnums,
33780
34916
  actionRenderIds,
@@ -33968,6 +35104,7 @@ var HISTORY_SELECTION_KEYS = [
33968
35104
  computedRootIds,
33969
35105
  conditionCheckType,
33970
35106
  conditionError,
35107
+ conditionFunction,
33971
35108
  conditionId,
33972
35109
  conditionKind,
33973
35110
  configurableResponses,
@@ -33979,6 +35116,8 @@ var HISTORY_SELECTION_KEYS = [
33979
35116
  contentTemplateTag,
33980
35117
  contrastRatio,
33981
35118
  controlDrawsDenial,
35119
+ controlEnumValues,
35120
+ controlEnums,
33982
35121
  controlMapReadsState,
33983
35122
  controlMapStateRootIds,
33984
35123
  controlMapUsesAuth,
@@ -34067,6 +35206,7 @@ var HISTORY_SELECTION_KEYS = [
34067
35206
  embedShapeBlocked,
34068
35207
  embeddedRefOf,
34069
35208
  emissionShapeLookup,
35209
+ emitEnumFile,
34070
35210
  emitFullAppFiles,
34071
35211
  emitGeneratedFiles,
34072
35212
  emitOverlayFiles,
@@ -34084,6 +35224,16 @@ var HISTORY_SELECTION_KEYS = [
34084
35224
  encodeRoot,
34085
35225
  endWithNewline,
34086
35226
  ensureWritable,
35227
+ enumEventStateWrites,
35228
+ enumEventWrites,
35229
+ enumFileBase,
35230
+ enumIdOf,
35231
+ enumLabels,
35232
+ enumMemberLabel,
35233
+ enumMemberName,
35234
+ enumModule,
35235
+ enumNameOf,
35236
+ enumValuesOf,
34087
35237
  evaluateVariantGate,
34088
35238
  eventPayloadTsType,
34089
35239
  everyFormReset,
@@ -34291,6 +35441,7 @@ var HISTORY_SELECTION_KEYS = [
34291
35441
  isCompleteVisibilitySource,
34292
35442
  isCompositionKind,
34293
35443
  isComputedEligible,
35444
+ isControlEnum,
34294
35445
  isControlVisible,
34295
35446
  isCountdown,
34296
35447
  isCustomPath,
@@ -34338,6 +35489,7 @@ var HISTORY_SELECTION_KEYS = [
34338
35489
  isNavRowShape,
34339
35490
  isNavVisibilityFunction,
34340
35491
  isOnChange,
35492
+ isOneFunctionComputed,
34341
35493
  isOptionRowShape,
34342
35494
  isOrderingMenuActionOperator,
34343
35495
  isOrderingOutputArmOperator,
@@ -34426,6 +35578,9 @@ var HISTORY_SELECTION_KEYS = [
34426
35578
  landsUnconditionally,
34427
35579
  levelStateComputeds,
34428
35580
  libImportsFrom,
35581
+ liftToList,
35582
+ liftToListInTemplate,
35583
+ liftsToList,
34429
35584
  linkDrift,
34430
35585
  linkTargetKind,
34431
35586
  linkedVariableReaders,
@@ -34435,6 +35590,7 @@ var HISTORY_SELECTION_KEYS = [
34435
35590
  listFeatures,
34436
35591
  listFilesUnder,
34437
35592
  listFunctions,
35593
+ listOneFunctions,
34438
35594
  listScreenComputeds,
34439
35595
  listScreenInputs,
34440
35596
  listScreenOutputs,
@@ -34543,6 +35699,7 @@ var HISTORY_SELECTION_KEYS = [
34543
35699
  navRowMiss,
34544
35700
  navRowSourceBindings,
34545
35701
  navRowSourceOptions,
35702
+ navRowStoreOptions,
34546
35703
  navSegmentId,
34547
35704
  navTailPathsOf,
34548
35705
  navVariantNavIds,
@@ -34590,6 +35747,13 @@ var HISTORY_SELECTION_KEYS = [
34590
35747
  normalizeTranslationKey,
34591
35748
  normalizeVariantName,
34592
35749
  offersOutputArms,
35750
+ oneFunctionArgFits,
35751
+ oneFunctionFromPickValue,
35752
+ oneFunctionOf,
35753
+ oneFunctionPickValue,
35754
+ oneFunctionReturns,
35755
+ oneFunctionSignature,
35756
+ oneFunctionSignatureText,
34593
35757
  openError,
34594
35758
  openId,
34595
35759
  openInputAnswered,
@@ -34846,6 +36010,7 @@ var HISTORY_SELECTION_KEYS = [
34846
36010
  sanitizeControlGroups,
34847
36011
  sanitizeControlVariants,
34848
36012
  sanitizeDistinct,
36013
+ sanitizeEnums,
34849
36014
  sanitizeMemberPath,
34850
36015
  sanitizeNavMap,
34851
36016
  sanitizeNpmAllowlist,
@@ -34876,6 +36041,7 @@ var HISTORY_SELECTION_KEYS = [
34876
36041
  screenControlAttrs,
34877
36042
  screenControlHasRequiredInputBindings,
34878
36043
  screenControlInputGuards,
36044
+ screenControlLiftsInput,
34879
36045
  screenEmbedGapReason,
34880
36046
  screenEmitBindingTargets,
34881
36047
  screenEmitConstTargets,
@@ -34909,6 +36075,10 @@ var HISTORY_SELECTION_KEYS = [
34909
36075
  screenPropertiesWithComputeds,
34910
36076
  screenTest,
34911
36077
  screenVariableActionEnumIds,
36078
+ screenVariableDataType,
36079
+ screenVariableEnumId,
36080
+ screenVariableEnumIds,
36081
+ screenVariableEnums,
34912
36082
  screenVariableInitialAllowed,
34913
36083
  screenVariableInitialIssue,
34914
36084
  screenVariableSourceType,
@@ -34934,6 +36104,8 @@ var HISTORY_SELECTION_KEYS = [
34934
36104
  sectionTableEmissions,
34935
36105
  sectionTableRef,
34936
36106
  sectionTableRows,
36107
+ sectionTableSortEnums,
36108
+ sectionTableSortIds,
34937
36109
  seedColumn,
34938
36110
  seedColumns,
34939
36111
  seedInstanceArgs,
@@ -34967,6 +36139,7 @@ var HISTORY_SELECTION_KEYS = [
34967
36139
  shapesInReach,
34968
36140
  sharedShapeHolders,
34969
36141
  signatureChanged,
36142
+ signatureEnums,
34970
36143
  signatureFormIds,
34971
36144
  signatureNamesOptionRow,
34972
36145
  signatureShapeIds,
@@ -34974,9 +36147,11 @@ var HISTORY_SELECTION_KEYS = [
34974
36147
  slug,
34975
36148
  slugifyComponentName,
34976
36149
  slugifyMessage,
36150
+ sortRowEnumId,
34977
36151
  sourceCarriesTrackKey,
34978
36152
  staleCases,
34979
36153
  staleMenuActionItems,
36154
+ stampStatePropertyEnums,
34980
36155
  standardMenuConfigs,
34981
36156
  starterFunction,
34982
36157
  stateComputedArgExpression,
@@ -35004,6 +36179,8 @@ var HISTORY_SELECTION_KEYS = [
35004
36179
  storeAppOptions,
35005
36180
  storeHookCallError,
35006
36181
  storeNameScope,
36182
+ storeOwnerOfValue,
36183
+ storeOwnerValue,
35007
36184
  storeReaders,
35008
36185
  storeTest,
35009
36186
  storesOf,
@@ -35139,7 +36316,9 @@ var HISTORY_SELECTION_KEYS = [
35139
36316
  withEmittedTests,
35140
36317
  withFormShapes,
35141
36318
  withListRowShape,
36319
+ withScreenEnums,
35142
36320
  withScreenMethodCallSites,
36321
+ withVariableEnums,
35143
36322
  wouldComputedCycle,
35144
36323
  wouldCycle,
35145
36324
  wouldScreenComputedCycle,