@uniformdev/canvas 19.159.1-alpha.16 → 19.159.1-alpha.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -4,6 +4,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __typeError = (msg) => {
8
+ throw TypeError(msg);
9
+ };
7
10
  var __commonJS = (cb, mod) => function __require() {
8
11
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
12
  };
@@ -23,19 +26,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
26
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
27
  mod
25
28
  ));
26
- var __accessCheck = (obj, member, msg) => {
27
- if (!member.has(obj))
28
- throw TypeError("Cannot " + msg);
29
- };
30
- var __privateGet = (obj, member, getter) => {
31
- __accessCheck(obj, member, "read from private field");
32
- return getter ? getter.call(obj) : member.get(obj);
33
- };
34
- var __privateAdd = (obj, member, value) => {
35
- if (member.has(obj))
36
- throw TypeError("Cannot add the same private member more than once");
37
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
38
- };
29
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
30
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
31
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
39
32
 
40
33
  // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
41
34
  var require_retry_operation = __commonJS({
@@ -1050,8 +1043,7 @@ function walkNodeTree(node, visitor, options) {
1050
1043
  const childContexts = /* @__PURE__ */ new Map();
1051
1044
  do {
1052
1045
  const currentQueueEntry = componentQueue.pop();
1053
- if (!currentQueueEntry)
1054
- continue;
1046
+ if (!currentQueueEntry) continue;
1055
1047
  const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
1056
1048
  let visitDescendants = true;
1057
1049
  let descendantContext = (_a = childContexts.get(currentComponent.node)) != null ? _a : currentQueueEntry.context;
@@ -1262,8 +1254,7 @@ function walkNodeTree(node, visitor, options) {
1262
1254
  const propertyEntries = Object.entries(properties);
1263
1255
  for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
1264
1256
  const [propKey, propObject] = propertyEntries[propIndex];
1265
- if (!isNestedNodeType(propObject.type))
1266
- continue;
1257
+ if (!isNestedNodeType(propObject.type)) continue;
1267
1258
  const blocks = (_b = propObject.value) != null ? _b : [];
1268
1259
  for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
1269
1260
  const enqueueingBlock = blocks[blockIndex];
@@ -1608,6 +1599,174 @@ function findParameterInNodeTree(data, predicate) {
1608
1599
  return results;
1609
1600
  }
1610
1601
 
1602
+ // src/enhancement/visibility/evaluateVisibilityCriteriaGroup.ts
1603
+ function evaluateVisibilityCriteriaGroup(options) {
1604
+ const { criteriaGroup, simplifyCriteria } = options;
1605
+ const earlyExitResult = criteriaGroup.op === "&" || !criteriaGroup.op ? false : true;
1606
+ let hasIndeterminateClauses = false;
1607
+ for (let index = criteriaGroup.clauses.length - 1; index >= 0; index--) {
1608
+ const clause = criteriaGroup.clauses[index];
1609
+ const criteriaResult = evaluateCriterion(clause, options);
1610
+ if (criteriaResult === null) {
1611
+ hasIndeterminateClauses = true;
1612
+ } else if (criteriaResult === earlyExitResult) {
1613
+ return earlyExitResult;
1614
+ } else if (criteriaResult !== null && simplifyCriteria) {
1615
+ criteriaGroup.clauses.splice(index, 1);
1616
+ }
1617
+ }
1618
+ return hasIndeterminateClauses ? null : !earlyExitResult;
1619
+ }
1620
+ function evaluateCriterion(clause, rootOptions) {
1621
+ if ("clauses" in clause) {
1622
+ return evaluateVisibilityCriteriaGroup({
1623
+ ...rootOptions,
1624
+ criteriaGroup: clause
1625
+ });
1626
+ }
1627
+ const rule = rootOptions.rules[clause.rule];
1628
+ if (rule) {
1629
+ return rule(clause);
1630
+ }
1631
+ return null;
1632
+ }
1633
+
1634
+ // src/enhancement/visibility/types.ts
1635
+ var CANVAS_VIZ_CONTROL_PARAM = "$viz";
1636
+
1637
+ // src/enhancement/visibility/evaluateNodeVisibility.ts
1638
+ function evaluateNodeVisibility({
1639
+ node,
1640
+ ...evaluateGroupOptions
1641
+ }) {
1642
+ var _a;
1643
+ const properties = getPropertiesValue(node);
1644
+ const vizCriteria = (_a = properties == null ? void 0 : properties[CANVAS_VIZ_CONTROL_PARAM]) == null ? void 0 : _a.value;
1645
+ if (vizCriteria == null ? void 0 : vizCriteria.explicitlyHidden) {
1646
+ return false;
1647
+ }
1648
+ if (!(vizCriteria == null ? void 0 : vizCriteria.criteria)) {
1649
+ return true;
1650
+ }
1651
+ const result = evaluateVisibilityCriteriaGroup({
1652
+ ...evaluateGroupOptions,
1653
+ criteriaGroup: vizCriteria.criteria
1654
+ });
1655
+ if (vizCriteria.criteria.clauses.length === 0 && evaluateGroupOptions.simplifyCriteria) {
1656
+ properties == null ? true : delete properties[CANVAS_VIZ_CONTROL_PARAM];
1657
+ }
1658
+ return result;
1659
+ }
1660
+
1661
+ // src/enhancement/visibility/evaluateWalkTreeVisibility.ts
1662
+ function evaluateWalkTreeVisibility({
1663
+ rules,
1664
+ showIndeterminate,
1665
+ context
1666
+ }) {
1667
+ const { type, node, actions } = context;
1668
+ if (type !== "component") {
1669
+ return;
1670
+ }
1671
+ const result = evaluateNodeVisibility({ node, rules, simplifyCriteria: true });
1672
+ if (result === null && !showIndeterminate || result === false) {
1673
+ actions.remove();
1674
+ return false;
1675
+ }
1676
+ return true;
1677
+ }
1678
+
1679
+ // src/enhancement/visibility/rules/evaluateStringMatch.ts
1680
+ var isEvaluator = (criteria, matchValue) => {
1681
+ if (Array.isArray(criteria)) {
1682
+ return criteria.includes(matchValue);
1683
+ }
1684
+ return criteria === matchValue;
1685
+ };
1686
+ var containsEvaluator = (criteria, matchValue) => {
1687
+ if (Array.isArray(criteria)) {
1688
+ return criteria.some((criterion) => matchValue.includes(criterion));
1689
+ }
1690
+ return matchValue.includes(criteria);
1691
+ };
1692
+ var startsWithEvaluator = (criteria, matchValue) => {
1693
+ if (Array.isArray(criteria)) {
1694
+ return criteria.some((criterion) => matchValue.startsWith(criterion));
1695
+ }
1696
+ return matchValue.startsWith(criteria);
1697
+ };
1698
+ var endsWithEvaluator = (criteria, matchValue) => {
1699
+ if (Array.isArray(criteria)) {
1700
+ return criteria.some((criterion) => matchValue.endsWith(criterion));
1701
+ }
1702
+ return matchValue.endsWith(criteria);
1703
+ };
1704
+ var emptyEvaluator = (_, matchValue) => {
1705
+ return matchValue === "";
1706
+ };
1707
+ var stringOperatorEvaluators = {
1708
+ is: isEvaluator,
1709
+ has: containsEvaluator,
1710
+ startswith: startsWithEvaluator,
1711
+ endswith: endsWithEvaluator,
1712
+ empty: emptyEvaluator
1713
+ };
1714
+ function evaluateStringMatch(criteria, matchValue, allow) {
1715
+ const { op, value } = criteria;
1716
+ if (allow && !allow.has(op)) {
1717
+ return null;
1718
+ }
1719
+ let opMatch = op;
1720
+ const negation = op.startsWith("!");
1721
+ if (negation) {
1722
+ opMatch = opMatch.slice(1);
1723
+ }
1724
+ const evaluator = stringOperatorEvaluators[opMatch];
1725
+ if (!evaluator) {
1726
+ return null;
1727
+ }
1728
+ const result = evaluator(value, matchValue);
1729
+ return negation ? !result : result;
1730
+ }
1731
+
1732
+ // src/enhancement/visibility/rules/dynamicInputVisibilityRule.ts
1733
+ var dynamicInputVisibilityOperators = /* @__PURE__ */ new Set([
1734
+ "is",
1735
+ "!is",
1736
+ "has",
1737
+ "!has",
1738
+ "startswith",
1739
+ "!startswith",
1740
+ "endswith",
1741
+ "!endswith",
1742
+ "empty",
1743
+ "!empty"
1744
+ ]);
1745
+ var CANVAS_VIZ_DI_RULE = "$di";
1746
+ function createDynamicInputVisibilityRule(dynamicInputs) {
1747
+ return {
1748
+ [CANVAS_VIZ_DI_RULE]: (criterion) => {
1749
+ const { source } = criterion;
1750
+ const diValue = source ? dynamicInputs[source] : void 0;
1751
+ return evaluateStringMatch(criterion, diValue != null ? diValue : "", dynamicInputVisibilityOperators);
1752
+ }
1753
+ };
1754
+ }
1755
+
1756
+ // src/enhancement/visibility/rules/localeVisibilityRule.ts
1757
+ var localeVisibilityOperators = /* @__PURE__ */ new Set(["is", "!is"]);
1758
+ var CANVAS_VIZ_LOCALE_RULE = "$locale";
1759
+ function createLocaleVisibilityRule(currentLocale) {
1760
+ return {
1761
+ [CANVAS_VIZ_LOCALE_RULE]: (criterion) => {
1762
+ if (!currentLocale) {
1763
+ return false;
1764
+ }
1765
+ return evaluateStringMatch(criterion, currentLocale, localeVisibilityOperators);
1766
+ }
1767
+ };
1768
+ }
1769
+
1611
1770
  // src/enhancement/localize.ts
1612
1771
  function extractLocales({ component }) {
1613
1772
  var _a;
@@ -1626,17 +1785,29 @@ function extractLocales({ component }) {
1626
1785
  function localize(options) {
1627
1786
  const nodes = "nodes" in options ? options.nodes : options.composition;
1628
1787
  const locale = options.locale;
1629
- walkNodeTree(nodes, ({ type, node, actions }) => {
1788
+ const isUsingModernOptions = typeof locale === "string";
1789
+ const vizControlLocaleRule = isUsingModernOptions ? createLocaleVisibilityRule(locale) : {};
1790
+ walkNodeTree(nodes, (context) => {
1791
+ const { type, node, actions } = context;
1630
1792
  if (type !== "component") {
1631
- if (typeof locale === "string") {
1793
+ if (isUsingModernOptions) {
1632
1794
  localizeProperties(node.fields, locale);
1633
1795
  }
1634
1796
  return;
1635
1797
  }
1636
- const shouldRunPropertyLocalization = typeof locale === "string";
1798
+ if (isUsingModernOptions) {
1799
+ const result = evaluateWalkTreeVisibility({
1800
+ context,
1801
+ rules: vizControlLocaleRule,
1802
+ showIndeterminate: true
1803
+ });
1804
+ if (!result) {
1805
+ return;
1806
+ }
1807
+ }
1637
1808
  if (node.type === CANVAS_LOCALIZATION_TYPE) {
1638
1809
  const locales = extractLocales({ component: node });
1639
- const resolvedLocale = typeof locale === "string" ? locale : locale == null ? void 0 : locale({ component: node, locales });
1810
+ const resolvedLocale = isUsingModernOptions ? locale : locale == null ? void 0 : locale({ component: node, locales });
1640
1811
  let replaceComponent;
1641
1812
  if (resolvedLocale) {
1642
1813
  replaceComponent = locales[resolvedLocale];
@@ -1644,7 +1815,7 @@ function localize(options) {
1644
1815
  if (replaceComponent == null ? void 0 : replaceComponent.length) {
1645
1816
  replaceComponent.forEach((component) => {
1646
1817
  removeLocaleProperty(component);
1647
- if (shouldRunPropertyLocalization) {
1818
+ if (isUsingModernOptions) {
1648
1819
  localizeProperties(getPropertiesValue(component), locale);
1649
1820
  }
1650
1821
  });
@@ -1656,7 +1827,7 @@ function localize(options) {
1656
1827
  } else {
1657
1828
  actions.remove();
1658
1829
  }
1659
- } else if (shouldRunPropertyLocalization) {
1830
+ } else if (isUsingModernOptions) {
1660
1831
  localizeProperties(getPropertiesValue(node), locale);
1661
1832
  }
1662
1833
  });
@@ -1735,8 +1906,7 @@ function walkComponentTree(component, visitor, initialContext) {
1735
1906
  const childContexts = /* @__PURE__ */ new Map();
1736
1907
  do {
1737
1908
  const currentQueueEntry = componentQueue.pop();
1738
- if (!currentQueueEntry)
1739
- continue;
1909
+ if (!currentQueueEntry) continue;
1740
1910
  const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
1741
1911
  let visitDescendants = true;
1742
1912
  let descendantContext = (_a = childContexts.get(currentComponent.component)) != null ? _a : currentQueueEntry.context;
@@ -2503,8 +2673,7 @@ var isSystemComponentDefinition = (componentType) => {
2503
2673
 
2504
2674
  // src/utils/mapSlotToPersonalizedVariations.ts
2505
2675
  function mapSlotToPersonalizedVariations(slot) {
2506
- if (!slot)
2507
- return [];
2676
+ if (!slot) return [];
2508
2677
  return slot.map((v, i) => {
2509
2678
  var _a, _b;
2510
2679
  const contextTag = (_b = (_a = v.parameters) == null ? void 0 : _a[CANVAS_PERSONALIZATION_PARAM]) == null ? void 0 : _b.value;
@@ -2519,8 +2688,7 @@ function mapSlotToPersonalizedVariations(slot) {
2519
2688
 
2520
2689
  // src/utils/mapSlotToTestVariations.ts
2521
2690
  function mapSlotToTestVariations(slot) {
2522
- if (!slot)
2523
- return [];
2691
+ if (!slot) return [];
2524
2692
  return slot.map((v, i) => {
2525
2693
  var _a, _b, _c;
2526
2694
  const contextTag = (_b = (_a = v.parameters) == null ? void 0 : _a[CANVAS_TEST_VARIANT_PARAM]) == null ? void 0 : _b.value;
@@ -2825,6 +2993,9 @@ export {
2825
2993
  CANVAS_TEST_SLOT,
2826
2994
  CANVAS_TEST_TYPE,
2827
2995
  CANVAS_TEST_VARIANT_PARAM,
2996
+ CANVAS_VIZ_CONTROL_PARAM,
2997
+ CANVAS_VIZ_DI_RULE,
2998
+ CANVAS_VIZ_LOCALE_RULE,
2828
2999
  CanvasClient,
2829
3000
  CanvasClientError,
2830
3001
  CategoryClient,
@@ -2867,11 +3038,15 @@ export {
2867
3038
  convertEntryToPutEntry,
2868
3039
  createBatchEnhancer,
2869
3040
  createCanvasChannel,
3041
+ createDynamicInputVisibilityRule,
2870
3042
  createEventBus,
2871
3043
  createLimitPolicy,
3044
+ createLocaleVisibilityRule,
2872
3045
  createUniformApiEnhancer,
2873
3046
  createVariableReference,
2874
3047
  enhance,
3048
+ evaluateVisibilityCriteriaGroup,
3049
+ evaluateWalkTreeVisibility,
2875
3050
  extractLocales,
2876
3051
  findParameterInNodeTree,
2877
3052
  flattenValues,
package/dist/index.js CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __typeError = (msg) => {
9
+ throw TypeError(msg);
10
+ };
8
11
  var __commonJS = (cb, mod) => function __require() {
9
12
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
13
  };
@@ -29,19 +32,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
32
  mod
30
33
  ));
31
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
- var __accessCheck = (obj, member, msg) => {
33
- if (!member.has(obj))
34
- throw TypeError("Cannot " + msg);
35
- };
36
- var __privateGet = (obj, member, getter) => {
37
- __accessCheck(obj, member, "read from private field");
38
- return getter ? getter.call(obj) : member.get(obj);
39
- };
40
- var __privateAdd = (obj, member, value) => {
41
- if (member.has(obj))
42
- throw TypeError("Cannot add the same private member more than once");
43
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
44
- };
35
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
36
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
37
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
45
38
 
46
39
  // ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
47
40
  var require_retry_operation = __commonJS({
@@ -305,6 +298,9 @@ __export(src_exports, {
305
298
  CANVAS_TEST_SLOT: () => CANVAS_TEST_SLOT,
306
299
  CANVAS_TEST_TYPE: () => CANVAS_TEST_TYPE,
307
300
  CANVAS_TEST_VARIANT_PARAM: () => CANVAS_TEST_VARIANT_PARAM,
301
+ CANVAS_VIZ_CONTROL_PARAM: () => CANVAS_VIZ_CONTROL_PARAM,
302
+ CANVAS_VIZ_DI_RULE: () => CANVAS_VIZ_DI_RULE,
303
+ CANVAS_VIZ_LOCALE_RULE: () => CANVAS_VIZ_LOCALE_RULE,
308
304
  CanvasClient: () => CanvasClient,
309
305
  CanvasClientError: () => CanvasClientError,
310
306
  CategoryClient: () => CategoryClient,
@@ -347,11 +343,15 @@ __export(src_exports, {
347
343
  convertEntryToPutEntry: () => convertEntryToPutEntry,
348
344
  createBatchEnhancer: () => createBatchEnhancer,
349
345
  createCanvasChannel: () => createCanvasChannel,
346
+ createDynamicInputVisibilityRule: () => createDynamicInputVisibilityRule,
350
347
  createEventBus: () => createEventBus,
351
348
  createLimitPolicy: () => createLimitPolicy,
349
+ createLocaleVisibilityRule: () => createLocaleVisibilityRule,
352
350
  createUniformApiEnhancer: () => createUniformApiEnhancer,
353
351
  createVariableReference: () => createVariableReference,
354
352
  enhance: () => enhance,
353
+ evaluateVisibilityCriteriaGroup: () => evaluateVisibilityCriteriaGroup,
354
+ evaluateWalkTreeVisibility: () => evaluateWalkTreeVisibility,
355
355
  extractLocales: () => extractLocales,
356
356
  findParameterInNodeTree: () => findParameterInNodeTree,
357
357
  flattenValues: () => flattenValues,
@@ -1188,8 +1188,7 @@ function walkNodeTree(node, visitor, options) {
1188
1188
  const childContexts = /* @__PURE__ */ new Map();
1189
1189
  do {
1190
1190
  const currentQueueEntry = componentQueue.pop();
1191
- if (!currentQueueEntry)
1192
- continue;
1191
+ if (!currentQueueEntry) continue;
1193
1192
  const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
1194
1193
  let visitDescendants = true;
1195
1194
  let descendantContext = (_a = childContexts.get(currentComponent.node)) != null ? _a : currentQueueEntry.context;
@@ -1400,8 +1399,7 @@ function walkNodeTree(node, visitor, options) {
1400
1399
  const propertyEntries = Object.entries(properties);
1401
1400
  for (let propIndex = propertyEntries.length - 1; propIndex >= 0; propIndex--) {
1402
1401
  const [propKey, propObject] = propertyEntries[propIndex];
1403
- if (!isNestedNodeType(propObject.type))
1404
- continue;
1402
+ if (!isNestedNodeType(propObject.type)) continue;
1405
1403
  const blocks = (_b = propObject.value) != null ? _b : [];
1406
1404
  for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
1407
1405
  const enqueueingBlock = blocks[blockIndex];
@@ -1746,6 +1744,174 @@ function findParameterInNodeTree(data, predicate) {
1746
1744
  return results;
1747
1745
  }
1748
1746
 
1747
+ // src/enhancement/visibility/evaluateVisibilityCriteriaGroup.ts
1748
+ function evaluateVisibilityCriteriaGroup(options) {
1749
+ const { criteriaGroup, simplifyCriteria } = options;
1750
+ const earlyExitResult = criteriaGroup.op === "&" || !criteriaGroup.op ? false : true;
1751
+ let hasIndeterminateClauses = false;
1752
+ for (let index = criteriaGroup.clauses.length - 1; index >= 0; index--) {
1753
+ const clause = criteriaGroup.clauses[index];
1754
+ const criteriaResult = evaluateCriterion(clause, options);
1755
+ if (criteriaResult === null) {
1756
+ hasIndeterminateClauses = true;
1757
+ } else if (criteriaResult === earlyExitResult) {
1758
+ return earlyExitResult;
1759
+ } else if (criteriaResult !== null && simplifyCriteria) {
1760
+ criteriaGroup.clauses.splice(index, 1);
1761
+ }
1762
+ }
1763
+ return hasIndeterminateClauses ? null : !earlyExitResult;
1764
+ }
1765
+ function evaluateCriterion(clause, rootOptions) {
1766
+ if ("clauses" in clause) {
1767
+ return evaluateVisibilityCriteriaGroup({
1768
+ ...rootOptions,
1769
+ criteriaGroup: clause
1770
+ });
1771
+ }
1772
+ const rule = rootOptions.rules[clause.rule];
1773
+ if (rule) {
1774
+ return rule(clause);
1775
+ }
1776
+ return null;
1777
+ }
1778
+
1779
+ // src/enhancement/visibility/types.ts
1780
+ var CANVAS_VIZ_CONTROL_PARAM = "$viz";
1781
+
1782
+ // src/enhancement/visibility/evaluateNodeVisibility.ts
1783
+ function evaluateNodeVisibility({
1784
+ node,
1785
+ ...evaluateGroupOptions
1786
+ }) {
1787
+ var _a;
1788
+ const properties = getPropertiesValue(node);
1789
+ const vizCriteria = (_a = properties == null ? void 0 : properties[CANVAS_VIZ_CONTROL_PARAM]) == null ? void 0 : _a.value;
1790
+ if (vizCriteria == null ? void 0 : vizCriteria.explicitlyHidden) {
1791
+ return false;
1792
+ }
1793
+ if (!(vizCriteria == null ? void 0 : vizCriteria.criteria)) {
1794
+ return true;
1795
+ }
1796
+ const result = evaluateVisibilityCriteriaGroup({
1797
+ ...evaluateGroupOptions,
1798
+ criteriaGroup: vizCriteria.criteria
1799
+ });
1800
+ if (vizCriteria.criteria.clauses.length === 0 && evaluateGroupOptions.simplifyCriteria) {
1801
+ properties == null ? true : delete properties[CANVAS_VIZ_CONTROL_PARAM];
1802
+ }
1803
+ return result;
1804
+ }
1805
+
1806
+ // src/enhancement/visibility/evaluateWalkTreeVisibility.ts
1807
+ function evaluateWalkTreeVisibility({
1808
+ rules,
1809
+ showIndeterminate,
1810
+ context
1811
+ }) {
1812
+ const { type, node, actions } = context;
1813
+ if (type !== "component") {
1814
+ return;
1815
+ }
1816
+ const result = evaluateNodeVisibility({ node, rules, simplifyCriteria: true });
1817
+ if (result === null && !showIndeterminate || result === false) {
1818
+ actions.remove();
1819
+ return false;
1820
+ }
1821
+ return true;
1822
+ }
1823
+
1824
+ // src/enhancement/visibility/rules/evaluateStringMatch.ts
1825
+ var isEvaluator = (criteria, matchValue) => {
1826
+ if (Array.isArray(criteria)) {
1827
+ return criteria.includes(matchValue);
1828
+ }
1829
+ return criteria === matchValue;
1830
+ };
1831
+ var containsEvaluator = (criteria, matchValue) => {
1832
+ if (Array.isArray(criteria)) {
1833
+ return criteria.some((criterion) => matchValue.includes(criterion));
1834
+ }
1835
+ return matchValue.includes(criteria);
1836
+ };
1837
+ var startsWithEvaluator = (criteria, matchValue) => {
1838
+ if (Array.isArray(criteria)) {
1839
+ return criteria.some((criterion) => matchValue.startsWith(criterion));
1840
+ }
1841
+ return matchValue.startsWith(criteria);
1842
+ };
1843
+ var endsWithEvaluator = (criteria, matchValue) => {
1844
+ if (Array.isArray(criteria)) {
1845
+ return criteria.some((criterion) => matchValue.endsWith(criterion));
1846
+ }
1847
+ return matchValue.endsWith(criteria);
1848
+ };
1849
+ var emptyEvaluator = (_, matchValue) => {
1850
+ return matchValue === "";
1851
+ };
1852
+ var stringOperatorEvaluators = {
1853
+ is: isEvaluator,
1854
+ has: containsEvaluator,
1855
+ startswith: startsWithEvaluator,
1856
+ endswith: endsWithEvaluator,
1857
+ empty: emptyEvaluator
1858
+ };
1859
+ function evaluateStringMatch(criteria, matchValue, allow) {
1860
+ const { op, value } = criteria;
1861
+ if (allow && !allow.has(op)) {
1862
+ return null;
1863
+ }
1864
+ let opMatch = op;
1865
+ const negation = op.startsWith("!");
1866
+ if (negation) {
1867
+ opMatch = opMatch.slice(1);
1868
+ }
1869
+ const evaluator = stringOperatorEvaluators[opMatch];
1870
+ if (!evaluator) {
1871
+ return null;
1872
+ }
1873
+ const result = evaluator(value, matchValue);
1874
+ return negation ? !result : result;
1875
+ }
1876
+
1877
+ // src/enhancement/visibility/rules/dynamicInputVisibilityRule.ts
1878
+ var dynamicInputVisibilityOperators = /* @__PURE__ */ new Set([
1879
+ "is",
1880
+ "!is",
1881
+ "has",
1882
+ "!has",
1883
+ "startswith",
1884
+ "!startswith",
1885
+ "endswith",
1886
+ "!endswith",
1887
+ "empty",
1888
+ "!empty"
1889
+ ]);
1890
+ var CANVAS_VIZ_DI_RULE = "$di";
1891
+ function createDynamicInputVisibilityRule(dynamicInputs) {
1892
+ return {
1893
+ [CANVAS_VIZ_DI_RULE]: (criterion) => {
1894
+ const { source } = criterion;
1895
+ const diValue = source ? dynamicInputs[source] : void 0;
1896
+ return evaluateStringMatch(criterion, diValue != null ? diValue : "", dynamicInputVisibilityOperators);
1897
+ }
1898
+ };
1899
+ }
1900
+
1901
+ // src/enhancement/visibility/rules/localeVisibilityRule.ts
1902
+ var localeVisibilityOperators = /* @__PURE__ */ new Set(["is", "!is"]);
1903
+ var CANVAS_VIZ_LOCALE_RULE = "$locale";
1904
+ function createLocaleVisibilityRule(currentLocale) {
1905
+ return {
1906
+ [CANVAS_VIZ_LOCALE_RULE]: (criterion) => {
1907
+ if (!currentLocale) {
1908
+ return false;
1909
+ }
1910
+ return evaluateStringMatch(criterion, currentLocale, localeVisibilityOperators);
1911
+ }
1912
+ };
1913
+ }
1914
+
1749
1915
  // src/enhancement/localize.ts
1750
1916
  function extractLocales({ component }) {
1751
1917
  var _a;
@@ -1764,17 +1930,29 @@ function extractLocales({ component }) {
1764
1930
  function localize(options) {
1765
1931
  const nodes = "nodes" in options ? options.nodes : options.composition;
1766
1932
  const locale = options.locale;
1767
- walkNodeTree(nodes, ({ type, node, actions }) => {
1933
+ const isUsingModernOptions = typeof locale === "string";
1934
+ const vizControlLocaleRule = isUsingModernOptions ? createLocaleVisibilityRule(locale) : {};
1935
+ walkNodeTree(nodes, (context) => {
1936
+ const { type, node, actions } = context;
1768
1937
  if (type !== "component") {
1769
- if (typeof locale === "string") {
1938
+ if (isUsingModernOptions) {
1770
1939
  localizeProperties(node.fields, locale);
1771
1940
  }
1772
1941
  return;
1773
1942
  }
1774
- const shouldRunPropertyLocalization = typeof locale === "string";
1943
+ if (isUsingModernOptions) {
1944
+ const result = evaluateWalkTreeVisibility({
1945
+ context,
1946
+ rules: vizControlLocaleRule,
1947
+ showIndeterminate: true
1948
+ });
1949
+ if (!result) {
1950
+ return;
1951
+ }
1952
+ }
1775
1953
  if (node.type === CANVAS_LOCALIZATION_TYPE) {
1776
1954
  const locales = extractLocales({ component: node });
1777
- const resolvedLocale = typeof locale === "string" ? locale : locale == null ? void 0 : locale({ component: node, locales });
1955
+ const resolvedLocale = isUsingModernOptions ? locale : locale == null ? void 0 : locale({ component: node, locales });
1778
1956
  let replaceComponent;
1779
1957
  if (resolvedLocale) {
1780
1958
  replaceComponent = locales[resolvedLocale];
@@ -1782,7 +1960,7 @@ function localize(options) {
1782
1960
  if (replaceComponent == null ? void 0 : replaceComponent.length) {
1783
1961
  replaceComponent.forEach((component) => {
1784
1962
  removeLocaleProperty(component);
1785
- if (shouldRunPropertyLocalization) {
1963
+ if (isUsingModernOptions) {
1786
1964
  localizeProperties(getPropertiesValue(component), locale);
1787
1965
  }
1788
1966
  });
@@ -1794,7 +1972,7 @@ function localize(options) {
1794
1972
  } else {
1795
1973
  actions.remove();
1796
1974
  }
1797
- } else if (shouldRunPropertyLocalization) {
1975
+ } else if (isUsingModernOptions) {
1798
1976
  localizeProperties(getPropertiesValue(node), locale);
1799
1977
  }
1800
1978
  });
@@ -1873,8 +2051,7 @@ function walkComponentTree(component, visitor, initialContext) {
1873
2051
  const childContexts = /* @__PURE__ */ new Map();
1874
2052
  do {
1875
2053
  const currentQueueEntry = componentQueue.pop();
1876
- if (!currentQueueEntry)
1877
- continue;
2054
+ if (!currentQueueEntry) continue;
1878
2055
  const currentComponent = currentQueueEntry.ancestorsAndSelf[0];
1879
2056
  let visitDescendants = true;
1880
2057
  let descendantContext = (_a = childContexts.get(currentComponent.component)) != null ? _a : currentQueueEntry.context;
@@ -2641,8 +2818,7 @@ var isSystemComponentDefinition = (componentType) => {
2641
2818
 
2642
2819
  // src/utils/mapSlotToPersonalizedVariations.ts
2643
2820
  function mapSlotToPersonalizedVariations(slot) {
2644
- if (!slot)
2645
- return [];
2821
+ if (!slot) return [];
2646
2822
  return slot.map((v, i) => {
2647
2823
  var _a, _b;
2648
2824
  const contextTag = (_b = (_a = v.parameters) == null ? void 0 : _a[CANVAS_PERSONALIZATION_PARAM]) == null ? void 0 : _b.value;
@@ -2657,8 +2833,7 @@ function mapSlotToPersonalizedVariations(slot) {
2657
2833
 
2658
2834
  // src/utils/mapSlotToTestVariations.ts
2659
2835
  function mapSlotToTestVariations(slot) {
2660
- if (!slot)
2661
- return [];
2836
+ if (!slot) return [];
2662
2837
  return slot.map((v, i) => {
2663
2838
  var _a, _b, _c;
2664
2839
  const contextTag = (_b = (_a = v.parameters) == null ? void 0 : _a[CANVAS_TEST_VARIANT_PARAM]) == null ? void 0 : _b.value;
@@ -2964,6 +3139,9 @@ var CanvasClientError = import_api15.ApiClientError;
2964
3139
  CANVAS_TEST_SLOT,
2965
3140
  CANVAS_TEST_TYPE,
2966
3141
  CANVAS_TEST_VARIANT_PARAM,
3142
+ CANVAS_VIZ_CONTROL_PARAM,
3143
+ CANVAS_VIZ_DI_RULE,
3144
+ CANVAS_VIZ_LOCALE_RULE,
2967
3145
  CanvasClient,
2968
3146
  CanvasClientError,
2969
3147
  CategoryClient,
@@ -3006,11 +3184,15 @@ var CanvasClientError = import_api15.ApiClientError;
3006
3184
  convertEntryToPutEntry,
3007
3185
  createBatchEnhancer,
3008
3186
  createCanvasChannel,
3187
+ createDynamicInputVisibilityRule,
3009
3188
  createEventBus,
3010
3189
  createLimitPolicy,
3190
+ createLocaleVisibilityRule,
3011
3191
  createUniformApiEnhancer,
3012
3192
  createVariableReference,
3013
3193
  enhance,
3194
+ evaluateVisibilityCriteriaGroup,
3195
+ evaluateWalkTreeVisibility,
3014
3196
  extractLocales,
3015
3197
  findParameterInNodeTree,
3016
3198
  flattenValues,