@magmonium/cli 0.8.26 → 0.8.28

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 +1485 -349
  2. package/package.json +1 -1
package/codegen/index.js CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  ACTION_NAME_READER: () => ACTION_NAME_READER,
24
+ ACTION_SELECTION_KEY: () => ACTION_SELECTION_KEY,
24
25
  ALL_VARIANT: () => ALL_VARIANT,
25
26
  API_SEGMENT: () => API_SEGMENT,
26
27
  APP_CONFIG_SOURCE: () => APP_CONFIG_SOURCE,
@@ -56,6 +57,8 @@ __export(index_exports, {
56
57
  BUSY_VARIANT_ID: () => BUSY_VARIANT_ID,
57
58
  BUSY_VARIANT_NAME: () => BUSY_VARIANT_NAME,
58
59
  BUTTON_CLICK_OUTPUT: () => BUTTON_CLICK_OUTPUT,
60
+ BUTTON_KEY_CONFIG_KEY: () => BUTTON_KEY_CONFIG_KEY,
61
+ BUTTON_KEY_PATTERN: () => BUTTON_KEY_PATTERN,
59
62
  CALL_ARG_SOURCES: () => CALL_ARG_SOURCES,
60
63
  CALL_ARG_TRANSFORM_LEAVES: () => CALL_ARG_TRANSFORM_LEAVES,
61
64
  CALL_CONDITION_KINDS: () => CALL_CONDITION_KINDS,
@@ -206,6 +209,7 @@ __export(index_exports, {
206
209
  METHOD_VARIANT_SOURCES: () => METHOD_VARIANT_SOURCES,
207
210
  MIGRATION_FLOOR: () => MIGRATION_FLOOR,
208
211
  MODAL_STORE: () => MODAL_STORE,
212
+ NATIVE_ONE_FUNCTION_SPECS: () => NATIVE_ONE_FUNCTION_SPECS,
209
213
  NAV_ID_SEP: () => NAV_ID_SEP2,
210
214
  NAV_LINK_KINDS: () => NAV_LINK_KINDS,
211
215
  NAV_PRESENTATIONS: () => NAV_PRESENTATIONS,
@@ -226,9 +230,12 @@ __export(index_exports, {
226
230
  ONE_FUNCTIONS: () => ONE_FUNCTIONS,
227
231
  ONE_FUNCTION_CATALOG: () => ONE_FUNCTION_CATALOG,
228
232
  ONE_FUNCTION_DATA_PARAM: () => ONE_FUNCTION_DATA_PARAM,
233
+ ONE_FUNCTION_IDS_PARAM: () => ONE_FUNCTION_IDS_PARAM,
229
234
  ONE_FUNCTION_ID_PARAM: () => ONE_FUNCTION_ID_PARAM,
235
+ ONE_FUNCTION_KEY_PARAM: () => ONE_FUNCTION_KEY_PARAM,
230
236
  ONE_FUNCTION_MAP_PARAM: () => ONE_FUNCTION_MAP_PARAM,
231
237
  ONE_FUNCTION_PREFIX: () => ONE_FUNCTION_PREFIX,
238
+ ONE_FUNCTION_SPECS: () => ONE_FUNCTION_SPECS,
232
239
  ONE_IMPORT_MODULE: () => ONE_IMPORT_MODULE,
233
240
  ONE_PACKAGE_VERSION: () => ONE_PACKAGE_VERSION,
234
241
  OPEN_SCREEN_INPUT_SOURCES: () => OPEN_SCREEN_INPUT_SOURCES,
@@ -318,6 +325,7 @@ __export(index_exports, {
318
325
  STYLE_DIRECTIVE_FORM: () => STYLE_DIRECTIVE_FORM,
319
326
  STYLE_DIRECTIVE_KEYS: () => STYLE_DIRECTIVE_KEYS,
320
327
  STYLE_DIRECTIVE_NAMES: () => STYLE_DIRECTIVE_NAMES,
328
+ SUBMIT_TARGET_KEY: () => SUBMIT_TARGET_KEY,
321
329
  TEST_RUNNER_DEV_DEPS: () => TEST_RUNNER_DEV_DEPS,
322
330
  TEXT_SOURCE: () => TEXT_SOURCE,
323
331
  TEXT_SOURCES: () => TEXT_SOURCES,
@@ -354,6 +362,7 @@ __export(index_exports, {
354
362
  actionEnumValues: () => actionEnumValues,
355
363
  actionEnums: () => actionEnums,
356
364
  actionRenderIds: () => actionRenderIds,
365
+ actionSelectionKey: () => actionSelectionKey,
357
366
  activeBackendUrl: () => activeBackendUrl,
358
367
  activeHosts: () => activeHosts,
359
368
  addMenuGroup: () => addMenuGroup,
@@ -446,6 +455,7 @@ __export(index_exports, {
446
455
  callArgStorageRead: () => callArgStorageRead,
447
456
  callArgTargetKey: () => callArgTargetKey,
448
457
  callArgTargets: () => callArgTargets,
458
+ callArgTransformSignature: () => callArgTransformSignature,
449
459
  callArgTypeMismatch: () => callArgTypeMismatch,
450
460
  callArgumentsExpression: () => callArgumentsExpression,
451
461
  callError: () => callError,
@@ -466,6 +476,7 @@ __export(index_exports, {
466
476
  canFillFormKey: () => canFillFormKey,
467
477
  canHostDefaultChild: () => canHostDefaultChild,
468
478
  canHostNavChildren: () => canHostNavChildren,
479
+ canNameSubmitTarget: () => canNameSubmitTarget,
469
480
  canOfferAddChild: () => canOfferAddChild,
470
481
  canOfferReplaceParent: () => canOfferReplaceParent,
471
482
  canOutputCall: () => canOutputCall,
@@ -535,22 +546,27 @@ __export(index_exports, {
535
546
  composeFunctionBinding: () => composeFunctionBinding,
536
547
  composeLabelValue: () => composeLabelValue,
537
548
  computeError: () => computeError,
549
+ computeFunction: () => computeFunction,
538
550
  computeId: () => computeId,
539
551
  computeInputMemberError: () => computeInputMemberError,
540
552
  computeInputPaths: () => computeInputPaths,
541
553
  computeIsRead: () => computeIsRead,
542
554
  computeMemberRead: () => computeMemberRead,
543
555
  computeNameTaken: () => computeNameTaken,
556
+ computeOneFunction: () => computeOneFunction,
557
+ computeOneReturns: () => computeOneReturns,
544
558
  computeReadable: () => computeReadable,
545
559
  computeTextPaths: () => computeTextPaths,
546
560
  computedAsProperty: () => computedAsProperty,
547
561
  computedLocalNames: () => computedLocalNames,
548
562
  computedRootIds: () => computedRootIds,
563
+ conditionArgValue: () => conditionArgValue,
549
564
  conditionCheckType: () => conditionCheckType,
550
565
  conditionError: () => conditionError,
551
566
  conditionFunction: () => conditionFunction,
552
567
  conditionId: () => conditionId,
553
568
  conditionKind: () => conditionKind,
569
+ conditionReadsCompute: () => conditionReadsCompute,
554
570
  configurableResponses: () => configurableResponses,
555
571
  confirmError: () => confirmError,
556
572
  confirmId: () => confirmId,
@@ -616,6 +632,7 @@ __export(index_exports, {
616
632
  defaultScreenEmitValue: () => defaultScreenEmitValue,
617
633
  defaultScreenWriteValue: () => defaultScreenWriteValue,
618
634
  defaultStateWriteValue: () => defaultStateWriteValue,
635
+ defaultSubmitTarget: () => defaultSubmitTarget,
619
636
  denialDialogOf: () => denialDialogOf,
620
637
  denialTranslationKeys: () => denialTranslationKeys,
621
638
  derivePaths: () => derivePaths,
@@ -639,6 +656,7 @@ __export(index_exports, {
639
656
  drawnVariants: () => drawnVariants,
640
657
  dropChainStep: () => dropChainStep,
641
658
  dropFormEventMember: () => dropFormEventMember,
659
+ dropOutputBlock: () => dropOutputBlock,
642
660
  dropStaleTrackKeys: () => dropStaleTrackKeys,
643
661
  duplicateMemberName: () => duplicateMemberName,
644
662
  duplicateShapeName: () => duplicateShapeName,
@@ -739,6 +757,7 @@ __export(index_exports, {
739
757
  foldedButtonNames: () => foldedButtonNames,
740
758
  foldedButtons: () => foldedButtons,
741
759
  foldedRouterLink: () => foldedRouterLink,
760
+ formEventFieldTypes: () => formEventFieldTypes,
742
761
  formEventMembers: () => formEventMembers,
743
762
  formFieldIds: () => formFieldIds,
744
763
  formFields: () => formFields,
@@ -747,13 +766,17 @@ __export(index_exports, {
747
766
  formInterfaceName: () => formInterfaceName,
748
767
  formModelFor: () => formModelFor,
749
768
  formModelKeyIssue: () => formModelKeyIssue,
769
+ formModelKeyMismatch: () => formModelKeyMismatch,
770
+ formModelKeySignature: () => formModelKeySignature,
750
771
  formModelKeyType: () => formModelKeyType,
751
772
  formModelKeyZero: () => formModelKeyZero,
773
+ formModelLandedType: () => formModelLandedType,
752
774
  formModelScreenOptions: () => formModelScreenOptions,
753
775
  formModelShapeKeys: () => formModelShapeKeys,
754
776
  formModelSourceReaders: () => formModelSourceReaders,
755
777
  formModelSourceType: () => formModelSourceType,
756
778
  formModelStateOptions: () => formModelStateOptions,
779
+ formModelTransforms: () => formModelTransforms,
757
780
  formRefName: () => formRefName,
758
781
  formRefNames: () => formRefNames,
759
782
  formResetDepths: () => formResetDepths,
@@ -843,12 +866,14 @@ __export(index_exports, {
843
866
  hasRouterOutlet: () => hasRouterOutlet,
844
867
  hasScreenVariableActionEnumConflict: () => hasScreenVariableActionEnumConflict,
845
868
  hasStore: () => hasStore,
869
+ hasSubmitTargetButton: () => hasSubmitTargetButton,
846
870
  hasTextSource: () => hasTextSource,
847
871
  hasValueSource: () => hasValueSource,
848
872
  hasVariableDrift: () => hasVariableDrift,
849
873
  heldFieldIds: () => heldFieldIds,
850
874
  heldProperties: () => heldProperties,
851
875
  holdKey: () => holdKey,
876
+ holdOutputBlock: () => holdOutputBlock,
852
877
  hostRoutesConst: () => hostRoutesConst,
853
878
  iconControlEmitConfigs: () => iconControlEmitConfigs,
854
879
  iconControlGlyph: () => iconControlGlyph,
@@ -908,6 +933,7 @@ __export(index_exports, {
908
933
  isFieldCheckEligible: () => isFieldCheckEligible,
909
934
  isFieldOptionSelected: () => isFieldOptionSelected,
910
935
  isFolderPickSupported: () => isFolderPickSupported,
936
+ isFormModelReadSource: () => isFormModelReadSource,
911
937
  isFormatPipeName: () => isFormatPipeName,
912
938
  isFunctionCheckBound: () => isFunctionCheckBound,
913
939
  isFunctionInUse: () => isFunctionInUse,
@@ -934,12 +960,14 @@ __export(index_exports, {
934
960
  isMethodInUse: () => isMethodInUse,
935
961
  isMountable: () => isMountable,
936
962
  isMovingScreenEmit: () => isMovingScreenEmit,
963
+ isNativeOneFunction: () => isNativeOneFunction,
937
964
  isNavAtOrBelow: () => isNavAtOrBelow,
938
965
  isNavInstanceFunction: () => isNavInstanceFunction,
939
966
  isNavRowShape: () => isNavRowShape,
940
967
  isNavVisibilityFunction: () => isNavVisibilityFunction,
941
968
  isOnChange: () => isOnChange,
942
969
  isOneFunctionComputed: () => isOneFunctionComputed,
970
+ isOneFunctionStateComputed: () => isOneFunctionStateComputed,
943
971
  isOptionRowShape: () => isOptionRowShape,
944
972
  isOrderingMenuActionOperator: () => isOrderingMenuActionOperator,
945
973
  isOrderingOutputArmOperator: () => isOrderingOutputArmOperator,
@@ -954,6 +982,7 @@ __export(index_exports, {
954
982
  isOutputCallBound: () => isOutputCallBound,
955
983
  isOutputCallKey: () => isOutputCallKey,
956
984
  isOutputConditional: () => isOutputConditional,
985
+ isOutputSelfEmit: () => isOutputSelfEmit,
957
986
  isOverlayDirectiveName: () => isOverlayDirectiveName,
958
987
  isOverlayType: () => isOverlayType,
959
988
  isPassthroughComputed: () => isPassthroughComputed,
@@ -991,6 +1020,7 @@ __export(index_exports, {
991
1020
  isTaglessFamily: () => isTaglessFamily,
992
1021
  isTextSource: () => isTextSource,
993
1022
  isTimerComplete: () => isTimerComplete,
1023
+ isToggleAction: () => isToggleAction,
994
1024
  isUnaryMenuActionOperator: () => isUnaryMenuActionOperator,
995
1025
  isUnaryOperator: () => isUnaryOperator,
996
1026
  isUnaryOutputArmOperator: () => isUnaryOutputArmOperator,
@@ -1204,12 +1234,21 @@ __export(index_exports, {
1204
1234
  normalizeVariantName: () => normalizeVariantName,
1205
1235
  offersOutputArms: () => offersOutputArms,
1206
1236
  oneFunctionArgFits: () => oneFunctionArgFits,
1237
+ oneFunctionBoundSignature: () => oneFunctionBoundSignature,
1238
+ oneFunctionFitsLanding: () => oneFunctionFitsLanding,
1207
1239
  oneFunctionFromPickValue: () => oneFunctionFromPickValue,
1240
+ oneFunctionLiftedAt: () => oneFunctionLiftedAt,
1241
+ oneFunctionMintsKey: () => oneFunctionMintsKey,
1208
1242
  oneFunctionOf: () => oneFunctionOf,
1209
1243
  oneFunctionPickValue: () => oneFunctionPickValue,
1210
1244
  oneFunctionReturns: () => oneFunctionReturns,
1211
1245
  oneFunctionSignature: () => oneFunctionSignature,
1212
1246
  oneFunctionSignatureText: () => oneFunctionSignatureText,
1247
+ oneFunctionSiteFits: () => oneFunctionSiteFits,
1248
+ oneParamFixedHeld: () => oneParamFixedHeld,
1249
+ oneParamStatePathOnly: () => oneParamStatePathOnly,
1250
+ oneParamTakesFixed: () => oneParamTakesFixed,
1251
+ oneParamTypeText: () => oneParamTypeText,
1213
1252
  openError: () => openError,
1214
1253
  openId: () => openId,
1215
1254
  openInputAnswered: () => openInputAnswered,
@@ -1288,6 +1327,7 @@ __export(index_exports, {
1288
1327
  outputOpenStatement: () => outputOpenStatement,
1289
1328
  outputOpenTargets: () => outputOpenTargets,
1290
1329
  outputOpenValueKinds: () => outputOpenValueKinds,
1330
+ outputSelfEmitCall: () => outputSelfEmitCall,
1291
1331
  overlayWidgetRefs: () => overlayWidgetRefs,
1292
1332
  overlayWidgetScreenIds: () => overlayWidgetScreenIds,
1293
1333
  overlayWidgetsProviderBlock: () => overlayWidgetsProviderBlock,
@@ -1333,6 +1373,7 @@ __export(index_exports, {
1333
1373
  persistableOptionSetRows: () => persistableOptionSetRows,
1334
1374
  pickFolder: () => pickFolder,
1335
1375
  pickedNavTail: () => pickedNavTail,
1376
+ placeOutputBlock: () => placeOutputBlock,
1336
1377
  planScreenEmit: () => planScreenEmit,
1337
1378
  pluginContractResync: () => pluginContractResync,
1338
1379
  pluginContracts: () => pluginContracts,
@@ -1344,6 +1385,7 @@ __export(index_exports, {
1344
1385
  pluginPortOf: () => pluginPortOf,
1345
1386
  pluginSourceOf: () => pluginSourceOf,
1346
1387
  presetHosts: () => presetHosts,
1388
+ projectionSlotOf: () => projectionSlotOf,
1347
1389
  propertiesWithComputeds: () => propertiesWithComputeds,
1348
1390
  propertyKey: () => propertyKey,
1349
1391
  pruneFormEventReads: () => pruneFormEventReads,
@@ -1601,6 +1643,7 @@ __export(index_exports, {
1601
1643
  signatureEnums: () => signatureEnums,
1602
1644
  signatureFormIds: () => signatureFormIds,
1603
1645
  signatureNamesOptionRow: () => signatureNamesOptionRow,
1646
+ signaturePipeIndex: () => signaturePipeIndex,
1604
1647
  signatureShapeIds: () => signatureShapeIds,
1605
1648
  signatureText: () => signatureText,
1606
1649
  slug: () => slug,
@@ -1608,6 +1651,7 @@ __export(index_exports, {
1608
1651
  slugifyMessage: () => slugifyMessage,
1609
1652
  sortRowEnumId: () => sortRowEnumId,
1610
1653
  sourceCarriesTrackKey: () => sourceCarriesTrackKey,
1654
+ splitAutoCallEmits: () => splitAutoCallEmits,
1611
1655
  stableId: () => stableId,
1612
1656
  staleCases: () => staleCases,
1613
1657
  staleMenuActionItems: () => staleMenuActionItems,
@@ -1616,6 +1660,7 @@ __export(index_exports, {
1616
1660
  starterFunction: () => starterFunction,
1617
1661
  stateComputedArgExpression: () => stateComputedArgExpression,
1618
1662
  stateComputedArgHeldType: () => stateComputedArgHeldType,
1663
+ stateComputedFunction: () => stateComputedFunction,
1619
1664
  stateInterfaceName: () => stateInterfaceName,
1620
1665
  statePathHeldType: () => statePathHeldType,
1621
1666
  statePathRead: () => statePathRead,
@@ -1656,9 +1701,15 @@ __export(index_exports, {
1656
1701
  subStoreSuffixError: () => subStoreSuffixError,
1657
1702
  subStoresOf: () => subStoresOf,
1658
1703
  subStoresReachedByMain: () => subStoresReachedByMain,
1704
+ submitTargetForms: () => submitTargetForms,
1705
+ submitTargetLink: () => submitTargetLink,
1706
+ submitTargetOf: () => submitTargetOf,
1659
1707
  successResponse: () => successResponse,
1660
1708
  suggestFormModelName: () => suggestFormModelName,
1661
1709
  suggestMethodName: () => suggestMethodName,
1710
+ suggestNavVariantName: () => suggestNavVariantName,
1711
+ suggestVariantName: () => suggestVariantName,
1712
+ suggestedButtonKeys: () => suggestedButtonKeys,
1662
1713
  survivingNavId: () => survivingNavId,
1663
1714
  swaggerUrlFromBackend: () => swaggerUrlFromBackend,
1664
1715
  syncScreenVariable: () => syncScreenVariable,
@@ -1704,6 +1755,7 @@ __export(index_exports, {
1704
1755
  typeLabel: () => typeLabel,
1705
1756
  typeSigil: () => typeSigil,
1706
1757
  typesMatch: () => typesMatch,
1758
+ typesMatchExactly: () => typesMatchExactly,
1707
1759
  unaryCall: () => unaryCall,
1708
1760
  unboundParams: () => unboundParams,
1709
1761
  unfilledVariables: () => unfilledVariables,
@@ -1712,6 +1764,7 @@ __export(index_exports, {
1712
1764
  updateRuleNode: () => updateRuleNode,
1713
1765
  usesAuthProperty: () => usesAuthProperty,
1714
1766
  usesStorage: () => usesStorage,
1767
+ validateButtonKey: () => validateButtonKey,
1715
1768
  validateCallArgs: () => validateCallArgs,
1716
1769
  validateFeatureName: () => validateFeatureName,
1717
1770
  validateFormName: () => validateFormName,
@@ -1778,6 +1831,7 @@ __export(index_exports, {
1778
1831
  withEventTransform: () => withEventTransform,
1779
1832
  withFormShapes: () => withFormShapes,
1780
1833
  withListRowShape: () => withListRowShape,
1834
+ withOutputSelfEmit: () => withOutputSelfEmit,
1781
1835
  withPropertyEnums: () => withPropertyEnums,
1782
1836
  withScreenEnums: () => withScreenEnums,
1783
1837
  withScreenMethodCallSites: () => withScreenMethodCallSites,
@@ -1880,6 +1934,7 @@ function isReservedVariantName(name3) {
1880
1934
  }
1881
1935
  var LEGACY_VARIANT_JOIN = "or";
1882
1936
  var isLinkedVariable = (variable) => variable.kind === "linked" && !!variable.source;
1937
+ var isFormModelReadSource = (source) => source.source !== "empty" && source.source !== "fixed";
1883
1938
  var isLinkedKeySource = (source) => source.source === "input" || source.source === "computed" || source.source === "path";
1884
1939
  var isLinkedFormModel = (model) => Object.values(model.keys).some(isLinkedKeySource);
1885
1940
  var screenAutoCallWhen = (call) => call.when ?? (call.args.some((row) => row.source === "input") || (call.emits ?? []).some(isMovingScreenEmit) || !!call.reads?.length ? "on-change" : "once");
@@ -1891,6 +1946,74 @@ var screenAutoCallError = (call) => {
1891
1946
  (row) => row.source === "input" || row.source === "binding"
1892
1947
  ) || (call.emits ?? []).some(isMovingScreenEmit) || !!call.reads?.length ? void 0 : "auto-call-never-fires";
1893
1948
  };
1949
+ var isOutputSelfEmit = (call) => {
1950
+ if (call.methodId || call.reads?.length || call.emits?.length !== 1)
1951
+ return false;
1952
+ if (!call.emits[0].value) return false;
1953
+ const { when: _drop, ...derived } = call;
1954
+ return !call.when || call.when === screenAutoCallWhen(derived);
1955
+ };
1956
+ var outputSelfEmitCall = (calls, outputId) => (calls ?? []).find(
1957
+ (call) => isOutputSelfEmit(call) && call.emits?.[0].outputId === outputId
1958
+ );
1959
+ var withOutputSelfEmit = (calls, outputId, value, mintId) => {
1960
+ const own = outputSelfEmitCall(calls, outputId);
1961
+ const rest = (calls ?? []).filter((call) => call !== own);
1962
+ if (!value) return rest;
1963
+ return [
1964
+ ...rest,
1965
+ {
1966
+ id: own?.id ?? mintId(),
1967
+ args: [],
1968
+ emits: [{ id: own?.emits?.[0].id ?? mintId(), outputId, value }]
1969
+ }
1970
+ ];
1971
+ };
1972
+ var splitAutoCallEmits = (calls, inputs = {}) => {
1973
+ const result = [];
1974
+ const selfFired = /* @__PURE__ */ new Set();
1975
+ const push = (call) => {
1976
+ if (isOutputSelfEmit(call)) {
1977
+ const outputId = call.emits?.[0].outputId ?? "";
1978
+ if (selfFired.has(outputId)) return;
1979
+ selfFired.add(outputId);
1980
+ }
1981
+ result.push(call);
1982
+ };
1983
+ for (const call of calls) {
1984
+ const emits = call.emits ?? [];
1985
+ if (!emits.length || !call.methodId && emits.length === 1) {
1986
+ push(call);
1987
+ continue;
1988
+ }
1989
+ const when = screenAutoCallWhen(call);
1990
+ const reads = [...call.reads ?? []];
1991
+ if (call.methodId) {
1992
+ const { emits: _drop, ...rest } = call;
1993
+ push(rest);
1994
+ if (when === "on-change") {
1995
+ const seen = new Set(reads.map((read) => JSON.stringify(read)));
1996
+ for (const row of call.args) {
1997
+ const id = row.source === "input" ? Object.values(inputs).find((one) => one.name === row.input)?.id : void 0;
1998
+ const read = row.source === "binding" ? row.binding : id ? { root: { kind: "input", id }, path: [] } : void 0;
1999
+ if (!read || seen.has(JSON.stringify(read))) continue;
2000
+ seen.add(JSON.stringify(read));
2001
+ reads.push(read);
2002
+ }
2003
+ }
2004
+ }
2005
+ emits.forEach((emit, at) => {
2006
+ const piece = {
2007
+ id: !call.methodId && at === 0 ? call.id : `${call.id}-${emit.id}`,
2008
+ args: [],
2009
+ emits: [emit],
2010
+ ...reads.length ? { reads } : {}
2011
+ };
2012
+ push(screenAutoCallWhen(piece) === when ? piece : { ...piece, when });
2013
+ });
2014
+ }
2015
+ return result;
2016
+ };
1894
2017
  var MENU_ACTION_MEMBERS = [
1895
2018
  "id",
1896
2019
  "label",
@@ -1979,15 +2102,19 @@ var hasRouterLink = (configs) => {
1979
2102
  };
1980
2103
 
1981
2104
  // libs/codegen/src/lib/action-fold-helper.ts
2105
+ var BUTTON_KEY_CONFIG_KEY = "buttonKey";
2106
+ var ACTION_SELECTION_KEY = "selection";
2107
+ var BUTTON_KEY_PATTERN = /^[a-zA-Z0-9_-]+$/;
1982
2108
  var foldedButtonName = (node) => {
1983
2109
  const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1984
- const candidates = ["name", "label", "icon"].map((key2) => node.configs?.[key2]).map((value) => String(value ?? "").trim()).find((value) => value && !uuid.test(value));
2110
+ const candidates = [BUTTON_KEY_CONFIG_KEY, "name", "label", "icon"].map((key2) => node.configs?.[key2]).map((value) => String(value ?? "").trim()).find((value) => value && !uuid.test(value));
1985
2111
  return candidates || "button";
1986
2112
  };
1987
2113
  var foldedButtons = (node) => node.type === "section_action" /* SECTION_ACTION */ ? node.childrens.filter((child) => child.type === "button" /* BUTTON */) : [];
1988
2114
  var foldedConfigs = (node) => {
1989
2115
  const configs = { ...node.configs ?? {} };
1990
2116
  delete configs["name"];
2117
+ delete configs[BUTTON_KEY_CONFIG_KEY];
1991
2118
  Object.entries(configs).forEach(([key2, value]) => {
1992
2119
  if (value === "" || value === void 0 || value === null) {
1993
2120
  delete configs[key2];
@@ -2055,6 +2182,22 @@ var actionButtonEntries = (node) => {
2055
2182
  return [name3, button];
2056
2183
  });
2057
2184
  };
2185
+ var isToggleAction = (node) => node?.type === "section_action" /* SECTION_ACTION */ && node.configs?.["variant"] === "toggle";
2186
+ var actionSelectionKey = (node) => {
2187
+ if (!isToggleAction(node)) return void 0;
2188
+ const id = node.configs?.[ACTION_SELECTION_KEY];
2189
+ if (typeof id !== "string" || !id) return void 0;
2190
+ return actionButtonEntries(node).find(([, button]) => button.id === id)?.[0];
2191
+ };
2192
+ var suggestedButtonKeys = (node) => new Map(actionButtonEntries(node).map(([name3, button]) => [button.id, name3]));
2193
+ var validateButtonKey = (bar, buttonId, key2) => {
2194
+ const trimmed = key2.trim();
2195
+ if (!BUTTON_KEY_PATTERN.test(trimmed)) return "button-key-invalid";
2196
+ const taken = actionButtonEntries(bar ?? {}).some(
2197
+ ([name3, button]) => button.id !== buttonId && name3 === trimmed
2198
+ );
2199
+ return taken ? "button-key-taken" : void 0;
2200
+ };
2058
2201
 
2059
2202
  // libs/codegen/src/lib/app-release-doc.ts
2060
2203
  var APP_RELEASE_DOC = `# Releasing an mm App
@@ -4759,6 +4902,29 @@ var CONTROL_CODEGEN = {
4759
4902
  importFrom: "@angular/router"
4760
4903
  }
4761
4904
  };
4905
+ var NAMED_SLOT_TAGS = /* @__PURE__ */ new Set([
4906
+ "m-section-header",
4907
+ "m-section-hero",
4908
+ "m-jumbotron",
4909
+ "m-section-search",
4910
+ "m-section-stepper",
4911
+ "m-section-badges",
4912
+ "m-section-toggle",
4913
+ "m-action",
4914
+ "m-one-action",
4915
+ "m-section-back",
4916
+ "m-section-filter",
4917
+ "m-section-filter-group",
4918
+ "m-carousel",
4919
+ "m-one-carousel",
4920
+ "m-section-pagination",
4921
+ "m-section-footer",
4922
+ "m-app-logo"
4923
+ ]);
4924
+ function projectionSlotOf(node) {
4925
+ const tag = CONTROL_CODEGEN[node.type]?.tag.split(" ")[0];
4926
+ return tag && NAMED_SLOT_TAGS.has(tag) ? tag : "";
4927
+ }
4762
4928
 
4763
4929
  // libs/codegen/src/lib/option-set-helper.ts
4764
4930
  function isValidOptionSetName(name3) {
@@ -5082,87 +5248,249 @@ var screenMethodCalls = (method) => method ? [
5082
5248
 
5083
5249
  // libs/codegen/src/model/one-function-catalog.ts
5084
5250
  var ONE_FUNCTION_ID_PARAM = "id";
5251
+ var ONE_FUNCTION_IDS_PARAM = "ids";
5085
5252
  var ONE_FUNCTION_MAP_PARAM = "map";
5086
5253
  var ONE_FUNCTION_DATA_PARAM = "data";
5254
+ var ONE_FUNCTION_KEY_PARAM = "key";
5087
5255
  var ONE_FUNCTION_PREFIX = "one:";
5088
- var signatureParam = (param, row) => ({
5089
- id: param.id,
5090
- name: param.name,
5091
- dataType: param.rule === "string-one" ? { type: "string" } : row,
5092
- cardinality: param.rule === "map-path" ? "map" : "one",
5093
- acceptsUndefined: true
5094
- });
5095
- var defineOneFunction = (spec) => {
5096
- const { returns, ...entry2 } = spec;
5097
- return {
5098
- ...entry2,
5099
- importFrom: ONE_IMPORT_MODULE,
5100
- returnsRow: returns !== "boolean",
5101
- signature: (row) => ({
5102
- params: entry2.params.map((param) => signatureParam(param, row)),
5103
- ...returns === "boolean" ? { returnType: { type: "boolean" }, returnCardinality: "one" } : returns === "row" ? { returnType: row, returnCardinality: "one", returnUndefined: true } : { returnType: row, returnCardinality: "map" }
5104
- })
5105
- };
5256
+ var ID = {
5257
+ id: ONE_FUNCTION_ID_PARAM,
5258
+ name: "id",
5259
+ type: "string",
5260
+ cardinality: "one"
5106
5261
  };
5107
- var ONE_FUNCTIONS = [
5262
+ var MAP = {
5263
+ id: ONE_FUNCTION_MAP_PARAM,
5264
+ name: "map",
5265
+ type: "T",
5266
+ cardinality: "map",
5267
+ statePathOnly: true
5268
+ };
5269
+ var ONE_FUNCTION_SPECS = {
5108
5270
  // `getFromMap<T>(id, map: Record<string, T>): T | undefined` — the row a
5109
5271
  // `map` holds under an id, typically a ScreenInput a Page was handed.
5110
- defineOneFunction({
5111
- name: "getFromMap",
5112
- reach: ["screen-computed"],
5113
- returns: "row",
5272
+ getFromMap: {
5273
+ params: [ID, MAP],
5274
+ returns: { type: "T", cardinality: "one", optional: true }
5275
+ },
5276
+ // `getManyFromMaps<T>(ids: string[], map: Record<string, T>): T[]` — the
5277
+ // rows a `map` holds under each id, in id order, a miss skipped. Over a
5278
+ // `map-many` it answers every id's list joined into one flat list, so its
5279
+ // return stays `many` where the record lifts.
5280
+ getManyFromMaps: {
5114
5281
  params: [
5115
- { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
5116
- { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
5282
+ {
5283
+ id: ONE_FUNCTION_IDS_PARAM,
5284
+ name: "ids",
5285
+ type: "string",
5286
+ cardinality: "many"
5287
+ },
5288
+ MAP
5117
5289
  ],
5118
- rowParamId: ONE_FUNCTION_MAP_PARAM,
5119
- rowCardinality: "map"
5120
- }),
5290
+ returns: { type: "T", cardinality: "many", liftsTo: "many" }
5291
+ },
5121
5292
  // `existsInMap(id, map: Record<string, unknown>): boolean` — whether a
5122
5293
  // `map` holds anything under an id (ADR 0202). `false` rather than
5123
5294
  // `undefined` while either is, so a gate on an unloaded store reads "not
5124
5295
  // there yet" and a computed over it never needs `?.`.
5125
- defineOneFunction({
5126
- name: "existsInMap",
5127
- reach: ["screen-computed", "call-condition"],
5128
- returns: "boolean",
5296
+ existsInMap: {
5297
+ params: [ID, MAP],
5298
+ returns: { type: "boolean", cardinality: "one" }
5299
+ },
5300
+ // `notExistsInMap(id, map: Record<string, unknown>): boolean` — the named
5301
+ // inverse, for a CallCondition alone: a computed reads `!existsInMap`.
5302
+ notExistsInMap: {
5303
+ params: [ID, MAP],
5304
+ returns: { type: "boolean", cardinality: "one" },
5305
+ narrowTo: ["call-condition"]
5306
+ },
5307
+ // `missingFromMap(ids: string[], map: Record<string, unknown>): string[] |
5308
+ // undefined` — the ids a `map` does not hold yet, in id order and each
5309
+ // once: what is still to fetch. `undefined` while the ids are missing or
5310
+ // empty and once the map holds every one; every id while the map is
5311
+ // missing. A ScreenComputed or a CallCompute by its signature: it answers
5312
+ // neither a `boolean` nor `T` (ADR 0216).
5313
+ missingFromMap: {
5129
5314
  params: [
5130
- { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
5131
- { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
5315
+ {
5316
+ id: ONE_FUNCTION_IDS_PARAM,
5317
+ name: "ids",
5318
+ type: "string",
5319
+ cardinality: "many"
5320
+ },
5321
+ MAP
5132
5322
  ],
5133
- rowParamId: ONE_FUNCTION_MAP_PARAM,
5134
- rowCardinality: "map"
5135
- }),
5136
- // `notExistsInMap(id, map: Record<string, unknown>): boolean` — the
5137
- // named inverse, offered on CallConditions (ADR 0202).
5138
- defineOneFunction({
5139
- name: "notExistsInMap",
5140
- reach: ["call-condition"],
5141
- returns: "boolean",
5323
+ returns: { type: "string", cardinality: "many", optional: true }
5324
+ },
5325
+ // `anyMissingFromMap(ids: string[], map: Record<string, unknown>): boolean`
5326
+ // — whether `missingFromMap` would answer any id: the gate a batch call is
5327
+ // dropped by once every row is held (ADR 0216). For a CallCondition alone:
5328
+ // a computed reads `missingFromMap` itself.
5329
+ anyMissingFromMap: {
5142
5330
  params: [
5143
- { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
5144
- { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
5331
+ {
5332
+ id: ONE_FUNCTION_IDS_PARAM,
5333
+ name: "ids",
5334
+ type: "string",
5335
+ cardinality: "many"
5336
+ },
5337
+ MAP
5145
5338
  ],
5146
- rowParamId: ONE_FUNCTION_MAP_PARAM,
5147
- rowCardinality: "map"
5148
- }),
5339
+ returns: { type: "boolean", cardinality: "one" },
5340
+ narrowTo: ["call-condition"]
5341
+ },
5149
5342
  // `setInMap<T>(id, data: T, map: Record<string, T>): Record<string, T>` —
5150
5343
  // the map with `data` held under `id`, every other entry kept (ADR 0205).
5151
- // `loadCoin(id)` answers one coin and `coinsById[id]` is where it lands.
5152
- // Offered on an OutcomeTransform alone, where the landing names `T`.
5153
- defineOneFunction({
5154
- name: "setInMap",
5155
- reach: ["outcome-transform"],
5156
- returns: "row-map",
5344
+ // For an OutcomeTransform alone: a computed has no landing to keep entries of.
5345
+ setInMap: {
5157
5346
  params: [
5158
- { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
5159
- { id: ONE_FUNCTION_DATA_PARAM, name: "data", rule: "row-one" },
5160
- { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
5347
+ ID,
5348
+ {
5349
+ id: ONE_FUNCTION_DATA_PARAM,
5350
+ name: "data",
5351
+ type: "T",
5352
+ cardinality: "one"
5353
+ },
5354
+ MAP
5161
5355
  ],
5162
- rowParamId: ONE_FUNCTION_DATA_PARAM,
5163
- rowCardinality: "one"
5164
- })
5356
+ returns: { type: "T", cardinality: "map" },
5357
+ narrowTo: ["outcome-transform"]
5358
+ },
5359
+ // `mapMany<T>(data: T[], key: keyof T, map: Record<string, T[]>):
5360
+ // Record<string, T[]>` — a flat list of rows landed into a `map-many`, each
5361
+ // row grouped under its `key` member: a batch `loadCurves(ids)` answers
5362
+ // every strategy's points in one list, each naming its strategy in `sid`.
5363
+ // A key the list names has its list replaced, every other entry is kept.
5364
+ mapMany: {
5365
+ params: [
5366
+ {
5367
+ id: ONE_FUNCTION_DATA_PARAM,
5368
+ name: "data",
5369
+ type: "T",
5370
+ cardinality: "many"
5371
+ },
5372
+ {
5373
+ id: ONE_FUNCTION_KEY_PARAM,
5374
+ name: "key",
5375
+ type: "string",
5376
+ cardinality: "one"
5377
+ },
5378
+ { ...MAP, cardinality: "map-many" }
5379
+ ],
5380
+ returns: { type: "T", cardinality: "map-many" },
5381
+ narrowTo: ["outcome-transform"]
5382
+ },
5383
+ // `pluckStrings<T>(items: T[], key: string): string[]` — the `string`
5384
+ // values one member of each row holds, in row order: the ids of a list a
5385
+ // later lookup reads by. `key` is typed in like `mapMany`'s, prefilled with
5386
+ // the row's id-named `string` member; a value that is not a string is
5387
+ // skipped, and missing items or key answer `[]` (ADR 0218).
5388
+ pluckStrings: {
5389
+ params: [
5390
+ {
5391
+ id: ONE_FUNCTION_DATA_PARAM,
5392
+ name: "items",
5393
+ type: "T",
5394
+ cardinality: "many"
5395
+ },
5396
+ {
5397
+ id: ONE_FUNCTION_KEY_PARAM,
5398
+ name: "key",
5399
+ type: "string",
5400
+ cardinality: "one"
5401
+ }
5402
+ ],
5403
+ returns: { type: "string", cardinality: "many" }
5404
+ }
5405
+ };
5406
+ var NATIVE_ONE_FUNCTION_SPECS = {
5407
+ // `Object.assign({}, target, source)` — a keyed answer merged into a keyed
5408
+ // landing: every entry of `source` held over `target`, every other entry of
5409
+ // `target` kept. Spelled onto a fresh `{}` so the store's own state object
5410
+ // is never written in place. Lifts like `setInMap`, so `{ [id]: points }`
5411
+ // merges into a `map-many` whole.
5412
+ "Object.assign": {
5413
+ params: [
5414
+ {
5415
+ id: ONE_FUNCTION_MAP_PARAM,
5416
+ name: "target",
5417
+ type: "T",
5418
+ cardinality: "map",
5419
+ statePathOnly: true
5420
+ },
5421
+ {
5422
+ id: ONE_FUNCTION_DATA_PARAM,
5423
+ name: "source",
5424
+ type: "T",
5425
+ cardinality: "map"
5426
+ }
5427
+ ],
5428
+ returns: { type: "T", cardinality: "map" },
5429
+ narrowTo: ["outcome-transform"],
5430
+ spell: (args) => `Object.assign({}, ${args.join(", ")})`
5431
+ }
5432
+ };
5433
+ var LIFT = {
5434
+ one: "many",
5435
+ map: "map-many"
5436
+ };
5437
+ var slots = (spec) => [
5438
+ ...spec.params,
5439
+ spec.returns
5440
+ ];
5441
+ var lifts = (spec) => slots(spec).some((slot) => slot.type === "T") && slots(spec).every((slot) => slot.type !== "T" || !!liftOf(slot));
5442
+ var liftOf = (slot) => slot.liftsTo ?? LIFT[slot.cardinality];
5443
+ var liftedCardinality = (slot, lifted) => lifted && slot.type === "T" ? liftOf(slot) ?? slot.cardinality : slot.cardinality;
5444
+ var slotDataType = (slot, row) => slot.type === "T" ? row : { type: slot.type };
5445
+ var oneFunctionSiteFits = (spec, reach) => reach === "call-condition" ? spec.returns.type === "boolean" && spec.returns.cardinality === "one" : reach === "outcome-transform" ? spec.returns.type === "T" : true;
5446
+ var REACHES = [
5447
+ "screen-computed",
5448
+ "state-computed",
5449
+ "call-condition",
5450
+ "call-compute",
5451
+ "outcome-transform"
5165
5452
  ];
5453
+ var defineOneFunction = (name3, spec) => {
5454
+ const liftable = lifts(spec);
5455
+ const params = spec.params.map(
5456
+ ({ liftsTo: _declared, ...param }) => ({
5457
+ ...param,
5458
+ ...liftable && param.type === "T" ? { liftsTo: liftOf(param) } : {}
5459
+ })
5460
+ );
5461
+ const rowParam = params.find((param) => param.type === "T" && param.statePathOnly) ?? params.find((param) => param.type === "T");
5462
+ return {
5463
+ name: name3,
5464
+ ..."spell" in spec ? { spell: spec.spell } : { importFrom: ONE_IMPORT_MODULE },
5465
+ reach: REACHES.filter(
5466
+ (reach) => oneFunctionSiteFits(spec, reach) && (!spec.narrowTo || spec.narrowTo.includes(reach))
5467
+ ),
5468
+ ...spec.narrowTo ? { narrowTo: spec.narrowTo } : {},
5469
+ returnsRow: spec.returns.type === "T",
5470
+ params,
5471
+ returns: spec.returns,
5472
+ rowParamId: rowParam?.id ?? "",
5473
+ signature: (row, lifted = false) => ({
5474
+ params: params.map(
5475
+ (param) => ({
5476
+ id: param.id,
5477
+ name: param.name,
5478
+ dataType: slotDataType(param, row),
5479
+ cardinality: liftedCardinality(param, lifted),
5480
+ acceptsUndefined: true
5481
+ })
5482
+ ),
5483
+ returnType: slotDataType(spec.returns, row),
5484
+ returnCardinality: liftedCardinality(spec.returns, lifted),
5485
+ ...spec.returns.optional ? { returnUndefined: true } : {}
5486
+ })
5487
+ };
5488
+ };
5489
+ var ONE_FUNCTIONS = [
5490
+ ...Object.entries(ONE_FUNCTION_SPECS),
5491
+ ...Object.entries(NATIVE_ONE_FUNCTION_SPECS)
5492
+ ].map(([name3, spec]) => defineOneFunction(name3, spec));
5493
+ var isNativeOneFunction = (entry2) => !!entry2?.spell;
5166
5494
  var ONE_FUNCTION_CATALOG = Object.fromEntries(ONE_FUNCTIONS.map((entry2) => [entry2.name, entry2]));
5167
5495
  var oneFunctionOf = (name3) => name3 ? ONE_FUNCTIONS.find((entry2) => entry2.name === name3) : void 0;
5168
5496
  var listOneFunctions = (reach = "screen-computed") => ONE_FUNCTIONS.filter((entry2) => entry2.reach.includes(reach)).sort(
@@ -5170,26 +5498,28 @@ var listOneFunctions = (reach = "screen-computed") => ONE_FUNCTIONS.filter((entr
5170
5498
  );
5171
5499
  var oneFunctionPickValue = (name3) => `${ONE_FUNCTION_PREFIX}${name3}`;
5172
5500
  var oneFunctionFromPickValue = (value) => value?.startsWith(ONE_FUNCTION_PREFIX) ? oneFunctionOf(value.slice(ONE_FUNCTION_PREFIX.length)) : void 0;
5501
+ var oneParamStatePathOnly = (param) => !!param.statePathOnly;
5502
+ var oneParamTakesFixed = (param) => param.type !== "T" && param.cardinality === "one" && !param.statePathOnly;
5503
+ var oneParamFixedHeld = (param, value) => oneParamTakesFixed(param) && param.type !== "T" && typeof value === param.type ? { dataType: { type: param.type }, cardinality: "one" } : void 0;
5173
5504
  function oneFunctionArgFits(param, held, fromPath) {
5174
5505
  if (!held) return false;
5175
- if (param.rule === "string-one")
5176
- return held.dataType.type === "string" && held.cardinality === "one";
5177
- if (param.rule === "row-one") return held.cardinality === "one";
5178
- return fromPath && isKeyedCardinality(held.cardinality);
5179
- }
5180
- var isKeyedCardinality = (cardinality) => cardinality === "map" || cardinality === "map-many";
5181
- function listedSignature(entry2, signature) {
5182
- return {
5183
- ...signature,
5184
- params: signature.params.map(
5185
- (param, index) => param.cardinality === "map" ? { ...param, cardinality: "map-many" } : entry2.params[index]?.rule === "row-one" ? { ...param, cardinality: "many" } : param
5186
- ),
5187
- returnCardinality: !entry2.returnsRow ? signature.returnCardinality : signature.returnCardinality === "map" ? "map-many" : "many"
5188
- };
5189
- }
5190
- var isListed = (entry2, cardinality) => entry2.returnsRow && (cardinality === "many" || cardinality === "map-many");
5191
- function oneFunctionReturns(entry2, row, mapCardinality = "map") {
5192
- const signature = mapCardinality === "map-many" ? listedSignature(entry2, entry2.signature(row)) : entry2.signature(row);
5506
+ if (param.statePathOnly && !fromPath) return false;
5507
+ if (param.type !== "T")
5508
+ return held.dataType.type === param.type && held.cardinality === param.cardinality;
5509
+ return held.cardinality === param.cardinality || held.cardinality === param.liftsTo;
5510
+ }
5511
+ var liftedBy = (entry2, paramId, cardinality) => {
5512
+ const param = entry2.params.find((candidate) => candidate.id === paramId);
5513
+ return !!param?.liftsTo && cardinality === param.liftsTo;
5514
+ };
5515
+ var oneFunctionLiftedAt = (entry2, cardinality) => entry2.returnsRow && !!entry2.params.some((param) => param.liftsTo) && cardinality !== entry2.returns.cardinality && cardinality === liftOf(entry2.returns);
5516
+ var oneFunctionFitsLanding = (entry2, cardinality) => entry2.returnsRow && (cardinality === entry2.returns.cardinality || oneFunctionLiftedAt(entry2, cardinality));
5517
+ var oneFunctionMintsKey = (entry2) => entry2.returnsRow && (entry2.returns.cardinality === "map" || entry2.returns.cardinality === "map-many");
5518
+ function oneFunctionReturns(entry2, row, heldCardinality) {
5519
+ const signature = entry2.signature(
5520
+ row,
5521
+ liftedBy(entry2, entry2.rowParamId, heldCardinality)
5522
+ );
5193
5523
  return {
5194
5524
  dataType: signature.returnType,
5195
5525
  cardinality: signature.returnCardinality,
@@ -5197,26 +5527,38 @@ function oneFunctionReturns(entry2, row, mapCardinality = "map") {
5197
5527
  };
5198
5528
  }
5199
5529
  function oneFunctionSignature(entry2, returns) {
5200
- const signature = entry2.signature(returns.dataType);
5201
5530
  return {
5202
5531
  id: "",
5203
5532
  name: entry2.name,
5204
5533
  // An entry answering a fixed type stores that type, not the row: its
5205
5534
  // `map` is spelled `Record<string, unknown>` by the library, so the stand-in
5206
5535
  // over the stored type reads the same at every reader.
5207
- ...isListed(entry2, returns.cardinality) ? listedSignature(entry2, signature) : signature,
5536
+ ...entry2.signature(
5537
+ returns.dataType,
5538
+ oneFunctionLiftedAt(entry2, returns.cardinality)
5539
+ ),
5540
+ body: ""
5541
+ };
5542
+ }
5543
+ function oneFunctionBoundSignature(entry2, row, heldCardinality) {
5544
+ return {
5545
+ id: "",
5546
+ name: entry2.name,
5547
+ ...entry2.signature(row, liftedBy(entry2, entry2.rowParamId, heldCardinality)),
5208
5548
  body: ""
5209
5549
  };
5210
5550
  }
5551
+ function oneParamTypeText(entry2, param, rowLabel) {
5552
+ const t = param.type !== "T" ? param.type : entry2.returnsRow ? rowLabel ?? "T" : "unknown";
5553
+ return param.cardinality === "map" ? `Record<string, ${t}>` : param.cardinality === "map-many" ? `Record<string, ${t}[]>` : param.cardinality === "many" ? `${t}[]` : t;
5554
+ }
5211
5555
  function oneFunctionSignatureText(entry2, rowLabel) {
5212
5556
  const generic = entry2.returnsRow && !rowLabel;
5213
- const t = entry2.returnsRow ? rowLabel ?? "T" : "unknown";
5214
5557
  const params = entry2.params.map(
5215
- (param) => param.rule === "string-one" ? `${param.name}: string` : param.rule === "row-one" ? `${param.name}: ${t}` : `${param.name}: Record<string, ${t}>`
5558
+ (param) => `${param.name}: ${oneParamTypeText(entry2, param, rowLabel)}`
5216
5559
  ).join(", ");
5217
- const signature = entry2.signature({ type: "string" });
5218
- const returns = !entry2.returnsRow ? "boolean" : signature.returnCardinality === "map" ? `Record<string, ${t}>` : `${t} | undefined`;
5219
- return `${entry2.name}${generic ? "<T>" : ""}(${params}): ${returns}`;
5560
+ const returns = oneParamTypeText(entry2, entry2.returns, rowLabel);
5561
+ return `${entry2.name}${generic ? "<T>" : ""}(${params}): ${entry2.returns.optional ? `${returns} | undefined` : returns}`;
5220
5562
  }
5221
5563
 
5222
5564
  // libs/codegen/src/lib/pure-function-helper.ts
@@ -5424,6 +5766,13 @@ function screenComputedFunction(computed, functions) {
5424
5766
  body: `return ${PASSTHROUGH_PARAM_ID};`
5425
5767
  };
5426
5768
  }
5769
+ function stateComputedFunction(computed, functions) {
5770
+ if (computed.functionId) return functions[computed.functionId];
5771
+ if (!computed.oneFunction || !computed.returns) return void 0;
5772
+ const entry2 = oneFunctionOf(computed.oneFunction);
5773
+ return entry2 ? oneFunctionSignature(entry2, computed.returns) : void 0;
5774
+ }
5775
+ var isOneFunctionStateComputed = (computed) => !computed.functionId && !!computed.oneFunction;
5427
5776
  var isPassthroughComputed = (computed) => !computed.functionId && !computed.oneFunction;
5428
5777
  var isOneFunctionComputed = (computed) => !computed.functionId && !!computed.oneFunction;
5429
5778
  function screenComputedNavIds(computed) {
@@ -5621,7 +5970,7 @@ function propertiesWithComputeds(properties, computeds = {}, functions = {}) {
5621
5970
  for (const computed of Object.values(computeds ?? {})) {
5622
5971
  const asProperty = computedAsProperty(
5623
5972
  computed,
5624
- functions[computed.functionId]
5973
+ stateComputedFunction(computed, functions)
5625
5974
  );
5626
5975
  if (asProperty) result[computed.id] = asProperty;
5627
5976
  }
@@ -6508,6 +6857,20 @@ var BINDING_TRANSFORM_LEAVES = [
6508
6857
  "binding"
6509
6858
  ];
6510
6859
 
6860
+ // libs/codegen/src/lib/compute-function.ts
6861
+ function computeFunction(compute, functions) {
6862
+ if (!compute) return void 0;
6863
+ if (compute.oneFunction) {
6864
+ const entry2 = computeOneFunction(compute);
6865
+ return entry2 && compute.returns ? oneFunctionSignature(entry2, compute.returns) : void 0;
6866
+ }
6867
+ return functions[compute.functionId];
6868
+ }
6869
+ var computeOneFunction = (compute) => {
6870
+ const entry2 = oneFunctionOf(compute.oneFunction);
6871
+ return entry2?.reach.includes("call-compute") ? entry2 : void 0;
6872
+ };
6873
+
6511
6874
  // libs/codegen/src/lib/outcome-transform-helper.ts
6512
6875
  var outcomeTransformOneFunction = (transform) => {
6513
6876
  const entry2 = oneFunctionOf(transform?.oneFunction);
@@ -6545,7 +6908,7 @@ var argValue = (binding, mapping, method, op, roots, shapes, functions) => {
6545
6908
  const compute = (method.computes ?? []).find(
6546
6909
  (candidate) => candidate.name === binding.name
6547
6910
  );
6548
- const fn = compute && functions[compute.functionId];
6911
+ const fn = computeFunction(compute, functions);
6549
6912
  return fn ? {
6550
6913
  value: {
6551
6914
  dataType: fn.returnType,
@@ -6652,7 +7015,8 @@ function outcomeTransformFailure(mapping, method, op, properties, shapes, functi
6652
7015
  }
6653
7016
  continue;
6654
7017
  }
6655
- if (one?.params[index]?.rule === "map-path" && binding?.source !== "state") {
7018
+ const oneParam = one?.params[index];
7019
+ if (oneParam && oneParamStatePathOnly(oneParam) && binding?.source !== "state") {
6656
7020
  return {
6657
7021
  error: "emit-gap-outcome-transform-source",
6658
7022
  paramIndex: index,
@@ -6734,6 +7098,13 @@ var SURFACE_LEAVES = {
6734
7098
  };
6735
7099
  var sameType2 = (a, b) => a.type === "shape" && b.type === "shape" ? a.shapeId === b.shapeId : a.type === b.type;
6736
7100
  var typesMatch = (a, b) => sameType2(a.dataType, b.dataType) && a.cardinality === b.cardinality;
7101
+ var typesMatchExactly = (a, b) => typesMatch(a, b) && enumIdOf(a.dataType) === enumIdOf(b.dataType) && (a.dataType.type !== "enum" || b.dataType.type !== "enum" || a.dataType.enumId === b.dataType.enumId);
7102
+ var signaturePipeIndex = (params, returnType, signature) => typesMatchExactly(returnType, signature.expected) ? params.findIndex(
7103
+ (param) => typesMatchExactly(
7104
+ { dataType: param.dataType, cardinality: param.cardinality },
7105
+ signature.pipe
7106
+ )
7107
+ ) : -1;
6737
7108
  var memberRead = (name3, ctx) => ctx.scope === "class" ? `this.${name3}` : name3;
6738
7109
  var isCall = (expr) => expr.kind === "call";
6739
7110
  var pipeParamValid = (expr, arity) => Number.isInteger(expr.pipeParam) && (expr.pipeParam >= 0 && expr.pipeParam < arity || expr.pipeParam === -1 && !expr.args.some((arg) => arg.kind === "pipe"));
@@ -7296,22 +7667,7 @@ function sanitizeLeaf(leaf) {
7296
7667
  }
7297
7668
  }
7298
7669
 
7299
- // libs/codegen/src/lib/binding-helper.ts
7300
- var screenComputedPresent = (id, screenComputeds, functions, inputs) => {
7301
- const computed = screenComputeds?.[id];
7302
- const fn = computed ? screenComputedFunction(computed, functions ?? {}) : void 0;
7303
- if (!computed || !fn) return false;
7304
- if (fn.returnUndefined === true || returnCardinalityOf(fn) !== "one") {
7305
- return false;
7306
- }
7307
- return !screenComputedIsOptional(
7308
- computed,
7309
- fn,
7310
- inputs ?? {},
7311
- screenComputeds ?? {},
7312
- functions ?? {}
7313
- );
7314
- };
7670
+ // libs/codegen/src/lib/binding-slot.ts
7315
7671
  var BINDING_SLOT = {
7316
7672
  // A `text` Control's label, and a Stat's (libs/one ADR 0022). Renders
7317
7673
  // verbatim — the case where a bound value *is* a translation key is what a
@@ -7370,7 +7726,29 @@ var BINDING_SLOT = {
7370
7726
  // A [ScoreSet]'s Score Date, named for the `m-score-set` input it lands on.
7371
7727
  // Content by the `total` test: whether the set reads stale *is* the datum's
7372
7728
  // age, read off the same record its Scores are.
7373
- scoreDate: "scoreDate"
7729
+ scoreDate: "scoreDate",
7730
+ // A toggle SectionAction's pick, named for the `m-action` input it lands on:
7731
+ // the ButtonKey the bar is lit on, followed rather than owned — a press still
7732
+ // moves it (m-one-ui ADR 0213). Exclusive with the static pick held in
7733
+ // `configs.selection`, a Button's Control id.
7734
+ selection: "selection"
7735
+ };
7736
+
7737
+ // libs/codegen/src/lib/binding-helper.ts
7738
+ var screenComputedPresent = (id, screenComputeds, functions, inputs) => {
7739
+ const computed = screenComputeds?.[id];
7740
+ const fn = computed ? screenComputedFunction(computed, functions ?? {}) : void 0;
7741
+ if (!computed || !fn) return false;
7742
+ if (fn.returnUndefined === true || returnCardinalityOf(fn) !== "one") {
7743
+ return false;
7744
+ }
7745
+ return !screenComputedIsOptional(
7746
+ computed,
7747
+ fn,
7748
+ inputs ?? {},
7749
+ screenComputeds ?? {},
7750
+ functions ?? {}
7751
+ );
7374
7752
  };
7375
7753
  var USER_VALUE_SLOTS = [
7376
7754
  BINDING_SLOT.id,
@@ -8382,7 +8760,7 @@ function fieldKeyType(configs) {
8382
8760
  if (type === "toggle" /* TOGGLE */ || type === "checkbox" /* CHECKBOX */) {
8383
8761
  return { dataType: { type: "boolean" }, cardinality: "one" };
8384
8762
  }
8385
- if (type === "rating" /* RATING */) {
8763
+ if (type === "rating" /* RATING */ || type === "number" /* NUMBER */ || type === "money" /* MONEY */ || type === "range" /* RANGE */) {
8386
8764
  return { dataType: { type: "number" }, cardinality: "one" };
8387
8765
  }
8388
8766
  if (type === "multi_range" /* MULTI_RANGE */) {
@@ -8486,6 +8864,14 @@ function formShapeMap(controlMap) {
8486
8864
  function formEventMembers(controlMap, formId) {
8487
8865
  return buildFormShape(controlMap, formId)?.keys.map((key2) => key2.name) ?? [];
8488
8866
  }
8867
+ function formEventFieldTypes(controlMap, formId) {
8868
+ return Object.fromEntries(
8869
+ (buildFormShape(controlMap, formId)?.keys ?? []).map((key2) => [
8870
+ key2.name,
8871
+ { dataType: key2.dataType, cardinality: key2.cardinality }
8872
+ ])
8873
+ );
8874
+ }
8489
8875
  var OUTPUT_EVENT_MAPS = [
8490
8876
  "outputArgs",
8491
8877
  "outputWrites",
@@ -8674,8 +9060,8 @@ var rootShapeId = (binding, scope, seen) => {
8674
9060
  return scope.formModels?.[root.id]?.formId;
8675
9061
  }
8676
9062
  if (root.kind === "computed") {
8677
- const functionId = scope.computeds?.[root.id]?.functionId;
8678
- const returnType = functionId ? scope.functions?.[functionId]?.returnType : void 0;
9063
+ const computed = scope.computeds?.[root.id];
9064
+ const returnType = computed ? stateComputedFunction(computed, scope.functions ?? {})?.returnType : void 0;
8679
9065
  if (returnType?.type === "shape") return returnType.shapeId;
8680
9066
  const folded = scope.properties?.[root.id]?.dataType;
8681
9067
  return folded?.type === "shape" ? folded.shapeId : void 0;
@@ -8743,7 +9129,7 @@ var bindingCardinality = (binding, scope, seen = /* @__PURE__ */ new Set()) => {
8743
9129
  }
8744
9130
  case "computed": {
8745
9131
  const computed = scope.computeds?.[root.id];
8746
- const fn = computed ? scope.functions?.[computed.functionId] : void 0;
9132
+ const fn = computed ? stateComputedFunction(computed, scope.functions ?? {}) : void 0;
8747
9133
  const folded = fn ? void 0 : scope.properties?.[root.id];
8748
9134
  dataType = fn?.returnType ?? folded?.dataType;
8749
9135
  cardinality = fn ? returnCardinalityOf(fn) : folded?.cardinality;
@@ -8932,7 +9318,7 @@ var bindingExpression = (binding, scope, guardAlias) => {
8932
9318
  const leafRead = (leaf) => bindingExpression(leaf, scope);
8933
9319
  const leaves = transformBindingLeaves(binding.transform);
8934
9320
  if (leaves.some((leaf) => !leafRead(leaf))) return void 0;
8935
- return emitTransformExpr(binding.transform, expr, {
9321
+ const call = emitTransformExpr(binding.transform, expr, {
8936
9322
  bindingRead: leafRead,
8937
9323
  functions: scope.functions ?? {},
8938
9324
  properties: roots,
@@ -8947,6 +9333,38 @@ var bindingExpression = (binding, scope, guardAlias) => {
8947
9333
  // one binding never spells the store two ways.
8948
9334
  storeReceiver: (rootId) => scope.storePropOf?.(rootId) ?? scope.storeProp ?? "store"
8949
9335
  });
9336
+ const guards = functionCallGuards(binding, expr, scope, leafRead);
9337
+ if (!guards.length) return call;
9338
+ const hoisted = scope.memberPrefix ? void 0 : guards.map((read) => scope.hoist?.(read));
9339
+ if (hoisted?.every((name3) => !!name3)) {
9340
+ const named = [...guards].map((read, i) => ({ read, name: hoisted[i] })).sort((a, b) => b.read.length - a.read.length).reduce((text3, { read, name: name3 }) => text3.split(read).join(name3), call);
9341
+ return `(${hoisted.map((name3) => `${name3} === undefined`).join(" || ")} ? undefined : ${named})`;
9342
+ }
9343
+ return `(${guards.map((read) => `${read} === undefined`).join(" || ")} ? undefined : ${call})`;
9344
+ };
9345
+ var functionCallGuards = (binding, pipeRead, scope, leafRead) => {
9346
+ if (binding.source !== "function") return [];
9347
+ const call = outerCall(binding.transform);
9348
+ const target = call?.target;
9349
+ if (!call || !target || !("functionId" in target)) return [];
9350
+ const fn = scope.functions?.[target.functionId];
9351
+ if (!fn) return [];
9352
+ const absent = (read, text3) => text3.includes("?.") || !rootIsPresent(read, scope);
9353
+ const guards = [];
9354
+ call.args.forEach((arg, i) => {
9355
+ if (fn.params[i]?.acceptsUndefined || "target" in arg) return;
9356
+ if (arg.kind === "pipe") {
9357
+ if (binding.root.kind !== "none" && absent(binding, pipeRead)) {
9358
+ guards.push(pipeRead);
9359
+ }
9360
+ return;
9361
+ }
9362
+ if (arg.kind === "binding" && arg.binding) {
9363
+ const read = leafRead(arg.binding);
9364
+ if (read && absent(arg.binding, read)) guards.push(read);
9365
+ }
9366
+ });
9367
+ return [...new Set(guards)];
8950
9368
  };
8951
9369
  var guardedBindingRead = (binding, scope, alias) => {
8952
9370
  const root = rootExpression(binding, scope);
@@ -9720,6 +10138,14 @@ var bindingPipeType = (row, target, scope) => {
9720
10138
  if (!picked?.dataType) return void 0;
9721
10139
  return { dataType: picked.dataType, cardinality: picked.cardinality };
9722
10140
  };
10141
+ function callArgTransformSignature(row, target, scope) {
10142
+ if (!target?.dataType) return void 0;
10143
+ const expected = {
10144
+ dataType: target.dataType,
10145
+ cardinality: target.cardinality
10146
+ };
10147
+ return { pipe: bindingPipeType(row, target, scope) ?? expected, expected };
10148
+ }
9723
10149
  var rowComplete = (row, target, payload, fieldNames, constants, functions, scope) => {
9724
10150
  if (!target) return "call-arg-unknown-target";
9725
10151
  if (!row.source) return "call-arg-incomplete";
@@ -10520,16 +10946,22 @@ function screenWriteToggleAllowed(variable) {
10520
10946
  function screenWriteEventAllowed(payload) {
10521
10947
  return payload !== "void";
10522
10948
  }
10523
- function writeEventReadType(value, payload) {
10524
- if (value.kind !== "event" || value.path?.length) return void 0;
10949
+ var PRIMITIVES = ["string", "number", "boolean"];
10950
+ function writeEventReadType(value, payload, fields = {}) {
10951
+ if (value.kind !== "event") return void 0;
10952
+ if (value.path?.length) {
10953
+ return value.path.length === 1 ? fields[value.path[0]] : void 0;
10954
+ }
10525
10955
  if (payload === "string" || payload === "number" || payload === "boolean") {
10526
10956
  return { dataType: { type: payload }, cardinality: "one" };
10527
10957
  }
10528
10958
  return void 0;
10529
10959
  }
10530
- function writeEventIssue(value, payload, target, functions) {
10960
+ var readMisfits = (read, target) => read.cardinality === "one" && target.cardinality === "one" && PRIMITIVES.includes(read.dataType.type) && read.dataType.type !== target.dataType.type;
10961
+ var typeName2 = (type) => type.cardinality === "many" ? `${type.dataType.type}[]` : type.dataType.type;
10962
+ function writeEventIssue(value, payload, target, functions, fields = {}) {
10531
10963
  if (value.kind !== "event") return void 0;
10532
- const read = writeEventReadType(value, payload);
10964
+ const read = writeEventReadType(value, payload, fields);
10533
10965
  if (value.transform) {
10534
10966
  const err = validateTransform(
10535
10967
  value.transform,
@@ -10541,19 +10973,26 @@ function writeEventIssue(value, payload, target, functions) {
10541
10973
  if (!err) return void 0;
10542
10974
  return err === "value-transform-incomplete" ? "incomplete" : "type-mismatch";
10543
10975
  }
10544
- if (!read || target.cardinality !== "one") return void 0;
10545
- return read.dataType.type === target.dataType.type ? void 0 : "type-mismatch";
10976
+ return read && readMisfits(read, target) ? "type-mismatch" : void 0;
10546
10977
  }
10547
- function writeEventMismatch(value, payload, target) {
10548
- if (value.kind !== "event" || value.transform) return void 0;
10549
- const read = writeEventReadType(value, payload);
10550
- if (!read || target.cardinality !== "one" || read.dataType.type === target.dataType.type) {
10551
- return void 0;
10978
+ function writeEventMismatch(value, payload, target, functions = {}, fields = {}) {
10979
+ if (value.kind !== "event") return void 0;
10980
+ const read = writeEventReadType(value, payload, fields);
10981
+ if (value.transform) {
10982
+ const inferred = inferTransformType(
10983
+ value.transform,
10984
+ read ?? target,
10985
+ "call-arg",
10986
+ functions
10987
+ );
10988
+ if (!inferred.ok || typesMatch(inferred.type, target)) return void 0;
10989
+ return { from: typeName2(inferred.type), to: typeName2(target) };
10552
10990
  }
10991
+ if (!read || !readMisfits(read, target)) return void 0;
10553
10992
  const fix = castTransform(read, target);
10554
10993
  return {
10555
- from: read.dataType.type,
10556
- to: target.dataType.type,
10994
+ from: typeName2(read),
10995
+ to: typeName2(target),
10557
10996
  ...fix ? { fix } : {}
10558
10997
  };
10559
10998
  }
@@ -10619,7 +11058,7 @@ function nextScreenWriteRow(variables, rows, payload, inputs, constants = {}) {
10619
11058
  value: defaultScreenWriteValue(free.variable, payload, inputs, constants)
10620
11059
  };
10621
11060
  }
10622
- function validateScreenWrites(variables, rows, payload, fieldNames, inputs, constants = {}, functions = {}) {
11061
+ function validateScreenWrites(variables, rows, payload, fieldNames, inputs, constants = {}, functions = {}, fields = {}) {
10623
11062
  const seen = /* @__PURE__ */ new Set();
10624
11063
  for (const row of rows) {
10625
11064
  if (seen.has(row.variableId)) return "screen-write-duplicate";
@@ -10658,7 +11097,8 @@ function validateScreenWrites(variables, rows, payload, fieldNames, inputs, cons
10658
11097
  value,
10659
11098
  payload,
10660
11099
  { dataType: { type: variable.dataType }, cardinality: variable.cardinality },
10661
- functions
11100
+ functions,
11101
+ fields
10662
11102
  );
10663
11103
  if (issue === "incomplete") return "screen-write-incomplete";
10664
11104
  if (issue) return "screen-write-type-mismatch";
@@ -10957,7 +11397,7 @@ function nextStateWriteRow(properties, rows, payload, inputs, constants = {}) {
10957
11397
  value: defaultStateWriteValue(free.property, payload, inputs, constants)
10958
11398
  };
10959
11399
  }
10960
- function validateStateWrites(properties, rows, payload, fieldNames, inputs, constants = {}, functions = {}) {
11400
+ function validateStateWrites(properties, rows, payload, fieldNames, inputs, constants = {}, functions = {}, fields = {}) {
10961
11401
  const seen = /* @__PURE__ */ new Set();
10962
11402
  for (const row of rows) {
10963
11403
  if (seen.has(row.propertyId)) return "state-write-duplicate";
@@ -10996,7 +11436,8 @@ function validateStateWrites(properties, rows, payload, fieldNames, inputs, cons
10996
11436
  value,
10997
11437
  payload,
10998
11438
  { dataType: property.dataType, cardinality: property.cardinality },
10999
- functions
11439
+ functions,
11440
+ fields
11000
11441
  );
11001
11442
  if (issue === "incomplete") return "state-write-incomplete";
11002
11443
  if (issue) return "state-write-type-mismatch";
@@ -11730,6 +12171,40 @@ function moveOutputBlock(control, from, block2, to) {
11730
12171
  [map]: writeKey(writeKey(all, from, void 0), to, row)
11731
12172
  };
11732
12173
  }
12174
+ var HELD_BLOCK_KEY = "__held-block";
12175
+ var detach = (value) => JSON.parse(JSON.stringify(value));
12176
+ function holdOutputBlock(control, from, block2) {
12177
+ if (block2.kind === "call" && !isOutputCallBound(control, outputCallKeys(control, from)[block2.index] ?? "")) {
12178
+ return void 0;
12179
+ }
12180
+ const lifted = moveOutputBlock(control, from, block2, HELD_BLOCK_KEY);
12181
+ if (!lifted || lifted === control) return void 0;
12182
+ return {
12183
+ kind: block2.kind,
12184
+ rows: detach(rowsAt(lifted, HELD_BLOCK_KEY))
12185
+ };
12186
+ }
12187
+ function dropOutputBlock(control, from, block2) {
12188
+ const lifted = moveOutputBlock(control, from, block2, HELD_BLOCK_KEY);
12189
+ if (!lifted || lifted === control) return void 0;
12190
+ return clearOutputGroupRows(lifted, HELD_BLOCK_KEY);
12191
+ }
12192
+ function placeOutputBlock(control, held, to) {
12193
+ if (held.kind === "close") return void 0;
12194
+ const seeded = { ...control };
12195
+ for (const [map, row] of Object.entries(held.rows)) {
12196
+ seeded[map] = {
12197
+ ...control[map] ?? {},
12198
+ [HELD_BLOCK_KEY]: detach(row)
12199
+ };
12200
+ }
12201
+ return moveOutputBlock(
12202
+ seeded,
12203
+ HELD_BLOCK_KEY,
12204
+ { kind: held.kind, index: 0 },
12205
+ to
12206
+ );
12207
+ }
11733
12208
  var outputGroupHoldsBlocks = (control, key2) => Object.keys(rowsAt(control, key2)).length > 0 || outputCallIds(control, key2).length > 0;
11734
12209
  function tidyOutputArms(control, output) {
11735
12210
  let next = control;
@@ -11863,6 +12338,82 @@ function validateVariantName(name3, variants, propertyNames, currentId) {
11863
12338
  ) || propertyNames.includes(name3);
11864
12339
  return taken ? "variant-name-taken" : null;
11865
12340
  }
12341
+ var SUGGESTED_NAME_MAX = 40;
12342
+ var OPERATOR_WORDS = {
12343
+ "==": "is",
12344
+ "!=": "is_not",
12345
+ ">": "gt",
12346
+ ">=": "gte",
12347
+ "<": "lt",
12348
+ "<=": "lte",
12349
+ contains: "has",
12350
+ not_contains: "lacks",
12351
+ exists: "has",
12352
+ not_exists: "no"
12353
+ };
12354
+ var toNameWords = (raw) => raw.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
12355
+ var joinWords = (...parts) => parts.filter(Boolean).join("_");
12356
+ var navWords = (navId) => joinWords(toNameWords(navId.split("/").at(-1) ?? ""), "open");
12357
+ function suggestVariantName(rule, sources, isTaken) {
12358
+ const { properties, shapes, functions = {} } = sources;
12359
+ const complete = (node) => ruleError(node, properties, shapes, functions) === null;
12360
+ const segmentNames = (path) => resolvePath(path, properties, shapes).map((segment) => segment.name);
12361
+ const checks = [];
12362
+ const collect2 = (node) => {
12363
+ if (node.kind === "group") node.children.forEach(collect2);
12364
+ else if (node.kind === "check" && complete(node)) checks.push(node);
12365
+ };
12366
+ collect2(rule);
12367
+ const lastCounts = /* @__PURE__ */ new Map();
12368
+ for (const check of checks) {
12369
+ const last = segmentNames(check.path).at(-1) ?? "";
12370
+ lastCounts.set(last, (lastCounts.get(last) ?? 0) + 1);
12371
+ }
12372
+ const pathWords = (path) => {
12373
+ const names = segmentNames(path);
12374
+ const last = names.at(-1) ?? "";
12375
+ return toNameWords(
12376
+ (lastCounts.get(last) ?? 0) > 1 ? names.join("_") : last
12377
+ );
12378
+ };
12379
+ const checkWords = (check) => {
12380
+ const path = joinWords(pathWords(check.path), check.count ? "count" : "");
12381
+ const quantifier = check.quantifier === "every" ? "all" : check.quantifier === "none" ? "no" : "";
12382
+ const op = OPERATOR_WORDS[check.operator];
12383
+ if (check.operator === "exists" || check.operator === "not_exists")
12384
+ return joinWords(quantifier, op, path);
12385
+ const right = check.operand.kind === "path" ? toNameWords(segmentNames(check.operand.path).at(-1) ?? "") : toNameWords(String(check.operand.value)) || "empty";
12386
+ return joinWords(quantifier, path, op, right);
12387
+ };
12388
+ const leaves = [];
12389
+ const words = (node) => {
12390
+ if (node.kind === "group") {
12391
+ const parts = node.children.map(words).filter(Boolean);
12392
+ if (!parts.length) return "";
12393
+ const joined = parts.join(node.connective === "all" ? "_and_" : "_or_");
12394
+ return node.negated ? joinWords("not", joined) : joined;
12395
+ }
12396
+ if (!complete(node)) return "";
12397
+ const leaf = node.kind === "check" ? checkWords(node) : node.kind === "call" ? toNameWords(globalRuleOf(node.ruleId)?.member ?? node.ruleId) : node.kind === "function" ? toNameWords(functions[node.functionId]?.name ?? "") : navWords(node.navId);
12398
+ if (leaf) leaves.push(leaf);
12399
+ return leaf;
12400
+ };
12401
+ const full = words(rule);
12402
+ const name3 = full.length > SUGGESTED_NAME_MAX ? joinWords(leaves[0], "etc") : full;
12403
+ return freeVariantName(name3, isTaken);
12404
+ }
12405
+ function suggestNavVariantName(navId, isTaken) {
12406
+ return navId ? freeVariantName(navWords(navId), isTaken) : "";
12407
+ }
12408
+ function freeVariantName(raw, isTaken) {
12409
+ if (!raw) return "";
12410
+ const name3 = /^[a-z]/.test(raw) ? raw : `v_${raw}`;
12411
+ const unavailable = (candidate) => candidate === BASE_VARIANT_NAME || isReservedVariantName(candidate) || isTaken(candidate);
12412
+ if (!unavailable(name3)) return name3;
12413
+ let n = 2;
12414
+ while (unavailable(`${name3}_${n}`)) n += 1;
12415
+ return `${name3}_${n}`;
12416
+ }
11866
12417
  function isKnownVariantId(id, variants) {
11867
12418
  if (variants[id]) return true;
11868
12419
  if (isBusyVariantId(id)) return true;
@@ -12584,40 +13135,40 @@ var isMenuActionSlotComplete = (slot) => slot.checks.length > 0 && slot.checks.e
12584
13135
  var menuActionSlot = (control, slotId) => menuActionSlots(control).find((slot) => slot.id === slotId);
12585
13136
  var menuActionCheckLabel = (check) => isUnaryMenuActionOperator(check.operator) ? `${check.member} ${check.operator.replace("_", " ")}` : `${check.member} ${check.operator} ${(check.value ?? "").trim()}`;
12586
13137
  var menuActionSummary = (slot) => slot.checks.map(menuActionCheckLabel).join(" and ");
12587
- var withSlots = (control, slots) => ({
13138
+ var withSlots = (control, slots2) => ({
12588
13139
  ...control,
12589
- menuActions: slots.length ? slots : void 0
13140
+ menuActions: slots2.length ? slots2 : void 0
12590
13141
  });
12591
13142
  function mintMenuActionSlot(control) {
12592
13143
  const slotId = genId();
12593
- const slots = [...menuActionSlots(control), { id: slotId, checks: [] }];
12594
- return { control: withSlots(control, slots), slotId };
13144
+ const slots2 = [...menuActionSlots(control), { id: slotId, checks: [] }];
13145
+ return { control: withSlots(control, slots2), slotId };
12595
13146
  }
12596
13147
  function setMenuActionChecks(control, slotId, checks) {
12597
- const slots = menuActionSlots(control);
12598
- if (!slots.some((slot) => slot.id === slotId)) return control;
13148
+ const slots2 = menuActionSlots(control);
13149
+ if (!slots2.some((slot) => slot.id === slotId)) return control;
12599
13150
  return withSlots(
12600
13151
  control,
12601
- slots.map((slot) => slot.id === slotId ? { ...slot, checks } : slot)
13152
+ slots2.map((slot) => slot.id === slotId ? { ...slot, checks } : slot)
12602
13153
  );
12603
13154
  }
12604
13155
  function moveMenuActionSlot(control, slotId, delta) {
12605
- const slots = menuActionSlots(control);
12606
- const from = slots.findIndex((slot) => slot.id === slotId);
13156
+ const slots2 = menuActionSlots(control);
13157
+ const from = slots2.findIndex((slot) => slot.id === slotId);
12607
13158
  if (from < 0) return control;
12608
- const to = Math.min(Math.max(from + delta, 0), slots.length - 1);
13159
+ const to = Math.min(Math.max(from + delta, 0), slots2.length - 1);
12609
13160
  if (to === from) return control;
12610
- const next = [...slots];
13161
+ const next = [...slots2];
12611
13162
  const [moved] = next.splice(from, 1);
12612
13163
  next.splice(to, 0, moved);
12613
13164
  return withSlots(control, next);
12614
13165
  }
12615
13166
  function removeMenuActionSlot(control, slotId) {
12616
- const slots = menuActionSlots(control);
12617
- if (!slots.some((slot) => slot.id === slotId)) return control;
13167
+ const slots2 = menuActionSlots(control);
13168
+ if (!slots2.some((slot) => slot.id === slotId)) return control;
12618
13169
  const dropped = withSlots(
12619
13170
  control,
12620
- slots.filter((slot) => slot.id !== slotId)
13171
+ slots2.filter((slot) => slot.id !== slotId)
12621
13172
  );
12622
13173
  return clearOutputGroupRows(dropped, menuActionKey(slotId));
12623
13174
  }
@@ -12625,9 +13176,9 @@ function renameMenuItemId(control, from, to) {
12625
13176
  const before = from.trim();
12626
13177
  const after = to.trim();
12627
13178
  if (!before || !after || before === after) return control;
12628
- const slots = menuActionSlots(control);
13179
+ const slots2 = menuActionSlots(control);
12629
13180
  let touched = false;
12630
- const next = slots.map((slot) => {
13181
+ const next = slots2.map((slot) => {
12631
13182
  if (!namesItem(slot, before)) return slot;
12632
13183
  touched = true;
12633
13184
  return {
@@ -12865,7 +13416,7 @@ function methodArgs(method, op) {
12865
13416
  out.push({
12866
13417
  name: param.name,
12867
13418
  dataType: param.dataType,
12868
- cardinality: "one",
13419
+ cardinality: param.cardinality ?? "one",
12869
13420
  shapes: {},
12870
13421
  optional: !param.required
12871
13422
  });
@@ -12883,7 +13434,7 @@ function argSubjectType(method, op, arg) {
12883
13434
  );
12884
13435
  }
12885
13436
  const param = (method.params ?? []).find((one) => one.name === arg);
12886
- return param ? { dataType: param.dataType, cardinality: "one" } : void 0;
13437
+ return param ? { dataType: param.dataType, cardinality: param.cardinality ?? "one" } : void 0;
12887
13438
  }
12888
13439
  function methodSignature(args) {
12889
13440
  if (!args.length) return "f()";
@@ -13145,7 +13696,7 @@ function authoredArgs(method) {
13145
13696
  out.push({
13146
13697
  name: param.name,
13147
13698
  dataType: param.dataType,
13148
- cardinality: "one",
13699
+ cardinality: param.cardinality ?? "one",
13149
13700
  shapes: {},
13150
13701
  optional: !param.required
13151
13702
  });
@@ -14491,7 +15042,9 @@ var FORMAT_PIPE_CATALOG = [
14491
15042
  // two are offered rather than typed.
14492
15043
  { name: "system", dataType: STR2, options: ["IN", "INTL"], default: "IN" },
14493
15044
  { name: "symbol", dataType: STR2, default: "\u20B9" },
14494
- { name: "forceSign", dataType: BOOL2, default: false }
15045
+ { name: "forceSign", dataType: BOOL2, default: false },
15046
+ // The modulus — the amount printed with no sign, negative or not.
15047
+ { name: "mod", dataType: BOOL2, default: false }
14495
15048
  ]
14496
15049
  },
14497
15050
  {
@@ -14903,6 +15456,65 @@ var createCompute = () => ({
14903
15456
  functionId: "",
14904
15457
  args: {}
14905
15458
  });
15459
+ function oneArgHeld(binding, compute, method, args, functions, properties, shapes) {
15460
+ if (binding.source === "fixed") return void 0;
15461
+ if (binding.source === "compute") {
15462
+ const computes = method.computes ?? [];
15463
+ if (!computeReadable(computes, compute.id, binding.name)) return void 0;
15464
+ const earlier = computeFunction(
15465
+ computes.find(
15466
+ (candidate) => candidate.name.trim() === binding.name.trim()
15467
+ ),
15468
+ functions
15469
+ );
15470
+ return earlier ? { dataType: earlier.returnType, cardinality: earlier.returnCardinality } : void 0;
15471
+ }
15472
+ const read = argValue2(binding, args, properties, shapes);
15473
+ return read?.value.dataType ? { dataType: read.value.dataType, cardinality: read.value.cardinality } : void 0;
15474
+ }
15475
+ function computeOneReturns(compute, method, args, functions, properties, shapes) {
15476
+ const entry2 = computeOneFunction(compute);
15477
+ const binding = entry2 && compute.args[entry2.rowParamId];
15478
+ const held = binding && oneArgHeld(binding, compute, method, args, functions, properties, shapes);
15479
+ return held ? oneFunctionReturns(entry2, held.dataType, held.cardinality) : void 0;
15480
+ }
15481
+ function oneComputeError(compute, method, args, functions, properties, shapes) {
15482
+ const entry2 = computeOneFunction(compute);
15483
+ if (!entry2 || !compute.returns) return "emit-gap-call-compute-function";
15484
+ for (const param of entry2.params) {
15485
+ const binding = compute.args[param.id];
15486
+ if (!binding) return "emit-gap-call-compute-args";
15487
+ if (binding.source === "fixed") {
15488
+ if (!oneParamFixedHeld(param, binding.value)) {
15489
+ return "emit-gap-call-compute-type";
15490
+ }
15491
+ continue;
15492
+ }
15493
+ const held = oneArgHeld(
15494
+ binding,
15495
+ compute,
15496
+ method,
15497
+ args,
15498
+ functions,
15499
+ properties,
15500
+ shapes
15501
+ );
15502
+ if (!held) return "emit-gap-call-compute-args";
15503
+ if (!oneFunctionArgFits(param, held, binding.source === "store")) {
15504
+ return "emit-gap-call-compute-type";
15505
+ }
15506
+ }
15507
+ const expected = computeOneReturns(
15508
+ compute,
15509
+ method,
15510
+ args,
15511
+ functions,
15512
+ properties,
15513
+ shapes
15514
+ );
15515
+ const stored = compute.returns;
15516
+ return expected && JSON.stringify(expected.dataType) === JSON.stringify(stored.dataType) && expected.cardinality === stored.cardinality && !!expected.optional === !!stored.optional ? void 0 : "emit-gap-call-compute-type";
15517
+ }
14906
15518
  function computeNameTaken(method, name3, args, ownId) {
14907
15519
  const wanted = name3.trim();
14908
15520
  if (!wanted) return false;
@@ -14936,6 +15548,16 @@ function computeError(compute, method, args, functions, properties, shapes) {
14936
15548
  if (computeNameTaken(method, compute.name, args, compute.id)) {
14937
15549
  return "emit-gap-call-compute-name";
14938
15550
  }
15551
+ if (compute.oneFunction) {
15552
+ return oneComputeError(
15553
+ compute,
15554
+ method,
15555
+ args,
15556
+ functions,
15557
+ properties,
15558
+ shapes
15559
+ );
15560
+ }
14939
15561
  const fn = functions[compute.functionId];
14940
15562
  if (!fn) return "emit-gap-call-compute-function";
14941
15563
  const computes = method.computes ?? [];
@@ -14959,7 +15581,7 @@ function computeError(compute, method, args, functions, properties, shapes) {
14959
15581
  const earlier = computes.find(
14960
15582
  (candidate) => candidate.name.trim() === binding.name.trim()
14961
15583
  );
14962
- const earlierFn = earlier && functions[earlier.functionId];
15584
+ const earlierFn = computeFunction(earlier, functions);
14963
15585
  if (!earlierFn) return "emit-gap-call-compute-args";
14964
15586
  if (!dataTypeFits(
14965
15587
  {
@@ -15023,7 +15645,7 @@ function computeMemberRead(fn, member, shapes) {
15023
15645
  function computeTextPaths(computes, functions, shapes) {
15024
15646
  const out = [];
15025
15647
  for (const compute of computes) {
15026
- const fn = functions[compute.functionId];
15648
+ const fn = computeFunction(compute, functions);
15027
15649
  const name3 = compute.name.trim();
15028
15650
  if (!fn || !name3 || fn.returnCardinality !== "one") continue;
15029
15651
  if (fn.returnType.type !== "shape") {
@@ -15054,7 +15676,7 @@ function computeTextPaths(computes, functions, shapes) {
15054
15676
  function computeInputPaths(computes, functions, shapes) {
15055
15677
  const out = [];
15056
15678
  for (const compute of computes) {
15057
- const fn = functions[compute.functionId];
15679
+ const fn = computeFunction(compute, functions);
15058
15680
  const name3 = compute.name.trim();
15059
15681
  if (!fn || !name3) continue;
15060
15682
  const walk = (member, label, dataType, cardinality, seen) => {
@@ -15083,7 +15705,7 @@ function computeInputMemberError(method, functions, shapes) {
15083
15705
  const compute = (method.computes ?? []).find(
15084
15706
  (c) => c.name === mapping.compute
15085
15707
  );
15086
- const fn = compute && functions[compute.functionId];
15708
+ const fn = computeFunction(compute, functions);
15087
15709
  if (!fn || !computeMemberRead(fn, mapping.member, shapes)) {
15088
15710
  return "input-incomplete";
15089
15711
  }
@@ -15101,6 +15723,13 @@ function computeIsRead(method, name3) {
15101
15723
  )) {
15102
15724
  return true;
15103
15725
  }
15726
+ if ((method.conditions ?? []).some(
15727
+ (condition) => condition.kind === "check" ? condition.check?.source === "compute" && condition.check.compute === wanted : Object.values(condition.args).some(
15728
+ (binding) => binding.source === "compute" && binding.name === wanted
15729
+ )
15730
+ )) {
15731
+ return true;
15732
+ }
15104
15733
  return (method.computes ?? []).some(
15105
15734
  (compute) => Object.values(compute.args).some(
15106
15735
  (binding) => binding.source === "compute" && binding.name === wanted
@@ -15178,7 +15807,7 @@ function variantCheckType(check, method, op, roots, shapes, functions) {
15178
15807
  const compute = (method.computes ?? []).find(
15179
15808
  (one) => one.name === check.compute
15180
15809
  );
15181
- const fn = compute ? functions[compute.functionId] : void 0;
15810
+ const fn = computeFunction(compute, functions);
15182
15811
  return fn ? { dataType: fn.returnType, cardinality: fn.returnCardinality } : void 0;
15183
15812
  }
15184
15813
  return responsePathAt(
@@ -15267,21 +15896,37 @@ function conditionFunction(condition, functions) {
15267
15896
  return functions[condition.functionId];
15268
15897
  }
15269
15898
  var answersBoolean = (fn) => fn.returnType.type === "boolean" && fn.returnCardinality === "one";
15270
- function conditionCheckType(check, args, properties, shapes) {
15271
- const read = check.source === "args" ? check.arg ? argValue2({ source: "args", arg: check.arg }, args, properties, shapes) : void 0 : check.path?.length ? argValue2(
15272
- { source: "store", path: check.path },
15273
- args,
15274
- properties,
15899
+ var conditionArgValue = (binding, args, properties, shapes, computes, functions) => {
15900
+ if (binding.source !== "compute") {
15901
+ return argValue2(binding, args, properties, shapes);
15902
+ }
15903
+ const fn = computeFunction(
15904
+ computes.find((compute) => compute.name.trim() === binding.name.trim()),
15905
+ functions
15906
+ );
15907
+ return fn ? {
15908
+ value: { dataType: fn.returnType, cardinality: fn.returnCardinality },
15275
15909
  shapes
15276
- ) : void 0;
15910
+ } : void 0;
15911
+ };
15912
+ function conditionCheckType(check, args, properties, shapes, computes = [], functions = {}) {
15913
+ const binding = check.source === "args" ? check.arg ? { source: "args", arg: check.arg } : void 0 : check.source === "compute" ? check.compute ? { source: "compute", name: check.compute } : void 0 : check.path?.length ? { source: "store", path: check.path } : void 0;
15914
+ const read = binding ? conditionArgValue(binding, args, properties, shapes, computes, functions) : void 0;
15277
15915
  return read ? {
15278
15916
  dataType: read.value.dataType ?? { type: "string" },
15279
15917
  cardinality: read.value.cardinality
15280
15918
  } : void 0;
15281
15919
  }
15282
- function checkError2(check, args, properties, shapes) {
15920
+ function checkError2(check, args, properties, shapes, computes, functions) {
15283
15921
  if (!check) return "condition-check-subject";
15284
- const type = conditionCheckType(check, args, properties, shapes);
15922
+ const type = conditionCheckType(
15923
+ check,
15924
+ args,
15925
+ properties,
15926
+ shapes,
15927
+ computes,
15928
+ functions
15929
+ );
15285
15930
  if (!type) return "condition-check-subject";
15286
15931
  if (!variantCheckOperators(type).includes(check.operator)) {
15287
15932
  return "condition-check-operator";
@@ -15289,9 +15934,17 @@ function checkError2(check, args, properties, shapes) {
15289
15934
  if (isUnaryOperator(check.operator)) return void 0;
15290
15935
  return validateLiteral(check.value ?? "", type.dataType, type.cardinality) ? "condition-check-value" : void 0;
15291
15936
  }
15292
- function conditionError(condition, args, functions, properties, shapes) {
15937
+ function conditionError(condition, args, functions, properties, shapes, computes = []) {
15938
+ const valueOf = (binding) => conditionArgValue(binding, args, properties, shapes, computes, functions);
15293
15939
  if (conditionKind(condition) === "check") {
15294
- return checkError2(condition.check, args, properties, shapes);
15940
+ return checkError2(
15941
+ condition.check,
15942
+ args,
15943
+ properties,
15944
+ shapes,
15945
+ computes,
15946
+ functions
15947
+ );
15295
15948
  }
15296
15949
  const entry2 = condition.oneFunction ? oneFunctionOf(condition.oneFunction) : void 0;
15297
15950
  if (condition.oneFunction) {
@@ -15301,11 +15954,10 @@ function conditionError(condition, args, functions, properties, shapes) {
15301
15954
  const binding = condition.args[param.id];
15302
15955
  if (!binding) return "condition-args";
15303
15956
  if (binding.source === "fixed") {
15304
- if (param.rule !== "string-one" || typeof binding.value !== "string")
15305
- return "condition-type";
15957
+ if (!oneParamFixedHeld(param, binding.value)) return "condition-type";
15306
15958
  continue;
15307
15959
  }
15308
- const read = argValue2(binding, args, properties, shapes);
15960
+ const read = valueOf(binding);
15309
15961
  if (!read) return "condition-args";
15310
15962
  const held = read.value.dataType ? { dataType: read.value.dataType, cardinality: read.value.cardinality } : void 0;
15311
15963
  if (!oneFunctionArgFits(param, held, binding.source === "store"))
@@ -15329,7 +15981,7 @@ function conditionError(condition, args, functions, properties, shapes) {
15329
15981
  if (invalid) return "condition-type";
15330
15982
  continue;
15331
15983
  }
15332
- const read = argValue2(binding, args, properties, shapes);
15984
+ const read = valueOf(binding);
15333
15985
  if (!read) return "condition-args";
15334
15986
  if (!dataTypeFits(
15335
15987
  read.value,
@@ -15342,9 +15994,22 @@ function conditionError(condition, args, functions, properties, shapes) {
15342
15994
  }
15343
15995
  return void 0;
15344
15996
  }
15345
- var drawnConditions = (method, args, functions, properties, shapes) => (method.conditions ?? []).filter(
15346
- (condition) => !conditionError(condition, args, functions, properties, shapes)
15347
- );
15997
+ var drawnConditions = (method, args, functions, properties, shapes) => {
15998
+ const computes = drawnComputes(method, args, functions, properties, shapes);
15999
+ return (method.conditions ?? []).filter(
16000
+ (condition) => !conditionError(condition, args, functions, properties, shapes, computes)
16001
+ );
16002
+ };
16003
+ var conditionReadsCompute = (condition, name3) => {
16004
+ const wanted = name3.trim();
16005
+ if (!wanted) return false;
16006
+ if (conditionKind(condition) === "check") {
16007
+ return condition.check?.source === "compute" && condition.check.compute?.trim() === wanted;
16008
+ }
16009
+ return Object.values(condition.args).some(
16010
+ (binding) => binding.source === "compute" && binding.name.trim() === wanted
16011
+ );
16012
+ };
15348
16013
 
15349
16014
  // libs/codegen/src/lib/translation-asset-helper.ts
15350
16015
  var SOURCE_LANG = "en";
@@ -15667,6 +16332,79 @@ function openError(open, screens) {
15667
16332
  var drawnOpen = (method, screens) => method.open && !openError(method.open, screens) ? method.open : void 0;
15668
16333
  var openScreenIds = (methods) => Object.values(methods).map((method) => method.open?.screenId).filter((id) => !!id);
15669
16334
 
16335
+ // libs/codegen/src/lib/submit-target-helper.ts
16336
+ var SUBMIT_TARGET_KEY = "submitTarget";
16337
+ var ancestors = (control, controls) => {
16338
+ const chain = [];
16339
+ const seen = /* @__PURE__ */ new Set();
16340
+ for (let id = control.parentId; id && !seen.has(id) && controls[id]; id = controls[id].parentId) {
16341
+ seen.add(id);
16342
+ chain.push(controls[id]);
16343
+ }
16344
+ return chain;
16345
+ };
16346
+ var opensScope = (control) => isTaglessFamily(control.type) || control.type === "content" /* CONTENT */ || (control.variants?.length ?? 0) > 0;
16347
+ var scopeOf = (control, controls) => [control, ...ancestors(control, controls)].find(opensScope);
16348
+ function canNameSubmitTarget(button, controls) {
16349
+ if (button.type !== "button" /* BUTTON */) return false;
16350
+ if (button.configs?.["isSubmit"] !== true) return false;
16351
+ if (button.configs?.["href"]) return false;
16352
+ if (hasRouterLinkDirective(button)) return false;
16353
+ return !ancestors(button, controls).some(
16354
+ (parent) => parent.type === "form" /* FORM */ || parent.type === "section_action" /* SECTION_ACTION */
16355
+ );
16356
+ }
16357
+ var refReaches = (button, buttonChain, form, controls) => {
16358
+ const scope = scopeOf(form, controls);
16359
+ if (!scope) return true;
16360
+ if (!buttonChain.has(scope.id)) return false;
16361
+ if (scope.type !== "branch_arm" /* BRANCH_ARM */) return true;
16362
+ const formSide = armChildOf(scope.id, form, controls);
16363
+ const buttonSide = armChildOf(scope.id, button, controls);
16364
+ return !!formSide && !!buttonSide && projectionSlotOf(formSide) === projectionSlotOf(buttonSide);
16365
+ };
16366
+ var queryReaches = (form, controls) => ![form, ...ancestors(form, controls)].some(
16367
+ (node) => isRepeatFamily(node.type) || node.type === "content" /* CONTENT */
16368
+ );
16369
+ var accessTo = (button, form, controls) => {
16370
+ if (form.type !== "form" /* FORM */) return void 0;
16371
+ const buttonChain = /* @__PURE__ */ new Set([
16372
+ button.id,
16373
+ ...ancestors(button, controls).map((parent) => parent.id)
16374
+ ]);
16375
+ if (refReaches(button, buttonChain, form, controls)) return "ref";
16376
+ return queryReaches(form, controls) ? "query" : void 0;
16377
+ };
16378
+ function submitTargetForms(button, controls) {
16379
+ if (!canNameSubmitTarget(button, controls)) return [];
16380
+ return Object.values(controls).filter(
16381
+ (form) => accessTo(button, form, controls) !== void 0
16382
+ );
16383
+ }
16384
+ var armChildOf = (armId, control, controls) => [control, ...ancestors(control, controls)].find(
16385
+ (node) => node.parentId === armId
16386
+ );
16387
+ function submitTargetOf(button, controls) {
16388
+ return submitTargetLink(button, controls)?.form;
16389
+ }
16390
+ function submitTargetLink(button, controls) {
16391
+ if (!canNameSubmitTarget(button, controls)) return void 0;
16392
+ const id = button.configs?.[SUBMIT_TARGET_KEY];
16393
+ if (typeof id !== "string" || !id) return void 0;
16394
+ const form = controls[id];
16395
+ const access = form ? accessTo(button, form, controls) : void 0;
16396
+ return form && access ? { form, access } : void 0;
16397
+ }
16398
+ function hasSubmitTargetButton(formId, controls) {
16399
+ return Object.values(controls).some(
16400
+ (control) => control.type === "button" /* BUTTON */ && submitTargetOf(control, controls)?.id === formId
16401
+ );
16402
+ }
16403
+ function defaultSubmitTarget(button, controls) {
16404
+ const forms = submitTargetForms(button, controls);
16405
+ return forms.length === 1 ? forms[0].id : void 0;
16406
+ }
16407
+
15670
16408
  // libs/codegen/src/lib/call-outcome-helper.ts
15671
16409
  var OUTCOME_ARMS = [
15672
16410
  "success",
@@ -15875,6 +16613,8 @@ function formRefNames(controls) {
15875
16613
  if (!form || form.type !== "form" /* FORM */) continue;
15876
16614
  refs.set(form.id, formRefName(form));
15877
16615
  }
16616
+ const target = submitTargetOf(control, controls);
16617
+ if (target) refs.set(target.id, formRefName(target));
15878
16618
  }
15879
16619
  return refs;
15880
16620
  }
@@ -16167,7 +16907,7 @@ function mappingExpression(mapping, target, properties, shapes, functions, compu
16167
16907
  if (mapping.source === "args") source = `${mapping.arg}`;
16168
16908
  else if (mapping.source === "compute") {
16169
16909
  const compute = computes.find((c) => c.name === mapping.compute);
16170
- const fn = compute && functions[compute.functionId];
16910
+ const fn = computeFunction(compute, functions);
16171
16911
  const absent = !!fn?.returnUndefined;
16172
16912
  const waits = absent && target.required;
16173
16913
  source = `compute.${mapping.compute}`;
@@ -16414,11 +17154,13 @@ function patchLiteral(mappings, properties, shapes, functions, subject, cast = f
16414
17154
  functions
16415
17155
  );
16416
17156
  if (!fn) return void 0;
16417
- const typeArgs = mapping.transform.oneFunction ? `<${spell(
17157
+ const one = oneFunctionOf(mapping.transform.oneFunction);
17158
+ const typeArgs = one && !one.spell ? `<${spell(
16418
17159
  property.dataType,
16419
- property.cardinality === "map-many" ? "many" : "one"
17160
+ oneFunctionLiftedAt(one, property.cardinality) ? "many" : "one"
16420
17161
  )}>` : "";
16421
- if (mapping.transform.oneFunction) oneFunctionNames.add(fn.name);
17162
+ if (mapping.transform.oneFunction && !one?.spell)
17163
+ oneFunctionNames.add(fn.name);
16422
17164
  const args = mapping.transform.args.map((binding, index) => {
16423
17165
  if (binding.source === "response") {
16424
17166
  return binding.path.length ? {
@@ -16477,7 +17219,10 @@ function patchLiteral(mappings, properties, shapes, functions, subject, cast = f
16477
17219
  }
16478
17220
  locals.set(index, local);
16479
17221
  });
16480
- const call = `${fn.name}${typeArgs}(${args.map((arg, index) => locals.get(index) ?? arg.expression).join(", ")})`;
17222
+ const argExpressions = args.map(
17223
+ (arg, index) => locals.get(index) ?? arg.expression
17224
+ );
17225
+ const call = one?.spell ? one.spell(argExpressions) : `${fn.name}${typeArgs}(${argExpressions.join(", ")})`;
16481
17226
  if (!locals.size) return { receiver, key: property.name, value: call };
16482
17227
  const guard = [...new Set(locals.values())].map((local) => `${local} === undefined`).join(" || ");
16483
17228
  const passTerms = [...new Set(locals.values())].map(
@@ -17220,79 +17965,10 @@ ${failureArms.map(
17220
17965
  const guardHead = guardArgs.size ? `(${guardReceiver}): ${guardReceiver} is ${argObjectType(true)} =>` : "() =>";
17221
17966
  const guardBlock = guards.length ? `
17222
17967
  filter(${guardHead} ${guards.join(" && ")}),` : "";
17223
- let conditionReadsArgs = false;
17224
- const conditions = drawnConditions(
17225
- method,
17226
- args,
17227
- functions,
17228
- roots,
17229
- shapes
17230
- ).map((condition) => {
17231
- const check = condition.check;
17232
- if (conditionKind(condition) === "check" && check) {
17233
- const type = conditionCheckType(check, args, roots, shapes);
17234
- if (check.source === "args") {
17235
- conditionReadsArgs = true;
17236
- return generateVariantCheckExpression(
17237
- check,
17238
- `${guardReceiver}.${check.arg}`,
17239
- type,
17240
- !!args.find((arg) => arg.name === check.arg)?.optional
17241
- );
17242
- }
17243
- return generateVariantCheckExpression(
17244
- check,
17245
- statePathExpression(
17246
- check.path ?? [],
17247
- roots,
17248
- shapes,
17249
- false,
17250
- receiverOf
17251
- ),
17252
- type,
17253
- true
17254
- );
17255
- }
17256
- const fn = conditionFunction(condition, functions);
17257
- if (condition.oneFunction && fn) oneFunctionNames.add(fn.name);
17258
- const waits = [];
17259
- const callArgs2 = (fn?.params ?? []).map((param) => {
17260
- const binding = condition.args[param.id];
17261
- if (!binding) return "undefined";
17262
- if (binding.source === "fixed") {
17263
- return literalExpression(String(binding.value), param.dataType);
17264
- }
17265
- if (binding.source === "args") {
17266
- conditionReadsArgs = true;
17267
- const read2 = `${guardReceiver}.${binding.arg}`;
17268
- if (!requiredArgs.has(binding.arg) && !param.acceptsUndefined) {
17269
- waits.push(`${read2} !== undefined`);
17270
- }
17271
- return read2;
17272
- }
17273
- const held = statePathValue(binding.path, roots, shapes);
17274
- const read = statePathExpression(
17275
- binding.path,
17276
- roots,
17277
- shapes,
17278
- false,
17279
- receiverOf
17280
- );
17281
- if (held?.cardinality === "many") return `${read} ?? []`;
17282
- if (isMapCardinality(held?.cardinality)) return `${read} ?? {}`;
17283
- if (param.acceptsUndefined) return read;
17284
- waits.push(`${read} !== undefined`);
17285
- return statePathExpression(binding.path, roots, shapes, true, receiverOf);
17286
- });
17287
- const negate = condition.oneFunction && condition.negate ? "!" : "";
17288
- return [
17289
- ...Array.from(new Set(waits)),
17290
- `${negate}${fn?.name}(${callArgs2.join(", ")})`
17291
- ].join(" && ");
17292
- });
17293
- const conditionBlock = conditions.length ? `
17294
- filter(${conditionReadsArgs ? guardReceiver : "()"} => ${conditions.join(" && ")}),` : "";
17295
- const readsCompute = (name3) => method.inputs.some((m) => m.source === "compute" && m.compute === name3) || method.response.some(
17968
+ const drawnConds = drawnConditions(method, args, functions, roots, shapes);
17969
+ const readsCompute = (name3) => drawnConds.some(
17970
+ (condition) => conditionReadsCompute(condition, name3)
17971
+ ) || method.inputs.some((m) => m.source === "compute" && m.compute === name3) || method.response.some(
17296
17972
  (mapping) => (mapping.transform?.args ?? []).some(
17297
17973
  (binding) => binding.source === "compute" && binding.name === name3
17298
17974
  )
@@ -17334,7 +18010,8 @@ ${failureArms.map(
17334
18010
  const computeGuards = [];
17335
18011
  let computeGuardsReadArgs = false;
17336
18012
  const computeLines = computes.map((compute) => {
17337
- const fn = functions[compute.functionId];
18013
+ const fn = computeFunction(compute, functions);
18014
+ if (compute.oneFunction && fn) oneFunctionNames.add(fn.name);
17338
18015
  const callArgs2 = (fn?.params ?? []).map((param) => {
17339
18016
  const binding = compute.args[param.id];
17340
18017
  if (!binding) return "undefined";
@@ -17381,6 +18058,104 @@ ${computeLines.map((line) => ` ${line}`).join("\n")}
17381
18058
  return { ${args.length ? `...${guardReceiver}, ` : ""}compute: { ${computes.map((compute) => compute.name).join(", ")} } };
17382
18059
  }),` : "";
17383
18060
  if (computes.length) emitsMap = true;
18061
+ let conditionReadsArgs = false;
18062
+ const conditions = drawnConds.map((condition) => {
18063
+ const check = condition.check;
18064
+ if (conditionKind(condition) === "check" && check) {
18065
+ const type = conditionCheckType(
18066
+ check,
18067
+ args,
18068
+ roots,
18069
+ shapes,
18070
+ computes,
18071
+ functions
18072
+ );
18073
+ if (check.source === "compute") {
18074
+ conditionReadsArgs = true;
18075
+ const fn2 = computeFunction(
18076
+ computes.find((compute) => compute.name === check.compute),
18077
+ functions
18078
+ );
18079
+ return generateVariantCheckExpression(
18080
+ check,
18081
+ `${guardReceiver}.${COMPUTE_BAG}.${check.compute}`,
18082
+ type,
18083
+ !!fn2?.returnUndefined
18084
+ );
18085
+ }
18086
+ if (check.source === "args") {
18087
+ conditionReadsArgs = true;
18088
+ return generateVariantCheckExpression(
18089
+ check,
18090
+ `${guardReceiver}.${check.arg}`,
18091
+ type,
18092
+ !!args.find((arg) => arg.name === check.arg)?.optional
18093
+ );
18094
+ }
18095
+ return generateVariantCheckExpression(
18096
+ check,
18097
+ statePathExpression(
18098
+ check.path ?? [],
18099
+ roots,
18100
+ shapes,
18101
+ false,
18102
+ receiverOf
18103
+ ),
18104
+ type,
18105
+ true
18106
+ );
18107
+ }
18108
+ const fn = conditionFunction(condition, functions);
18109
+ if (condition.oneFunction && fn) oneFunctionNames.add(fn.name);
18110
+ const waits = [];
18111
+ const callArgs2 = (fn?.params ?? []).map((param) => {
18112
+ const binding = condition.args[param.id];
18113
+ if (!binding) return "undefined";
18114
+ if (binding.source === "fixed") {
18115
+ return literalExpression(String(binding.value), param.dataType);
18116
+ }
18117
+ if (binding.source === "compute") {
18118
+ conditionReadsArgs = true;
18119
+ const read2 = `${guardReceiver}.${COMPUTE_BAG}.${binding.name}`;
18120
+ const held2 = computeFunction(
18121
+ computes.find((compute) => compute.name === binding.name),
18122
+ functions
18123
+ );
18124
+ if (held2?.returnUndefined && !param.acceptsUndefined) {
18125
+ waits.push(`${read2} !== undefined`);
18126
+ }
18127
+ return read2;
18128
+ }
18129
+ if (binding.source === "args") {
18130
+ conditionReadsArgs = true;
18131
+ const read2 = `${guardReceiver}.${binding.arg}`;
18132
+ if (!requiredArgs.has(binding.arg) && !param.acceptsUndefined) {
18133
+ waits.push(`${read2} !== undefined`);
18134
+ }
18135
+ return read2;
18136
+ }
18137
+ const held = statePathValue(binding.path, roots, shapes);
18138
+ const read = statePathExpression(
18139
+ binding.path,
18140
+ roots,
18141
+ shapes,
18142
+ false,
18143
+ receiverOf
18144
+ );
18145
+ if (held?.cardinality === "many") return `${read} ?? []`;
18146
+ if (isMapCardinality(held?.cardinality)) return `${read} ?? {}`;
18147
+ if (param.acceptsUndefined) return read;
18148
+ waits.push(`${read} !== undefined`);
18149
+ return statePathExpression(binding.path, roots, shapes, true, receiverOf);
18150
+ });
18151
+ const negate = condition.oneFunction && condition.negate ? "!" : "";
18152
+ return [
18153
+ ...Array.from(new Set(waits)),
18154
+ `${negate}${fn?.name}(${callArgs2.join(", ")})`
18155
+ ].join(" && ");
18156
+ });
18157
+ const conditionBlock = conditions.length ? `
18158
+ filter(${conditionReadsArgs ? guardReceiver : "()"} => ${conditions.join(" && ")}),` : "";
17384
18159
  const computeValueGuards = method.inputs.flatMap((mapping) => {
17385
18160
  if (mapping.source !== "compute" || !mapping.compute) return [];
17386
18161
  const target = targets.find(
@@ -17388,7 +18163,7 @@ ${computeLines.map((line) => ` ${line}`).join("\n")}
17388
18163
  );
17389
18164
  if (!target) return [];
17390
18165
  const compute = computes.find((c) => c.name === mapping.compute);
17391
- const fn = compute && functions[compute.functionId];
18166
+ const fn = computeFunction(compute, functions);
17392
18167
  if (!fn?.returnUndefined) return [];
17393
18168
  const read = `${COMPUTE_BAG}.${mapping.compute}`;
17394
18169
  return [
@@ -17404,7 +18179,7 @@ ${computeLines.map((line) => ` ${line}`).join("\n")}
17404
18179
  for (const [slot, binding] of Object.entries(confirm?.params ?? {})) {
17405
18180
  if (binding.source === "compute") {
17406
18181
  const compute = computes.find((c) => c.name === binding.name);
17407
- const fn = compute && functions[compute.functionId];
18182
+ const fn = computeFunction(compute, functions);
17408
18183
  if (!fn) continue;
17409
18184
  const member = computeMemberRead(fn, binding.member, shapes);
17410
18185
  if (!member) continue;
@@ -17521,7 +18296,7 @@ ${beforePersists.map((line) => ` ${line}`).join("\n")}
17521
18296
  // ends — `finalize` fires on success, on error and when a later call
17522
18297
  // replaces it, so the wait never outlives the request (ADR 0139).
17523
18298
  ` ${method.name}: rxMethod<${argType}>(
17524
- pipe(${debounceBlock}${guardBlock}${conditionBlock}${computeGuardBlock}${computeBlock}${computeValueGuardBlock}${confirmBlock}${beforeBlock}
18299
+ pipe(${debounceBlock}${guardBlock}${computeGuardBlock}${computeBlock}${conditionBlock}${computeValueGuardBlock}${confirmBlock}${beforeBlock}
17525
18300
  switchMap(${callArgName} => {${settleOnly ? `
17526
18301
  const { onSent, onSettled } = (input || {}) as { ${SETTLE_MEMBERS.join("; ")} };` : ""}
17527
18302
  onSent?.();
@@ -17532,7 +18307,7 @@ ${beforePersists.map((line) => ` ${line}`).join("\n")}
17532
18307
  )
17533
18308
  ),`
17534
18309
  ) : ` ${method.name}: rxMethod<${argType}>(
17535
- pipe(${debounceBlock}${guardBlock}${conditionBlock}${computeGuardBlock}${computeBlock}${computeValueGuardBlock}${confirmBlock}${beforeBlock}
18310
+ pipe(${debounceBlock}${guardBlock}${computeGuardBlock}${computeBlock}${conditionBlock}${computeValueGuardBlock}${confirmBlock}${beforeBlock}
17536
18311
  switchMap(${callArgName} =>
17537
18312
  ${apiCall}.pipe(${tapBlock}${catchBlock}
17538
18313
  )
@@ -20008,8 +20783,9 @@ function limitSources(scope) {
20008
20783
  });
20009
20784
  });
20010
20785
  Object.values(scope.computeds ?? {}).forEach((computed) => {
20011
- const fn = functions[computed.functionId];
20012
- if (fn && isNumberScalar(fn.returnType, returnCardinalityOf(fn)))
20786
+ const fn = computed.functionId ? functions[computed.functionId] : void 0;
20787
+ const held = fn ? { dataType: fn.returnType, cardinality: returnCardinalityOf(fn) } : computed.returns;
20788
+ if (held && isNumberScalar(held.dataType, held.cardinality))
20013
20789
  add({
20014
20790
  id: computed.id,
20015
20791
  name: computed.name,
@@ -20153,11 +20929,13 @@ var STOCK_VALIDATOR = {
20153
20929
  function stockStatement(kind, check, fieldName, controlMap, limitRead) {
20154
20930
  const call = STOCK_VALIDATOR[kind];
20155
20931
  const limit = limitRead ? `state.${limitRead.name}` : `${check.limit}`;
20932
+ const drawn = takesLimit(kind) ? (check.message ?? "").trim() : "";
20933
+ const message = drawn ? `, '${drawn.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'${limitRead ? `, '${limitRead.name}'` : ""}` : "";
20156
20934
  if (kind === "email" || kind === "url") {
20157
20935
  return ` ${call}(tree['${fieldName}'] as SchemaPath<string>);`;
20158
20936
  }
20159
20937
  if (kind === "minAge") {
20160
- return ` ${call}(tree['${fieldName}'] as SchemaPath<string>, ${limit});`;
20938
+ return ` ${call}(tree['${fieldName}'] as SchemaPath<string>, ${limit}${message ? `, undefined${message}` : ""});`;
20161
20939
  }
20162
20940
  if (kind === "matchField") {
20163
20941
  const target = check.matchFieldId ? controlMap[check.matchFieldId] : void 0;
@@ -20176,7 +20954,7 @@ function stockStatement(kind, check, fieldName, controlMap, limitRead) {
20176
20954
  ` );`
20177
20955
  ].join("\n");
20178
20956
  }
20179
- return ` ${call}(tree, ['${fieldName}'], ${limit});`;
20957
+ return ` ${call}(tree, ['${fieldName}'], ${limit}${message});`;
20180
20958
  }
20181
20959
  function generateFormValidation(controlMap, formId, functions, properties = {}, sources = {}) {
20182
20960
  const shape = buildFormShape(controlMap, formId);
@@ -20705,10 +21483,41 @@ function formModelSourceType(source, scope) {
20705
21483
  return void 0;
20706
21484
  }
20707
21485
  function canFillFormKey(source, key2) {
20708
- if (source.cardinality !== key2.cardinality) return false;
21486
+ if (source.cardinality === "many" && key2.cardinality === "one") return false;
21487
+ if (source.dataType === "file" || key2.dataType === "file") {
21488
+ return source.dataType === key2.dataType;
21489
+ }
20709
21490
  if (key2.dataType === "string") return true;
20710
21491
  return source.dataType === key2.dataType;
20711
21492
  }
21493
+ var asTransformType = (type) => ({
21494
+ dataType: { type: type.dataType === "file" ? "string" : type.dataType },
21495
+ cardinality: type.cardinality
21496
+ });
21497
+ var fromTransformType = (type) => {
21498
+ const { type: dataType } = type.dataType;
21499
+ if (dataType !== "string" && dataType !== "number" && dataType !== "boolean") {
21500
+ return void 0;
21501
+ }
21502
+ if (!isKeyCardinality(type.cardinality)) return void 0;
21503
+ return { dataType, cardinality: type.cardinality };
21504
+ };
21505
+ var keyTypeLabel = (type) => `${type.dataType}${type.cardinality === "many" ? "[]" : ""}`;
21506
+ function transformedKeyType(transform, sourceType, scope) {
21507
+ if (transformIncomplete(transform, scope.functions)) {
21508
+ return { ok: false, issue: "transform-incomplete" };
21509
+ }
21510
+ const inferred = inferTransformType(
21511
+ transform,
21512
+ asTransformType(sourceType),
21513
+ "call-arg",
21514
+ scope.functions
21515
+ );
21516
+ if (inferred.ok === false) return { ok: false, issue: "transform-incomplete" };
21517
+ const type = fromTransformType(inferred.type);
21518
+ if (!type) return { ok: false, issue: "transform-type-mismatch" };
21519
+ return { ok: true, type };
21520
+ }
20712
21521
  function formModelKeyIssue(key2, source, scope) {
20713
21522
  const keyType = formModelKeyType(key2);
20714
21523
  if (!keyType) return "source-type-mismatch";
@@ -20724,8 +21533,45 @@ function formModelKeyIssue(key2, source, scope) {
20724
21533
  }
20725
21534
  const sourceType = formModelSourceType(source, scope);
20726
21535
  if (!sourceType) return "source-missing";
21536
+ if (isFormModelReadSource(source) && source.transform) {
21537
+ const out = transformedKeyType(source.transform, sourceType, scope);
21538
+ if (out.ok === false) return out.issue;
21539
+ return canFillFormKey(out.type, keyType) ? void 0 : "transform-type-mismatch";
21540
+ }
20727
21541
  return canFillFormKey(sourceType, keyType) ? void 0 : "source-type-mismatch";
20728
21542
  }
21543
+ function formModelKeyMismatch(key2, source, scope) {
21544
+ if (!isFormModelReadSource(source) || source.transform) return void 0;
21545
+ const keyType = formModelKeyType(key2);
21546
+ const sourceType = formModelSourceType(source, scope);
21547
+ if (!keyType || !sourceType || canFillFormKey(sourceType, keyType)) {
21548
+ return void 0;
21549
+ }
21550
+ const fix = keyType.dataType === "file" ? void 0 : castTransform(asTransformType(sourceType), asTransformType(keyType));
21551
+ return {
21552
+ from: keyTypeLabel(sourceType),
21553
+ to: keyTypeLabel(keyType),
21554
+ ...fix ? { fix } : {}
21555
+ };
21556
+ }
21557
+ function formModelKeySignature(key2, source, scope) {
21558
+ if (!isFormModelReadSource(source)) return void 0;
21559
+ const keyType = formModelKeyType(key2);
21560
+ const sourceType = formModelSourceType(source, scope);
21561
+ if (!keyType || !sourceType || keyType.dataType === "file") return void 0;
21562
+ return {
21563
+ pipe: asTransformType(sourceType),
21564
+ expected: asTransformType(keyType)
21565
+ };
21566
+ }
21567
+ function formModelLandedType(source, scope) {
21568
+ const sourceType = formModelSourceType(source, scope);
21569
+ if (!sourceType) return void 0;
21570
+ if (!isFormModelReadSource(source) || !source.transform) return sourceType;
21571
+ const out = transformedKeyType(source.transform, sourceType, scope);
21572
+ return out.ok ? out.type : void 0;
21573
+ }
21574
+ var isDemoted = (issue) => !!issue && issue !== "source-type-mismatch" && issue !== "transform-incomplete" && issue !== "transform-type-mismatch";
20729
21575
  function reconcileFormModel(model, controlMap, scope) {
20730
21576
  const form = controlMap[model.formId];
20731
21577
  if (!form) return void 0;
@@ -20733,10 +21579,21 @@ function reconcileFormModel(model, controlMap, scope) {
20733
21579
  const keys = {};
20734
21580
  shapeKeys.forEach((key2) => {
20735
21581
  const stored = model.keys[key2.id] ?? { source: "empty" };
20736
- keys[key2.id] = formModelKeyIssue(key2, stored, scope) ? { source: "empty" } : stored;
21582
+ keys[key2.id] = isDemoted(formModelKeyIssue(key2, stored, scope)) ? { source: "empty" } : stored;
20737
21583
  });
20738
21584
  return { ...model, keys };
20739
21585
  }
21586
+ function formModelTransforms(models, controlMap, scope) {
21587
+ return models.flatMap(
21588
+ (model) => formModelShapeKeys(controlMap, model.formId).flatMap((key2) => {
21589
+ const source = model.keys[key2.id];
21590
+ if (!source || !isFormModelReadSource(source) || !source.transform) {
21591
+ return [];
21592
+ }
21593
+ return formModelKeyIssue(key2, source, scope) ? [] : [source.transform];
21594
+ })
21595
+ );
21596
+ }
20740
21597
  function reconcileFormModels(models, controlMap, scope) {
20741
21598
  const next = {};
20742
21599
  Object.entries(models).forEach(([id, model]) => {
@@ -20805,16 +21662,18 @@ function decodeKeySource(value) {
20805
21662
  if (kind === "fixed") return { source: "fixed", value: "" };
20806
21663
  return { source: "empty" };
20807
21664
  }
21665
+ var isPrimitive = (type) => type === "string" || type === "number" || type === "boolean";
21666
+ var sourceOptionLabel = (label, type, key2) => canFillFormKey(type, key2) ? label : `${label} (${keyTypeLabel(type)})`;
20808
21667
  function formModelScreenOptions(key2, scope) {
20809
21668
  const found = [];
20810
21669
  const walk = (prefix, label, dataType, cardinality, member, depth) => {
20811
21670
  if (dataType.type !== "shape" && dataType.type !== "form") {
20812
- const type = isKeyCardinality(cardinality) ? {
20813
- dataType: dataType.type,
20814
- cardinality
20815
- } : void 0;
20816
- if (type && canFillFormKey(type, key2)) {
20817
- found.push({ value: `${prefix}|${member.join(".")}`, label });
21671
+ const type = isKeyCardinality(cardinality) && isPrimitive(dataType.type) ? { dataType: dataType.type, cardinality } : void 0;
21672
+ if (type) {
21673
+ found.push({
21674
+ value: `${prefix}|${member.join(".")}`,
21675
+ label: sourceOptionLabel(label, type, key2)
21676
+ });
20818
21677
  }
20819
21678
  return;
20820
21679
  }
@@ -20847,9 +21706,14 @@ function formModelScreenOptions(key2, scope) {
20847
21706
  );
20848
21707
  });
20849
21708
  Object.values(scope.constants).forEach((constant) => {
20850
- if (canFillFormKey({ dataType: constant.dataType, cardinality: "one" }, key2)) {
20851
- found.push({ value: `constant|${constant.id}`, label: constant.name });
20852
- }
21709
+ found.push({
21710
+ value: `constant|${constant.id}`,
21711
+ label: sourceOptionLabel(
21712
+ constant.name,
21713
+ { dataType: constant.dataType, cardinality: "one" },
21714
+ key2
21715
+ )
21716
+ });
20853
21717
  });
20854
21718
  return found.sort((a, b) => a.label.localeCompare(b.label));
20855
21719
  }
@@ -20859,9 +21723,12 @@ function formModelStateOptions(key2, scope) {
20859
21723
  const found = [];
20860
21724
  const walk = (path, label, dataType, cardinality, depth) => {
20861
21725
  if (dataType.type !== "shape" && dataType.type !== "form") {
20862
- const type = isKeyCardinality(cardinality) ? { dataType: dataType.type, cardinality } : void 0;
20863
- if (type && canFillFormKey(type, key2)) {
20864
- found.push({ value: `path|${path.join(".")}`, label });
21726
+ const type = isKeyCardinality(cardinality) && isPrimitive(dataType.type) ? { dataType: dataType.type, cardinality } : void 0;
21727
+ if (type) {
21728
+ found.push({
21729
+ value: `path|${path.join(".")}`,
21730
+ label: sourceOptionLabel(label, type, key2)
21731
+ });
20865
21732
  }
20866
21733
  return;
20867
21734
  }
@@ -21229,6 +22096,15 @@ function bodyConfigs(node) {
21229
22096
  if (node.type === "audience_picker" /* AUDIENCE_PICKER */) {
21230
22097
  delete configs[AUDIENCE_PICKER_LEVELS_KEY];
21231
22098
  }
22099
+ if (node.type === "button" /* BUTTON */) {
22100
+ delete configs[SUBMIT_TARGET_KEY];
22101
+ delete configs[BUTTON_KEY_CONFIG_KEY];
22102
+ }
22103
+ if (node.type === "section_action" /* SECTION_ACTION */) {
22104
+ const key2 = actionSelectionKey(node);
22105
+ if (key2) configs[ACTION_SELECTION_KEY] = key2;
22106
+ else delete configs[ACTION_SELECTION_KEY];
22107
+ }
21232
22108
  if (node.type === "section_table" /* SECTION_TABLE */) {
21233
22109
  for (const key2 of Object.keys(configs)) {
21234
22110
  if (!SECTION_TABLE_INPUTS.has(key2)) delete configs[key2];
@@ -21359,7 +22235,11 @@ var RAW_BOUND_SLOTS = {
21359
22235
  ["heat_swatch" /* HEAT_SWATCH */]: [BINDING_SLOT.value],
21360
22236
  ["score_set_item" /* SCORE_SET_ITEM */]: [BINDING_SLOT.value],
21361
22237
  ["score_set" /* SCORE_SET */]: [BINDING_SLOT.scoreDate],
21362
- ["scale_mark" /* SCALE_MARK */]: [BINDING_SLOT.value]
22238
+ ["scale_mark" /* SCALE_MARK */]: [BINDING_SLOT.value],
22239
+ // A toggle SectionAction's pick: a ButtonKey or nothing, and `m-action` reads
22240
+ // nothing — or a key none of its Buttons hold — as its first Button
22241
+ // (m-one-ui ADR 0213).
22242
+ ["section_action" /* SECTION_ACTION */]: [BINDING_SLOT.selection]
21363
22243
  };
21364
22244
  var SECTION_TABLE_INPUTS = /* @__PURE__ */ new Set([
21365
22245
  "sticky",
@@ -21706,7 +22586,7 @@ function renderBranch(node, indent2, names, methods, operationOf, storeProp, ctx
21706
22586
  return render(chain[0].arm.childrens, indent2).join("\n");
21707
22587
  }
21708
22588
  const pad2 = " ".repeat(indent2);
21709
- const slots = branchSlots(chain.map((entry2) => entry2.arm));
22589
+ const slots2 = branchSlots(chain.map((entry2) => entry2.arm));
21710
22590
  const chainFor = (slot) => {
21711
22591
  const lines = [];
21712
22592
  chain.forEach((entry2, index) => {
@@ -21732,30 +22612,7 @@ function renderBranch(node, indent2, names, methods, operationOf, storeProp, ctx
21732
22612
  lines.push(`${pad2}}`);
21733
22613
  return lines.join("\n");
21734
22614
  };
21735
- return slots.map(chainFor).join("\n");
21736
- }
21737
- var NAMED_SLOT_TAGS = /* @__PURE__ */ new Set([
21738
- "m-section-header",
21739
- "m-section-hero",
21740
- "m-jumbotron",
21741
- "m-section-search",
21742
- "m-section-stepper",
21743
- "m-section-badges",
21744
- "m-section-toggle",
21745
- "m-action",
21746
- "m-one-action",
21747
- "m-section-back",
21748
- "m-section-filter",
21749
- "m-section-filter-group",
21750
- "m-carousel",
21751
- "m-one-carousel",
21752
- "m-section-pagination",
21753
- "m-section-footer",
21754
- "m-app-logo"
21755
- ]);
21756
- function projectionSlotOf(node) {
21757
- const tag = codegenFor(node.type)?.tag.split(" ")[0];
21758
- return tag && NAMED_SLOT_TAGS.has(tag) ? tag : "";
22615
+ return slots2.map(chainFor).join("\n");
21759
22616
  }
21760
22617
  function branchSlots(arms) {
21761
22618
  const named = /* @__PURE__ */ new Set();
@@ -21942,7 +22799,11 @@ function renderNode(node, indent2, names, methods, operationOf, storeProp, ctx,
21942
22799
  const guard = isScreenOwnedKind(node.variantKind) ? screenVariantGuard(node, ctx.screenVariants ?? {}) : variantGuard(node, names, storeProp);
21943
22800
  const inner = guard ? indent2 + 1 : indent2;
21944
22801
  const gaps = bindingGapComments(node, ctx, storeProp, " ".repeat(indent2));
21945
- const tag = renderTag(
22802
+ ctx.letNames ??= /* @__PURE__ */ new Set();
22803
+ const outerSink = ctx.letSink;
22804
+ const lets = [];
22805
+ ctx.letSink = lets;
22806
+ const drawn = renderTag(
21946
22807
  node,
21947
22808
  inner,
21948
22809
  names,
@@ -21953,9 +22814,24 @@ function renderNode(node, indent2, names, methods, operationOf, storeProp, ctx,
21953
22814
  wires,
21954
22815
  payloads
21955
22816
  );
21956
- if (!tag) return "";
22817
+ ctx.letSink = outerSink;
22818
+ if (!drawn) return "";
22819
+ const innerPad = " ".repeat(inner);
22820
+ const tag = `${lets.map((line) => `${innerPad}${line}
22821
+ `).join("")}${drawn}`;
21957
22822
  return `${gaps}${wrapInGuard(tag, guard, " ".repeat(indent2))}`;
21958
22823
  }
22824
+ var hoistLet = (ctx, read) => {
22825
+ const sink = ctx.letSink;
22826
+ const taken = ctx.letNames;
22827
+ if (!sink || !taken) return void 0;
22828
+ const base = `${/([A-Za-z_$][\w$]*)\W*$/.exec(read)?.[1] ?? "arg"}Value`;
22829
+ let name3 = base;
22830
+ for (let n = 2; taken.has(name3); n += 1) name3 = `${base}${n}`;
22831
+ taken.add(name3);
22832
+ sink.push(`@let ${name3} = ${read};`);
22833
+ return name3;
22834
+ };
21959
22835
  var attrBindingSlots = (type) => {
21960
22836
  if (type === "form" /* FORM */) return [BINDING_SLOT.data];
21961
22837
  if (type === "field" /* FIELD */ || type === "context_menu" /* CONTEXT_MENU */)
@@ -21995,10 +22871,10 @@ var optionsGapReason = (binding, ctx, storeProp) => {
21995
22871
  function bindingGapComments(node, ctx, storeProp, pad2) {
21996
22872
  const bindings = ctx.controlMap?.[node.id]?.bindings;
21997
22873
  if (!bindings) return "";
21998
- const slots = attrBindingSlots(node.type);
21999
- if (!slots.length) return "";
22874
+ const slots2 = attrBindingSlots(node.type);
22875
+ if (!slots2.length) return "";
22000
22876
  const scope = bindingScope(ctx, storeProp);
22001
- return slots.map((slot) => {
22877
+ return slots2.map((slot) => {
22002
22878
  const binding = bindings[slot];
22003
22879
  if (!binding) return "";
22004
22880
  const reason = slot === BINDING_SLOT.options && node.type !== "context_menu" /* CONTEXT_MENU */ ? optionsGapReason(binding, ctx, storeProp) : bindingGapReason(binding, scope);
@@ -22029,6 +22905,9 @@ var checkLimitSources = (ctx) => limitSources({
22029
22905
  storePropOf: ctx.storePropOf
22030
22906
  });
22031
22907
  var bindingScope = (ctx, storeProp) => ({
22908
+ // The render path hands its EmitContext here; any other caller carries no
22909
+ // `letSink`, and the read stays inline.
22910
+ hoist: (read) => hoistLet(ctx, read),
22032
22911
  properties: ctx.properties,
22033
22912
  shapes: ctx.shapes,
22034
22913
  computeds: ctx.computeds,
@@ -22133,7 +23012,7 @@ var boundCardinality = (binding, ctx) => {
22133
23012
  }
22134
23013
  case "computed": {
22135
23014
  const computed = ctx.computeds?.[binding.root.id];
22136
- const fn = computed ? ctx.functions?.[computed.functionId] : void 0;
23015
+ const fn = computed ? stateComputedFunction(computed, ctx.functions ?? {}) : void 0;
22137
23016
  dataType = fn?.returnType;
22138
23017
  cardinality = fn ? returnCardinalityOf(fn) : void 0;
22139
23018
  break;
@@ -22256,6 +23135,7 @@ function boundAttrs(node, ctx, storeProp) {
22256
23135
  if (total) parts.push(` [total]="${total.read}"`);
22257
23136
  for (const slot of RAW_BOUND_SLOTS[node.type] ?? []) {
22258
23137
  if (!bindings?.[slot]) continue;
23138
+ if (slot === BINDING_SLOT.selection && !isToggleAction(node)) continue;
22259
23139
  const expr = bindingExpression(bindings[slot], scope);
22260
23140
  if (expr) parts.push(` [${slot}]="${expr}"`);
22261
23141
  }
@@ -22356,6 +23236,41 @@ var inSectionHeader = (node, ctx) => {
22356
23236
  const parentId = ctx.controlMap?.[node.id]?.parentId;
22357
23237
  return !!parentId && ctx.controlMap?.[parentId]?.type === "section_header" /* SECTION_HEADER */;
22358
23238
  };
23239
+ var submitTargetMember = (form) => `${formRefName(form).replace(/Ref$/, "")}SubmitTarget`;
23240
+ function submitTargetReads(node, ctx) {
23241
+ if (node.type !== "button" /* BUTTON */) return void 0;
23242
+ const controls = ctx.controlMap ?? {};
23243
+ const button = controls[node.id];
23244
+ const link = button ? submitTargetLink(button, controls) : void 0;
23245
+ if (!link) return void 0;
23246
+ if (link.access === "ref") {
23247
+ const ref = formRefName(link.form);
23248
+ return { blocked: `${ref}.blocked()`, submit: `${ref}.submitNow()` };
23249
+ }
23250
+ const member = submitTargetMember(link.form);
23251
+ return {
23252
+ blocked: `${member}()?.blocked() ?? true`,
23253
+ submit: `${member}()?.submitNow()`
23254
+ };
23255
+ }
23256
+ function submitTargetQueriesBlock(controls) {
23257
+ const forms = /* @__PURE__ */ new Map();
23258
+ for (const control of Object.values(controls)) {
23259
+ const link = submitTargetLink(control, controls);
23260
+ if (link?.access === "query") forms.set(link.form.id, link.form);
23261
+ }
23262
+ return [...forms.values()].map(
23263
+ (form) => `
23264
+ protected readonly ${submitTargetMember(
23265
+ form
23266
+ )} = viewChild<SectionFormComponent>('${formRefName(form)}');
23267
+ `
23268
+ ).join("");
23269
+ }
23270
+ function withSubmitCall(outputs, submit) {
23271
+ if (!submit) return outputs;
23272
+ return outputs.includes(' (clicked)="') ? outputs.replace(' (clicked)="', ` (clicked)="${submit}; `) : `${outputs} (clicked)="${submit}"`;
23273
+ }
22359
23274
  function tagAttrs(node, ctx, storeProp) {
22360
23275
  if (node.type === "audience_picker" /* AUDIENCE_PICKER */) {
22361
23276
  const config = ctx.audiencePickerConfigNames?.get(node.id);
@@ -22384,6 +23299,14 @@ function tagAttrs(node, ctx, storeProp) {
22384
23299
  const ref = formRefNames(ctx.controlMap ?? {}).get(node.id);
22385
23300
  return `${ref ? ` #${ref}` : ""}${inlineAttrs(node)}${member ? ` [validation]="${member}"` : ""}${boundAttrs(node, ctx, storeProp)}`;
22386
23301
  }
23302
+ const submitReads = submitTargetReads(node, ctx);
23303
+ if (submitReads) {
23304
+ const configs2 = { ...node.configs ?? {} };
23305
+ delete configs2["isSubmit"];
23306
+ const locked = configs2["disabled"] === true;
23307
+ if (!locked) delete configs2["disabled"];
23308
+ return `${inlineAttrs({ ...node, configs: configs2 })}${locked ? "" : ` [disabled]="${submitReads.blocked}"`}${boundAttrs(node, ctx, storeProp)}`;
23309
+ }
22387
23310
  if (node.type === "section_carousel" /* SECTION_CAROUSEL */) {
22388
23311
  const slides = cardEmit(
22389
23312
  node,
@@ -23078,7 +24001,7 @@ ${" ".repeat(indent2 + index)}}`,
23078
24001
  ctx.overlayNames,
23079
24002
  bindingScope(ctx, storeProp),
23080
24003
  ctx.controlMap?.[node.id]?.bindings
23081
- )}${sectionTableRowItemAttr(node, ctx.controlMap)}${foldedName ? "" : outputAttrs(node, methods, operationOf, storeProp, ctx)}`;
24004
+ )}${sectionTableRowItemAttr(node, ctx.controlMap)}${foldedName ? "" : withSubmitCall(outputAttrs(node, methods, operationOf, storeProp, ctx), submitTargetReads(node, ctx)?.submit)}`;
23082
24005
  const totalGuard = paginationTotalRead(node, ctx, storeProp)?.guard;
23083
24006
  if (totalGuard) {
23084
24007
  return `${pad2}@if (${totalGuard}; as ${PAGINATION_TOTAL_ALIAS}) {
@@ -23603,8 +24526,18 @@ var formModelDeclsBlock = (models, scope) => {
23603
24526
  }
23604
24527
  return void 0;
23605
24528
  };
23606
- const coerce = (read, type) => {
23607
- if (type.cardinality === "many") return `${read} ?? []`;
24529
+ const keyScope = {
24530
+ inputs: scope.inputs,
24531
+ computeds: scope.computeds,
24532
+ constants: scope.constants,
24533
+ functions: scope.functions,
24534
+ shapes: scope.shapes,
24535
+ ...scope.storeProp ? { properties: scope.properties } : {}
24536
+ };
24537
+ const coerce = (read, type, landed) => {
24538
+ if (type.cardinality === "many") {
24539
+ return landed?.cardinality === "one" ? `[${read}].filter((value) => value !== undefined)` : `${read} ?? []`;
24540
+ }
23608
24541
  if (type.dataType === "boolean") return `${read} ?? false`;
23609
24542
  if (type.dataType === "number" || type.dataType === "file") return read;
23610
24543
  return `String(${read} ?? '')`;
@@ -23620,13 +24553,21 @@ var formModelDeclsBlock = (models, scope) => {
23620
24553
  const keyType = formModelKeyType(key2);
23621
24554
  if (!keyType) return ` ${key2.name}: undefined,`;
23622
24555
  const source = model.keys[key2.id] ?? { source: "empty" };
24556
+ if (formModelKeyIssue(key2, source, keyScope)) {
24557
+ return ` ${key2.name}: ${formModelKeyZero(keyType)},`;
24558
+ }
23623
24559
  if (source.source === "fixed") {
23624
24560
  return ` ${key2.name}: ${literalExpression(source.value, {
23625
24561
  type: keyType.dataType
23626
24562
  })},`;
23627
24563
  }
23628
- const read = sourceRead(source);
23629
- return ` ${key2.name}: ${read ? coerce(read, keyType) : formModelKeyZero(keyType)},`;
24564
+ const raw = sourceRead(source);
24565
+ const read = raw && isFormModelReadSource(source) && source.transform ? emitTransformExpr(source.transform, raw, {
24566
+ functions: scope.functions,
24567
+ constants: scope.constants,
24568
+ scope: "class"
24569
+ }) : raw;
24570
+ return ` ${key2.name}: ${read ? coerce(read, keyType, formModelLandedType(source, keyScope)) : formModelKeyZero(keyType)},`;
23630
24571
  });
23631
24572
  const body = rows.length ? `
23632
24573
  ${rows.join("\n")}
@@ -23872,7 +24813,7 @@ ${statements.map((line) => ` ${line};`).join("\n")}
23872
24813
  });
23873
24814
  return emitted.join("");
23874
24815
  }
23875
- function outputOpenEmit(node, output, ctx, storeProp, indent2 = " ", methods = {}, operationOf = () => void 0) {
24816
+ function outputOpenEmit(node, output, ctx, storeProp, indent2 = " ", methods = {}, operationOf = () => void 0, aliasArgs = false) {
23876
24817
  const open = outputOpenOf(node.outputOpens, output);
23877
24818
  if (!open?.screenId) return void 0;
23878
24819
  const ref = ctx.outputOpenRef?.(open.screenId);
@@ -23881,6 +24822,10 @@ function outputOpenEmit(node, output, ctx, storeProp, indent2 = " ", methods
23881
24822
  if (ref.inputs.some((input) => input.required && !filled.has(input.id)))
23882
24823
  return void 0;
23883
24824
  const payload = nodePayloadShape(node, output, ctx);
24825
+ const aliasParams = /* @__PURE__ */ new Map();
24826
+ const readsAlias = (binding) => binding.root.kind === "alias" || transformBindingLeaves(binding.transform).some(
24827
+ (leaf) => leaf.root.kind === "alias"
24828
+ );
23884
24829
  const entries = outputOpenInputEntries(
23885
24830
  open,
23886
24831
  ref.inputs,
@@ -23898,14 +24843,24 @@ function outputOpenEmit(node, output, ctx, storeProp, indent2 = " ", methods
23898
24843
  const member = screenMemberExpression(binding, ctx);
23899
24844
  return member ? `this.${member}` : void 0;
23900
24845
  },
23901
- (binding) => bindingExpression(binding, {
23902
- ...bindingScope(ctx, storeProp),
23903
- memberPrefix: "this."
23904
- }),
24846
+ (binding) => {
24847
+ if (!readsAlias(binding))
24848
+ return bindingExpression(binding, {
24849
+ ...bindingScope(ctx, storeProp),
24850
+ memberPrefix: "this."
24851
+ });
24852
+ if (!aliasArgs || binding.transform) return void 0;
24853
+ const read = bindingExpression(binding, bindingScope(ctx, storeProp));
24854
+ if (!read) return void 0;
24855
+ const param = aliasParams.get(read) ?? `$row${aliasParams.size}`;
24856
+ aliasParams.set(read, param);
24857
+ return param;
24858
+ },
23905
24859
  screenSourceReader(ctx, bindingScope(ctx, storeProp))
23906
24860
  );
23907
24861
  if (!entries) return void 0;
23908
24862
  return {
24863
+ aliasReads: [...aliasParams.keys()],
23909
24864
  member: outputOpenMemberName(node.id, output),
23910
24865
  // A member reading nothing off the gesture takes no parameter, so a void
23911
24866
  // output such as `clicked` opens the overlay with an empty call.
@@ -24088,11 +25043,14 @@ function outputOpenCall(node, output, ctx, scope, storeProp, methods, operationO
24088
25043
  storeProp,
24089
25044
  " ",
24090
25045
  methods,
24091
- operationOf
25046
+ operationOf,
25047
+ true
24092
25048
  );
24093
25049
  if (!emit) return "";
25050
+ if (scope === "class" && emit.aliasReads.length) return "";
24094
25051
  const self = scope === "class" ? "this." : "";
24095
- return `${self}${emit.member}(${emit.readsEvent ? "$event" : ""})`;
25052
+ const args = [...emit.readsEvent ? ["$event"] : [], ...emit.aliasReads];
25053
+ return `${self}${emit.member}(${args.join(", ")})`;
24096
25054
  }
24097
25055
  function outputOpenMembersBlock(tree, ctx, payloads, storeProp, methods, operationOf) {
24098
25056
  const emitted = [];
@@ -24109,13 +25067,19 @@ function outputOpenMembersBlock(tree, ctx, payloads, storeProp, methods, operati
24109
25067
  storeProp,
24110
25068
  " ",
24111
25069
  methods,
24112
- operationOf
25070
+ operationOf,
25071
+ true
24113
25072
  );
24114
25073
  if (!emit) continue;
24115
25074
  const payload = nodePayloadShape(node, output, ctx);
24116
- const param = emit.readsEvent ? `$event: ${payloads.get(node.id)?.type ?? handlerEventType(payload, node.type, output)}` : "";
25075
+ const params = [
25076
+ ...emit.readsEvent ? [
25077
+ `$event: ${payloads.get(node.id)?.type ?? handlerEventType(payload, node.type, output)}`
25078
+ ] : [],
25079
+ ...emit.aliasReads.map((_, index) => `$row${index}: unknown`)
25080
+ ].join(", ");
24117
25081
  emitted.push(`
24118
- protected readonly ${emit.member} = (${param}): void => {
25082
+ protected readonly ${emit.member} = (${params}): void => {
24119
25083
  ${emit.statement}
24120
25084
  };
24121
25085
  `);
@@ -24583,13 +25547,13 @@ function menuActionHandlersBlock(tree, methods, operationOf, storeProp, ctx, pay
24583
25547
  walk(node.childrens);
24584
25548
  continue;
24585
25549
  }
24586
- const slots = menuActionSlots(node).filter(
25550
+ const slots2 = menuActionSlots(node).filter(
24587
25551
  isMenuActionSlotComplete
24588
25552
  );
24589
- if (!slots.length) continue;
25553
+ if (!slots2.length) continue;
24590
25554
  const payload = payloadShape(MENU_ACTION_OUTPUT, node.type, node.configs);
24591
25555
  const arms = [];
24592
- for (const slot of slots) {
25556
+ for (const slot of slots2) {
24593
25557
  const key2 = menuActionKey(slot.id);
24594
25558
  const statements = gatedCallSiteStatements(
24595
25559
  node,
@@ -25690,7 +26654,10 @@ ${record(" ")}
25690
26654
  )
25691
26655
  ).sort();
25692
26656
  const levels = computedLevels.map((level) => {
25693
- const entries = level.map((computed) => ({ computed, fn: functions[computed.functionId] })).filter(
26657
+ const entries = level.map((computed) => ({
26658
+ computed,
26659
+ fn: stateComputedFunction(computed, functions)
26660
+ })).filter(
25694
26661
  (pair) => !!pair.fn
25695
26662
  );
25696
26663
  const destructured = Array.from(
@@ -25786,8 +26753,15 @@ ${lines.join("\n")}
25786
26753
  ...drawn.needsModal ? [MODAL_STORE] : [],
25787
26754
  // A `denied` arm's refusal is claimed off the library (api ADR 0005).
25788
26755
  ...drawn.needsDenial ? ["claimDenial"] : [],
25789
- // A CallCondition asking a OneFunction (ADR 0202).
25790
- ...drawn.oneFunctions ?? [],
26756
+ // A CallCondition asking a OneFunction (ADR 0202), and a StateComputed
26757
+ // calling one (ADR 0218) — one name imported once.
26758
+ .../* @__PURE__ */ new Set([
26759
+ ...drawn.oneFunctions ?? [],
26760
+ ...Object.values(computeds).filter(isOneFunctionStateComputed).flatMap((computed) => {
26761
+ const entry2 = oneFunctionOf(computed.oneFunction);
26762
+ return entry2 && !isNativeOneFunction(entry2) ? [entry2.name] : [];
26763
+ })
26764
+ ]),
25791
26765
  ...hooks.needsStorage || drawn.needsStorage || storageMethods.needsStorage ? [STORAGE_SERVICE] : [],
25792
26766
  // What the host's search box is read through, drawn per row the way every
25793
26767
  // other source's import is (ADR 0184).
@@ -25803,7 +26777,9 @@ ${lines.join("\n")}
25803
26777
  const storageImport = oneImports.length ? `import { ${oneImports.join(", ")} } from '@magmonium/one';
25804
26778
  ` : "";
25805
26779
  const functionImports = Array.from(
25806
- Object.values(computeds).map((computed) => functions[computed.functionId]).concat((drawn.functionIds ?? []).map((id) => functions[id])).concat(hooks.feedFunctionId ? [functions[hooks.feedFunctionId]] : []).concat(
26780
+ Object.values(computeds).map(
26781
+ (computed) => computed.functionId ? functions[computed.functionId] : void 0
26782
+ ).concat((drawn.functionIds ?? []).map((id) => functions[id])).concat(hooks.feedFunctionId ? [functions[hooks.feedFunctionId]] : []).concat(
25807
26783
  ruleFunctionImports(
25808
26784
  variantList.map((variant) => variant.rule),
25809
26785
  rootProperties,
@@ -26513,9 +27489,13 @@ ${tables.map(
26513
27489
  ctx.storePropOf,
26514
27490
  ctx.outputs ?? {}
26515
27491
  );
27492
+ const submitTargetQueriesBody = submitTargetQueriesBlock(
27493
+ ctx.controlMap ?? {}
27494
+ );
26516
27495
  const angularCore = [
26517
27496
  "ChangeDetectionStrategy",
26518
27497
  "Component",
27498
+ ...submitTargetQueriesBody ? ["viewChild"] : [],
26519
27499
  ...screenComputedsBody || screenVariantsBody || cardsBody || messageParamsBody ? ["computed"] : [],
26520
27500
  ...autoCalls.length ? ["effect"] : [],
26521
27501
  ...autoCallsBody.includes("untracked(") ? ["untracked"] : [],
@@ -26544,6 +27524,24 @@ ${tables.map(
26544
27524
  if (fn) screenFunctions.set(fn.name, fn);
26545
27525
  }
26546
27526
  for (const fn of variantFunctions) screenFunctions.set(fn.name, fn);
27527
+ for (const id of templateTransformRefs(
27528
+ formModelTransforms(
27529
+ Object.values(ctx.formModels ?? {}),
27530
+ ctx.controlMap ?? {},
27531
+ {
27532
+ inputs: ctx.inputs ?? {},
27533
+ computeds: screenComputeds,
27534
+ constants,
27535
+ functions: ctx.functions ?? {},
27536
+ shapes,
27537
+ ...needsStore ? { properties: ctx.properties ?? {} } : {}
27538
+ }
27539
+ ),
27540
+ ctx.functions ?? {}
27541
+ ).functionIds) {
27542
+ const fn = (ctx.functions ?? {})[id];
27543
+ if (fn) screenFunctions.set(fn.name, fn);
27544
+ }
26547
27545
  for (const handler of Object.values(ctx.screenMethods ?? {})) {
26548
27546
  for (const one of screenMethodCalls(handler)) {
26549
27547
  const fn = (ctx.functions ?? {})[one.functionId ?? ""];
@@ -26793,7 +27791,7 @@ ${`${outcomeHandlersBody}${menuActionHandlersBody}`.includes("$event: MenuItem")
26793
27791
  width: 100%
26794
27792
  \`,
26795
27793
  })
26796
- 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}}
27794
+ 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}${submitTargetQueriesBody}${checksBody}${screenMethodsBody}${outputOpenBody}${outputLinkBody}${outcomeHandlersBody}${menuActionHandlersBody}${menuConditionBody}${outputArmHandlersBody}${autoCallsBody}}
26797
27795
  `;
26798
27796
  }
26799
27797
  function assetName(node) {
@@ -27131,7 +28129,7 @@ __export(package_exports, {
27131
28129
  version: () => version
27132
28130
  });
27133
28131
  var name = "@magmonium/one";
27134
- var version = "0.4.96";
28132
+ var version = "0.4.114";
27135
28133
  var description = "Magmonium One \u2014 Angular design-system primitives for mm Apps";
27136
28134
  var author = "magmonium";
27137
28135
  var license = "MIT";
@@ -27199,7 +28197,7 @@ __export(package_exports2, {
27199
28197
  version: () => version2
27200
28198
  });
27201
28199
  var name2 = "@magmonium/cli";
27202
- var version2 = "0.8.26";
28200
+ var version2 = "0.8.28";
27203
28201
  var description2 = "A powerful and extensible asset compilation tool that can be shared across multiple projects";
27204
28202
  var bin = {
27205
28203
  "mag-cli": "bin/cli.js"
@@ -27498,6 +28496,49 @@ var migrateLadder = (id, ladder, out) => {
27498
28496
  };
27499
28497
  };
27500
28498
 
28499
+ // libs/codegen/src/lib/button-key-migration.ts
28500
+ var recordOf2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
28501
+ var backfillButtonKeys = (controlMap) => {
28502
+ const map = recordOf2(controlMap);
28503
+ if (!map) return controlMap;
28504
+ const out = { ...map };
28505
+ for (const [id, raw] of Object.entries(map)) {
28506
+ const bar = recordOf2(raw);
28507
+ if (bar?.["type"] !== "section_action" /* SECTION_ACTION */) continue;
28508
+ const childIds = (Array.isArray(bar["childrens"]) ? bar["childrens"] : []).filter(
28509
+ (c) => typeof c === "string"
28510
+ );
28511
+ const childrens = childIds.flatMap((childId) => {
28512
+ const child = recordOf2(map[childId]);
28513
+ if (!child) return [];
28514
+ return [
28515
+ {
28516
+ id: childId,
28517
+ type: child["type"],
28518
+ configs: recordOf2(child["configs"]) ?? {},
28519
+ childrens: []
28520
+ }
28521
+ ];
28522
+ });
28523
+ const keys = suggestedButtonKeys({
28524
+ id,
28525
+ type: "section_action" /* SECTION_ACTION */,
28526
+ configs: recordOf2(bar["configs"]) ?? {},
28527
+ childrens
28528
+ });
28529
+ for (const [buttonId, key2] of keys) {
28530
+ const button = recordOf2(out[buttonId]);
28531
+ const configs = recordOf2(button?.["configs"]) ?? {};
28532
+ if (!button || configs[BUTTON_KEY_CONFIG_KEY]) continue;
28533
+ out[buttonId] = {
28534
+ ...button,
28535
+ configs: { ...configs, [BUTTON_KEY_CONFIG_KEY]: key2 }
28536
+ };
28537
+ }
28538
+ }
28539
+ return out;
28540
+ };
28541
+
27501
28542
  // libs/codegen/src/model/control-group.ts
27502
28543
  var CONTROL_GROUP_NAME_MAX = 40;
27503
28544
  var NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
@@ -27738,7 +28779,7 @@ function navRowSourceOptions(feature, owner) {
27738
28779
  const value = owner && storeOwnerValue(owner);
27739
28780
  return storesOf(feature).filter((store) => !value || storeOwnerValue(store.owner) === value).flatMap(
27740
28781
  (store) => Object.values(store.computeds).filter((computed) => {
27741
- const fn = feature.functions?.[computed.functionId];
28782
+ const fn = stateComputedFunction(computed, feature.functions ?? {});
27742
28783
  return !!fn && isNavRowShape(fn.returnType, fn.returnCardinality, feature.shapes);
27743
28784
  }).map((computed) => ({
27744
28785
  value: computed.id,
@@ -28974,7 +30015,7 @@ var caseEquals = (actual, expected) => {
28974
30015
  };
28975
30016
 
28976
30017
  // libs/codegen/src/lib/workspace-codec.ts
28977
- var WORKSPACE_SCHEMA_VERSION = 31;
30018
+ var WORKSPACE_SCHEMA_VERSION = 32;
28978
30019
  var MIGRATION_FLOOR = 18;
28979
30020
  var DEPLOY_TOKEN_METHOD_IDS = {
28980
30021
  "@UserStore.ensureDeployToken": "@AuthStore.ensureDeployToken",
@@ -29090,34 +30131,34 @@ var SCREEN_OUTPUT_SIBLINGS = [
29090
30131
  ["screenOutputScreenWrites", "outputScreenWrites"],
29091
30132
  ["screenOutputOutcomes", "outputOutcomes"]
29092
30133
  ];
29093
- var recordOf2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
30134
+ var recordOf3 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
29094
30135
  var migrateScreenOutputMaps = (control) => {
29095
30136
  if (!Object.keys(control).some((key2) => key2.startsWith("screenOutput"))) {
29096
30137
  return control;
29097
30138
  }
29098
30139
  const next = { ...control };
29099
30140
  const merge = (field, key2, value) => {
29100
- next[field] = { ...recordOf2(next[field]) ?? {}, [key2]: value };
30141
+ next[field] = { ...recordOf3(next[field]) ?? {}, [key2]: value };
29101
30142
  };
29102
30143
  for (const [from, to] of SCREEN_OUTPUT_SIBLINGS) {
29103
- for (const [key2, value] of Object.entries(recordOf2(control[from]) ?? {})) {
30144
+ for (const [key2, value] of Object.entries(recordOf3(control[from]) ?? {})) {
29104
30145
  merge(to, key2, value);
29105
30146
  }
29106
30147
  delete next[from];
29107
30148
  }
29108
- const emits = recordOf2(control["screenOutputEmits"]) ?? {};
30149
+ const emits = recordOf3(control["screenOutputEmits"]) ?? {};
29109
30150
  for (const [key2, rows] of Object.entries(emits)) {
29110
30151
  merge("outputEmits", key2, rows);
29111
30152
  }
29112
30153
  delete next["screenOutputEmits"];
29113
- const bindings = recordOf2(control["screenOutputs"]) ?? {};
30154
+ const bindings = recordOf3(control["screenOutputs"]) ?? {};
29114
30155
  for (const [key2, raw] of Object.entries(bindings)) {
29115
30156
  const binding = raw;
29116
30157
  if (binding?.kind === "method") {
29117
30158
  merge("outputs", key2, binding.methodId);
29118
30159
  if (binding.args?.length) merge("outputArgs", key2, binding.args);
29119
30160
  } else if (binding?.kind === "output") {
29120
- const drawn = recordOf2(next["outputEmits"])?.[key2];
30161
+ const drawn = recordOf3(next["outputEmits"])?.[key2];
29121
30162
  merge("outputEmits", key2, [
29122
30163
  ...Array.isArray(drawn) ? drawn : [],
29123
30164
  { id: `reemit-${key2}`, outputId: binding.outputId, value: { kind: "event" } }
@@ -29224,6 +30265,10 @@ var screenOnly = (step) => ({
29224
30265
  step
29225
30266
  });
29226
30267
  var MIGRATIONS = {
30268
+ // 31 → 32: every folded Button keeps the name its bar rendered it under as
30269
+ // its ButtonKey, in a Screen's ControlMap and in every ControlGroup
30270
+ // (m-one-ui ADR 0213).
30271
+ 31: everyKind((blob) => mapBlobControlMaps(blob, backfillButtonKeys)),
29227
30272
  // 30 → 31: a PriceLadder becomes a Scale — its marks ScaleMarks, its chips
29228
30273
  // and picked indicators ScaleRelations — in a Screen's ControlMap and in
29229
30274
  // every ControlGroup (libs/one GLOSSARY.md Scale).
@@ -29506,9 +30551,7 @@ function sanitizeShapes(shapes, reachable = {}, owner = "feature") {
29506
30551
  const raw = value.keys;
29507
30552
  if (!Array.isArray(raw)) continue;
29508
30553
  const takenKeys = /* @__PURE__ */ new Set();
29509
- named[id].keys = raw.filter((key2) => !!key2 && typeof key2 === "object").filter(
29510
- (key2) => typeof key2.name === "string" && isValidPropertyName(key2.name)
29511
- ).filter(
30554
+ named[id].keys = raw.filter((key2) => !!key2 && typeof key2 === "object").filter((key2) => typeof key2.name === "string" && key2.name.trim() !== "").filter(
29512
30555
  (key2) => !takenKeys.has(key2.name) && takenKeys.add(key2.name) !== null
29513
30556
  ).map((key2) => {
29514
30557
  const dataType = sanitizeDataType(key2.dataType, {
@@ -29771,9 +30814,10 @@ function sanitizeMethods(methods, properties, functions = {}) {
29771
30814
  (persist) => (persist.sourceKind !== "clear" && persist.sourceKind !== "function" || persist.timing === "before" && persist.shelf === "store") && (persist.sourceKind !== "function" || !!persist.transform) && (persist.sourceKind !== "response" || persist.timing === "after") && (persist.sourceKind !== "state" || !!persist.source.length && !!properties[persist.source[0]]) && (persist.sourceKind !== "args" || !!persist.arg) && (persist.sourceKind !== "fixed" || typeof persist.value === "string") && (persist.shelf === "store" ? persist.sourceKind !== "state" && !!properties[persist.propertyId ?? ""] : !!persist.key.trim())
29772
30815
  );
29773
30816
  const computes = (Array.isArray(method.computes) ? method.computes : []).filter(
29774
- (compute) => !!compute && typeof compute.id === "string" && !!compute.id && typeof compute.name === "string" && !!compute.name.trim() && typeof compute.functionId === "string" && !!functions[compute.functionId] && !!compute.args && typeof compute.args === "object"
29775
- ).map((compute) => ({
30817
+ (compute) => !!compute && typeof compute.id === "string" && !!compute.id && typeof compute.name === "string" && !!compute.name.trim() && (compute.oneFunction ? !!computeOneFunction(compute) && !!compute.returns && typeof compute.returns === "object" && !!compute.returns.dataType && typeof compute.returns.cardinality === "string" : typeof compute.functionId === "string" && !!functions[compute.functionId]) && !!compute.args && typeof compute.args === "object"
30818
+ ).map(({ oneFunction, returns, ...compute }) => ({
29776
30819
  ...compute,
30820
+ ...oneFunction ? { functionId: "", oneFunction, returns } : {},
29777
30821
  args: Object.fromEntries(
29778
30822
  Object.entries(compute.args).filter(([, binding]) => {
29779
30823
  if (!binding) return false;
@@ -29814,18 +30858,21 @@ function sanitizeMethods(methods, properties, functions = {}) {
29814
30858
  if (!binding) return false;
29815
30859
  if (binding.source === "args") return !!binding.arg;
29816
30860
  if (binding.source === "fixed") return binding.value !== void 0;
30861
+ if (binding.source === "compute")
30862
+ return typeof binding.name === "string" && !!binding.name;
29817
30863
  return binding.source === "store" && Array.isArray(binding.path) && !!binding.path.length && !!properties[binding.path[0]];
29818
30864
  })
29819
30865
  )
29820
30866
  });
29821
30867
  const conditions = (Array.isArray(method.conditions) ? method.conditions : []).filter(
29822
- (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")
30868
+ (condition) => !!condition && typeof condition.id === "string" && !!condition.id && (condition.kind === "check" ? !!condition.check && (condition.check.source === "store" || condition.check.source === "args" || condition.check.source === "compute") && 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")
29823
30869
  ).map((condition) => {
29824
30870
  const check = condition.check;
29825
30871
  if (condition.kind !== "check" || !check)
29826
30872
  return functionCondition(condition);
29827
30873
  const path = check.source === "store" && Array.isArray(check.path) && check.path.every((segment) => typeof segment === "string") && !!check.path.length && !!properties[check.path[0]] ? check.path : void 0;
29828
30874
  const arg = check.source === "args" && typeof check.arg === "string" ? check.arg : void 0;
30875
+ const compute = check.source === "compute" && typeof check.compute === "string" ? check.compute : void 0;
29829
30876
  return {
29830
30877
  id: condition.id,
29831
30878
  kind: "check",
@@ -29836,6 +30883,7 @@ function sanitizeMethods(methods, properties, functions = {}) {
29836
30883
  operator: check.operator,
29837
30884
  ...path ? { path } : {},
29838
30885
  ...arg ? { arg } : {},
30886
+ ...compute ? { compute } : {},
29839
30887
  ...typeof check.value === "string" ? { value: check.value } : {}
29840
30888
  }
29841
30889
  };
@@ -29872,6 +30920,7 @@ function sanitizeMethods(methods, properties, functions = {}) {
29872
30920
  id: param.id,
29873
30921
  name: param.name.trim(),
29874
30922
  dataType: { type: param.dataType.type },
30923
+ ...param.cardinality === "many" ? { cardinality: "many" } : {},
29875
30924
  // The one axis the User answers for a parameter nothing sends, so the
29876
30925
  // load is where it would otherwise be lost silently (GLOSSARY.md
29877
30926
  // MethodParam).
@@ -30195,9 +31244,27 @@ function sanitizeStateComputeds(value, functions, reservedNames) {
30195
31244
  if (typeof computed.name !== "string" || !isValidPropertyName(computed.name) || taken.has(computed.name)) {
30196
31245
  continue;
30197
31246
  }
31247
+ const args = computed.args ?? {};
31248
+ const returns = computed.functionId ? void 0 : sanitizeComputedReturns(computed.returns);
31249
+ const oneFunction = !computed.functionId && typeof computed.oneFunction === "string" ? computed.oneFunction : void 0;
31250
+ if (oneFunction && returns) {
31251
+ const stored = {
31252
+ id,
31253
+ name: computed.name,
31254
+ oneFunction,
31255
+ args,
31256
+ returns
31257
+ };
31258
+ const fn2 = stateComputedFunction(stored, {});
31259
+ if (fn2 && fn2.params.some((param) => args[param.id] === void 0)) {
31260
+ continue;
31261
+ }
31262
+ taken.add(computed.name);
31263
+ result[id] = stored;
31264
+ continue;
31265
+ }
30198
31266
  const fn = computed.functionId ? functions[computed.functionId] : void 0;
30199
31267
  if (!fn) continue;
30200
- const args = computed.args ?? {};
30201
31268
  if (fn.params.some((param) => args[param.id] === void 0)) continue;
30202
31269
  taken.add(computed.name);
30203
31270
  result[id] = { id, name: computed.name, functionId: fn.id, args };
@@ -30600,6 +31667,11 @@ function sanitizeFormKeySource(value, scope) {
30600
31667
  const source = value;
30601
31668
  const member = source.member;
30602
31669
  const walk = Array.isArray(member) && member.every((id) => typeof id === "string") ? member : void 0;
31670
+ const transform = sanitizeTransform(
31671
+ source.transform,
31672
+ scope.functions
31673
+ );
31674
+ const fit = transform ? { transform } : {};
30603
31675
  if (source.source === "fixed") {
30604
31676
  return typeof source.value === "string" && source.value.trim() ? { source: "fixed", value: source.value } : EMPTY_KEY;
30605
31677
  }
@@ -30607,24 +31679,26 @@ function sanitizeFormKeySource(value, scope) {
30607
31679
  return scope.inputs[source.inputId] ? {
30608
31680
  source: "input",
30609
31681
  inputId: source.inputId,
30610
- ...walk ? { member: walk } : {}
31682
+ ...walk ? { member: walk } : {},
31683
+ ...fit
30611
31684
  } : EMPTY_KEY;
30612
31685
  }
30613
31686
  if (source.source === "computed") {
30614
31687
  return scope.computedIds.has(source.computedId) ? {
30615
31688
  source: "computed",
30616
31689
  computedId: source.computedId,
30617
- ...walk ? { member: walk } : {}
31690
+ ...walk ? { member: walk } : {},
31691
+ ...fit
30618
31692
  } : EMPTY_KEY;
30619
31693
  }
30620
31694
  if (source.source === "constant") {
30621
- return scope.constants[source.constantId] ? { source: "constant", constantId: source.constantId } : EMPTY_KEY;
31695
+ return scope.constants[source.constantId] ? { source: "constant", constantId: source.constantId, ...fit } : EMPTY_KEY;
30622
31696
  }
30623
31697
  if (source.source === "path") {
30624
31698
  if (!scope.hasStore) return EMPTY_KEY;
30625
31699
  if (!Array.isArray(source.path) || !source.path.length) return EMPTY_KEY;
30626
31700
  if (!source.path.every((id) => typeof id === "string")) return EMPTY_KEY;
30627
- return scope.properties[source.path[0]] ? { source: "path", path: source.path } : EMPTY_KEY;
31701
+ return scope.properties[source.path[0]] ? { source: "path", path: source.path, ...fit } : EMPTY_KEY;
30628
31702
  }
30629
31703
  return EMPTY_KEY;
30630
31704
  }
@@ -30749,7 +31823,10 @@ function sanitizeScreens(screens, features, appFunctions, sharedShapes = {}, enu
30749
31823
  if (Object.keys(variants).length) meta.variants = variants;
30750
31824
  const outputs = sanitizeScreenOutputs(screen.outputs, kind);
30751
31825
  if (Object.keys(outputs).length) meta.outputs = outputs;
30752
- const autoCalls = sanitizeAutoCalls(screen.autoCalls, kind);
31826
+ const autoCalls = splitAutoCallEmits(
31827
+ sanitizeAutoCalls(screen.autoCalls, kind),
31828
+ inputs
31829
+ );
30753
31830
  if (autoCalls.length) meta.autoCalls = autoCalls;
30754
31831
  if (screen.exposed === true && kind !== "page") meta.exposed = true;
30755
31832
  const taken = /* @__PURE__ */ new Set([
@@ -30809,7 +31886,8 @@ function sanitizeScreens(screens, features, appFunctions, sharedShapes = {}, enu
30809
31886
  constants,
30810
31887
  computedIds: new Set(Object.keys(computeds)),
30811
31888
  properties: feature?.properties ?? {},
30812
- hasStore: hasStore(kind)
31889
+ hasStore: hasStore(kind),
31890
+ functions: feature ? { ...appFunctions, ...feature.functions } : appFunctions
30813
31891
  });
30814
31892
  if (Object.keys(formModels).length) meta.formModels = formModels;
30815
31893
  const screenMethods = sanitizeScreenMethods(screen.methods, taken);
@@ -35574,6 +36652,10 @@ var HISTORY_LABELS = [
35574
36652
  // Screen's slot riding it beside the target's (GLOSSARY.md ScreenLink).
35575
36653
  "paste-screen-link",
35576
36654
  "paste-control",
36655
+ // A block row's Cut, so `undo` knows to empty the OutputBlockClipboard the
36656
+ // way it empties the Control clipboard after `cut-control`; and its Paste.
36657
+ "cut-output-block",
36658
+ "paste-output-block",
35577
36659
  "edit-control",
35578
36660
  "edit-binding",
35579
36661
  "edit-variant",
@@ -35629,6 +36711,7 @@ var HISTORY_SELECTION_KEYS = [
35629
36711
  // Annotate the CommonJS export names for ESM import in node:
35630
36712
  0 && (module.exports = {
35631
36713
  ACTION_NAME_READER,
36714
+ ACTION_SELECTION_KEY,
35632
36715
  ALL_VARIANT,
35633
36716
  API_SEGMENT,
35634
36717
  APP_CONFIG_SOURCE,
@@ -35664,6 +36747,8 @@ var HISTORY_SELECTION_KEYS = [
35664
36747
  BUSY_VARIANT_ID,
35665
36748
  BUSY_VARIANT_NAME,
35666
36749
  BUTTON_CLICK_OUTPUT,
36750
+ BUTTON_KEY_CONFIG_KEY,
36751
+ BUTTON_KEY_PATTERN,
35667
36752
  CALL_ARG_SOURCES,
35668
36753
  CALL_ARG_TRANSFORM_LEAVES,
35669
36754
  CALL_CONDITION_KINDS,
@@ -35814,6 +36899,7 @@ var HISTORY_SELECTION_KEYS = [
35814
36899
  METHOD_VARIANT_SOURCES,
35815
36900
  MIGRATION_FLOOR,
35816
36901
  MODAL_STORE,
36902
+ NATIVE_ONE_FUNCTION_SPECS,
35817
36903
  NAV_ID_SEP,
35818
36904
  NAV_LINK_KINDS,
35819
36905
  NAV_PRESENTATIONS,
@@ -35834,9 +36920,12 @@ var HISTORY_SELECTION_KEYS = [
35834
36920
  ONE_FUNCTIONS,
35835
36921
  ONE_FUNCTION_CATALOG,
35836
36922
  ONE_FUNCTION_DATA_PARAM,
36923
+ ONE_FUNCTION_IDS_PARAM,
35837
36924
  ONE_FUNCTION_ID_PARAM,
36925
+ ONE_FUNCTION_KEY_PARAM,
35838
36926
  ONE_FUNCTION_MAP_PARAM,
35839
36927
  ONE_FUNCTION_PREFIX,
36928
+ ONE_FUNCTION_SPECS,
35840
36929
  ONE_IMPORT_MODULE,
35841
36930
  ONE_PACKAGE_VERSION,
35842
36931
  OPEN_SCREEN_INPUT_SOURCES,
@@ -35926,6 +37015,7 @@ var HISTORY_SELECTION_KEYS = [
35926
37015
  STYLE_DIRECTIVE_FORM,
35927
37016
  STYLE_DIRECTIVE_KEYS,
35928
37017
  STYLE_DIRECTIVE_NAMES,
37018
+ SUBMIT_TARGET_KEY,
35929
37019
  TEST_RUNNER_DEV_DEPS,
35930
37020
  TEXT_SOURCE,
35931
37021
  TEXT_SOURCES,
@@ -35962,6 +37052,7 @@ var HISTORY_SELECTION_KEYS = [
35962
37052
  actionEnumValues,
35963
37053
  actionEnums,
35964
37054
  actionRenderIds,
37055
+ actionSelectionKey,
35965
37056
  activeBackendUrl,
35966
37057
  activeHosts,
35967
37058
  addMenuGroup,
@@ -36054,6 +37145,7 @@ var HISTORY_SELECTION_KEYS = [
36054
37145
  callArgStorageRead,
36055
37146
  callArgTargetKey,
36056
37147
  callArgTargets,
37148
+ callArgTransformSignature,
36057
37149
  callArgTypeMismatch,
36058
37150
  callArgumentsExpression,
36059
37151
  callError,
@@ -36074,6 +37166,7 @@ var HISTORY_SELECTION_KEYS = [
36074
37166
  canFillFormKey,
36075
37167
  canHostDefaultChild,
36076
37168
  canHostNavChildren,
37169
+ canNameSubmitTarget,
36077
37170
  canOfferAddChild,
36078
37171
  canOfferReplaceParent,
36079
37172
  canOutputCall,
@@ -36143,22 +37236,27 @@ var HISTORY_SELECTION_KEYS = [
36143
37236
  composeFunctionBinding,
36144
37237
  composeLabelValue,
36145
37238
  computeError,
37239
+ computeFunction,
36146
37240
  computeId,
36147
37241
  computeInputMemberError,
36148
37242
  computeInputPaths,
36149
37243
  computeIsRead,
36150
37244
  computeMemberRead,
36151
37245
  computeNameTaken,
37246
+ computeOneFunction,
37247
+ computeOneReturns,
36152
37248
  computeReadable,
36153
37249
  computeTextPaths,
36154
37250
  computedAsProperty,
36155
37251
  computedLocalNames,
36156
37252
  computedRootIds,
37253
+ conditionArgValue,
36157
37254
  conditionCheckType,
36158
37255
  conditionError,
36159
37256
  conditionFunction,
36160
37257
  conditionId,
36161
37258
  conditionKind,
37259
+ conditionReadsCompute,
36162
37260
  configurableResponses,
36163
37261
  confirmError,
36164
37262
  confirmId,
@@ -36224,6 +37322,7 @@ var HISTORY_SELECTION_KEYS = [
36224
37322
  defaultScreenEmitValue,
36225
37323
  defaultScreenWriteValue,
36226
37324
  defaultStateWriteValue,
37325
+ defaultSubmitTarget,
36227
37326
  denialDialogOf,
36228
37327
  denialTranslationKeys,
36229
37328
  derivePaths,
@@ -36247,6 +37346,7 @@ var HISTORY_SELECTION_KEYS = [
36247
37346
  drawnVariants,
36248
37347
  dropChainStep,
36249
37348
  dropFormEventMember,
37349
+ dropOutputBlock,
36250
37350
  dropStaleTrackKeys,
36251
37351
  duplicateMemberName,
36252
37352
  duplicateShapeName,
@@ -36347,6 +37447,7 @@ var HISTORY_SELECTION_KEYS = [
36347
37447
  foldedButtonNames,
36348
37448
  foldedButtons,
36349
37449
  foldedRouterLink,
37450
+ formEventFieldTypes,
36350
37451
  formEventMembers,
36351
37452
  formFieldIds,
36352
37453
  formFields,
@@ -36355,13 +37456,17 @@ var HISTORY_SELECTION_KEYS = [
36355
37456
  formInterfaceName,
36356
37457
  formModelFor,
36357
37458
  formModelKeyIssue,
37459
+ formModelKeyMismatch,
37460
+ formModelKeySignature,
36358
37461
  formModelKeyType,
36359
37462
  formModelKeyZero,
37463
+ formModelLandedType,
36360
37464
  formModelScreenOptions,
36361
37465
  formModelShapeKeys,
36362
37466
  formModelSourceReaders,
36363
37467
  formModelSourceType,
36364
37468
  formModelStateOptions,
37469
+ formModelTransforms,
36365
37470
  formRefName,
36366
37471
  formRefNames,
36367
37472
  formResetDepths,
@@ -36451,12 +37556,14 @@ var HISTORY_SELECTION_KEYS = [
36451
37556
  hasRouterOutlet,
36452
37557
  hasScreenVariableActionEnumConflict,
36453
37558
  hasStore,
37559
+ hasSubmitTargetButton,
36454
37560
  hasTextSource,
36455
37561
  hasValueSource,
36456
37562
  hasVariableDrift,
36457
37563
  heldFieldIds,
36458
37564
  heldProperties,
36459
37565
  holdKey,
37566
+ holdOutputBlock,
36460
37567
  hostRoutesConst,
36461
37568
  iconControlEmitConfigs,
36462
37569
  iconControlGlyph,
@@ -36516,6 +37623,7 @@ var HISTORY_SELECTION_KEYS = [
36516
37623
  isFieldCheckEligible,
36517
37624
  isFieldOptionSelected,
36518
37625
  isFolderPickSupported,
37626
+ isFormModelReadSource,
36519
37627
  isFormatPipeName,
36520
37628
  isFunctionCheckBound,
36521
37629
  isFunctionInUse,
@@ -36542,12 +37650,14 @@ var HISTORY_SELECTION_KEYS = [
36542
37650
  isMethodInUse,
36543
37651
  isMountable,
36544
37652
  isMovingScreenEmit,
37653
+ isNativeOneFunction,
36545
37654
  isNavAtOrBelow,
36546
37655
  isNavInstanceFunction,
36547
37656
  isNavRowShape,
36548
37657
  isNavVisibilityFunction,
36549
37658
  isOnChange,
36550
37659
  isOneFunctionComputed,
37660
+ isOneFunctionStateComputed,
36551
37661
  isOptionRowShape,
36552
37662
  isOrderingMenuActionOperator,
36553
37663
  isOrderingOutputArmOperator,
@@ -36562,6 +37672,7 @@ var HISTORY_SELECTION_KEYS = [
36562
37672
  isOutputCallBound,
36563
37673
  isOutputCallKey,
36564
37674
  isOutputConditional,
37675
+ isOutputSelfEmit,
36565
37676
  isOverlayDirectiveName,
36566
37677
  isOverlayType,
36567
37678
  isPassthroughComputed,
@@ -36599,6 +37710,7 @@ var HISTORY_SELECTION_KEYS = [
36599
37710
  isTaglessFamily,
36600
37711
  isTextSource,
36601
37712
  isTimerComplete,
37713
+ isToggleAction,
36602
37714
  isUnaryMenuActionOperator,
36603
37715
  isUnaryOperator,
36604
37716
  isUnaryOutputArmOperator,
@@ -36812,12 +37924,21 @@ var HISTORY_SELECTION_KEYS = [
36812
37924
  normalizeVariantName,
36813
37925
  offersOutputArms,
36814
37926
  oneFunctionArgFits,
37927
+ oneFunctionBoundSignature,
37928
+ oneFunctionFitsLanding,
36815
37929
  oneFunctionFromPickValue,
37930
+ oneFunctionLiftedAt,
37931
+ oneFunctionMintsKey,
36816
37932
  oneFunctionOf,
36817
37933
  oneFunctionPickValue,
36818
37934
  oneFunctionReturns,
36819
37935
  oneFunctionSignature,
36820
37936
  oneFunctionSignatureText,
37937
+ oneFunctionSiteFits,
37938
+ oneParamFixedHeld,
37939
+ oneParamStatePathOnly,
37940
+ oneParamTakesFixed,
37941
+ oneParamTypeText,
36821
37942
  openError,
36822
37943
  openId,
36823
37944
  openInputAnswered,
@@ -36896,6 +38017,7 @@ var HISTORY_SELECTION_KEYS = [
36896
38017
  outputOpenStatement,
36897
38018
  outputOpenTargets,
36898
38019
  outputOpenValueKinds,
38020
+ outputSelfEmitCall,
36899
38021
  overlayWidgetRefs,
36900
38022
  overlayWidgetScreenIds,
36901
38023
  overlayWidgetsProviderBlock,
@@ -36941,6 +38063,7 @@ var HISTORY_SELECTION_KEYS = [
36941
38063
  persistableOptionSetRows,
36942
38064
  pickFolder,
36943
38065
  pickedNavTail,
38066
+ placeOutputBlock,
36944
38067
  planScreenEmit,
36945
38068
  pluginContractResync,
36946
38069
  pluginContracts,
@@ -36952,6 +38075,7 @@ var HISTORY_SELECTION_KEYS = [
36952
38075
  pluginPortOf,
36953
38076
  pluginSourceOf,
36954
38077
  presetHosts,
38078
+ projectionSlotOf,
36955
38079
  propertiesWithComputeds,
36956
38080
  propertyKey,
36957
38081
  pruneFormEventReads,
@@ -37209,6 +38333,7 @@ var HISTORY_SELECTION_KEYS = [
37209
38333
  signatureEnums,
37210
38334
  signatureFormIds,
37211
38335
  signatureNamesOptionRow,
38336
+ signaturePipeIndex,
37212
38337
  signatureShapeIds,
37213
38338
  signatureText,
37214
38339
  slug,
@@ -37216,6 +38341,7 @@ var HISTORY_SELECTION_KEYS = [
37216
38341
  slugifyMessage,
37217
38342
  sortRowEnumId,
37218
38343
  sourceCarriesTrackKey,
38344
+ splitAutoCallEmits,
37219
38345
  stableId,
37220
38346
  staleCases,
37221
38347
  staleMenuActionItems,
@@ -37224,6 +38350,7 @@ var HISTORY_SELECTION_KEYS = [
37224
38350
  starterFunction,
37225
38351
  stateComputedArgExpression,
37226
38352
  stateComputedArgHeldType,
38353
+ stateComputedFunction,
37227
38354
  stateInterfaceName,
37228
38355
  statePathHeldType,
37229
38356
  statePathRead,
@@ -37264,9 +38391,15 @@ var HISTORY_SELECTION_KEYS = [
37264
38391
  subStoreSuffixError,
37265
38392
  subStoresOf,
37266
38393
  subStoresReachedByMain,
38394
+ submitTargetForms,
38395
+ submitTargetLink,
38396
+ submitTargetOf,
37267
38397
  successResponse,
37268
38398
  suggestFormModelName,
37269
38399
  suggestMethodName,
38400
+ suggestNavVariantName,
38401
+ suggestVariantName,
38402
+ suggestedButtonKeys,
37270
38403
  survivingNavId,
37271
38404
  swaggerUrlFromBackend,
37272
38405
  syncScreenVariable,
@@ -37312,6 +38445,7 @@ var HISTORY_SELECTION_KEYS = [
37312
38445
  typeLabel,
37313
38446
  typeSigil,
37314
38447
  typesMatch,
38448
+ typesMatchExactly,
37315
38449
  unaryCall,
37316
38450
  unboundParams,
37317
38451
  unfilledVariables,
@@ -37320,6 +38454,7 @@ var HISTORY_SELECTION_KEYS = [
37320
38454
  updateRuleNode,
37321
38455
  usesAuthProperty,
37322
38456
  usesStorage,
38457
+ validateButtonKey,
37323
38458
  validateCallArgs,
37324
38459
  validateFeatureName,
37325
38460
  validateFormName,
@@ -37386,6 +38521,7 @@ var HISTORY_SELECTION_KEYS = [
37386
38521
  withEventTransform,
37387
38522
  withFormShapes,
37388
38523
  withListRowShape,
38524
+ withOutputSelfEmit,
37389
38525
  withPropertyEnums,
37390
38526
  withScreenEnums,
37391
38527
  withScreenMethodCallSites,