@arcgis/coding-components 4.30.0-next.3 → 4.30.0-next.30

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 (131) hide show
  1. package/dist/arcgis-coding-components/arcgis-coding-components.css +1 -1
  2. package/dist/arcgis-coding-components/arcgis-coding-components.esm.js +2 -2
  3. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ar.json +25 -0
  4. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.bg.json +25 -0
  5. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.bs.json +25 -0
  6. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ca.json +25 -0
  7. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.cs.json +25 -0
  8. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.da.json +25 -0
  9. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.de.json +25 -0
  10. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.el.json +25 -0
  11. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.en.json +25 -0
  12. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.es.json +25 -0
  13. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.et.json +25 -0
  14. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.fi.json +25 -0
  15. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.fr.json +25 -0
  16. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.he.json +25 -0
  17. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.hr.json +25 -0
  18. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.hu.json +25 -0
  19. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.id.json +25 -0
  20. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.it.json +25 -0
  21. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ja.json +25 -0
  22. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ko.json +25 -0
  23. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.lt.json +25 -0
  24. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.lv.json +25 -0
  25. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.nb.json +25 -0
  26. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.nl.json +25 -0
  27. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.pl.json +25 -0
  28. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.pt-BR.json +25 -0
  29. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.pt-PT.json +25 -0
  30. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ro.json +25 -0
  31. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ru.json +25 -0
  32. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.sk.json +25 -0
  33. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.sl.json +25 -0
  34. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.sr.json +25 -0
  35. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.sv.json +25 -0
  36. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.th.json +25 -0
  37. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.tr.json +25 -0
  38. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.uk.json +25 -0
  39. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.vi.json +25 -0
  40. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.zh-CN.json +25 -0
  41. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.zh-HK.json +25 -0
  42. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.zh-TW.json +25 -0
  43. package/dist/arcgis-coding-components/assets/code-editor/arcade.worker.js +1 -1
  44. package/dist/arcgis-coding-components/assets/code-editor/css.worker.js +1 -1
  45. package/dist/arcgis-coding-components/assets/code-editor/editor.worker.js +1 -1
  46. package/dist/arcgis-coding-components/assets/code-editor/html.worker.js +1 -1
  47. package/dist/arcgis-coding-components/assets/code-editor/json.worker.js +1 -1
  48. package/dist/arcgis-coding-components/assets/code-editor/ts.worker.js +1 -1
  49. package/dist/arcgis-coding-components/index.esm.js +2 -2
  50. package/dist/arcgis-coding-components/{p-f09b91f0.js → p-05407167.js} +2 -2
  51. package/dist/arcgis-coding-components/p-0e4fd488.entry.js +6 -0
  52. package/dist/arcgis-coding-components/{p-a2e6cf69.js → p-1b04872b.js} +3 -3
  53. package/dist/arcgis-coding-components/{p-f27bc17e.js → p-305e6a27.js} +3 -3
  54. package/dist/arcgis-coding-components/{p-19754f5a.js → p-38778060.js} +2 -2
  55. package/dist/arcgis-coding-components/{p-fa769562.js → p-3e84bed2.js} +2 -2
  56. package/dist/arcgis-coding-components/{p-57e4af30.js → p-50cbdef2.js} +2 -2
  57. package/dist/arcgis-coding-components/p-51032f3c.js +68 -0
  58. package/dist/arcgis-coding-components/{p-0c7d8400.js → p-61a3a32b.js} +2 -2
  59. package/dist/arcgis-coding-components/{p-ee00010b.js → p-7f41598e.js} +2 -2
  60. package/dist/arcgis-coding-components/p-a09a2021.js +7 -0
  61. package/dist/arcgis-coding-components/{p-a8ee78f9.js → p-f2b266c1.js} +1 -1
  62. package/dist/cjs/{arcade-defaults-9108b927.js → arcade-defaults-18a60f03.js} +480 -160
  63. package/dist/cjs/{arcade-mode-99f89a80.js → arcade-mode-c53bfc0e.js} +45 -51
  64. package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +1613 -202
  65. package/dist/cjs/arcgis-coding-components.cjs.js +3 -3
  66. package/dist/cjs/{css-f717453b.js → css-56924b29.js} +1 -1
  67. package/dist/cjs/{cssMode-9a365842.js → cssMode-ea630257.js} +3 -3
  68. package/dist/cjs/{html-64741c89.js → html-3d953aa2.js} +3 -3
  69. package/dist/cjs/{htmlMode-4e8b2289.js → htmlMode-f3da6666.js} +3 -3
  70. package/dist/cjs/{index-42d71c10.js → index-084a0845.js} +42 -4
  71. package/dist/cjs/index.cjs.js +3 -3
  72. package/dist/cjs/{javascript-340e4ba6.js → javascript-470dd761.js} +4 -4
  73. package/dist/cjs/{jsonMode-bc9bd096.js → jsonMode-f2bad76f.js} +3 -3
  74. package/dist/cjs/loader.cjs.js +3 -3
  75. package/dist/cjs/{tsMode-99f43f9f.js → tsMode-4dbfa911.js} +3 -3
  76. package/dist/cjs/{typescript-4a00545a.js → typescript-8fb2fceb.js} +3 -3
  77. package/dist/components/arcade-api.js +11 -17
  78. package/dist/components/arcade-contribution.js +71 -13
  79. package/dist/components/arcade-defaults.js +61 -61
  80. package/dist/components/arcade-mode.js +44 -50
  81. package/dist/components/arcade-results.js +40 -51
  82. package/dist/components/arcade-suggestions.js +12 -18
  83. package/dist/components/arcade-variables.js +13 -22
  84. package/dist/components/arcgis-arcade-api.js +1 -1
  85. package/dist/components/arcgis-arcade-editor.js +41 -106
  86. package/dist/components/arcgis-arcade-results.js +1 -1
  87. package/dist/components/arcgis-arcade-suggestions.js +1 -1
  88. package/dist/components/arcgis-arcade-variables.js +1 -1
  89. package/dist/components/arcgis-assets.d.ts +1 -1
  90. package/dist/components/arcgis-assets.js +1 -1
  91. package/dist/components/arcgis-code-editor.js +1 -1
  92. package/dist/components/chunk-FQ4KFKVY.js +1448 -0
  93. package/dist/components/code-editor.js +14 -14
  94. package/dist/components/fields.js +2 -66
  95. package/dist/components/index.d.ts +3 -18
  96. package/dist/components/index.js +1 -1
  97. package/dist/components/index2.js +387 -3
  98. package/dist/components/markdown.js +9 -11
  99. package/dist/components/utilities.js +3 -3
  100. package/dist/esm/{arcade-defaults-372ecf79.js → arcade-defaults-3f0e1c43.js} +467 -147
  101. package/dist/esm/{arcade-mode-b2b0b42d.js → arcade-mode-5aef1763.js} +45 -51
  102. package/dist/esm/arcgis-arcade-api_6.entry.js +1613 -202
  103. package/dist/esm/arcgis-coding-components.js +4 -4
  104. package/dist/esm/{css-81c81ba2.js → css-4c710cf8.js} +1 -1
  105. package/dist/esm/{cssMode-41873574.js → cssMode-54cea919.js} +3 -3
  106. package/dist/esm/{html-d42d34ab.js → html-3908d2da.js} +3 -3
  107. package/dist/esm/{htmlMode-143da753.js → htmlMode-2fa6e6a4.js} +3 -3
  108. package/dist/esm/{index-3bfb710a.js → index-06d390be.js} +42 -5
  109. package/dist/esm/index.js +3 -3
  110. package/dist/esm/{javascript-c5306510.js → javascript-1d86322d.js} +4 -4
  111. package/dist/esm/{jsonMode-60732e84.js → jsonMode-27eb619c.js} +3 -3
  112. package/dist/esm/loader.js +4 -4
  113. package/dist/esm/{tsMode-5a10d9e9.js → tsMode-9a8f9af2.js} +3 -3
  114. package/dist/esm/{typescript-bb6b1528.js → typescript-7a26367c.js} +3 -3
  115. package/dist/loader/cdn.js +1 -1
  116. package/dist/loader/index.cjs.js +1 -1
  117. package/dist/loader/index.es2017.js +1 -1
  118. package/dist/loader/index.js +1 -1
  119. package/dist/types/components/arcade-api/arcade-api.d.ts +4 -5
  120. package/dist/types/components/arcade-editor/arcade-editor.d.ts +7 -4
  121. package/dist/types/components/arcade-results/arcade-results.d.ts +4 -7
  122. package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +4 -5
  123. package/dist/types/components/arcade-variables/arcade-variables.d.ts +4 -6
  124. package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/internal/arcade-editor/arcade-editor.stories.d.ts +37 -0
  125. package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/internal/code-editor/code-editor.stories.d.ts +6 -0
  126. package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/reference/stories/arcade-editor.stories.d.ts +9 -0
  127. package/dist/types/utils/arcade-monaco/arcade-language-features.d.ts +1 -1
  128. package/package.json +19 -19
  129. package/dist/arcgis-coding-components/p-84b69395.entry.js +0 -6
  130. package/dist/arcgis-coding-components/p-e75d3e9e.js +0 -68
  131. package/dist/arcgis-coding-components/p-fa458a74.js +0 -7
@@ -1,10 +1,10 @@
1
1
  /*!
2
2
  * All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  * See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
- * v4.30.0-next.3
4
+ * v4.30.0-next.30
5
5
  */
6
- import { r as registerInstance, c as createEvent, g as getAssetPath, h, H as Host, a as getElement, F as Fragment } from './index-3bfb710a.js';
7
- import { g as generateTokensCSSForColorMap, e as editor, S as StandaloneServices, I as IStandaloneThemeService, c as createCommonjsModule, b as commonjsGlobal, i as ie, s as se, d as importRequest, l as languages, f as arcadeDefaults, B, U as Uri, q, W, h as filterCollection, G, j as importArcade, k as h$1, m as U, n as k, K as KeyCode, Z, D, o as supportedFields, p as K, R as Range, x, r as KeyMod } from './arcade-defaults-372ecf79.js';
6
+ import { f as forceUpdate, g as getAssetPath, r as registerInstance, c as createEvent, h, H as Host, a as getElement, F as Fragment } from './index-06d390be.js';
7
+ import { g as generateTokensCSSForColorMap, e as editor, S as StandaloneServices, I as IStandaloneThemeService, c as createCommonjsModule, b as commonjsGlobal, i as importCoreAccessor, d as importCoreAccessorSupportDecorators, f as isURL, h as hasSameOrigin, j as importRequest, l as languages, k as arcadeDefaults, U as Uri, s as setFocusOnElement, m as filterCollection, n as addLTRMark, o as importArcade, D as Deferred$1, p as generateGuid, q as getElementTheme, K as KeyCode, r as setValuesInString, t as quoteString, u as supportedFields, v as createFilterExpression, R as Range, w as observeAncestorsMutation$1, x as KeyMod } from './arcade-defaults-3f0e1c43.js';
8
8
 
9
9
  async function colorizeCode(code) {
10
10
  return await editor.colorize(code, "arcade", { tabSize: 2 });
@@ -2917,24 +2917,1460 @@ var marked_umd = createCommonjsModule(function (module, exports) {
2917
2917
  // Set up the marked library to use GitHub Flavored Markdown and to use the custom renderer for links.
2918
2918
  marked_umd.marked.use({
2919
2919
  gfm: true,
2920
+ breaks: true,
2921
+ async: false,
2920
2922
  renderer: {
2921
2923
  link(href, title, text) {
2922
2924
  return `<calcite-link href="${href}" title="${title ?? text}" target="Arcade Help">${text}</calcite-link>`;
2923
- }
2924
- }
2925
+ },
2926
+ },
2925
2927
  });
2926
2928
  /**
2927
2929
  * Converts a markdown string to HTML using the marked library.
2928
2930
  */
2929
2931
  function convertMarkdownString(value) {
2930
- value ?? (value = "");
2931
- const result = marked_umd.marked(typeof value === "string" ? value : value.value, {
2932
- gfm: true,
2933
- breaks: true,
2934
- headerIds: false,
2935
- mangle: false
2932
+ if (value === null || value === undefined) {
2933
+ return "";
2934
+ }
2935
+ return marked_umd.marked.parse(typeof value === "string" ? value : value.value);
2936
+ }
2937
+
2938
+ // ../components-utils/dist/index.js
2939
+ var Deferred = class {
2940
+ /**
2941
+ * Creates a new deferred promise.
2942
+ */
2943
+ constructor() {
2944
+ this.resolve = () => void 0;
2945
+ this.reject = () => void 0;
2946
+ this.promise = new Promise((resolve, reject) => {
2947
+ this.resolve = resolve;
2948
+ this.reject = reject;
2949
+ });
2950
+ }
2951
+ };
2952
+ function inTargetElement(element, targetElement) {
2953
+ let currentElement = element;
2954
+ while (currentElement) {
2955
+ if (currentElement === targetElement) {
2956
+ return true;
2957
+ }
2958
+ if (!currentElement.parentNode) {
2959
+ return false;
2960
+ }
2961
+ if (currentElement.parentNode instanceof ShadowRoot) {
2962
+ currentElement = currentElement.parentNode.host;
2963
+ } else {
2964
+ currentElement = currentElement.parentNode;
2965
+ }
2966
+ }
2967
+ return false;
2968
+ }
2969
+ function observeAncestorsMutation(element, attributeFilter, callback) {
2970
+ const { subscribe } = observe(attributeFilter);
2971
+ return subscribe((mutations) => {
2972
+ const matched = mutations.some((mutation) => inTargetElement(element, mutation.target));
2973
+ if (matched)
2974
+ callback();
2975
+ });
2976
+ }
2977
+ var observers = {};
2978
+ function observe(attributeFilter) {
2979
+ const attributes = attributeFilter.join(",");
2980
+ const previousObserver = observers[attributes];
2981
+ if (previousObserver !== void 0)
2982
+ return previousObserver;
2983
+ const subscribers = /* @__PURE__ */ new Set();
2984
+ const mutationObserver = new MutationObserver((mutations) => subscribers.forEach((callback) => callback(mutations)));
2985
+ mutationObserver.observe(document.documentElement, {
2986
+ attributes: true,
2987
+ attributeFilter,
2988
+ subtree: true
2989
+ });
2990
+ const observer = {
2991
+ subscribe(callback) {
2992
+ subscribers.add(callback);
2993
+ return {
2994
+ remove: () => {
2995
+ subscribers.delete(callback);
2996
+ if (subscribers.size === 0) {
2997
+ mutationObserver.disconnect();
2998
+ observers[attributes] = void 0;
2999
+ }
3000
+ }
3001
+ };
3002
+ }
3003
+ };
3004
+ observers[attributes] = observer;
3005
+ return observer;
3006
+ }
3007
+ function closestElement(base, selector) {
3008
+ let currentElement = base;
3009
+ while (currentElement) {
3010
+ const element = currentElement.closest(selector);
3011
+ if (element) {
3012
+ return element;
3013
+ }
3014
+ const rootElement = currentElement.getRootNode();
3015
+ if (rootElement === document) {
3016
+ return null;
3017
+ }
3018
+ currentElement = rootElement.host;
3019
+ }
3020
+ return null;
3021
+ }
3022
+ function getElementAttribute(el, prop, fallbackValue) {
3023
+ const closest = closestElement(el, `[${prop}]`);
3024
+ return closest?.getAttribute(prop) ?? fallbackValue;
3025
+ }
3026
+ function safeCall(callback) {
3027
+ try {
3028
+ return callback?.();
3029
+ } catch (error) {
3030
+ console.error(error, callback);
3031
+ }
3032
+ return void 0;
3033
+ }
3034
+ async function safeAsyncCall(callback) {
3035
+ try {
3036
+ return await callback();
3037
+ } catch (error) {
3038
+ console.error(error, callback);
3039
+ }
3040
+ return void 0;
3041
+ }
3042
+ var capitalize = (string) => string.charAt(0).toUpperCase() + string.slice(1);
3043
+ var camelToHuman = (value) => capitalize(value.replaceAll(/([a-z])([A-Z])/gu, "$1 $2"));
3044
+ var supportedLocales = /* @__PURE__ */ new Set([
3045
+ "ar",
3046
+ "bg",
3047
+ "bs",
3048
+ "ca",
3049
+ "cs",
3050
+ "da",
3051
+ "de",
3052
+ "el",
3053
+ "en",
3054
+ "es",
3055
+ "et",
3056
+ "fi",
3057
+ "fr",
3058
+ "he",
3059
+ "hr",
3060
+ "hu",
3061
+ "id",
3062
+ "it",
3063
+ "ja",
3064
+ "ko",
3065
+ "lt",
3066
+ "lv",
3067
+ "nl",
3068
+ "nb",
3069
+ "pl",
3070
+ "pt-BR",
3071
+ "pt-PT",
3072
+ "ro",
3073
+ "ru",
3074
+ "sk",
3075
+ "sl",
3076
+ "sr",
3077
+ "sv",
3078
+ "th",
3079
+ "tr",
3080
+ "uk",
3081
+ "vi",
3082
+ "zh-CN",
3083
+ "zh-HK",
3084
+ "zh-TW"
3085
+ ]);
3086
+ var defaultLocale = "en";
3087
+ async function fetchT9NStringsBundle(locale, assetsPath, prefix = "") {
3088
+ const path = `${assetsPath}/${prefix}`;
3089
+ const filePath = `${path}${locale}.json`;
3090
+ t9nStringsCache[filePath] ?? (t9nStringsCache[filePath] = fetchBundle(locale, path));
3091
+ return await t9nStringsCache[filePath];
3092
+ }
3093
+ var t9nStringsCache = {};
3094
+ async function fetchBundle(locale, path) {
3095
+ const filePath = `${path}${locale}.json`;
3096
+ try {
3097
+ const response = await fetch(filePath);
3098
+ if (response.ok)
3099
+ return await response.json();
3100
+ } catch (error) {
3101
+ console.error(error);
3102
+ return fallbackBundle;
3103
+ }
3104
+ if (locale === defaultLocale)
3105
+ return fallbackBundle;
3106
+ return await fetchBundle(defaultLocale, path);
3107
+ }
3108
+ var fallbackBundle = new Proxy(
3109
+ {},
3110
+ {
3111
+ get: (_target, property) => camelToHuman(property.toString())
3112
+ }
3113
+ );
3114
+ function getElementLocales(element) {
3115
+ const lang = getElementAttribute(element, "lang", navigator.language || defaultLocale);
3116
+ if (supportedLocales.has(lang)) {
3117
+ return { lang, t9nLocale: lang };
3118
+ }
3119
+ const rootCode = lang.slice(0, 2);
3120
+ return { lang, t9nLocale: supportedLocales.has(rootCode) ? rootCode : defaultLocale };
3121
+ }
3122
+ function startLocaleObserver(element, assetsPath, onUpdated, assetName) {
3123
+ let result = void 0;
3124
+ const callback = () => void updateComponentLocateState(element, assetsPath, assetName).then((newResult) => {
3125
+ if (result?.lang !== newResult.lang || result.t9nLocale !== newResult.t9nLocale || result.t9nStrings !== newResult.t9nStrings)
3126
+ onUpdated(newResult);
3127
+ result = newResult;
3128
+ }).catch(console.error);
3129
+ callback();
3130
+ return observeAncestorsMutation(element, ["lang"], callback);
3131
+ }
3132
+ async function updateComponentLocateState(element, assetsPath, assetName = element.tagName.toLowerCase().replace("arcgis-", "")) {
3133
+ const { lang, t9nLocale } = getElementLocales(element);
3134
+ const t9nAssetsPath = `${assetsPath}/${assetName}/t9n`;
3135
+ const prefix = `${assetName}.t9n.`;
3136
+ const t9nStrings = await fetchT9NStringsBundle(t9nLocale, t9nAssetsPath, prefix);
3137
+ return { lang, t9nLocale, t9nStrings };
3138
+ }
3139
+
3140
+ // src/types.ts
3141
+ var controllerSymbol = Symbol("controller");
3142
+
3143
+ // src/utils.ts
3144
+ function extendObject(base, extend) {
3145
+ Object.entries(extend).forEach(([key, value]) => {
3146
+ if (key in base)
3147
+ throw new Error(`Unable to extend object because property "${key}" is already defined`);
3148
+ const thisBase = base;
3149
+ thisBase[key] = value;
3150
+ });
3151
+ return base;
3152
+ }
3153
+ var isController = (value) => typeof value === "object" && value !== null && (controllerSymbol in value || "hostConnected" in value || "hostDisconnected" in value || "hostUpdate" in value || "hostUpdated" in value);
3154
+
3155
+ // src/ControllerInternals.ts
3156
+ var ControllerInternals = class {
3157
+ constructor() {
3158
+ this._ambientControllers = [];
3159
+ /**
3160
+ * The type definition has to be duplicated due to the
3161
+ * "'use' is referenced directly or indirectly in its own type annotation."
3162
+ * error
3163
+ */
3164
+ this.use = async (value, watchExports) => {
3165
+ const controller = this._useRefSync(value);
3166
+ if (controller === void 0) {
3167
+ if (typeof watchExports === "function") {
3168
+ const error = new Error(
3169
+ `Unable to resolve a controller from the provided value, so can't watch it's exports. ${unresolvableExports}`
3170
+ );
3171
+ console.error(error);
3172
+ }
3173
+ return value;
3174
+ }
3175
+ await controller.ready;
3176
+ if (typeof watchExports === "function") {
3177
+ if (controller.watchExports === void 0)
3178
+ throw new Error(`The controller must implement watchExports method to support watching exports`);
3179
+ const unsubscribe = controller.watchExports(
3180
+ (exports) => watchExports(exports, unsubscribe)
3181
+ );
3182
+ }
3183
+ return controller.exports;
3184
+ };
3185
+ this.useRef = async (value) => {
3186
+ const controller = this._useRefSync(value);
3187
+ if (controller === void 0)
3188
+ throw new Error(`Unable to resolve a controller from the provided value. ${unresolvableExports}`);
3189
+ await controller.ready;
3190
+ return controller;
3191
+ };
3192
+ this.shouldBypassSetter = false;
3193
+ this.shouldBypassGetter = false;
3194
+ this.shouldBypassReadonly = false;
3195
+ /**
3196
+ * A map from component instance or component element to component instance.
3197
+ * To get from component instance or component element to component element,
3198
+ * you can just use the .el property
3199
+ */
3200
+ this.elementToInstance = /* @__PURE__ */ new WeakMap();
3201
+ }
3202
+ /*
3203
+ * Allow controllers to implicitly retrieve which component they are in, to
3204
+ * improve DX (avoids the need to pass "this" explicitly for each controller)
3205
+ */
3206
+ setAmbientComponent(component) {
3207
+ if (this._ambientComponent === component)
3208
+ return;
3209
+ this._ambientComponent = component;
3210
+ queueMicrotask(() => {
3211
+ if (this._ambientComponent === component)
3212
+ this._ambientComponent = void 0;
3213
+ });
3214
+ }
3215
+ retrieveComponent(name) {
3216
+ if (this._ambientComponent === void 0)
3217
+ throw new Error(
3218
+ [
3219
+ `Unable to find out which component ${name || "this"} controller `,
3220
+ "belongs to. This might happen if you tried to create a controller ",
3221
+ "outside the component. If so, please wrap your controller ",
3222
+ "definition in an arrow function, ",
3223
+ "`const myController = ()=>makeController(...);` and call that",
3224
+ "function inside the component `my = myController();`, or ",
3225
+ "define your controller using makeGenericController/GenericController ",
3226
+ "instead.\n",
3227
+ "If you wish to use a controller inside an async controller, ",
3228
+ "make sure you are using controller.use.\n",
3229
+ "You might also have multiple instances of Controllers loaded"
3230
+ ].join("\n")
3231
+ );
3232
+ return this._ambientComponent;
3233
+ }
3234
+ /*
3235
+ * Aids proxyExports() in knowing who is it's host
3236
+ */
3237
+ setParentController(controller) {
3238
+ if (controller === void 0) {
3239
+ this._ambientControllers = [];
3240
+ return;
3241
+ }
3242
+ const index = this._ambientControllers.indexOf(controller);
3243
+ this._ambientControllers = index === -1 ? [...this._ambientControllers, controller] : this._ambientControllers.slice(0, index + 1);
3244
+ queueMicrotask(() => {
3245
+ this._ambientControllers = [];
3246
+ });
3247
+ }
3248
+ retrieveParentControllers() {
3249
+ return this._ambientControllers;
3250
+ }
3251
+ /*
3252
+ * Aids controller.use in retrieving controller value when it receives
3253
+ * controller exports, rather than the controller itself
3254
+ */
3255
+ setAmbientChildController(controller) {
3256
+ if (this._ambientChildController === controller)
3257
+ return;
3258
+ this._ambientChildController = controller;
3259
+ queueMicrotask(() => {
3260
+ if (this._ambientChildController === controller)
3261
+ this._ambientChildController = void 0;
3262
+ });
3263
+ }
3264
+ retrieveAmbientChildController() {
3265
+ const controller = this._ambientChildController;
3266
+ this._ambientChildController = void 0;
3267
+ return controller;
3268
+ }
3269
+ /**
3270
+ * Try to resolve a controller, without awaiting it's load
3271
+ */
3272
+ _useRefSync(value) {
3273
+ const ambientChildController = this.retrieveAmbientChildController();
3274
+ if (ambientChildController !== void 0)
3275
+ return ambientChildController;
3276
+ const component = Controller.internals.retrieveComponent();
3277
+ const controller = component.manager.internals.resolveExports(value);
3278
+ if (controller !== void 0)
3279
+ return controller;
3280
+ if (isController(value))
3281
+ return value;
3282
+ return void 0;
3283
+ }
3284
+ };
3285
+ var unresolvableExports = [
3286
+ "The value you passed is not a controller and not a controller exports. If ",
3287
+ "your controller exports a literal value, try making your controller export ",
3288
+ "an object instead"
3289
+ ].join("");
3290
+
3291
+ // src/stencil.ts
3292
+ function retrieveComponentMeta(component) {
3293
+ const constructor = component.constructor;
3294
+ const meta = constructor.__registerControllers?.(component) ?? void 0;
3295
+ constructor.__registerControllers = void 0;
3296
+ if (typeof meta !== "object")
3297
+ throw new Error(
3298
+ "Failed to retrieve internal component meta. Make sure you have the useComponentsControllers() Rollup Plugin for Stencil Controllers configured in your Stencil config."
3299
+ );
3300
+ component.manager.internals.meta = { members: meta[0], watchers: meta[1] };
3301
+ }
3302
+ function parsePropertyValue(value, type = 8 /* Any */) {
3303
+ const isComplex = value == null || typeof value === "object" || typeof value === "function";
3304
+ if (isComplex)
3305
+ return value;
3306
+ if ((type & 4 /* Boolean */) !== 0)
3307
+ return value === "false" ? false : value === "" || !!value;
3308
+ else if ((type & 2 /* Number */) !== 0)
3309
+ return Number.parseFloat(value.toString());
3310
+ else if ((type & 1 /* String */) !== 0)
3311
+ return String(value);
3312
+ else
3313
+ return value;
3314
+ }
3315
+ var makeMemberFilter = (filter) => (component) => {
3316
+ const members = component.manager.internals.meta?.members;
3317
+ return Object.entries(members ?? {}).filter(([_name, [propType]]) => (propType & filter) !== 0).map(([name]) => name);
3318
+ };
3319
+ var getPropLikeMembers = makeMemberFilter(63 /* PropLike */);
3320
+ var getMemberType = (component, name) => component.manager.internals.meta.members?.[name]?.[0];
3321
+ function getPropType(component, name) {
3322
+ const type = getMemberType(component, name);
3323
+ if (type === void 0)
3324
+ return void 0;
3325
+ else if (type & 32 /* State */)
3326
+ return "state";
3327
+ else
3328
+ return "prop";
3329
+ }
3330
+ function addPropertyWatcher(component, property) {
3331
+ const meta = component.manager.internals.meta;
3332
+ meta.watchers ?? (meta.watchers = {});
3333
+ const watchers = meta.watchers;
3334
+ if (!(property in watchers))
3335
+ watchers[property] = [];
3336
+ if (!watchers[property].includes(watcherCallbackName))
3337
+ watchers[property].push(watcherCallbackName);
3338
+ }
3339
+ var watcherCallbackName = "dynamicWatcherCallback";
3340
+
3341
+ // src/Controller.ts
3342
+ var _a;
3343
+ var _Controller = class _Controller {
3344
+ constructor(component) {
3345
+ this._ready = new Deferred();
3346
+ this._lifecycleDisconnected = [];
3347
+ this.connectedCalled = false;
3348
+ this.willLoadCalled = false;
3349
+ this.didLoadCalled = false;
3350
+ this[_a] = true;
3351
+ this.ready = this._ready.promise;
3352
+ /*
3353
+ * Setting default exports to "this" so that controllers that don't use
3354
+ * exports/proxyExports(), could still be used as if they did
3355
+ * (i.e with controller.use)
3356
+ */
3357
+ this._exports = makeProvisionalValue(this);
3358
+ this._exportWatchers = /* @__PURE__ */ new Set();
3359
+ const resolvedComponent = toControllerHost(
3360
+ component ?? _Controller.internals.retrieveComponent(new.target.name)
3361
+ );
3362
+ Object.defineProperty(this, "component", {
3363
+ writable: false,
3364
+ enumerable: false,
3365
+ configurable: true,
3366
+ value: resolvedComponent
2936
3367
  });
3368
+ this.component.addController(this);
3369
+ const manager = this.component.manager;
3370
+ this.connected = manager?.connected;
3371
+ this.internals = manager?.internals;
3372
+ _Controller.internals.setParentController(this);
3373
+ if ("hostDestroy" in this)
3374
+ this.component.manager.ensureHasDestroy();
3375
+ if (manager !== void 0)
3376
+ queueMicrotask(() => this.catchUpLifecycle());
3377
+ const controller = this;
3378
+ this._callbacks = {
3379
+ hostConnected: "hostConnected" in this ? [() => controller.hostConnected?.()] : [],
3380
+ hostDisconnected: "hostDisconnected" in this ? [() => controller.hostDisconnected?.()] : [],
3381
+ hostLoad: "hostLoad" in this ? [() => controller.hostLoad?.()] : [],
3382
+ hostLoaded: "hostLoaded" in this ? [() => controller.hostLoaded?.()] : [],
3383
+ hostRender: "hostRender" in this ? [() => controller.hostRender?.()] : [],
3384
+ hostRendered: "hostRendered" in this ? [() => controller.hostRendered?.()] : [],
3385
+ hostUpdate: "hostUpdate" in this ? [() => controller.hostUpdate?.()] : [],
3386
+ hostUpdated: "hostUpdated" in this ? [() => controller.hostUpdated?.()] : [],
3387
+ hostDestroy: "hostDestroy" in this ? [() => controller.hostDestroy?.()] : [],
3388
+ hostLifecycle: "hostLifecycle" in this ? [() => controller.hostLifecycle?.()] : []
3389
+ };
3390
+ }
3391
+ /**
3392
+ * If controller is being added dynamically, after the component
3393
+ * construction, then trigger connected and load right away
3394
+ */
3395
+ catchUpLifecycle() {
3396
+ if (this.connectedCalled)
3397
+ return;
3398
+ this.triggerConnected();
3399
+ const loadWillStillHappen = !this.component.manager.willLoadCalled;
3400
+ if (loadWillStillHappen)
3401
+ return;
3402
+ this.triggerLoad().then(() => {
3403
+ const loadedWillStillHappen = !this.component.manager.didLoadCalled;
3404
+ if (loadedWillStillHappen)
3405
+ return;
3406
+ this.triggerLoaded();
3407
+ }).catch(console.error);
3408
+ }
3409
+ get exports() {
3410
+ return this._exports;
3411
+ }
3412
+ /**
3413
+ * Set controller's exports property (for usage with proxyExports()) and mark
3414
+ * controller as ready (for usage in other controllers). Also, triggers
3415
+ * re-render of the component
3416
+ */
3417
+ set exports(exports) {
3418
+ if (this._exports !== exports) {
3419
+ this._exports = exports;
3420
+ if (this.connectedCalled)
3421
+ this.component.requestUpdate();
3422
+ this._exportWatchers.forEach((callback) => callback(exports));
3423
+ }
3424
+ this._ready.resolve(exports);
3425
+ }
3426
+ setProvisionalExports(exports) {
3427
+ this._exports = makeProvisionalValue(exports);
3428
+ this._exportWatchers.forEach((callback) => callback(this._exports));
3429
+ }
3430
+ watchExports(callback) {
3431
+ const safeCallback = (exports) => safeCall(() => callback(exports));
3432
+ this._exportWatchers.add(safeCallback);
3433
+ return () => void this._exportWatchers.delete(safeCallback);
3434
+ }
3435
+ /**
3436
+ * A flexible utility for making sure a controller is loaded before it's used,
3437
+ * regardless of how or where a controller was defined:
3438
+ *
3439
+ * @example
3440
+ * makeGenericController(async (component, controller) => {
3441
+ * // Await some controller from the component:
3442
+ * await controller.use(component.someController);
3443
+ * // Initialize new controllers
3444
+ * await controller.use(load(importCoreReactiveUtils));
3445
+ * await controller.use(new ViewModelController(component,newWidgetsHomeHomeViewModel));
3446
+ * await controller.use(someController(component));
3447
+ * });
3448
+ *
3449
+ * @remarks
3450
+ * If your controller is not async, and you are not creating it async, then
3451
+ * you are not required to use controller.use - you can use it directly.
3452
+ * Similarly, accessing controllers after componentWillLoad callback does not
3453
+ * require awaiting them as they are guaranteed to be loaded by then.
3454
+ */
3455
+ get use() {
3456
+ _Controller.internals.setAmbientComponent(this.component);
3457
+ return _Controller.internals.use;
3458
+ }
3459
+ /**
3460
+ * Just like controller.use, but returns the controller itself, rather than it's
3461
+ * exports
3462
+ *
3463
+ * Use cases:
3464
+ * - You have a controller and you want to make sure it's loaded before you
3465
+ * try to use it
3466
+ * - Your controller is not using exports, so you wish to access some props on
3467
+ * it directly
3468
+ * - You have a controller exports only, and you want to retrieve the
3469
+ * controller itself. This is useful if you wish to call .watchExports() or
3470
+ * some other method on the controller
3471
+ */
3472
+ get useRef() {
3473
+ _Controller.internals.setAmbientComponent(this.component);
3474
+ return _Controller.internals.useRef;
3475
+ }
3476
+ /**
3477
+ * If you need to set a prop/state without triggering the custom setter you
3478
+ * defined with getSet()/dynamicGetSet()/readonly(), set the value inside
3479
+ * of this function
3480
+ *
3481
+ * @example
3482
+ * @Prop() readOnly = this.manager.readOnly(true);
3483
+ *
3484
+ * someAction(): void {
3485
+ * this.manager.bypassSetter(()=>{
3486
+ * this.readOnly = false;
3487
+ * });
3488
+ * }
3489
+ *
3490
+ */
3491
+ bypassSetter(callback) {
3492
+ _Controller.internals.shouldBypassSetter = true;
3493
+ const result = safeCall(callback);
3494
+ _Controller.internals.shouldBypassSetter = false;
2937
3495
  return result;
3496
+ }
3497
+ /**
3498
+ * Like bypassSetter, but only bypasses this.manager.readonly(), rather that
3499
+ * all setters set using this.manager.getSet()
3500
+ */
3501
+ bypassReadonly(callback) {
3502
+ _Controller.internals.shouldBypassReadonly = true;
3503
+ const result = safeCall(callback);
3504
+ _Controller.internals.shouldBypassReadonly = false;
3505
+ return result;
3506
+ }
3507
+ /**
3508
+ * Property reads inside of this function will bypass any custom getter you
3509
+ * may have, and read the value directly from what's stored in Stencil.
3510
+ *
3511
+ * This also bypasses reactiveUtils integration - reading a property inside of
3512
+ * bypassGetter won't make that property tracked.
3513
+ *
3514
+ * @example
3515
+ * reactiveUtils.watch(
3516
+ * ()=>{
3517
+ * this.manager.bypassGetter(()=>{
3518
+ * console.log(this.someProp);
3519
+ * });
3520
+ * return this.prop;
3521
+ * },
3522
+ * console.log
3523
+ * )
3524
+ */
3525
+ bypassGetter(callback) {
3526
+ _Controller.internals.shouldBypassGetter = true;
3527
+ const result = safeCall(callback);
3528
+ _Controller.internals.shouldBypassGetter = false;
3529
+ return result;
3530
+ }
3531
+ /**
3532
+ * Like this.manager.getSet(), but can be called on any component's
3533
+ * state/prop from anywhere, rather than just from the default value
3534
+ */
3535
+ dynamicGetSet(name, getSet) {
3536
+ this.genericGetSet(name, getSet);
3537
+ }
3538
+ /**
3539
+ * Like dynamicGetSet, but less type-safe. Useful in cases when trying to set
3540
+ * getters/setters in place where property names & types are not known
3541
+ * statically
3542
+ */
3543
+ genericGetSet(property, getSet) {
3544
+ var _a2, _b;
3545
+ const genericGetSet = getSet;
3546
+ if (genericGetSet.get !== void 0) {
3547
+ (_a2 = this.internals.getters)[property] ?? (_a2[property] = []);
3548
+ this.internals.getters[property].unshift(genericGetSet.get);
3549
+ }
3550
+ if (genericGetSet.set !== void 0) {
3551
+ (_b = this.internals.setters)[property] ?? (_b[property] = []);
3552
+ this.internals.setters[property].unshift(genericGetSet.set);
3553
+ }
3554
+ }
3555
+ // FEATURE: improve typings
3556
+ /**
3557
+ * Dynamically set a watcher for any @Prop()/@State() property
3558
+ */
3559
+ watch(property, callback) {
3560
+ var _a2;
3561
+ const type = getMemberType(this.component, property);
3562
+ if (type === void 0)
3563
+ throw new Error(
3564
+ `Trying to watch a non-@Prop, non-@State property "${property}". Either convert it into a @State() or use manager.getSet/dynamicGetSet`
3565
+ );
3566
+ addPropertyWatcher(this.component, property);
3567
+ (_a2 = this.internals.watchers)[property] ?? (_a2[property] = []);
3568
+ const watchers = this.internals.watchers[property];
3569
+ const genericCallback = callback;
3570
+ const safeCallback = (newValue, oldValue, propertyName) => safeCall(() => genericCallback(newValue, oldValue, propertyName));
3571
+ watchers.push(safeCallback);
3572
+ return () => {
3573
+ const index = watchers.indexOf(safeCallback);
3574
+ if (index !== -1)
3575
+ watchers.splice(index, 1);
3576
+ };
3577
+ }
3578
+ // Register a lifecycle callback
3579
+ onConnected(callback) {
3580
+ this._callbacks.hostConnected.push(callback);
3581
+ }
3582
+ onDisconnected(callback) {
3583
+ this._callbacks.hostDisconnected.push(callback);
3584
+ }
3585
+ onLoad(callback) {
3586
+ this._callbacks.hostLoad.push(callback);
3587
+ }
3588
+ onLoaded(callback) {
3589
+ this._callbacks.hostLoaded.push(callback);
3590
+ }
3591
+ onRender(callback) {
3592
+ this._callbacks.hostRender.push(callback);
3593
+ }
3594
+ onRendered(callback) {
3595
+ this._callbacks.hostRendered.push(callback);
3596
+ }
3597
+ onUpdate(callback) {
3598
+ this._callbacks.hostUpdate.push(callback);
3599
+ }
3600
+ onUpdated(callback) {
3601
+ this._callbacks.hostUpdated.push(callback);
3602
+ }
3603
+ onDestroy(callback) {
3604
+ this.component.manager.ensureHasDestroy();
3605
+ this._callbacks.hostDestroy.push(callback);
3606
+ }
3607
+ onLifecycle(callback) {
3608
+ this._callbacks.hostLifecycle.push(callback);
3609
+ if (this.connectedCalled && this.component.el.isConnected)
3610
+ this._callLifecycle(callback);
3611
+ }
3612
+ // Call each lifecycle hook
3613
+ triggerConnected() {
3614
+ this._callbacks.hostConnected.forEach(safeCall);
3615
+ this.triggerLifecycle();
3616
+ this.connectedCalled = true;
3617
+ }
3618
+ triggerDisconnected() {
3619
+ this._callbacks.hostDisconnected.forEach(safeCall);
3620
+ this._lifecycleDisconnected.forEach(safeCall);
3621
+ this._lifecycleDisconnected = [];
3622
+ }
3623
+ async triggerLoad() {
3624
+ if (this.willLoadCalled)
3625
+ return;
3626
+ this.willLoadCalled = true;
3627
+ if (this._callbacks.hostLoad.length > 0)
3628
+ await Promise.allSettled(this._callbacks.hostLoad.map(safeAsyncCall));
3629
+ this._ready.resolve(this._exports);
3630
+ }
3631
+ triggerLoaded() {
3632
+ if (this.didLoadCalled)
3633
+ return;
3634
+ this._callbacks.hostLoaded.forEach(safeCall);
3635
+ this.didLoadCalled = true;
3636
+ }
3637
+ async triggerRender() {
3638
+ if (this._callbacks.hostRender.length > 0)
3639
+ await Promise.allSettled(this._callbacks.hostRender.map(safeAsyncCall));
3640
+ }
3641
+ triggerRendered() {
3642
+ this._callbacks.hostRendered.forEach(safeCall);
3643
+ }
3644
+ async triggerUpdate() {
3645
+ if (this._callbacks.hostUpdate.length > 0)
3646
+ await Promise.allSettled(this._callbacks.hostUpdate.map(safeAsyncCall));
3647
+ }
3648
+ triggerUpdated() {
3649
+ this._callbacks.hostUpdated.forEach(safeCall);
3650
+ }
3651
+ triggerDestroy() {
3652
+ this._callbacks.hostDestroy.forEach(safeCall);
3653
+ }
3654
+ triggerLifecycle() {
3655
+ this._callbacks.hostLifecycle.forEach((callback) => this._callLifecycle(callback));
3656
+ }
3657
+ _callLifecycle(callback) {
3658
+ const cleanupRaw = safeCall(callback);
3659
+ const cleanup = Array.isArray(cleanupRaw) ? cleanupRaw : [cleanupRaw];
3660
+ cleanup.forEach((cleanup2) => {
3661
+ if (typeof cleanup2 === "function")
3662
+ this._lifecycleDisconnected.push(cleanup2);
3663
+ else if (typeof cleanup2 === "object" && typeof cleanup2.remove === "function")
3664
+ this._lifecycleDisconnected.push(cleanup2.remove);
3665
+ });
3666
+ }
3667
+ };
3668
+ _a = controllerSymbol;
3669
+ _Controller.internals = new ControllerInternals();
3670
+ var Controller = _Controller;
3671
+ var GenericController = class extends Controller {
3672
+ // Redundant constructor needed to improve typing
3673
+ constructor(component) {
3674
+ super(component);
3675
+ }
3676
+ // Overriding super's watch only to improve typing
3677
+ watch(property, callback) {
3678
+ return super.watch(
3679
+ property,
3680
+ callback
3681
+ );
3682
+ }
3683
+ /**
3684
+ * Silence "Property 'dynamicGetSet' in type
3685
+ * 'GenericController<Exports, Requires>' is not assignable to the same
3686
+ * property in base type 'Controller<Exports>'", as TypeScript is being overly
3687
+ * conservative here with what it allows
3688
+ */
3689
+ dynamicGetSet(property, getSet) {
3690
+ super.genericGetSet(property, getSet);
3691
+ }
3692
+ };
3693
+ function makeProvisionalValue(base) {
3694
+ if (typeof base !== "object" && typeof base !== "function" || base === null)
3695
+ return base;
3696
+ const proxy3 = new Proxy(base, {
3697
+ get(target, prop, receiver) {
3698
+ if (cyclical.has(prop) && prop in target && target[prop] === proxy3)
3699
+ return void 0;
3700
+ if (prop in target || prop in Promise.prototype || typeof prop === "symbol")
3701
+ return typeof target === "function" ? target[prop] : Reflect.get(target, prop, receiver);
3702
+ console.error(`Trying to access "${prop.toString()}" on the controller before it's loaded. ${accessBeforeLoad}`);
3703
+ return void 0;
3704
+ },
3705
+ set(target, prop, newValue, receiver) {
3706
+ console.error(`Trying to set "${prop.toString()}" on the controller before it's loaded. ${accessBeforeLoad}`);
3707
+ return Reflect.set(target, prop, newValue, receiver);
3708
+ }
3709
+ });
3710
+ return proxy3;
3711
+ }
3712
+ var cyclical = /* @__PURE__ */ new Set(["exports", "_exports"]);
3713
+ var accessBeforeLoad = [
3714
+ "This might be the case if you are trying to access an async controller in ",
3715
+ "connectedCallback(). Or, if you are using it inside of ",
3716
+ "componentWillLoad()/another controller without controller.use. Example correct ",
3717
+ "usage:\n",
3718
+ "makeController(async (component, controller)=>{ await controller.use(someOtherController); });"
3719
+ ].join("");
3720
+ function toControllerHost(component) {
3721
+ if ("addController" in component)
3722
+ return component;
3723
+ else
3724
+ throw new Error(
3725
+ "Component does not implement ControllerHost. This might be because you forgot to add 'manager: Controller<this> = useControllerManager(this);' in your component, or you tried to use some controller before that line"
3726
+ );
3727
+ }
3728
+
3729
+ // src/trackPropertyKey.ts
3730
+ function trackPropertyKey(object, onResolved, defaultValue) {
3731
+ const keys = Object.keys(object);
3732
+ const keyCount = keys.length;
3733
+ if (keyTrackMap === void 0)
3734
+ queueMicrotask(keyTrackResolve);
3735
+ keyTrackMap ?? (keyTrackMap = /* @__PURE__ */ new Map());
3736
+ let pendingTrackers = keyTrackMap.get(object);
3737
+ if (pendingTrackers === void 0) {
3738
+ pendingTrackers = { callbacks: [], keyCount };
3739
+ keyTrackMap.set(object, pendingTrackers);
3740
+ }
3741
+ if (pendingTrackers.keyCount !== keyCount) {
3742
+ pendingTrackers.callbacks.forEach((resolve) => resolve(keys));
3743
+ pendingTrackers.callbacks = [];
3744
+ pendingTrackers.keyCount = keyCount;
3745
+ }
3746
+ pendingTrackers.callbacks.push((keys2) => {
3747
+ const callback = (key2) => safeCall(() => onResolved(key2));
3748
+ const key = keys2[keyCount];
3749
+ if (key === void 0)
3750
+ callback(void 0);
3751
+ else if (object[key] === defaultValue)
3752
+ callback(key);
3753
+ else
3754
+ callback(void 0);
3755
+ });
3756
+ return defaultValue;
3757
+ }
3758
+ var keyTrackMap = void 0;
3759
+ function keyTrackResolve() {
3760
+ Array.from(keyTrackMap?.entries() ?? []).forEach(([object, { callbacks }]) => {
3761
+ const keys = Object.keys(object);
3762
+ callbacks.forEach((commit) => commit(keys));
3763
+ });
3764
+ keyTrackMap = void 0;
3765
+ }
3766
+
3767
+ // src/ComponentInternals.ts
3768
+ var ComponentInternals = class {
3769
+ constructor(component) {
3770
+ this.trackKey = (hostsCandidates, onResolved, defaultValue) => {
3771
+ const candidateHosts = Array.isArray(hostsCandidates) ? hostsCandidates : [hostsCandidates];
3772
+ let leftToResolve = candidateHosts.length + 1;
3773
+ const resolved = (resolution) => {
3774
+ leftToResolve -= 1;
3775
+ if (resolution !== void 0)
3776
+ leftToResolve = 0;
3777
+ if (leftToResolve === 0)
3778
+ onResolved(resolution);
3779
+ };
3780
+ candidateHosts.forEach(
3781
+ (host) => this.component.manager.trackPropertyKey(
3782
+ host,
3783
+ (key) => resolved(
3784
+ key === void 0 ? void 0 : {
3785
+ key,
3786
+ host,
3787
+ type: "property",
3788
+ domValue: void 0
3789
+ }
3790
+ ),
3791
+ defaultValue
3792
+ )
3793
+ );
3794
+ this.component.manager.trackPropKey((key, domValue) => {
3795
+ const propType = key === void 0 ? void 0 : getPropType(this.component, key);
3796
+ resolved(
3797
+ key === void 0 ? void 0 : {
3798
+ key,
3799
+ host: this.component,
3800
+ type: propType ?? "prop",
3801
+ domValue: propType === "prop" ? domValue : void 0
3802
+ }
3803
+ );
3804
+ }, defaultValue);
3805
+ return defaultValue;
3806
+ };
3807
+ this.trackPropKey = (onResolved, defaultValue) => {
3808
+ if (this._trackedValue !== nothing && this._trackedValue !== defaultValue)
3809
+ this._firePropertyTrackers(void 0, void 0, void 0);
3810
+ if (this._keyTrackers.length === 0)
3811
+ queueMicrotask(() => this._firePropertyTrackers(void 0, void 0, void 0));
3812
+ this._trackedValue = defaultValue;
3813
+ this._keyTrackers.push(
3814
+ (key, value, previousValue) => safeCall(() => onResolved(defaultValue === value ? key : void 0, previousValue))
3815
+ );
3816
+ return defaultValue;
3817
+ };
3818
+ this._trackedValue = nothing;
3819
+ this._keyTrackers = [];
3820
+ this.getters = {};
3821
+ this.setters = {};
3822
+ this.accessorGetter = {};
3823
+ this.accessorSetter = {};
3824
+ this._exports = /* @__PURE__ */ new WeakMap();
3825
+ Object.defineProperty(this, "component", {
3826
+ writable: false,
3827
+ enumerable: false,
3828
+ configurable: true,
3829
+ value: component
3830
+ });
3831
+ }
3832
+ _firePropertyTrackers(key, value, oldValue) {
3833
+ const trackers = this._keyTrackers;
3834
+ this._trackedValue = nothing;
3835
+ this._keyTrackers = [];
3836
+ trackers.forEach((tracker) => tracker(key, value, oldValue));
3837
+ }
3838
+ /**
3839
+ * Configure a getter or setter for a given \@Prop/\@State
3840
+ *
3841
+ * Note, since props are defined on the prototype, they are shared between all
3842
+ * instances of a component. Thus, instead of passing a reference to the
3843
+ * getter/setter function, you should update the
3844
+ * ComponentInternals.getters/setters properties, and then call getSetProxy
3845
+ * to apply the changes to the prototype
3846
+ */
3847
+ getSetProxy(property, hasGetter, hasSetter) {
3848
+ const classPrototype = Object.getPrototypeOf(this.component);
3849
+ this._getSetProxy(classPrototype, property, hasGetter, hasSetter, "class");
3850
+ const htmlPrototype = Object.getPrototypeOf(this.component.el);
3851
+ if (classPrototype !== htmlPrototype)
3852
+ this._getSetProxy(htmlPrototype, property, hasGetter, hasSetter, "html");
3853
+ }
3854
+ _getSetProxy(prototype, name, hasGetter, hasSetter, type) {
3855
+ const component = this.component;
3856
+ const propType = getMemberType(component, name);
3857
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, name);
3858
+ const tolerateNotFound = type === "html";
3859
+ if (descriptor?.set === void 0 || descriptor.get === void 0)
3860
+ if (descriptor !== void 0 && "value" in descriptor)
3861
+ throw new Error(
3862
+ `getSet() should only be used on Stencil's @Prop and @State properties. For internal component properties, use regular get/set syntax. Tried to use it on "${name}" in ${component.el.tagName}`
3863
+ );
3864
+ else if (tolerateNotFound)
3865
+ return;
3866
+ else
3867
+ throw new Error(`Unable to find "${name}" property on the ${component.el.tagName} component`);
3868
+ const { get: originalGet, set: originalSet } = descriptor;
3869
+ const isGetterAlreadyOverwritten = customAccessor in originalGet;
3870
+ const isSetterAlreadyOverwritten = customAccessor in originalSet;
3871
+ const shouldOverwriteGet = !isGetterAlreadyOverwritten && hasGetter;
3872
+ const shouldOverwriteSet = !isSetterAlreadyOverwritten && hasSetter;
3873
+ if (!shouldOverwriteGet && !shouldOverwriteSet)
3874
+ return;
3875
+ const finalGetter = shouldOverwriteGet ? function getter() {
3876
+ let value = originalGet.call(this);
3877
+ if (Controller.internals.shouldBypassGetter)
3878
+ return value;
3879
+ const component2 = Controller.internals.elementToInstance.get(this);
3880
+ const internals = component2.manager.internals;
3881
+ value = internals.accessorGetter[name](value, name);
3882
+ const getters = internals.getters[name] ?? emptyArray;
3883
+ for (let i = 0; i < getters.length; i++)
3884
+ value = getters[i](value, name);
3885
+ return value;
3886
+ } : originalGet;
3887
+ const finalSetter = shouldOverwriteSet ? function setter(rawNewValue) {
3888
+ const oldValue = originalGet.call(this);
3889
+ let newValue = parsePropertyValue(rawNewValue, propType);
3890
+ const component2 = Controller.internals.elementToInstance.get(this);
3891
+ const internals = component2.manager.internals;
3892
+ if (newValue === oldValue)
3893
+ originalSet.call(this, rawNewValue);
3894
+ else {
3895
+ const setters = Controller.internals.shouldBypassSetter ? emptyArray : internals.setters[name] ?? emptyArray;
3896
+ for (let i = 0; i < setters.length; i++)
3897
+ newValue = setters[i](newValue, oldValue, name);
3898
+ newValue = internals.accessorSetter[name](newValue, oldValue, name);
3899
+ originalSet.call(this, newValue);
3900
+ }
3901
+ if (internals._keyTrackers.length > 0)
3902
+ internals?._firePropertyTrackers(name, rawNewValue, oldValue);
3903
+ } : originalSet;
3904
+ if (shouldOverwriteGet)
3905
+ Object.defineProperty(finalGetter, customAccessor, { value: true });
3906
+ if (shouldOverwriteSet)
3907
+ Object.defineProperty(finalSetter, customAccessor, { value: true });
3908
+ Object.defineProperty(prototype, name, {
3909
+ ...descriptor,
3910
+ get: finalGetter,
3911
+ set: finalSetter
3912
+ });
3913
+ }
3914
+ /**
3915
+ * Associate an exports object with a controller for reverse lookup in
3916
+ * controller.use
3917
+ */
3918
+ markExports(controller, exports) {
3919
+ if (typeof exports === "object" && exports !== null || typeof exports === "function")
3920
+ this._exports.set(exports, controller);
3921
+ }
3922
+ resolveExports(exports) {
3923
+ if (typeof exports === "object" && exports !== null || typeof exports === "function")
3924
+ return this._exports.get(exports);
3925
+ else
3926
+ return void 0;
3927
+ }
3928
+ };
3929
+ var emptyArray = [];
3930
+ var customAccessor = Symbol("controllersCustomAccessor");
3931
+ var nothing = Symbol("nothing");
3932
+ var accessorPromise = Promise.all([importCoreAccessor(), importCoreAccessorSupportDecorators()]);
3933
+ function reactiveUtilsIntegration(component) {
3934
+ const members = getPropLikeMembers(component);
3935
+ const internals = component.manager.internals;
3936
+ members.forEach((name) => {
3937
+ internals.accessorGetter[name] = defaultGetterSetter;
3938
+ internals.accessorSetter[name] = defaultGetterSetter;
3939
+ internals.getSetProxy(name, true, true);
3940
+ });
3941
+ return async (enabledMembers = members) => {
3942
+ const [Accessor, { subclass, property }] = await accessorPromise;
3943
+ class AccessorSubclass extends Accessor {
3944
+ }
3945
+ const getter = (_value, propertyName) => accessor[propertyName];
3946
+ function setter(newValue, _oldValue, propertyName) {
3947
+ if (accessor !== void 0)
3948
+ accessor[propertyName] = newValue;
3949
+ return newValue;
3950
+ }
3951
+ component.manager.bypassGetter(
3952
+ () => enabledMembers.forEach((name) => {
3953
+ internals.accessorGetter[name] = getter;
3954
+ internals.accessorSetter[name] = setter;
3955
+ property({
3956
+ value: component[name]
3957
+ })(AccessorSubclass.prototype, name);
3958
+ })
3959
+ );
3960
+ const Subclass = subclass(component.el.tagName)(AccessorSubclass);
3961
+ const accessor = new Subclass();
3962
+ };
3963
+ }
3964
+ var defaultGetterSetter = (value) => value;
3965
+
3966
+ // src/ControllerManager.ts
3967
+ var useControllerManager = (component) => new ControllerManager(component);
3968
+ var ControllerManager = class extends GenericController {
3969
+ constructor(component) {
3970
+ const controllers = /* @__PURE__ */ new Set();
3971
+ const watchers = {};
3972
+ const controllerHost = {
3973
+ addController: (controller) => {
3974
+ controllers.add(controller);
3975
+ },
3976
+ [watcherCallbackName]: (newValue, oldValue, propertyName) => {
3977
+ watchers[propertyName]?.forEach((callback) => callback(newValue, oldValue, propertyName));
3978
+ },
3979
+ removeController: (controller) => {
3980
+ controllers.delete(controller);
3981
+ },
3982
+ requestUpdate: () => forceUpdate(component)
3983
+ };
3984
+ extendObject(component, controllerHost);
3985
+ super(component);
3986
+ this._connected = new Deferred();
3987
+ this.internals = new ComponentInternals(this.component);
3988
+ this.connected = this._connected.promise;
3989
+ this.hasDestroy = false;
3990
+ this.destroyed = false;
3991
+ this._updatePromise = new Deferred();
3992
+ this._originalLifecycles = {};
3993
+ /**
3994
+ * A magical solution to finding out what property name a given controller
3995
+ * on a given object was assigned to. Note, this does not work for properties
3996
+ * that have \@Prop() or \@State() decorator - for those, use
3997
+ * manager.trackPropKey() instead.
3998
+ *
3999
+ * @example
4000
+ * function trackMe<T>(defaultValue:T, component:BaseComponent):T {
4001
+ * component.manager.trackPropertyKey(component, (key)=>console.log(key), defaultValue);
4002
+ * return defaultValue;
4003
+ * }
4004
+ *
4005
+ * class MyComponent extends BaseComponent {
4006
+ * // Will console log "myProp"
4007
+ * myProp = trackMe('a', this);
4008
+ * }
4009
+ *
4010
+ */
4011
+ this.trackPropertyKey = trackPropertyKey;
4012
+ /**
4013
+ * Like manager.trackPropertyKey(), but for props that have \@State() or \@Prop()
4014
+ * decorator
4015
+ *
4016
+ * @example
4017
+ * function trackMe(component:BaseComponent) {
4018
+ * component.manager.trackPropKey((key)=>console.log(key));
4019
+ * }
4020
+ *
4021
+ * class MyComponent extends BaseComponent {
4022
+ * // Will console log "myProp"
4023
+ * @Prop() myProp = trackMe(this);
4024
+ *
4025
+ * // Will console log "myState"
4026
+ * @State() myState = trackMe(this);
4027
+ * }
4028
+ */
4029
+ this.trackPropKey = this.internals.trackPropKey;
4030
+ /**
4031
+ * A combination of trackPropertyKey() and trackPropKey(). For usage when
4032
+ * you want to track a property, but don't know if it will be defined with the
4033
+ * \@Prop() decorator or not
4034
+ */
4035
+ this.trackKey = this.internals.trackKey;
4036
+ this._readonlySetter = (newValue, _oldValue, property) => {
4037
+ if (Controller.internals.shouldBypassReadonly)
4038
+ return newValue;
4039
+ const isProp = getPropType(this.component, property) === "prop";
4040
+ if (isProp)
4041
+ forceUpdate(this.component);
4042
+ throw new Error(
4043
+ `Cannot assign to read-only property "${property}" of ${this.component.el.tagName.toLowerCase()}. Trying to assign "${String(
4044
+ newValue
4045
+ )}"`
4046
+ );
4047
+ };
4048
+ /**
4049
+ * In development, on hot module reload, controller would be re-initialized
4050
+ * with all Props and State values persistent, but properties lost. This unsafe
4051
+ * development-only API lets you set or get data for a controller that would
4052
+ * persist across hot reloads.
4053
+ */
4054
+ this.devOnlySetPersistentControllerData = void 0 ;
4055
+ this.devOnlyGetPersistentControllerData = void 0 ;
4056
+ this.component.manager = this;
4057
+ retrieveComponentMeta(component);
4058
+ this._controllers = controllers;
4059
+ this.internals.watchers = watchers;
4060
+ this.exports = void 0;
4061
+ this.hasDestroy = "preserveOnDisconnect" in this.component && typeof this.component.destroy === "function";
4062
+ if (this.hasDestroy)
4063
+ this.watch("preserveOnDisconnect", () => this._preserveOnDisconnectWatcher());
4064
+ this._bindLifecycleMethods();
4065
+ Object.defineProperty(component, "updateComplete", {
4066
+ get: async () => await this._updatePromise.promise
4067
+ });
4068
+ this.internals.reactiveUtilsIntegration = reactiveUtilsIntegration(this.component);
4069
+ Controller.internals.setParentController(void 0);
4070
+ Controller.internals.setAmbientComponent(component);
4071
+ Controller.internals.elementToInstance.set(component.el, component);
4072
+ Controller.internals.elementToInstance.set(component, component);
4073
+ }
4074
+ _bindLifecycleMethods() {
4075
+ const component = this.component;
4076
+ this._originalLifecycles = {
4077
+ connectedCallback: component.connectedCallback,
4078
+ disconnectedCallback: component.disconnectedCallback,
4079
+ componentWillLoad: component.componentWillLoad,
4080
+ componentDidLoad: component.componentDidLoad,
4081
+ componentWillRender: component.componentWillRender,
4082
+ componentDidRender: component.componentDidRender,
4083
+ componentWillUpdate: component.componentWillUpdate,
4084
+ componentDidUpdate: component.componentDidUpdate,
4085
+ destroy: component.destroy
4086
+ };
4087
+ component.connectedCallback = this._connectedCallback.bind(this);
4088
+ component.disconnectedCallback = this._disconnectedCallback.bind(this);
4089
+ component.componentWillLoad = this._componentWillLoad.bind(this);
4090
+ component.componentDidLoad = this._componentDidLoad.bind(this);
4091
+ component.componentWillRender = this._componentWillRender.bind(this);
4092
+ component.componentDidRender = this._componentDidRender.bind(this);
4093
+ component.componentWillUpdate = this._componentWillUpdate.bind(this);
4094
+ component.componentDidUpdate = this._componentDidUpdate.bind(this);
4095
+ if (this.hasDestroy)
4096
+ component.destroy = this.destroy.bind(this);
4097
+ }
4098
+ /**
4099
+ * Throws an error if component does not implement destroy() lifecycle, but
4100
+ * tries to use it.
4101
+ */
4102
+ ensureHasDestroy() {
4103
+ if (!this.hasDestroy)
4104
+ throw new Error(destroyErrorMessage);
4105
+ }
4106
+ /**
4107
+ * Private because this is not supposed to be called by Component directly.
4108
+ * Instead, _bindLifecycleMethods will take care of that. Otherwise, you risk
4109
+ * calling lifecycle methods twice.
4110
+ */
4111
+ _connectedCallback() {
4112
+ if (this.destroyed) {
4113
+ const tagName = this.component.el.tagName.toLowerCase();
4114
+ this.component.el.remove();
4115
+ throw new Error(
4116
+ `The ${tagName} component has already been destroyed. It can not be used again. If you meant to disconnect and reconnect a component without automatic destroy, set the preserveOnDisconnect prop.`
4117
+ );
4118
+ }
4119
+ keyTrackResolve();
4120
+ this._connected.resolve();
4121
+ this._controllers.forEach(
4122
+ (controller) => "triggerConnected" in controller ? controller.triggerConnected() : safeCall(() => controller.hostConnected?.())
4123
+ );
4124
+ this._originalLifecycles.connectedCallback?.call(this.component);
4125
+ }
4126
+ _disconnectedCallback() {
4127
+ if (this.destroyed)
4128
+ return;
4129
+ this._controllers.forEach(
4130
+ (controller) => "triggerDisconnected" in controller ? controller.triggerDisconnected() : safeCall(() => controller.hostDisconnected?.())
4131
+ );
4132
+ this._originalLifecycles.disconnectedCallback?.call(this.component);
4133
+ if (this.hasDestroy)
4134
+ this._preserveOnDisconnectWatcher();
4135
+ }
4136
+ async _componentWillLoad() {
4137
+ await this.internals.reactiveUtilsIntegration();
4138
+ await Promise.allSettled(
4139
+ Array.from(
4140
+ this._controllers,
4141
+ async (controller) => "triggerLoad" in controller ? await controller.triggerLoad() : await safeAsyncCall(async () => await controller.hostLoad?.())
4142
+ )
4143
+ );
4144
+ await this._originalLifecycles.componentWillLoad?.call(this.component);
4145
+ }
4146
+ _componentDidLoad() {
4147
+ this._controllers.forEach(
4148
+ (controller) => "triggerLoaded" in controller ? controller.triggerLoaded() : safeCall(() => controller.hostLoaded?.())
4149
+ );
4150
+ this._originalLifecycles.componentDidLoad?.call(this.component);
4151
+ }
4152
+ async _componentWillRender() {
4153
+ await Promise.allSettled(
4154
+ Array.from(
4155
+ this._controllers,
4156
+ async (controller) => "triggerRender" in controller ? await controller.triggerRender() : await safeAsyncCall(async () => await controller.hostRender?.())
4157
+ )
4158
+ );
4159
+ await this._originalLifecycles.componentWillRender?.call(this.component);
4160
+ }
4161
+ _componentDidRender() {
4162
+ this._controllers.forEach(
4163
+ (controller) => "triggerRendered" in controller ? controller.triggerRendered() : safeCall(() => controller.hostRendered?.())
4164
+ );
4165
+ this._originalLifecycles.componentDidRender?.call(this.component);
4166
+ }
4167
+ async _componentWillUpdate() {
4168
+ await Promise.allSettled(
4169
+ Array.from(
4170
+ this._controllers,
4171
+ async (controller) => "triggerUpdate" in controller ? await controller.triggerUpdate() : await safeAsyncCall(async () => await controller.hostUpdate?.())
4172
+ )
4173
+ );
4174
+ await this._originalLifecycles.componentWillUpdate?.call(this.component);
4175
+ }
4176
+ _componentDidUpdate() {
4177
+ this._controllers.forEach(
4178
+ (controller) => "triggerUpdated" in controller ? controller.triggerUpdated() : safeCall(() => controller.hostUpdated?.())
4179
+ );
4180
+ this._originalLifecycles.componentDidUpdate?.call(this.component);
4181
+ const updatePromise = this._updatePromise;
4182
+ this._updatePromise = new Deferred();
4183
+ updatePromise.resolve(true);
4184
+ }
4185
+ async destroy() {
4186
+ this.ensureHasDestroy();
4187
+ if (this.destroyed)
4188
+ return;
4189
+ if (this.component.el.isConnected) {
4190
+ this.hasDestroy = false;
4191
+ this.component.el.remove();
4192
+ this.hasDestroy = true;
4193
+ }
4194
+ this.destroyed = true;
4195
+ this._controllers.forEach(
4196
+ (controller) => "triggerDestroy" in controller ? controller.triggerDestroy() : safeCall(() => controller.hostDestroy?.())
4197
+ );
4198
+ await this._originalLifecycles.destroy?.call(this.component);
4199
+ }
4200
+ _preserveOnDisconnectWatcher() {
4201
+ if (!this.component.el.isConnected && !this.component.preserveOnDisconnect)
4202
+ void this.destroy().catch(console.error);
4203
+ }
4204
+ /**
4205
+ * Make a @Prop() or @State() readonly (prevent overwriting default value).
4206
+ *
4207
+ * For internal properties, prefer TypeScript's "readonly" modifier instead.
4208
+ *
4209
+ * @example
4210
+ * // Defining readonly prop
4211
+ * @Prop({ reflect: true }) prop = this.manager.readonly('a');
4212
+ *
4213
+ * @example
4214
+ * // Overwriting readonly prop internally
4215
+ * this.manager.bypassReadonly(()=>{
4216
+ * this.prop = 'b';
4217
+ * });
4218
+ *
4219
+ */
4220
+ readonly(value) {
4221
+ return this.getSet(value, { set: this._readonlySetter });
4222
+ }
4223
+ /**
4224
+ * Listen for any component's @State()/@Prop() change, and mutate it's
4225
+ * value before it is set.
4226
+ * This is necessary because Stencil's Compiler does not support get/set for
4227
+ * @State()/@Prop().
4228
+ * For private component properties, you should use regular get/set syntax.
4229
+ *
4230
+ * @example
4231
+ * @Prop() exampleProp = this.manager.getSet(defaultValue,{get,set})
4232
+ * @Prop() someProp = this.manager.getSet(
4233
+ * undefined as string | undefined,
4234
+ * {
4235
+ * get: (value)=>value.trim(),
4236
+ * set: (newValue,oldValue) => newValue.trim() ?? oldValue
4237
+ * }
4238
+ * )
4239
+ *
4240
+ * @remarks
4241
+ * Unlike a native get/set, the get function receives the current attribute
4242
+ * value, and can modify it before returning it (or can disregard the current
4243
+ * value and get it from elsewhere instead).
4244
+ * Similarly, setter is called with the new and old value, and is expected to
4245
+ * return the final new value (or return the old value to undo the change)
4246
+ */
4247
+ getSet(defaultValue, getSet) {
4248
+ return this.component.manager.trackPropKey((name) => {
4249
+ var _a2;
4250
+ if (name === void 0)
4251
+ throw new Error(
4252
+ "Unable to resolve get/set's prop name. Make sure you are using it like @Prop() someProp = this.manager.getSet(defaultValue,{get,set})"
4253
+ );
4254
+ if (getSet.set === this._readonlySetter) {
4255
+ (_a2 = this.internals).readonlyProps ?? (_a2.readonlyProps = /* @__PURE__ */ new Set());
4256
+ this.internals.readonlyProps.add(name);
4257
+ }
4258
+ const genericComponent = this.component;
4259
+ const value = genericComponent[name];
4260
+ if (value != null && value !== defaultValue && typeof getSet.set === "function" && getSet.initialSet !== false) {
4261
+ const newValue = getSet.set(value, defaultValue, name);
4262
+ if (newValue !== value)
4263
+ genericComponent[name] = newValue;
4264
+ }
4265
+ this.genericGetSet(name, getSet);
4266
+ }, defaultValue);
4267
+ }
4268
+ };
4269
+ var destroyErrorMessage = `
4270
+ If the component uses a controller that uses destroy() method, then the
4271
+ component must have the following properties:
4272
+ ${// Don't expose internal code in production, and keep bundle smaller:
4273
+ `preserveOnDisconnect and destroy` }
4274
+ `.trim();
4275
+
4276
+ // src/proxyExports.ts
4277
+ var proxyExports = (Class) => (...args) => {
4278
+ const ambientControllers = Controller.internals.retrieveParentControllers();
4279
+ const instance = new Class(...args);
4280
+ const initialExports = instance.exports;
4281
+ Controller.internals.setParentController(ambientControllers.at(-1));
4282
+ const internals = instance.component.manager.internals;
4283
+ internals.markExports(instance, initialExports);
4284
+ instance.watchExports((exports) => internals.markExports(instance, exports));
4285
+ Controller.internals.setAmbientChildController(instance);
4286
+ const hostCandidates = [instance.component, ...ambientControllers].reverse();
4287
+ return internals.trackKey(
4288
+ hostCandidates,
4289
+ (resolution) => resolution === void 0 ? void 0 : setProxy(instance, resolution.host, resolution.key, initialExports),
4290
+ initialExports
4291
+ );
4292
+ };
4293
+ function setProxy(controller, host, key, initialExports) {
4294
+ const genericHost = host;
4295
+ const controllerValueChanged = genericHost[key] !== controller.exports;
4296
+ const hostValueChanged = genericHost[key] !== initialExports;
4297
+ const controllerUpdatedExports = initialExports !== controller.exports;
4298
+ if (controllerValueChanged && !hostValueChanged && controllerUpdatedExports)
4299
+ genericHost[key] = controller.exports;
4300
+ controller.watchExports(() => {
4301
+ if (genericHost[key] === controller.exports)
4302
+ return;
4303
+ const manager = controller.component.manager;
4304
+ const isReadOnly = manager.internals.readonlyProps?.has(key) === true;
4305
+ if (isReadOnly)
4306
+ manager.bypassReadonly(() => {
4307
+ genericHost[key] = controller.exports;
4308
+ });
4309
+ else
4310
+ genericHost[key] = controller.exports;
4311
+ });
4312
+ }
4313
+
4314
+ // src/functional.ts
4315
+ var makeController = (constructor) => proxy(void 0, constructor);
4316
+ var FunctionalController = class extends Controller {
4317
+ constructor(component, constructor) {
4318
+ super(component);
4319
+ const originalExports = this.exports;
4320
+ try {
4321
+ Controller.internals.setAmbientComponent(this.component);
4322
+ const value = constructor(this.component, this);
4323
+ const constructorChangedExports = this.exports !== originalExports;
4324
+ if (value instanceof Promise) {
4325
+ if (!constructorChangedExports)
4326
+ this.setProvisionalExports(value);
4327
+ const resolved = value.then((result) => {
4328
+ this.exports = result;
4329
+ super.catchUpLifecycle();
4330
+ }).catch((error) => {
4331
+ this._ready.reject(error);
4332
+ console.error(error);
4333
+ });
4334
+ this.onLoad(async () => await resolved);
4335
+ } else {
4336
+ if (!constructorChangedExports || value !== void 0)
4337
+ this.exports = value;
4338
+ queueMicrotask(() => super.catchUpLifecycle());
4339
+ }
4340
+ } catch (error) {
4341
+ this._ready.reject(error);
4342
+ console.error(error);
4343
+ }
4344
+ }
4345
+ /** Noop - will be called in the constructor instead */
4346
+ catchUpLifecycle() {
4347
+ return;
4348
+ }
4349
+ };
4350
+ var proxy = proxyExports(FunctionalController);
4351
+ function useT9n({
4352
+ blocking = false,
4353
+ name
4354
+ } = {}) {
4355
+ return makeController((component, controller) => {
4356
+ controller.onLifecycle(
4357
+ () => startLocaleObserver(
4358
+ component.el,
4359
+ getAssetPath("./assets"),
4360
+ ({ t9nLocale, t9nStrings, lang }) => {
4361
+ controller.exports = { ...t9nStrings, _lang: lang, _t9nLocale: t9nLocale };
4362
+ const label = t9nStrings.componentLabel ?? t9nStrings.widgetLabel;
4363
+ if (typeof label === "string" && "label" in component && component.label == null)
4364
+ component.label ?? (component.label = label);
4365
+ },
4366
+ name
4367
+ )
4368
+ );
4369
+ if (blocking)
4370
+ return controller.ready;
4371
+ const locale = getElementLocales(component.el);
4372
+ return { _lang: locale.lang, _t9nLocale: locale.t9nLocale };
4373
+ });
2938
4374
  }
2939
4375
 
2940
4376
  function isMonacoEnvironmentSetup() {
@@ -2977,21 +4413,81 @@ function setupMonacoEnvironment(assetsPath) {
2977
4413
  break;
2978
4414
  }
2979
4415
  // If we have a relative path or we are on same orgin, we can use the default js implementation
2980
- if (!ie(url) || se(url, globalThis.location.href, true)) {
4416
+ if (!isURL(url) || hasSameOrigin(url, globalThis.location.href, true)) {
2981
4417
  return new Worker(url, { name: languageId });
2982
4418
  }
2983
4419
  // For cross orgin, we will load the worker code as a string and manufacture a blob
2984
4420
  const esriRequest = await importRequest();
2985
4421
  const response = await esriRequest(url, {
2986
- responseType: "text"
4422
+ responseType: "text",
2987
4423
  });
2988
4424
  return new Worker(URL.createObjectURL(new Blob([response.data], {
2989
- type: "text/javascript"
4425
+ type: "text/javascript",
2990
4426
  })));
2991
- }
4427
+ },
2992
4428
  };
2993
4429
  }
2994
4430
 
4431
+ const themeConfig = {
4432
+ "arcade-light-theme": {
4433
+ comment: "#606060",
4434
+ constant: "#9809C8",
4435
+ date: "#296389",
4436
+ identifier: "#0000B3",
4437
+ keyword: "#BF4900",
4438
+ number: "#136D3D",
4439
+ string: "#A31515"
4440
+ },
4441
+ "arcade-dark-theme": {
4442
+ comment: "#BFBFBF",
4443
+ constant: "#CDBAEA",
4444
+ date: "#97A6CE",
4445
+ identifier: "#9FD4F3",
4446
+ keyword: "#EEAA5A",
4447
+ number: "#AAD04B",
4448
+ string: "#F2877B"
4449
+ }
4450
+ };
4451
+
4452
+ function setupArcadeTheme() {
4453
+ ["light", "dark"].forEach((theme) => {
4454
+ const base = theme === "light" ? "vs" : "vs-dark";
4455
+ const colors = themeConfig[`arcade-${theme}-theme`];
4456
+ // Defines the light and dark theme based on the calcite theme name
4457
+ editor.defineTheme(base, {
4458
+ base,
4459
+ inherit: true,
4460
+ rules: [
4461
+ { token: "comment.arc", foreground: colors.comment },
4462
+ { token: "constant.arc", foreground: colors.constant },
4463
+ { token: "keyword.arc", foreground: colors.keyword },
4464
+ { token: "identifier.arc", foreground: colors.identifier },
4465
+ { token: "number.arc", foreground: colors.number },
4466
+ { token: "string.arc", foreground: colors.string },
4467
+ ],
4468
+ colors: {},
4469
+ });
4470
+ });
4471
+ }
4472
+ const monacoThemeKeys = ["comment", "keyword", "identifier", "string", "number", "constant"];
4473
+ const colorRulesKeys = [...monacoThemeKeys, "date"];
4474
+ function updateThemeColors(theme, colorRules) {
4475
+ if (colorRules === undefined) {
4476
+ setupArcadeTheme();
4477
+ return;
4478
+ }
4479
+ const base = theme === "light" ? "vs" : "vs-dark";
4480
+ const rules = [];
4481
+ monacoThemeKeys.forEach((key) => {
4482
+ const foreground = colorRules[key];
4483
+ if (!foreground) {
4484
+ return;
4485
+ }
4486
+ rules.push({ token: `${key}.arc`, foreground });
4487
+ });
4488
+ editor.defineTheme(base, { base, inherit: true, rules, colors: {} });
4489
+ }
4490
+
2995
4491
  /**
2996
4492
  * Returns the arcade diagnostic service.
2997
4493
  * Example:
@@ -3021,23 +4517,22 @@ async function getArcadeWorker(uri) {
3021
4517
  }
3022
4518
  /**
3023
4519
  * Request the arcade mode
3024
- * @returns mode for arcade
4520
+ * @returns arcade mode module
3025
4521
  */
3026
4522
  async function getMode() {
3027
- return await import('./arcade-mode-b2b0b42d.js');
4523
+ return await import('./arcade-mode-5aef1763.js');
3028
4524
  }
3029
4525
  // Register the language in Monaco
3030
4526
  languages.register({
3031
4527
  id: arcadeDefaults.languageId,
3032
4528
  aliases: ["Arcade", "arcade"],
3033
4529
  extensions: [".arc"],
3034
- mimetypes: ["application/arcade"]
4530
+ mimetypes: ["application/arcade"],
3035
4531
  });
3036
4532
  // An event emitted when a language is first time needed
3037
4533
  languages.onLanguage(arcadeDefaults.languageId, () => {
3038
- // Setup the assets path on the arcadeDefaults
4534
+ setupArcadeTheme();
3039
4535
  arcadeDefaults.setLanguageOptions({ assetsPath: `${getAssetsPath() ?? "."}/arcade-language` });
3040
- // Async import the language mode
3041
4536
  getMode()
3042
4537
  .then((mode) => {
3043
4538
  // Setup the language mode
@@ -3048,13 +4543,15 @@ languages.onLanguage(arcadeDefaults.languageId, () => {
3048
4543
  });
3049
4544
  });
3050
4545
 
3051
- const arcadeApiCss = ":host{background-color:var(--calcite-color-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-quarter);padding:var(--calcite-spacing-half);background-color:var(--calcite-color-foreground-1)}:host .sticky{position:sticky;top:0px;z-index:10}:host calcite-flow{height:100%}:host calcite-block p:first-of-type{margin-top:0}:host calcite-block code{font-family:var(--calcite-code-family)}:host calcite-block pre{direction:ltr;overflow-x:auto;background-color:var(--calcite-color-foreground-2);padding:var(--calcite-spacing-half)}:host calcite-block pre code{font-size:var(--calcite-font-size--2)}";
4546
+ const arcadeApiCss = ":host{background-color:var(--calcite-color-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}:host .sticky{position:sticky;top:0px;z-index:10}:host calcite-flow{height:100%}:host calcite-block p:first-of-type{margin-top:0}:host calcite-block code{font-family:var(--calcite-code-family)}:host calcite-block pre{direction:ltr;overflow-x:auto;background-color:var(--calcite-color-foreground-2);padding:var(--calcite-spacing-sm)}:host calcite-block pre code{font-size:var(--calcite-font-size--2)}";
3052
4547
 
3053
4548
  const ArcgisArcadeApi = class {
3054
4549
  constructor(hostRef) {
3055
4550
  registerInstance(this, hostRef);
3056
4551
  this.close = createEvent(this, "close", 3);
3057
4552
  this.itemSelected = createEvent(this, "itemSelected", 3);
4553
+ this.manager = useControllerManager(this);
4554
+ this.messages = useT9n();
3058
4555
  this._emitItemSelected = (e) => {
3059
4556
  const item = e.target?.["data-item"];
3060
4557
  if (!item) {
@@ -3094,9 +4591,6 @@ const ArcgisArcadeApi = class {
3094
4591
  this._updateFilterValue = (e) => {
3095
4592
  this._filterValue = e.target?.value ?? "";
3096
4593
  };
3097
- this._lang = "";
3098
- this._t9nLocale = "";
3099
- this._t9nStrings = undefined;
3100
4594
  this._selectedApiItem = undefined;
3101
4595
  this._filterValue = "";
3102
4596
  this._colorizeStyle = "";
@@ -3110,7 +4604,6 @@ const ArcgisArcadeApi = class {
3110
4604
  async componentWillLoad() {
3111
4605
  this._colorizeStyle = generateColorizeStyles();
3112
4606
  this._themeChangedListner = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
3113
- await B(this, getAssetPath("./assets"));
3114
4607
  arcadeDefaults.onModelContextDidChange((key) => {
3115
4608
  if (!this.modelId || key !== Uri.parse(this.modelId).toString()) {
3116
4609
  return;
@@ -3120,7 +4613,6 @@ const ArcgisArcadeApi = class {
3120
4613
  await this._updateApiLibrary();
3121
4614
  }
3122
4615
  disconnectedCallback() {
3123
- q(this);
3124
4616
  this._flowObserver?.disconnect();
3125
4617
  this._themeChangedListner?.dispose();
3126
4618
  }
@@ -3165,7 +4657,7 @@ const ArcgisArcadeApi = class {
3165
4657
  // When switching between flow the same reference is reused
3166
4658
  this._flowObserver = new MutationObserver(() => {
3167
4659
  // Get the last panel and try to set focus on the input element
3168
- W(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
4660
+ setFocusOnElement(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
3169
4661
  });
3170
4662
  this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
3171
4663
  }
@@ -3176,14 +4668,14 @@ const ArcgisArcadeApi = class {
3176
4668
  if (!filteredApiItems.length) {
3177
4669
  return null;
3178
4670
  }
3179
- return (h("calcite-list-item-group", { heading: category.title }, filteredApiItems.map((apiItem) => (h("calcite-list-item", { label: G(apiItem.completion.detail), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": apiItem }, h("calcite-action", { slot: "actions-end", text: this._t9nStrings?.expand ?? "Expand", icon: "chevron-right", iconFlipRtl: true, scale: "s", onClick: this._selectItem, "data-item": apiItem }))))));
4671
+ return (h("calcite-list-item-group", { heading: category.title }, filteredApiItems.map((apiItem) => (h("calcite-list-item", { label: addLTRMark(apiItem.completion.detail), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": apiItem }, h("calcite-action", { slot: "actions-end", text: this.messages.expand ?? "Expand", icon: "chevron-right", iconFlipRtl: true, scale: "s", onClick: this._selectItem, "data-item": apiItem }))))));
3180
4672
  }
3181
4673
  renderApiItemFlowItem() {
3182
4674
  const apiItem = this._selectedApiItem;
3183
4675
  if (!apiItem) {
3184
4676
  return null;
3185
4677
  }
3186
- return (h("calcite-flow-item", { heading: this._t9nStrings?.constantsandfunctions, beforeBack: this._unselectItem, closable: true, onCalciteFlowItemClose: this._emitClose }, this.hideDocumentationActions ? null : (h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", scale: "s", href: apiItem.link, target: "Arcade Help", "icon-start": "information" }, this._t9nStrings?.moreinformation)), h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", "icon-start": "code", scale: "s", onClick: this._emitItemSelectedAndClose, "data-item": apiItem, ref: (e) => void e?.setFocus() }, this._t9nStrings?.insert ?? "Insert"), h("calcite-block", { open: true, heading: G(apiItem.completion.detail) }, h("div", { innerHTML: convertMarkdownString(apiItem.completion.documentation) }), apiItem.examples ? (h("div", { ref: (e) => {
4678
+ return (h("calcite-flow-item", { heading: this.messages.constantsandfunctions, beforeBack: this._unselectItem, closable: true, onCalciteFlowItemClose: this._emitClose }, this.hideDocumentationActions ? null : (h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", scale: "s", href: apiItem.link, target: "Arcade Help", "icon-start": "information" }, this.messages.moreinformation)), h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", "icon-start": "code", scale: "s", onClick: this._emitItemSelectedAndClose, "data-item": apiItem, ref: (e) => void e?.setFocus() }, this.messages.insert ?? "Insert"), h("calcite-block", { open: true, heading: addLTRMark(apiItem.completion.detail) }, h("div", { innerHTML: convertMarkdownString(apiItem.completion.documentation) }), apiItem.examples ? (h("div", { ref: (e) => {
3187
4679
  if (!e) {
3188
4680
  return;
3189
4681
  }
@@ -3194,10 +4686,10 @@ const ArcgisArcadeApi = class {
3194
4686
  render() {
3195
4687
  const categories = (this._apiLibrary ?? []).map((apiCategory) => this.renderApiCategory(apiCategory));
3196
4688
  const empty = categories.every((g) => !g);
3197
- return (h(Host, null, h("style", null, this._colorizeStyle), h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, h("calcite-flow-item", { heading: this._t9nStrings?.constantsandfunctions, closable: true, onCalciteFlowItemClose: this._emitClose }, h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), this._preparingApi ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: this._t9nStrings?.loading ?? "Loading" })) : (h("calcite-list", null, empty ? h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No items") : categories))), this.renderApiItemFlowItem())));
4689
+ return (h(Host, null, h("style", null, this._colorizeStyle), h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, h("calcite-flow-item", { heading: this.messages.constantsandfunctions, closable: true, onCalciteFlowItemClose: this._emitClose }, h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), this._preparingApi ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: this.messages.loading ?? "Loading" })) : (h("calcite-list", null, empty ? h("div", { class: "notice-container" }, this.messages.noitems ?? "No items") : categories))), this.renderApiItemFlowItem())));
3198
4690
  }
3199
4691
  static get assetsDirs() { return ["assets"]; }
3200
- get _hostElement() { return getElement(this); }
4692
+ get el() { return getElement(this); }
3201
4693
  };
3202
4694
  ArcgisArcadeApi.style = arcadeApiCss;
3203
4695
 
@@ -3384,7 +4876,7 @@ async function executeScript(editorProfile, script, testContext, console) {
3384
4876
  // Setup an executor with the script
3385
4877
  const arcade = await importArcade();
3386
4878
  const executor = await arcade.createArcadeExecutor(script ?? "", {
3387
- variables: editorProfile?.variables ?? []
4879
+ variables: editorProfile?.variables ?? [],
3388
4880
  });
3389
4881
  // We want to measure the execution time
3390
4882
  const t1 = performance.now();
@@ -3394,7 +4886,7 @@ async function executeScript(editorProfile, script, testContext, console) {
3394
4886
  spatialReference,
3395
4887
  timeZone,
3396
4888
  rawOutput: true,
3397
- console
4889
+ console,
3398
4890
  };
3399
4891
  // Execute the script
3400
4892
  const scriptOutput = await executor.executeAsync(profileVariableInstances, executeContext);
@@ -3418,81 +4910,21 @@ async function executeScript(editorProfile, script, testContext, console) {
3418
4910
  error,
3419
4911
  timeStamp,
3420
4912
  compilationTime: 0,
3421
- executionTime: 0
4913
+ executionTime: 0,
3422
4914
  };
3423
4915
  }
3424
4916
  }
3425
4917
 
3426
- const themeConfig = {
3427
- "arcade-light-theme": {
3428
- comment: "#606060",
3429
- constant: "#9809C8",
3430
- date: "#296389",
3431
- identifier: "#0000B3",
3432
- keyword: "#BF4900",
3433
- number: "#136D3D",
3434
- string: "#A31515"
3435
- },
3436
- "arcade-dark-theme": {
3437
- comment: "#BFBFBF",
3438
- constant: "#CDBAEA",
3439
- date: "#97A6CE",
3440
- identifier: "#9FD4F3",
3441
- keyword: "#EEAA5A",
3442
- number: "#AAD04B",
3443
- string: "#F2877B"
3444
- }
3445
- };
4918
+ const arcadeEditorCss = "arcgis-arcade-editor{display:flex;flex-direction:column;position:relative;overflow:hidden;border:1px solid var(--calcite-color-border-3);box-sizing:border-box;background-color:var(--calcite-color-foreground-1);height:100%}arcgis-arcade-editor .flex-adjustable{flex:1 1 auto;overflow:hidden}arcgis-arcade-editor .flex-panel{flex:1 0 auto}arcgis-arcade-editor .position-relative{position:relative}arcgis-arcade-editor .flex-row{display:flex;flex-direction:row;overflow:hidden}arcgis-arcade-editor .flex-column{display:flex;flex-direction:column;overflow:hidden}arcgis-arcade-editor .border-inline-start{border-inline-start:1px solid var(--calcite-color-border-3);box-sizing:border-box}arcgis-arcade-editor .border-inline-end{border-inline-end:1px solid var(--calcite-color-border-3);box-sizing:border-box}arcgis-arcade-editor .sticky{position:sticky;top:0px;z-index:10}arcgis-arcade-editor .notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1);text-align:center}arcgis-arcade-editor .side-action-bar{max-width:25%}arcgis-arcade-editor .side-panel{max-width:45%;width:600px}arcgis-arcade-editor .side-panel calcite-flow{height:100%}arcgis-arcade-editor .main-action-bar{border-bottom:1px solid var(--calcite-color-border-3);flex:0 0 auto}arcgis-arcade-editor .main-action-bar calcite-action-group{padding-inline-end:var(--calcite-spacing-sm)}arcgis-arcade-editor .main-action-bar calcite-action-group calcite-action{padding-inline-end:var(--calcite-spacing-sm)}arcgis-arcade-editor .main-action-bar calcite-action-group calcite-action:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}arcgis-arcade-editor .main-action-bar calcite-action-group:last-child{border-inline-end-width:0px}arcgis-arcade-editor .main-action-bar calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}arcgis-arcade-editor arcgis-arcade-results{border-top:1px solid var(--calcite-color-border-3);box-sizing:border-box;max-height:50%;min-height:50%;margin-bottom:-1px}arcgis-arcade-editor calcite-flow [slot=footer]{word-break:break-word}arcgis-arcade-editor calcite-list-item-group calcite-list-item{margin-bottom:1px;box-shadow:0 1px 0 var(--calcite-color-border-3)}arcgis-arcade-editor calcite-list-item-group calcite-list-item:last-child{box-shadow:none}arcgis-arcade-editor calcite-list-item-group:last-child{margin-bottom:var(--calcite-spacing-xl)}";
3446
4919
 
3447
- function setupArcadeTheme() {
3448
- ["light", "dark"].forEach((theme) => {
3449
- const base = theme === "light" ? "vs" : "vs-dark";
3450
- const colors = themeConfig[`arcade-${theme}-theme`];
3451
- // Defines the light and dark theme based on the calcite theme name
3452
- editor.defineTheme(base, {
3453
- base,
3454
- inherit: true,
3455
- rules: [
3456
- { token: "comment.arc", foreground: colors.comment },
3457
- { token: "constant.arc", foreground: colors.constant },
3458
- { token: "keyword.arc", foreground: colors.keyword },
3459
- { token: "identifier.arc", foreground: colors.identifier },
3460
- { token: "number.arc", foreground: colors.number },
3461
- { token: "string.arc", foreground: colors.string }
3462
- ],
3463
- colors: {}
3464
- });
3465
- });
3466
- }
3467
- const monacoThemeKeys = ["comment", "keyword", "identifier", "string", "number", "constant"];
3468
- const colorRulesKeys = [...monacoThemeKeys, "date"];
3469
- function updateThemeColors(theme, colorRules) {
3470
- if (colorRules === undefined) {
3471
- setupArcadeTheme();
3472
- return;
3473
- }
3474
- const base = theme === "light" ? "vs" : "vs-dark";
3475
- const rules = [];
3476
- monacoThemeKeys.forEach((key) => {
3477
- const foreground = colorRules[key];
3478
- if (!foreground) {
3479
- return;
3480
- }
3481
- rules.push({ token: `${key}.arc`, foreground });
3482
- });
3483
- editor.defineTheme(base, { base, inherit: true, rules, colors: {} });
3484
- }
3485
-
3486
- const arcadeEditorCss = "arcgis-arcade-editor{display:flex;flex-direction:column;height:100%;width:100%;position:relative;overflow:hidden;border:1px solid var(--calcite-color-border-3);box-sizing:border-box;background-color:var(--calcite-color-foreground-1)}arcgis-arcade-editor .flex-adjustable{flex:1 1 auto;overflow:hidden}arcgis-arcade-editor .flex-panel{flex:1 0 auto}arcgis-arcade-editor .position-relative{position:relative}arcgis-arcade-editor .flex-row{display:flex;flex-direction:row;overflow:hidden}arcgis-arcade-editor .flex-column{display:flex;flex-direction:column;overflow:hidden}arcgis-arcade-editor .border-inline-start{border-inline-start:1px solid var(--calcite-color-border-3);box-sizing:border-box}arcgis-arcade-editor .border-inline-end{border-inline-end:1px solid var(--calcite-color-border-3);box-sizing:border-box}arcgis-arcade-editor .sticky{position:sticky;top:0px;z-index:10}arcgis-arcade-editor .notice-container{margin:var(--calcite-spacing-quarter);padding:var(--calcite-spacing-half);background-color:var(--calcite-color-foreground-1);text-align:center}arcgis-arcade-editor .side-action-bar{max-width:25%}arcgis-arcade-editor .side-panel{max-width:45%;width:600px}arcgis-arcade-editor .side-panel calcite-flow{height:100%}arcgis-arcade-editor .main-action-bar{border-bottom:1px solid var(--calcite-color-border-3);flex:0 0 auto}arcgis-arcade-editor .main-action-bar calcite-action-group{padding-inline-end:var(--calcite-spacing-half)}arcgis-arcade-editor .main-action-bar calcite-action-group calcite-action{padding-inline-end:var(--calcite-spacing-half)}arcgis-arcade-editor .main-action-bar calcite-action-group calcite-action:not(:first-child){padding-inline-start:var(--calcite-spacing-half)}arcgis-arcade-editor .main-action-bar calcite-action-group:last-child{border-inline-end-width:0px}arcgis-arcade-editor .main-action-bar calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-half)}arcgis-arcade-editor arcgis-arcade-results{border-top:1px solid var(--calcite-color-border-3);box-sizing:border-box;max-height:50%;min-height:50%;margin-bottom:-1px}arcgis-arcade-editor calcite-flow [slot=footer]{word-break:break-word}arcgis-arcade-editor calcite-list-item-group calcite-list-item{margin-bottom:1px;box-shadow:0 1px 0 var(--calcite-color-border-3)}arcgis-arcade-editor calcite-list-item-group calcite-list-item:last-child{box-shadow:none}arcgis-arcade-editor calcite-list-item-group:last-child{margin-bottom:var(--calcite-spacing-1)}";
3487
-
3488
- setupArcadeTheme();
3489
4920
  const ArcgisArcadeEditor = class {
3490
4921
  constructor(hostRef) {
3491
4922
  registerInstance(this, hostRef);
3492
4923
  this.scriptChange = createEvent(this, "scriptChange", 3);
3493
4924
  this.diagnosticsChange = createEvent(this, "diagnosticsChange", 3);
3494
- this._componentReadyDefer = new h$1();
3495
- this._modelId = U();
4925
+ this.manager = useControllerManager(this);
4926
+ this._componentReadyDefer = new Deferred$1();
4927
+ this._modelId = generateGuid();
3496
4928
  this._editorProfilePromise = Promise.resolve(undefined);
3497
4929
  this._disposables = [];
3498
4930
  this._executeScript = async () => {
@@ -3541,9 +4973,7 @@ const ArcgisArcadeEditor = class {
3541
4973
  this._insertAsText = (e) => void this._codeEditorElt?.insertText(e.detail).catch(console.error);
3542
4974
  this._onResultPanelChange = (e) => void (this._resultPanel = e.detail);
3543
4975
  this._onExecutionPanelClose = () => void (this._showExecutionPanel = false);
3544
- this._lang = "";
3545
- this._t9nLocale = "";
3546
- this._t9nStrings = undefined;
4976
+ this.messages = useT9n();
3547
4977
  this._standaloneCodeEditor = undefined;
3548
4978
  this._preparingProfile = false;
3549
4979
  this._editorProfile = undefined;
@@ -3574,7 +5004,7 @@ const ArcgisArcadeEditor = class {
3574
5004
  }
3575
5005
  _snippetChanged() {
3576
5006
  arcadeDefaults.updateApiContextForModel(this._modelId, {
3577
- snippets: this.snippets
5007
+ snippets: this.snippets,
3578
5008
  });
3579
5009
  }
3580
5010
  // #endregion
@@ -3623,11 +5053,11 @@ const ArcgisArcadeEditor = class {
3623
5053
  * @internal
3624
5054
  */
3625
5055
  async updateThemeColors(colorRules) {
3626
- const theme = k(this._hostElement);
5056
+ const theme = getElementTheme(this.el);
3627
5057
  updateThemeColors(theme, colorRules);
3628
5058
  if (colorRules === undefined) {
3629
5059
  colorRulesKeys.forEach((key) => {
3630
- this._hostElement.style.removeProperty(`--arcgis-arcade-editor-${key}`);
5060
+ this.el.style.removeProperty(`--arcgis-arcade-editor-${key}`);
3631
5061
  });
3632
5062
  return;
3633
5063
  }
@@ -3636,7 +5066,7 @@ const ArcgisArcadeEditor = class {
3636
5066
  if (!foreground) {
3637
5067
  return;
3638
5068
  }
3639
- this._hostElement.style.setProperty(`--arcgis-arcade-editor-${key}`, foreground);
5069
+ this.el.style.setProperty(`--arcgis-arcade-editor-${key}`, foreground);
3640
5070
  });
3641
5071
  }
3642
5072
  // #endregion
@@ -3648,10 +5078,9 @@ const ArcgisArcadeEditor = class {
3648
5078
  // However, we need to setup the environment before the code editor is instantiated because
3649
5079
  // we need to access the arcade language service to get the api library.
3650
5080
  setupMonacoEnvironment(assetsPath);
3651
- // Starts a locale observer. It will load the correct t9n strings for the component
3652
- // when the locale changes. We also pass updateEditorProfile. It will be invoked the first
3653
- // and on each locale change. The profile has to be refreshed on locale change as well.
3654
- await B(this, assetsPath, async () => await this._updateEditorProfile());
5081
+ await this._updateEditorProfile();
5082
+ // The profile has to be refreshed on locale change
5083
+ this.manager.watch("messages", () => void this._updateEditorProfile().catch(console.error));
3655
5084
  }
3656
5085
  async componentDidLoad() {
3657
5086
  // Mark on component as ready.
@@ -3674,12 +5103,11 @@ const ArcgisArcadeEditor = class {
3674
5103
  if (this.testData) {
3675
5104
  this._executeScript().catch(console.error);
3676
5105
  }
3677
- }
5106
+ },
3678
5107
  });
3679
5108
  await this._codeEditorElt?.setFocus();
3680
5109
  }
3681
5110
  disconnectedCallback() {
3682
- q(this);
3683
5111
  arcadeDefaults.disposeApiContextForModel(this._modelId);
3684
5112
  arcadeDefaults.disposeEditorProfileForModel(this._modelId);
3685
5113
  while (this._disposables.length) {
@@ -3696,8 +5124,8 @@ const ArcgisArcadeEditor = class {
3696
5124
  try {
3697
5125
  // Set a new profile for the model using the profile definition and the locale.
3698
5126
  await arcadeDefaults.setProfileForModel(this._modelId, this.profile, {
3699
- locale: this._t9nLocale,
3700
- snippets: this.snippets
5127
+ locale: this.messages._t9nLocale,
5128
+ snippets: this.snippets,
3701
5129
  });
3702
5130
  // Get the corresponding editor profile for the model.
3703
5131
  // The editor profile contains the specialized profile for the UI.
@@ -3717,7 +5145,7 @@ const ArcgisArcadeEditor = class {
3717
5145
  if (!this.testData) {
3718
5146
  return null;
3719
5147
  }
3720
- return (h("calcite-action-bar", { class: "main-action-bar", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, h("calcite-action-group", { scale: "s" }, h("calcite-action", { text: this._t9nStrings?.run ?? "Run", "text-enabled": true, icon: "play", scale: "s", loading: this._preparingProfile, onClick: this._executeScript }), this._executionResult ? (h("calcite-action", { text: this._t9nStrings?.lastresults ?? "Last results", active: this._showExecutionPanel, "text-enabled": true, icon: "access-string-results", iconFlipRtl: true, scale: "s", onClick: this._toggleShowExecutionPanel })) : null)));
5148
+ return (h("calcite-action-bar", { class: "main-action-bar", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, h("calcite-action-group", { scale: "s" }, h("calcite-action", { text: this.messages.run ?? "Run", "text-enabled": true, icon: "play", scale: "s", loading: this._preparingProfile, onClick: this._executeScript }), this._executionResult ? (h("calcite-action", { text: this.messages.lastresults ?? "Last results", active: this._showExecutionPanel, "text-enabled": true, icon: "access-string-results", iconFlipRtl: true, scale: "s", onClick: this._toggleShowExecutionPanel })) : null)));
3721
5149
  }
3722
5150
  //#endregion
3723
5151
  //#region Render Main Panel
@@ -3726,7 +5154,7 @@ const ArcgisArcadeEditor = class {
3726
5154
  }
3727
5155
  //#endregion
3728
5156
  //#region Rendering the Action Bar
3729
- renderAction({ id, label, icon, active, panelName, onClick = this._toggleSidePanel }) {
5157
+ renderAction({ id, label, icon, active, panelName, onClick = this._toggleSidePanel, }) {
3730
5158
  return (h(Fragment, null, h("calcite-action", { id: id, text: label, icon: icon, active: active, onClick: onClick, "data-panel-name": panelName }), !this.sideActionBarExpanded && (h("calcite-tooltip", { label: label, "reference-element": id }, h("span", null, label)))));
3731
5159
  }
3732
5160
  renderSideActionBar() {
@@ -3735,33 +5163,33 @@ const ArcgisArcadeEditor = class {
3735
5163
  }
3736
5164
  return (h("calcite-action-bar", { class: "side-action-bar border-inline-start", expanded: !!this.sideActionBarExpanded, position: "end", onCalciteActionBarToggle: this._toggleSideActionBarExpanded }, h("calcite-action-group", null, this.renderAction({
3737
5165
  id: "profile-variables-action",
3738
- label: this._t9nStrings?.profilevariables ?? "Profile variables",
5166
+ label: this.messages.profilevariables ?? "Profile variables",
3739
5167
  icon: "profile-variables",
3740
5168
  active: this.openedSidePanel === "variables",
3741
- panelName: "variables"
5169
+ panelName: "variables",
3742
5170
  }), this.renderAction({
3743
5171
  id: "function-action",
3744
- label: this._t9nStrings?.constantsandfunctions ?? "Constants and functions",
5172
+ label: this.messages.constantsandfunctions ?? "Constants and functions",
3745
5173
  icon: "function",
3746
5174
  active: this.openedSidePanel === "api",
3747
- panelName: "api"
5175
+ panelName: "api",
3748
5176
  }), this.suggestions?.length
3749
5177
  ? this.renderAction({
3750
5178
  id: "suggestions-action",
3751
- label: this._t9nStrings?.suggestions ?? "Suggestions",
5179
+ label: this.messages.suggestions ?? "Suggestions",
3752
5180
  icon: "lightbulb",
3753
5181
  active: this.openedSidePanel === "suggestions",
3754
- panelName: "suggestions"
5182
+ panelName: "suggestions",
3755
5183
  })
3756
5184
  : null, this.hideDocumentationActions
3757
5185
  ? null
3758
5186
  : this.renderAction({
3759
5187
  id: "developer-website-action",
3760
- label: this._t9nStrings?.help ?? "Help",
5188
+ label: this.messages.help ?? "Help",
3761
5189
  icon: "question",
3762
5190
  active: false,
3763
5191
  panelName: "none",
3764
- onClick: this._openArcadeHelp
5192
+ onClick: this._openArcadeHelp,
3765
5193
  }))));
3766
5194
  }
3767
5195
  //#endregion
@@ -3795,7 +5223,7 @@ const ArcgisArcadeEditor = class {
3795
5223
  return (h(Host, null, this.renderMainActionBar(), h("div", { class: "flex-row flex-adjustable" }, h("div", { class: "flex-column flex-adjustable" }, this.renderMainPanel(), this.renderResultsPanel()), this.renderSidePanel(), this.renderSideActionBar())));
3796
5224
  }
3797
5225
  static get assetsDirs() { return ["assets"]; }
3798
- get _hostElement() { return getElement(this); }
5226
+ get el() { return getElement(this); }
3799
5227
  static get watchers() { return {
3800
5228
  "profile": ["_profileChanged"],
3801
5229
  "testData": ["_testDataChanged"],
@@ -3804,20 +5232,20 @@ const ArcgisArcadeEditor = class {
3804
5232
  };
3805
5233
  ArcgisArcadeEditor.style = arcadeEditorCss;
3806
5234
 
3807
- const arcadeResultsCss = ":host{display:flex;flex-direction:column;width:100%;background-color:var(--calcite-color-foreground-1);color:var(--calcite-color-text-2)}:host .flex-adjustable{flex:1 1 auto;overflow:hidden}:host .flex-row{display:flex;flex-direction:row;overflow:hidden}:host .flex-column{display:flex;flex-direction:column;overflow:hidden}:host .y-scrollable-container{overflow-y:auto;block-size:100%;background-color:var(--calcite-color-foreground-1)}:host header{border-bottom:1px solid var(--calcite-color-border-3);flex:0 0 auto}:host .ltr-container{direction:ltr}:host calcite-action-bar calcite-action-group{padding-inline-end:var(--calcite-spacing-half)}:host calcite-action-bar calcite-action-group calcite-action{padding-inline-end:var(--calcite-spacing-half)}:host calcite-action-bar calcite-action-group calcite-action:not(:first-child){padding-inline-start:var(--calcite-spacing-half)}:host calcite-action-bar calcite-action-group:last-child{border-inline-end-width:0px}:host calcite-action-bar calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-half)}:host .notice-container{margin:var(--calcite-spacing-quarter);padding:var(--calcite-spacing-half);background-color:var(--calcite-color-foreground-1)}:host .color-info{color:var(--calcite-color-status-info)}:host .color-error{color:var(--calcite-color-status-danger)}:host .color-success{color:var(--calcite-color-status-success)}:host [class*=result-value-]{font-size:var(--calcite-font-size--2);line-height:1.25rem;background-color:var(--calcite-color-foreground-1);margin:var(--calcite-spacing-three-quarter)}:host .console-logs-container{background-color:var(--calcite-color-foreground-1);padding:0 var(--calcite-spacing-three-quarter);font-family:var(--calcite-code-family);font-size:var(--calcite-font-size--2);font-weight:var(--calcite-font-weight-normal)}:host .result-value-table table{display:block;max-width:fit-content;overflow-x:auto;border-spacing:0;border-collapse:collapse;text-align:start;white-space:nowrap}:host .result-value-table table thead{background-color:var(--calcite-color-foreground-2)}:host .result-value-table table tr{border-top:1px solid var(--calcite-color-border-3);border-bottom:1px solid var(--calcite-color-border-3)}:host .result-value-table table th,:host .result-value-table table td{border-inline-start:1px solid var(--calcite-color-border-3);border-inline-end:1px solid var(--calcite-color-border-3);text-align:start;padding:var(--calcite-spacing-quarter)}:host .result-value-table table th .string-value,:host .result-value-table table td .string-value{white-space:pre}:host .result-value-table table th{font-weight:var(--calcite-font-weight-medium)}:host .tree-item-label,:host .number-value,:host .string-value,:host .boolean-value{font-family:var(--calcite-code-family)}:host .tree-item-label,:host .value-type{color:var(--calcite-color-text-2);font-weight:var(--calcite-font-weight-normal)}:host .dictionary-property{color:var(--arcgis-arcade-editor-identifier)}:host .number-value{color:var(--arcgis-arcade-editor-number)}:host .string-value{color:var(--arcgis-arcade-editor-string);white-space:pre-wrap}:host .constant-value{color:var(--arcgis-arcade-editor-constant)}:host .date-value{color:var(--arcgis-arcade-editor-date)}";
5235
+ const arcadeResultsCss = ":host{display:flex;flex-direction:column;width:100%;background-color:var(--calcite-color-foreground-1);color:var(--calcite-color-text-2)}:host .flex-adjustable{flex:1 1 auto;overflow:hidden}:host .flex-row{display:flex;flex-direction:row;overflow:hidden}:host .flex-column{display:flex;flex-direction:column;overflow:hidden}:host .y-scrollable-container{overflow-y:auto;block-size:100%;background-color:var(--calcite-color-foreground-1)}:host header{border-bottom:1px solid var(--calcite-color-border-3);flex:0 0 auto}:host .ltr-container{direction:ltr}:host calcite-action-bar calcite-action-group{padding-inline-end:var(--calcite-spacing-sm)}:host calcite-action-bar calcite-action-group calcite-action{padding-inline-end:var(--calcite-spacing-sm)}:host calcite-action-bar calcite-action-group calcite-action:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}:host calcite-action-bar calcite-action-group:last-child{border-inline-end-width:0px}:host calcite-action-bar calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}:host .notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}:host .color-info{color:var(--calcite-color-status-info)}:host .color-error{color:var(--calcite-color-status-danger)}:host .color-success{color:var(--calcite-color-status-success)}:host [class*=result-value-]{font-size:var(--calcite-font-size--2);line-height:1.25rem;background-color:var(--calcite-color-foreground-1);margin:var(--calcite-spacing-md)}:host .console-logs-container{background-color:var(--calcite-color-foreground-1);padding:0 var(--calcite-spacing-md);font-family:var(--calcite-code-family);font-size:var(--calcite-font-size--2);font-weight:var(--calcite-font-weight-normal)}:host .result-value-table table{display:block;max-width:fit-content;overflow-x:auto;border-spacing:0;border-collapse:collapse;text-align:start;white-space:nowrap}:host .result-value-table table thead{background-color:var(--calcite-color-foreground-2)}:host .result-value-table table tr{border-top:1px solid var(--calcite-color-border-3);border-bottom:1px solid var(--calcite-color-border-3)}:host .result-value-table table th,:host .result-value-table table td{border-inline-start:1px solid var(--calcite-color-border-3);border-inline-end:1px solid var(--calcite-color-border-3);text-align:start;padding:var(--calcite-spacing-xxs)}:host .result-value-table table th .string-value,:host .result-value-table table td .string-value{white-space:pre}:host .result-value-table table th{font-weight:var(--calcite-font-weight-medium)}:host .tree-item-label,:host .number-value,:host .string-value,:host .boolean-value{font-family:var(--calcite-code-family)}:host .tree-item-label,:host .value-type{color:var(--calcite-color-text-2);font-weight:var(--calcite-font-weight-normal)}:host .dictionary-property{color:var(--arcgis-arcade-editor-identifier)}:host .number-value{color:var(--arcgis-arcade-editor-number)}:host .string-value{color:var(--arcgis-arcade-editor-string);white-space:pre-wrap}:host .constant-value{color:var(--arcgis-arcade-editor-constant)}:host .date-value{color:var(--arcgis-arcade-editor-date)}";
3808
5236
 
3809
5237
  //#region Specialized Constants
3810
5238
  const treeProps = {
3811
5239
  lines: true,
3812
5240
  selectionMode: "none",
3813
5241
  scale: "s",
3814
- onCalciteTreeSelect: (e) => e.target.selectedItems.forEach((itemElt) => (itemElt.selected = false))
5242
+ onCalciteTreeSelect: (e) => e.target.selectedItems.forEach((itemElt) => (itemElt.selected = false)),
3815
5243
  };
3816
5244
  const expandableTreeItemProps = {
3817
5245
  onClick: (e) => {
3818
5246
  const item = e.currentTarget;
3819
5247
  item.expanded = !item.expanded;
3820
- }
5248
+ },
3821
5249
  };
3822
5250
  //#endregion
3823
5251
  //#region Helper Functions
@@ -3836,7 +5264,7 @@ function renderSimpleValue(arcadeResult) {
3836
5264
  case "null":
3837
5265
  return h("span", { class: "constant-value" }, arcadeResult.type);
3838
5266
  case "text":
3839
- return h("span", { class: "string-value" }, D(arcadeResult.value));
5267
+ return h("span", { class: "string-value" }, quoteString(arcadeResult.value));
3840
5268
  case "number":
3841
5269
  return h("span", { class: "number-value" }, arcadeResult.value.toString());
3842
5270
  case "boolean":
@@ -3844,9 +5272,9 @@ function renderSimpleValue(arcadeResult) {
3844
5272
  case "date":
3845
5273
  return h("span", { class: "date-value" }, formatArcadeResultDate(arcadeResult));
3846
5274
  case "dateOnly":
3847
- return h("span", { class: "string-value" }, D(formatArcadeResultDateOnly(arcadeResult)));
5275
+ return h("span", { class: "string-value" }, quoteString(formatArcadeResultDateOnly(arcadeResult)));
3848
5276
  case "time":
3849
- return h("span", { class: "string-value" }, D(formatArcadeResultTimeOnly(arcadeResult)));
5277
+ return h("span", { class: "string-value" }, quoteString(formatArcadeResultTimeOnly(arcadeResult)));
3850
5278
  default:
3851
5279
  return null;
3852
5280
  }
@@ -3868,6 +5296,9 @@ const ArcgisArcadeResults = class {
3868
5296
  registerInstance(this, hostRef);
3869
5297
  this.openedResultPanelChange = createEvent(this, "openedResultPanelChange", 3);
3870
5298
  this.close = createEvent(this, "close", 3);
5299
+ this.manager = useControllerManager(this);
5300
+ //#region Private Properties
5301
+ this.messages = useT9n();
3871
5302
  this._switchResultPanel = (e) => {
3872
5303
  if (!e.target) {
3873
5304
  return;
@@ -3879,23 +5310,12 @@ const ArcgisArcadeResults = class {
3879
5310
  this.updateResultPanel(panelName);
3880
5311
  };
3881
5312
  this._emitClose = () => this.close.emit();
3882
- this._lang = "";
3883
- this._t9nLocale = "";
3884
- this._t9nStrings = undefined;
3885
5313
  this.loading = true;
3886
5314
  this.openedResultPanel = "output";
3887
5315
  this.result = undefined;
3888
5316
  this.consoleLogs = undefined;
3889
5317
  }
3890
5318
  //#endregion
3891
- // #region Component lifecycle events
3892
- async componentWillLoad() {
3893
- await B(this, getAssetPath("./assets"));
3894
- }
3895
- disconnectedCallback() {
3896
- q(this);
3897
- }
3898
- // #endregion
3899
5319
  //#region Private Methods
3900
5320
  updateResultPanel(resultPanelType) {
3901
5321
  this.openedResultPanel = resultPanelType;
@@ -3910,7 +5330,7 @@ const ArcgisArcadeResults = class {
3910
5330
  if (this.loading && !this.consoleLogs?.length) {
3911
5331
  return h("calcite-loader", { scale: "s", type: "indeterminate", label: "" });
3912
5332
  }
3913
- return (h("div", { class: "console-logs-container ltr-container" }, this.consoleLogs?.length ? (this.consoleLogs.map((log) => h("p", null, log))) : (h("p", null, this._t9nStrings?.consolemessage))));
5333
+ return (h("div", { class: "console-logs-container ltr-container" }, this.consoleLogs?.length ? this.consoleLogs.map((log) => h("p", null, log)) : h("p", null, this.messages.consolemessage)));
3914
5334
  }
3915
5335
  renderLogPanel() {
3916
5336
  if (this.openedResultPanel !== "log") {
@@ -3920,24 +5340,24 @@ const ArcgisArcadeResults = class {
3920
5340
  return h("calcite-loader", { scale: "s", type: "indeterminate", label: "" });
3921
5341
  }
3922
5342
  const iconClass = this.result?.type === "error" ? "color-error" : "color-success";
3923
- return (h("calcite-list", null, this.result ? (h(Fragment, null, h("calcite-list-item", { label: Z(this._t9nStrings?.lastexecutionformat, {
3924
- timeStamp: new Intl.DateTimeFormat(this._t9nLocale, {
5343
+ return (h("calcite-list", null, this.result ? (h(Fragment, null, h("calcite-list-item", { label: setValuesInString(this.messages.lastexecutionformat, {
5344
+ timeStamp: new Intl.DateTimeFormat(this.messages._t9nLocale, {
3925
5345
  dateStyle: "medium",
3926
- timeStyle: "medium"
3927
- }).format(this.result.timeStamp)
3928
- }) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), h("calcite-list-item", { label: Z(this._t9nStrings?.compilationtimeformat, {
3929
- time: new Intl.NumberFormat(this._t9nLocale, {
5346
+ timeStyle: "medium",
5347
+ }).format(this.result.timeStamp),
5348
+ }) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), h("calcite-list-item", { label: setValuesInString(this.messages.compilationtimeformat, {
5349
+ time: new Intl.NumberFormat(this.messages._t9nLocale, {
3930
5350
  style: "unit",
3931
5351
  unit: "millisecond",
3932
- maximumFractionDigits: 2
3933
- }).format(this.result.compilationTime ?? 0)
3934
- }) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), h("calcite-list-item", { label: Z(this._t9nStrings?.executiontimeformat, {
3935
- time: new Intl.NumberFormat(this._t9nLocale, {
5352
+ maximumFractionDigits: 2,
5353
+ }).format(this.result.compilationTime ?? 0),
5354
+ }) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), h("calcite-list-item", { label: setValuesInString(this.messages.executiontimeformat, {
5355
+ time: new Intl.NumberFormat(this.messages._t9nLocale, {
3936
5356
  style: "unit",
3937
5357
  unit: "millisecond",
3938
- maximumFractionDigits: 2
3939
- }).format(this.result.executionTime ?? 0)
3940
- }) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })))) : (h("calcite-list-item", { label: this._t9nStrings?.runscriptmessage ?? "No output, run the script once." }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: "color-info" })))));
5358
+ maximumFractionDigits: 2,
5359
+ }).format(this.result.executionTime ?? 0),
5360
+ }) }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })))) : (h("calcite-list-item", { label: this.messages.runscriptmessage ?? "No output, run the script once." }, h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: "color-info" })))));
3941
5361
  }
3942
5362
  renderOutputPanel() {
3943
5363
  if (this.openedResultPanel !== "output") {
@@ -3948,8 +5368,8 @@ const ArcgisArcadeResults = class {
3948
5368
  }
3949
5369
  switch (this.result?.type) {
3950
5370
  case "error":
3951
- return (h("div", { class: "result-value-simple flex-adjustable" }, Z(this._t9nStrings?.executionerrorformat, {
3952
- message: this.result.value
5371
+ return (h("div", { class: "result-value-simple flex-adjustable" }, setValuesInString(this.messages.executionerrorformat, {
5372
+ message: this.result.value,
3953
5373
  })));
3954
5374
  case "null":
3955
5375
  case "unknown":
@@ -3979,14 +5399,14 @@ const ArcgisArcadeResults = class {
3979
5399
  case "knowledgeGraph":
3980
5400
  return (h("div", { class: "result-value-simple ltr-container" }, h("span", { class: "value-type" }, this.result.type, ":\u00A0"), h("span", { class: "string-value" }, this.result.value.url)));
3981
5401
  default:
3982
- return (h("div", { class: "result-value-simple flex-adjustable ltr-container" }, this._t9nStrings?.runscriptmessage));
5402
+ return h("div", { class: "result-value-simple flex-adjustable ltr-container" }, this.messages.runscriptmessage);
3983
5403
  }
3984
5404
  }
3985
5405
  renderArrayHeader(arcadeResult) {
3986
5406
  const items = arcadeResult.value ?? [];
3987
5407
  const leftoverCount = Math.max(items.length - MaxArrayItems, 0);
3988
- return (h(Fragment, null, h("span", null, `${arcadeResult.type}(${items.length ?? 0})`), leftoverCount > 0 ? (h("span", null, "\u00A0", Z(this._t9nStrings?.showingfirstitemsformat, {
3989
- count: MaxArrayItems.toString()
5408
+ return (h(Fragment, null, h("span", null, `${arcadeResult.type}(${items.length ?? 0})`), leftoverCount > 0 ? (h("span", null, "\u00A0", setValuesInString(this.messages.showingfirstitemsformat, {
5409
+ count: MaxArrayItems.toString(),
3990
5410
  }))) : null));
3991
5411
  }
3992
5412
  renderArrayTree(items, subtree = false) {
@@ -4031,15 +5451,15 @@ const ArcgisArcadeResults = class {
4031
5451
  }
4032
5452
  }
4033
5453
  renderFeatureSetLabel(arcadeResult) {
4034
- return (h("div", { class: "value-type" }, h("span", null, arcadeResult.type, ":"), arcadeResult.features.length >= BatchSize ? (h("span", null, "\u00A0", Z(this._t9nStrings?.showingfirstitemsformat, {
4035
- count: BatchSize.toString()
5454
+ return (h("div", { class: "value-type" }, h("span", null, arcadeResult.type, ":"), arcadeResult.features.length >= BatchSize ? (h("span", null, "\u00A0", setValuesInString(this.messages.showingfirstitemsformat, {
5455
+ count: BatchSize.toString(),
4036
5456
  }))) : null));
4037
5457
  }
4038
5458
  render() {
4039
- return (h(Host, null, h("header", { class: "flex-row" }, h("calcite-action-bar", { class: "flex-adjustable", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, h("calcite-action-group", { scale: "s" }, h("calcite-action", { active: this.openedResultPanel === "output", text: this._t9nStrings?.output ?? "Output", "text-enabled": true, scale: "s", icon: "list-show-all", iconFlipRtl: true, onClick: this._switchResultPanel, "data-panel-name": "output" }), h("calcite-action", { active: this.openedResultPanel === "console", text: this._t9nStrings?.console ?? "Console", "text-enabled": true, scale: "s", icon: "console", iconFlipRtl: true, onClick: this._switchResultPanel, "data-panel-name": "console" }), h("calcite-action", { active: this.openedResultPanel === "log", text: this._t9nStrings?.log ?? "Log", "text-enabled": true, scale: "s", icon: "list", iconFlipRtl: true, onClick: this._switchResultPanel, "data-panel-name": "log" }))), h("calcite-action", { scale: "s", icon: "x", text: this._t9nStrings?.close ?? "", onClick: this._emitClose })), h("article", { class: "flex-adjustable" }, this.loading ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: "" })) : (h("div", { class: "flex-column y-scrollable-container" }, this.renderOutputPanel(), this.renderConsolePanel(), this.renderLogPanel())))));
5459
+ return (h(Host, null, h("header", { class: "flex-row" }, h("calcite-action-bar", { class: "flex-adjustable", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, h("calcite-action-group", { scale: "s" }, h("calcite-action", { active: this.openedResultPanel === "output", text: this.messages.output ?? "Output", "text-enabled": true, scale: "s", icon: "list-show-all", iconFlipRtl: true, onClick: this._switchResultPanel, "data-panel-name": "output" }), h("calcite-action", { active: this.openedResultPanel === "console", text: this.messages.console ?? "Console", "text-enabled": true, scale: "s", icon: "console", iconFlipRtl: true, onClick: this._switchResultPanel, "data-panel-name": "console" }), h("calcite-action", { active: this.openedResultPanel === "log", text: this.messages.log ?? "Log", "text-enabled": true, scale: "s", icon: "list", iconFlipRtl: true, onClick: this._switchResultPanel, "data-panel-name": "log" }))), h("calcite-action", { scale: "s", icon: "x", text: this.messages.close ?? "", onClick: this._emitClose })), h("article", { class: "flex-adjustable" }, this.loading ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: "" })) : (h("div", { class: "flex-column y-scrollable-container" }, this.renderOutputPanel(), this.renderConsolePanel(), this.renderLogPanel())))));
4040
5460
  }
4041
5461
  static get assetsDirs() { return ["assets"]; }
4042
- get _hostElement() { return getElement(this); }
5462
+ get el() { return getElement(this); }
4043
5463
  };
4044
5464
  ArcgisArcadeResults.style = arcadeResultsCss;
4045
5465
 
@@ -4053,13 +5473,15 @@ function isSuggestionGroups(item) {
4053
5473
  return Array.isArray(item[0].suggestions);
4054
5474
  }
4055
5475
 
4056
- const arcadeSuggestionsCss = ":host{background-color:var(--calcite-color-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-quarter);padding:var(--calcite-spacing-half);background-color:var(--calcite-color-foreground-1)}:host .sticky{position:sticky;top:0px;z-index:10}:host calcite-flow{height:100%}:host calcite-block p:first-of-type{margin-top:0}:host calcite-block code{font-family:var(--calcite-code-family)}:host calcite-block pre{direction:ltr;overflow-x:auto;background-color:var(--calcite-color-foreground-2);padding:var(--calcite-spacing-half)}:host calcite-block pre code{font-size:var(--calcite-font-size--2)}";
5476
+ const arcadeSuggestionsCss = ":host{background-color:var(--calcite-color-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}:host .sticky{position:sticky;top:0px;z-index:10}:host calcite-flow{height:100%}:host calcite-block p:first-of-type{margin-top:0}:host calcite-block code{font-family:var(--calcite-code-family)}:host calcite-block pre{direction:ltr;overflow-x:auto;background-color:var(--calcite-color-foreground-2);padding:var(--calcite-spacing-sm)}:host calcite-block pre code{font-size:var(--calcite-font-size--2)}";
4057
5477
 
4058
5478
  const ArcgisArcadeSuggestions = class {
4059
5479
  constructor(hostRef) {
4060
5480
  registerInstance(this, hostRef);
4061
5481
  this.close = createEvent(this, "close", 3);
4062
5482
  this.itemSelected = createEvent(this, "itemSelected", 3);
5483
+ this.manager = useControllerManager(this);
5484
+ this.messages = useT9n();
4063
5485
  this._updateFilterValue = (e) => {
4064
5486
  this._filterValue = e.target?.value ?? "";
4065
5487
  };
@@ -4088,9 +5510,6 @@ const ArcgisArcadeSuggestions = class {
4088
5510
  this._beforeBack = async () => {
4089
5511
  this._selectedSuggestion = undefined;
4090
5512
  };
4091
- this._lang = "";
4092
- this._t9nLocale = "";
4093
- this._t9nStrings = undefined;
4094
5513
  this._selectedSuggestion = undefined;
4095
5514
  this._filterValue = "";
4096
5515
  this._colorizeStyle = "";
@@ -4104,12 +5523,10 @@ const ArcgisArcadeSuggestions = class {
4104
5523
  async componentWillLoad() {
4105
5524
  this._colorizeStyle = generateColorizeStyles();
4106
5525
  this._themeChangedListner = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
4107
- await B(this, getAssetPath("./assets"));
4108
5526
  }
4109
5527
  disconnectedCallback() {
4110
5528
  this._flowObserver?.disconnect();
4111
5529
  this._themeChangedListner?.dispose();
4112
- q(this);
4113
5530
  }
4114
5531
  // #endregion
4115
5532
  //#region Private Methods
@@ -4127,7 +5544,7 @@ const ArcgisArcadeSuggestions = class {
4127
5544
  // When switching between flow the same reference is reused
4128
5545
  this._flowObserver = new MutationObserver(() => {
4129
5546
  // Get the last panel and try to set focus on the input element
4130
- W(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
5547
+ setFocusOnElement(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
4131
5548
  });
4132
5549
  this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
4133
5550
  }
@@ -4145,29 +5562,29 @@ const ArcgisArcadeSuggestions = class {
4145
5562
  renderSuggestionListItems(suggestions) {
4146
5563
  suggestions = filterCollection(suggestions, "label", this._filterValue);
4147
5564
  if (!suggestions.length) {
4148
- return h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No item");
5565
+ return h("div", { class: "notice-container" }, this.messages.noitems ?? "No item");
4149
5566
  }
4150
- return suggestions.map((suggestion) => (h("calcite-list-item", { label: suggestion.label, description: suggestion.description, onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": suggestion }, h("calcite-action", { slot: "actions-end", text: this._t9nStrings?.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showSuggestionDetail, "data-item": suggestion }))));
5567
+ return suggestions.map((suggestion) => (h("calcite-list-item", { label: suggestion.label, description: suggestion.description, onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": suggestion }, h("calcite-action", { slot: "actions-end", text: this.messages.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showSuggestionDetail, "data-item": suggestion }))));
4151
5568
  }
4152
5569
  renderSuggestionFlowItem() {
4153
5570
  const suggestion = this._selectedSuggestion;
4154
5571
  if (!suggestion) {
4155
5572
  return null;
4156
5573
  }
4157
- return (h("calcite-flow-item", { heading: this._t9nStrings?.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose, beforeBack: this._beforeBack }, h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", "icon-start": "code", scale: "s", onClick: this._emitItemSelected, ref: (e) => void e?.setFocus(), "data-item": suggestion }, this._t9nStrings?.insert), h("calcite-block", { open: true, heading: suggestion.label, description: suggestion.description }, h("div", { innerHTML: convertMarkdownString(suggestion.documentation) }), h("pre", null, h("code", { ref: (e) => e === undefined ? undefined : void colorizeCodeElement(e, suggestion.code).catch(console.error) })))));
5574
+ return (h("calcite-flow-item", { heading: this.messages.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose, beforeBack: this._beforeBack }, h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", "icon-start": "code", scale: "s", onClick: this._emitItemSelected, ref: (e) => void e?.setFocus(), "data-item": suggestion }, this.messages.insert), h("calcite-block", { open: true, heading: suggestion.label, description: suggestion.description }, h("div", { innerHTML: convertMarkdownString(suggestion.documentation) }), h("pre", null, h("code", { ref: (e) => e === undefined ? undefined : void colorizeCodeElement(e, suggestion.code).catch(console.error) })))));
4158
5575
  }
4159
5576
  render() {
4160
- return (h(Host, null, h("style", null, this._colorizeStyle), h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, h("calcite-flow-item", { heading: this._t9nStrings?.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose }, h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), h("calcite-list", null, this.renderSuggestionGroups())), this.renderSuggestionFlowItem())));
5577
+ return (h(Host, null, h("style", null, this._colorizeStyle), h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, h("calcite-flow-item", { heading: this.messages.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose }, h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), h("calcite-list", null, this.renderSuggestionGroups())), this.renderSuggestionFlowItem())));
4161
5578
  }
4162
5579
  static get assetsDirs() { return ["assets"]; }
4163
- get _hostElement() { return getElement(this); }
5580
+ get el() { return getElement(this); }
4164
5581
  static get watchers() { return {
4165
5582
  "suggestions": ["suggestionsPropChanged"]
4166
5583
  }; }
4167
5584
  };
4168
5585
  ArcgisArcadeSuggestions.style = arcadeSuggestionsCss;
4169
5586
 
4170
- const arcadeVariablesCss = ":host{background-color:var(--calcite-color-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-quarter);padding:var(--calcite-spacing-half);background-color:var(--calcite-color-foreground-1)}:host .sticky{position:sticky;top:0px;z-index:10}:host calcite-flow{height:100%}";
5587
+ const arcadeVariablesCss = ":host{background-color:var(--calcite-color-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}:host .sticky{position:sticky;top:0px;z-index:10}:host calcite-flow{height:100%}";
4171
5588
 
4172
5589
  function stopEnterPropagation(e) {
4173
5590
  if (e.key === "Enter") {
@@ -4179,6 +5596,8 @@ const ArcgisArcadeVariables = class {
4179
5596
  registerInstance(this, hostRef);
4180
5597
  this.close = createEvent(this, "close", 3);
4181
5598
  this.itemSelected = createEvent(this, "itemSelected", 3);
5599
+ this.manager = useControllerManager(this);
5600
+ this.messages = useT9n();
4182
5601
  this._updateFilterValue = (e) => {
4183
5602
  this._filterValue = e.target.value;
4184
5603
  };
@@ -4211,9 +5630,6 @@ const ArcgisArcadeVariables = class {
4211
5630
  e.stopPropagation();
4212
5631
  this.addPanelRenderer(this.collectionBasedVariableRenderer(collectionVariable));
4213
5632
  };
4214
- this._lang = "";
4215
- this._t9nLocale = "";
4216
- this._t9nStrings = undefined;
4217
5633
  this._mutationCounter = 1;
4218
5634
  this._flowItemRenderers = [];
4219
5635
  this._filterValue = "";
@@ -4224,12 +5640,7 @@ const ArcgisArcadeVariables = class {
4224
5640
  this._flowItemRenderers = [];
4225
5641
  }
4226
5642
  //#endregion
4227
- // #region Component lifecycle events
4228
- async componentWillLoad() {
4229
- await B(this, getAssetPath("./assets"));
4230
- }
4231
5643
  disconnectedCallback() {
4232
- q(this);
4233
5644
  this._flowObserver?.disconnect();
4234
5645
  }
4235
5646
  // #endregion
@@ -4254,7 +5665,7 @@ const ArcgisArcadeVariables = class {
4254
5665
  // When switching between flow the same reference is reused
4255
5666
  this._flowObserver = new MutationObserver(() => {
4256
5667
  // Get the last panel and try to set focus on the input element
4257
- W(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
5668
+ setFocusOnElement(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
4258
5669
  });
4259
5670
  this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
4260
5671
  }
@@ -4283,15 +5694,15 @@ const ArcgisArcadeVariables = class {
4283
5694
  });
4284
5695
  loading = true;
4285
5696
  }
4286
- return (h("calcite-flow-item", { heading: this._t9nStrings?.profilevariables, description: collection.breadcrumb, beforeBack: this._beforeBack, closable: true, onCalciteFlowItemClose: this._emitClose }, h("calcite-action", { slot: "header-actions-end", text: this._t9nStrings?.backtotop ?? "Back to top", scale: "m", hidden: topPanel, icon: "chevrons-left", iconFlipRtl: true, onClick: this._backToTop }), h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), loading ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: this._t9nStrings?.loading ?? "Loading" })) : (h("calcite-list", null, this.renderEditorVariables(collection)))));
5697
+ return (h("calcite-flow-item", { heading: this.messages.profilevariables, description: collection.breadcrumb, beforeBack: this._beforeBack, closable: true, onCalciteFlowItemClose: this._emitClose }, h("calcite-action", { slot: "header-actions-end", text: this.messages.backtotop ?? "Back to top", scale: "m", hidden: topPanel, icon: "chevrons-left", iconFlipRtl: true, onClick: this._backToTop }), h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), loading ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: this.messages.loading ?? "Loading" })) : (h("calcite-list", null, this.renderEditorVariables(collection)))));
4287
5698
  };
4288
5699
  }
4289
5700
  renderEditorVariables(collection) {
4290
5701
  // Filter the variables. Skip group, we will filter the children later on.
4291
- const filterExpression = K(this._filterValue);
5702
+ const filterExpression = createFilterExpression(this._filterValue);
4292
5703
  const filteredVariables = collection.variables.filter((variable) => variable.passFilter(filterExpression));
4293
5704
  if (!filteredVariables.length) {
4294
- return h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No item");
5705
+ return h("div", { class: "notice-container" }, this.messages.noitems ?? "No item");
4295
5706
  }
4296
5707
  return filteredVariables.map((variable) => this.renderEditorVariable(variable));
4297
5708
  }
@@ -4301,18 +5712,18 @@ const ArcgisArcadeVariables = class {
4301
5712
  // Group is a collection but we represent it differently
4302
5713
  return (h("calcite-list-item-group", { heading: variable.getLabel() }, this.renderEditorVariables(variable)));
4303
5714
  default:
4304
- return (h("calcite-list-item", { label: variable.getLabel(), description: variable.getDescription(), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": variable }, variable.isCollection ? (h("calcite-action", { slot: "actions-end", text: this._t9nStrings?.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showCollectionPanel, onKeyPress: stopEnterPropagation, "data-item": variable })) : null, variable.icon ? h("calcite-icon", { icon: variable.icon, scale: "s", slot: "content-start" }) : null));
5715
+ return (h("calcite-list-item", { label: variable.getLabel(), description: variable.getDescription(), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": variable }, variable.isCollection ? (h("calcite-action", { slot: "actions-end", text: this.messages.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showCollectionPanel, onKeyPress: stopEnterPropagation, "data-item": variable })) : null, variable.icon ? h("calcite-icon", { icon: variable.icon, scale: "s", slot: "content-start" }) : null));
4305
5716
  }
4306
5717
  }
4307
5718
  render() {
4308
5719
  const profile = arcadeDefaults.getEditorProfileForModel(this.modelId ?? "");
4309
5720
  if (!this.loading && !profile?.variables.length) {
4310
- return (h("calcite-flow", null, h("calcite-flow-item", { heading: this._t9nStrings?.profilevariables, closable: true, onCalciteFlowItemClose: this._emitClose }, h("div", { class: "notice-container" }, this._t9nStrings?.noprofilevariablesmessage ?? ""))));
5721
+ return (h("calcite-flow", null, h("calcite-flow-item", { heading: this.messages.profilevariables, closable: true, onCalciteFlowItemClose: this._emitClose }, h("div", { class: "notice-container" }, this.messages.noprofilevariablesmessage ?? ""))));
4311
5722
  }
4312
5723
  return (h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, this.collectionBasedVariableRenderer(profile, true)(), this._flowItemRenderers.map((renderer) => renderer())));
4313
5724
  }
4314
5725
  static get assetsDirs() { return ["assets"]; }
4315
- get _hostElement() { return getElement(this); }
5726
+ get el() { return getElement(this); }
4316
5727
  static get watchers() { return {
4317
5728
  "modelId": ["modelIdPropChanged"]
4318
5729
  }; }
@@ -4330,20 +5741,20 @@ const EditorOptionsDefaults = {
4330
5741
  renderLineHighlight: "none",
4331
5742
  suggest: {
4332
5743
  snippetsPreventQuickSuggestions: false,
4333
- showWords: false
5744
+ showWords: false,
4334
5745
  },
4335
5746
  tabSize: 2,
4336
- useShadowDOM: true
5747
+ useShadowDOM: true,
4337
5748
  };
4338
5749
  const ArcgisCodeEditor = class {
4339
5750
  constructor(hostRef) {
4340
5751
  registerInstance(this, hostRef);
4341
5752
  this.valueChange = createEvent(this, "valueChange", 3);
4342
- this._componentReadyDefer = new h$1();
5753
+ this._componentReadyDefer = new Deferred$1();
4343
5754
  this._disposables = [];
4344
5755
  this.value = undefined;
4345
5756
  this.language = undefined;
4346
- this.modelId = U();
5757
+ this.modelId = generateGuid();
4347
5758
  this.options = undefined;
4348
5759
  }
4349
5760
  valuePropChange(newValue) {
@@ -4471,7 +5882,7 @@ const ArcgisCodeEditor = class {
4471
5882
  ...(this.options ?? {}),
4472
5883
  model,
4473
5884
  fixedOverflowWidgets: true,
4474
- scrollBeyondLastLine: false
5885
+ scrollBeyondLastLine: false,
4475
5886
  });
4476
5887
  this._disposables.push(this._editorInstance);
4477
5888
  // Set the value now to trigger a diagnostic again
@@ -4485,7 +5896,7 @@ const ArcgisCodeEditor = class {
4485
5896
  this.valueChange.emit(script);
4486
5897
  });
4487
5898
  // Detect if the host element or its ancestors got a theme attribute mutation
4488
- this._themeObserver = x(this._hostElt, ["class"], () => this.updateTheme());
5899
+ this._themeObserver = observeAncestorsMutation$1(this._hostElt, ["class"], () => this.updateTheme());
4489
5900
  // Update the theme of the Monaco Editor
4490
5901
  this.updateTheme();
4491
5902
  // Creates a resize observer to re-layout the editor on size changing
@@ -4498,7 +5909,7 @@ const ArcgisCodeEditor = class {
4498
5909
  while (this._disposables.length) {
4499
5910
  this._disposables.pop()?.dispose();
4500
5911
  }
4501
- this._themeObserver?.disconnect();
5912
+ this._themeObserver?.remove();
4502
5913
  }
4503
5914
  //#endregion
4504
5915
  // #region Private methods API
@@ -4516,7 +5927,7 @@ const ArcgisCodeEditor = class {
4516
5927
  // This is called the first time and subsequently by the Mutation Observer
4517
5928
  // Figure out the theme by walking the ancestor path.
4518
5929
  // If no theme is found then default to light.
4519
- const theme = k(this._hostElt) === "light" ? "vs" : "vs-dark";
5930
+ const theme = getElementTheme(this._hostElt) === "light" ? "vs" : "vs-dark";
4520
5931
  if (theme === this._currentTheme) {
4521
5932
  return;
4522
5933
  }
@@ -4541,7 +5952,7 @@ const ArcgisCodeEditor = class {
4541
5952
  contextMenuOrder: 1,
4542
5953
  // Method that will be executed when the action is triggered.
4543
5954
  // @param editor The editor instance is passed in as a convenience
4544
- run: async () => await zoomInFn?.run()
5955
+ run: async () => await zoomInFn?.run(),
4545
5956
  });
4546
5957
  this._editorInstance?.addAction({
4547
5958
  id: "editor.action.fontZoomOut",
@@ -4549,7 +5960,7 @@ const ArcgisCodeEditor = class {
4549
5960
  keybindings: [KeyMod.CtrlCmd | KeyCode.Minus],
4550
5961
  contextMenuGroupId: "zooming",
4551
5962
  contextMenuOrder: 2,
4552
- run: async () => await zoomOutFn?.run()
5963
+ run: async () => await zoomOutFn?.run(),
4553
5964
  });
4554
5965
  }
4555
5966
  //#endregion