@arcgis/coding-components 4.30.0-next.4 → 4.30.0-next.40

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 (132) 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-c7bb7c6a.js → p-1653b162.js} +2 -2
  51. package/dist/arcgis-coding-components/{p-78220a75.js → p-23558e30.js} +2 -2
  52. package/dist/arcgis-coding-components/{p-25023832.js → p-5d7eed5c.js} +3 -3
  53. package/dist/arcgis-coding-components/p-65b666c8.js +7 -0
  54. package/dist/arcgis-coding-components/{p-cd9e95f9.js → p-749ed871.js} +2 -2
  55. package/dist/arcgis-coding-components/{p-08f272e7.js → p-8eaff8ec.js} +3 -3
  56. package/dist/arcgis-coding-components/p-8ff03bd1.entry.js +6 -0
  57. package/dist/arcgis-coding-components/{p-4d158786.js → p-922df385.js} +2 -2
  58. package/dist/arcgis-coding-components/{p-73e2476b.js → p-9735b66c.js} +2 -2
  59. package/dist/arcgis-coding-components/{p-b63557ba.js → p-bf1ba8d4.js} +2 -2
  60. package/dist/arcgis-coding-components/{p-e88c0d1d.js → p-c49852a4.js} +1 -1
  61. package/dist/arcgis-coding-components/p-ef6760f3.js +68 -0
  62. package/dist/cjs/{arcade-defaults-d41420df.js → arcade-defaults-11bd4fd0.js} +481 -160
  63. package/dist/cjs/{arcade-mode-55360f90.js → arcade-mode-88678d5f.js} +45 -51
  64. package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +1655 -232
  65. package/dist/cjs/arcgis-coding-components.cjs.js +3 -3
  66. package/dist/cjs/{css-9a006c1a.js → css-e76d50a6.js} +1 -1
  67. package/dist/cjs/{cssMode-c9458ea4.js → cssMode-c03af136.js} +3 -3
  68. package/dist/cjs/{html-45d9defe.js → html-4f60da43.js} +3 -3
  69. package/dist/cjs/{htmlMode-1716753f.js → htmlMode-92c12a89.js} +3 -3
  70. package/dist/cjs/{index-25b044b5.js → index-ddb7b8ae.js} +42 -4
  71. package/dist/cjs/index.cjs.js +3 -3
  72. package/dist/cjs/{javascript-9ce57501.js → javascript-81f722d2.js} +4 -4
  73. package/dist/cjs/{jsonMode-3945e8f7.js → jsonMode-fc58459d.js} +3 -3
  74. package/dist/cjs/loader.cjs.js +3 -3
  75. package/dist/cjs/{tsMode-7eaeb36b.js → tsMode-9cfa1c84.js} +3 -3
  76. package/dist/cjs/{typescript-ec5da0c4.js → typescript-96de25d8.js} +3 -3
  77. package/dist/components/arcade-api.js +19 -31
  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 +46 -60
  82. package/dist/components/arcade-suggestions.js +19 -30
  83. package/dist/components/arcade-variables.js +20 -35
  84. package/dist/components/arcgis-arcade-api.js +1 -1
  85. package/dist/components/arcgis-arcade-editor.js +48 -140
  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-HXHHCYA6.js +1460 -0
  93. package/dist/components/code-editor.js +16 -16
  94. package/dist/components/fields.js +2 -66
  95. package/dist/components/index.js +1 -1
  96. package/dist/components/index2.js +388 -3
  97. package/dist/components/markdown.js +9 -11
  98. package/dist/components/utilities.js +3 -3
  99. package/dist/esm/{arcade-defaults-0bce2095.js → arcade-defaults-690c65b0.js} +468 -147
  100. package/dist/esm/{arcade-mode-57782d19.js → arcade-mode-88a880fd.js} +45 -51
  101. package/dist/esm/arcgis-arcade-api_6.entry.js +1655 -232
  102. package/dist/esm/arcgis-coding-components.js +4 -4
  103. package/dist/esm/{css-70f18054.js → css-ba86d792.js} +1 -1
  104. package/dist/esm/{cssMode-488c3e86.js → cssMode-cc7d2728.js} +3 -3
  105. package/dist/esm/{html-59102be0.js → html-664c0f74.js} +3 -3
  106. package/dist/esm/{htmlMode-cfdd852e.js → htmlMode-34f81854.js} +3 -3
  107. package/dist/esm/{index-78a96626.js → index-33ae02ee.js} +42 -5
  108. package/dist/esm/index.js +3 -3
  109. package/dist/esm/{javascript-8ee5b791.js → javascript-1e3278d9.js} +4 -4
  110. package/dist/esm/{jsonMode-771e71b0.js → jsonMode-aa8a70d8.js} +3 -3
  111. package/dist/esm/loader.js +4 -4
  112. package/dist/esm/{tsMode-f95b693f.js → tsMode-3100d961.js} +3 -3
  113. package/dist/esm/{typescript-055e39ac.js → typescript-d8d38af2.js} +3 -3
  114. package/dist/loader/cdn.js +1 -1
  115. package/dist/loader/index.cjs.js +1 -1
  116. package/dist/loader/index.es2017.js +1 -1
  117. package/dist/loader/index.js +1 -1
  118. package/dist/types/components/arcade-api/arcade-api.d.ts +6 -7
  119. package/dist/types/components/arcade-editor/arcade-editor.d.ts +9 -6
  120. package/dist/types/components/arcade-results/arcade-results.d.ts +6 -9
  121. package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +6 -7
  122. package/dist/types/components/arcade-variables/arcade-variables.d.ts +6 -8
  123. package/dist/types/components/code-editor/code-editor.d.ts +1 -1
  124. package/dist/types/components.d.ts +22 -22
  125. 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
  126. 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
  127. 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
  128. package/dist/types/utils/arcade-monaco/arcade-language-features.d.ts +1 -1
  129. package/package.json +20 -19
  130. package/dist/arcgis-coding-components/p-04561935.entry.js +0 -6
  131. package/dist/arcgis-coding-components/p-871217d9.js +0 -68
  132. package/dist/arcgis-coding-components/p-c23d1605.js +0 -7
@@ -1,14 +1,14 @@
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.4
4
+ * v4.30.0-next.40
5
5
  */
6
6
  'use strict';
7
7
 
8
8
  Object.defineProperty(exports, '__esModule', { value: true });
9
9
 
10
- const index = require('./index-25b044b5.js');
11
- const arcadeDefaults = require('./arcade-defaults-d41420df.js');
10
+ const index = require('./index-ddb7b8ae.js');
11
+ const arcadeDefaults = require('./arcade-defaults-11bd4fd0.js');
12
12
 
13
13
  async function colorizeCode(code) {
14
14
  return await arcadeDefaults.editor.colorize(code, "arcade", { tabSize: 2 });
@@ -2921,24 +2921,1472 @@ var marked_umd = arcadeDefaults.createCommonjsModule(function (module, exports)
2921
2921
  // Set up the marked library to use GitHub Flavored Markdown and to use the custom renderer for links.
2922
2922
  marked_umd.marked.use({
2923
2923
  gfm: true,
2924
+ breaks: true,
2925
+ async: false,
2924
2926
  renderer: {
2925
2927
  link(href, title, text) {
2926
2928
  return `<calcite-link href="${href}" title="${title ?? text}" target="Arcade Help">${text}</calcite-link>`;
2927
- }
2928
- }
2929
+ },
2930
+ },
2929
2931
  });
2930
2932
  /**
2931
2933
  * Converts a markdown string to HTML using the marked library.
2932
2934
  */
2933
2935
  function convertMarkdownString(value) {
2934
- value ?? (value = "");
2935
- const result = marked_umd.marked(typeof value === "string" ? value : value.value, {
2936
- gfm: true,
2937
- breaks: true,
2938
- headerIds: false,
2939
- mangle: false
2936
+ if (value === null || value === undefined) {
2937
+ return "";
2938
+ }
2939
+ return marked_umd.marked.parse(typeof value === "string" ? value : value.value);
2940
+ }
2941
+
2942
+ // src/stencil.ts
2943
+ function retrieveComponentMeta(component) {
2944
+ const constructor = component.constructor;
2945
+ const members = constructor.__registerControllers?.(component) ?? void 0;
2946
+ constructor.__registerControllers = void 0;
2947
+ if (typeof members !== "object")
2948
+ throw new Error(
2949
+ "Failed to retrieve internal component meta. Make sure you have the useComponentsControllers() Rollup Plugin for Stencil Controllers configured in your Stencil config."
2950
+ );
2951
+ component.manager.internals.members = members;
2952
+ }
2953
+ function parsePropertyValue(value, type = 8 /* Any */) {
2954
+ const isComplex = value == null || typeof value === "object" || typeof value === "function";
2955
+ if (isComplex)
2956
+ return value;
2957
+ if ((type & 4 /* Boolean */) !== 0)
2958
+ return value === "false" ? false : value === "" || !!value;
2959
+ else if ((type & 2 /* Number */) !== 0)
2960
+ return Number.parseFloat(value.toString());
2961
+ else if ((type & 1 /* String */) !== 0)
2962
+ return String(value);
2963
+ else
2964
+ return value;
2965
+ }
2966
+ var makeMemberFilter = (filter) => (component) => {
2967
+ const members = component.manager.internals.members;
2968
+ return Object.entries(members ?? {}).filter(([_name, [propType]]) => (propType & filter) !== 0).map(([name]) => name);
2969
+ };
2970
+ var getPropLikeMembers = makeMemberFilter(63 /* PropLike */);
2971
+ var getMemberType = (component, name) => component.manager.internals.members?.[name]?.[0];
2972
+ function getPropType(component, name) {
2973
+ const type = getMemberType(component, name);
2974
+ if (type === void 0)
2975
+ return void 0;
2976
+ else if (type & 32 /* State */)
2977
+ return "state";
2978
+ else
2979
+ return "prop";
2980
+ }
2981
+
2982
+ // ../components-utils/dist/index.js
2983
+ var Deferred = class {
2984
+ /**
2985
+ * Creates a new deferred promise.
2986
+ */
2987
+ constructor() {
2988
+ this.resolve = () => void 0;
2989
+ this.reject = () => void 0;
2990
+ this.promise = new Promise((resolve, reject) => {
2991
+ this.resolve = resolve;
2992
+ this.reject = reject;
2993
+ });
2994
+ }
2995
+ };
2996
+ function inTargetElement(element, targetElement) {
2997
+ let currentElement = element;
2998
+ while (currentElement) {
2999
+ if (currentElement === targetElement) {
3000
+ return true;
3001
+ }
3002
+ if (!currentElement.parentNode) {
3003
+ return false;
3004
+ }
3005
+ if (currentElement.parentNode instanceof ShadowRoot) {
3006
+ currentElement = currentElement.parentNode.host;
3007
+ } else {
3008
+ currentElement = currentElement.parentNode;
3009
+ }
3010
+ }
3011
+ return false;
3012
+ }
3013
+ function observeAncestorsMutation(element, attributeFilter, callback) {
3014
+ const { subscribe } = observe(attributeFilter);
3015
+ return subscribe((mutations) => {
3016
+ const matched = mutations.some((mutation) => inTargetElement(element, mutation.target));
3017
+ if (matched)
3018
+ callback();
3019
+ });
3020
+ }
3021
+ var observers = {};
3022
+ function observe(attributeFilter) {
3023
+ const attributes = attributeFilter.join(",");
3024
+ const previousObserver = observers[attributes];
3025
+ if (previousObserver !== void 0)
3026
+ return previousObserver;
3027
+ const subscribers = /* @__PURE__ */ new Set();
3028
+ const mutationObserver = new MutationObserver((mutations) => subscribers.forEach((callback) => callback(mutations)));
3029
+ mutationObserver.observe(document.documentElement, {
3030
+ attributes: true,
3031
+ attributeFilter,
3032
+ subtree: true
3033
+ });
3034
+ const observer = {
3035
+ subscribe(callback) {
3036
+ subscribers.add(callback);
3037
+ return {
3038
+ remove: () => {
3039
+ subscribers.delete(callback);
3040
+ if (subscribers.size === 0) {
3041
+ mutationObserver.disconnect();
3042
+ observers[attributes] = void 0;
3043
+ }
3044
+ }
3045
+ };
3046
+ }
3047
+ };
3048
+ observers[attributes] = observer;
3049
+ return observer;
3050
+ }
3051
+ function closestElement(base, selector) {
3052
+ let currentElement = base;
3053
+ while (currentElement) {
3054
+ const element = currentElement.closest(selector);
3055
+ if (element) {
3056
+ return element;
3057
+ }
3058
+ const rootElement = currentElement.getRootNode();
3059
+ if (rootElement === document) {
3060
+ return null;
3061
+ }
3062
+ currentElement = rootElement.host;
3063
+ }
3064
+ return null;
3065
+ }
3066
+ function getElementAttribute(el, prop, fallbackValue) {
3067
+ const closest = closestElement(el, `[${prop}]`);
3068
+ return closest?.getAttribute(prop) ?? fallbackValue;
3069
+ }
3070
+ function safeCall(callback) {
3071
+ try {
3072
+ return callback?.();
3073
+ } catch (error) {
3074
+ console.error(error, callback);
3075
+ }
3076
+ return void 0;
3077
+ }
3078
+ async function safeAsyncCall(callback) {
3079
+ try {
3080
+ return await callback();
3081
+ } catch (error) {
3082
+ console.error(error, callback);
3083
+ }
3084
+ return void 0;
3085
+ }
3086
+ var upperBeforeLower = /[A-Z]+(?![a-z])|[A-Z]/gu;
3087
+ var capitalize = (string) => string.charAt(0).toUpperCase() + string.slice(1);
3088
+ var camelToHuman = (string) => capitalize(string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : " "}${upper}`));
3089
+ var supportedLocales = /* @__PURE__ */ new Set([
3090
+ "ar",
3091
+ "bg",
3092
+ "bs",
3093
+ "ca",
3094
+ "cs",
3095
+ "da",
3096
+ "de",
3097
+ "el",
3098
+ "en",
3099
+ "es",
3100
+ "et",
3101
+ "fi",
3102
+ "fr",
3103
+ "he",
3104
+ "hr",
3105
+ "hu",
3106
+ "id",
3107
+ "it",
3108
+ "ja",
3109
+ "ko",
3110
+ "lt",
3111
+ "lv",
3112
+ "nl",
3113
+ "nb",
3114
+ "pl",
3115
+ "pt-BR",
3116
+ "pt-PT",
3117
+ "ro",
3118
+ "ru",
3119
+ "sk",
3120
+ "sl",
3121
+ "sr",
3122
+ "sv",
3123
+ "th",
3124
+ "tr",
3125
+ "uk",
3126
+ "vi",
3127
+ "zh-CN",
3128
+ "zh-HK",
3129
+ "zh-TW"
3130
+ ]);
3131
+ var defaultLocale = "en";
3132
+ async function fetchT9NStringsBundle(locale, assetsPath, prefix = "") {
3133
+ const path = `${assetsPath}/${prefix}`;
3134
+ const filePath = `${path}${locale}.json`;
3135
+ t9nStringsCache[filePath] ?? (t9nStringsCache[filePath] = fetchBundle(locale, path));
3136
+ return await t9nStringsCache[filePath];
3137
+ }
3138
+ var t9nStringsCache = {};
3139
+ async function fetchBundle(locale, path) {
3140
+ const filePath = `${path}${locale}.json`;
3141
+ try {
3142
+ const response = await fetch(filePath);
3143
+ if (response.ok)
3144
+ return await response.json();
3145
+ } catch (error) {
3146
+ console.error(error);
3147
+ return fallbackBundle;
3148
+ }
3149
+ if (locale === defaultLocale)
3150
+ return fallbackBundle;
3151
+ return await fetchBundle(defaultLocale, path);
3152
+ }
3153
+ var fallbackBundle = new Proxy(
3154
+ {},
3155
+ {
3156
+ get: (_target, property) => camelToHuman(property.toString())
3157
+ }
3158
+ );
3159
+ function getElementLocales(element) {
3160
+ const lang = getElementAttribute(element, "lang", navigator.language || defaultLocale);
3161
+ if (supportedLocales.has(lang)) {
3162
+ return { lang, t9nLocale: lang };
3163
+ }
3164
+ const rootCode = lang.slice(0, 2);
3165
+ return { lang, t9nLocale: supportedLocales.has(rootCode) ? rootCode : defaultLocale };
3166
+ }
3167
+ function startLocaleObserver(element, assetsPath, onUpdated, assetName) {
3168
+ let result = void 0;
3169
+ const callback = () => void updateComponentLocateState(element, assetsPath, assetName).then((newResult) => {
3170
+ if (result?.lang !== newResult.lang || result.t9nLocale !== newResult.t9nLocale || result.t9nStrings !== newResult.t9nStrings)
3171
+ onUpdated(newResult);
3172
+ result = newResult;
3173
+ }).catch(console.error);
3174
+ callback();
3175
+ return observeAncestorsMutation(element, ["lang"], callback);
3176
+ }
3177
+ async function updateComponentLocateState(element, assetsPath, assetName = element.tagName.toLowerCase().replace("arcgis-", "")) {
3178
+ const { lang, t9nLocale } = getElementLocales(element);
3179
+ const t9nAssetsPath = `${assetsPath}/${assetName}/t9n`;
3180
+ const prefix = `${assetName}.t9n.`;
3181
+ const t9nStrings = await fetchT9NStringsBundle(t9nLocale, t9nAssetsPath, prefix);
3182
+ return { lang, t9nLocale, t9nStrings };
3183
+ }
3184
+
3185
+ // src/types.ts
3186
+ var controllerSymbol = Symbol("controller");
3187
+
3188
+ // src/utils.ts
3189
+ function extendObject(base, extend) {
3190
+ Object.entries(extend).forEach(([key, value]) => {
3191
+ if (key in base)
3192
+ throw new Error(`Unable to extend object because property "${key}" is already defined`);
3193
+ const thisBase = base;
3194
+ thisBase[key] = value;
3195
+ });
3196
+ return base;
3197
+ }
3198
+ var isController = (value) => typeof value === "object" && value !== null && (controllerSymbol in value || "hostConnected" in value || "hostDisconnected" in value || "hostUpdate" in value || "hostUpdated" in value);
3199
+
3200
+ // src/ControllerInternals.ts
3201
+ var ControllerInternals = class {
3202
+ constructor() {
3203
+ this._ambientControllers = [];
3204
+ /**
3205
+ * The type definition has to be duplicated due to the
3206
+ * "'use' is referenced directly or indirectly in its own type annotation."
3207
+ * error
3208
+ */
3209
+ this.use = async (value, watchExports) => {
3210
+ const controller = this.useRefSync(value);
3211
+ if (controller === void 0) {
3212
+ if (typeof watchExports === "function") {
3213
+ const error = new Error(
3214
+ `Unable to resolve a controller from the provided value, so can't watch it's exports. ${unresolvableExports}`
3215
+ );
3216
+ console.error(error);
3217
+ }
3218
+ return value;
3219
+ }
3220
+ await controller.ready;
3221
+ if (typeof watchExports === "function") {
3222
+ if (controller.watchExports === void 0)
3223
+ throw new Error(`The controller must implement watchExports method to support watching exports`);
3224
+ const unsubscribe = controller.watchExports(
3225
+ (exports) => watchExports(exports, unsubscribe)
3226
+ );
3227
+ }
3228
+ return controller.exports;
3229
+ };
3230
+ this.useRef = async (value) => {
3231
+ const controller = this.useRefSync(value);
3232
+ if (controller === void 0)
3233
+ throw new Error(`Unable to resolve a controller from the provided value. ${unresolvableExports}`);
3234
+ await controller.ready;
3235
+ return controller;
3236
+ };
3237
+ this.shouldBypassSetter = false;
3238
+ this.shouldBypassGetter = false;
3239
+ this.shouldBypassReadonly = false;
3240
+ /**
3241
+ * A map from component instance or component element to component instance.
3242
+ * To get from component instance or component element to component element,
3243
+ * you can just use the .el property
3244
+ */
3245
+ this.elementToInstance = /* @__PURE__ */ new WeakMap();
3246
+ }
3247
+ /*
3248
+ * Allow controllers to implicitly retrieve which component they are in, to
3249
+ * improve DX (avoids the need to pass "this" explicitly for each controller)
3250
+ */
3251
+ setAmbientComponent(component) {
3252
+ if (this._ambientComponent === component)
3253
+ return;
3254
+ this._ambientComponent = component;
3255
+ queueMicrotask(() => {
3256
+ if (this._ambientComponent === component)
3257
+ this._ambientComponent = void 0;
3258
+ });
3259
+ }
3260
+ retrieveComponent(name) {
3261
+ if (this._ambientComponent === void 0)
3262
+ throw new Error(
3263
+ [
3264
+ `Unable to find out which component ${name || "this"} controller `,
3265
+ "belongs to. This might happen if you tried to create a controller ",
3266
+ "outside the component. If so, please wrap your controller ",
3267
+ "definition in an arrow function, ",
3268
+ "`const myController = ()=>makeController(...);` and call that",
3269
+ "function inside the component `my = myController();`, or ",
3270
+ "define your controller using makeGenericController/GenericController ",
3271
+ "instead.\n",
3272
+ "If you wish to use a controller inside an async controller, ",
3273
+ "make sure you are using controller.use.\n",
3274
+ "You might also have multiple instances of Controllers loaded"
3275
+ ].join("\n")
3276
+ );
3277
+ return this._ambientComponent;
3278
+ }
3279
+ /*
3280
+ * Aids proxyExports() in knowing who is it's host
3281
+ */
3282
+ setParentController(controller) {
3283
+ if (controller === void 0) {
3284
+ this._ambientControllers = [];
3285
+ return;
3286
+ }
3287
+ const index = this._ambientControllers.indexOf(controller);
3288
+ this._ambientControllers = index === -1 ? [...this._ambientControllers, controller] : this._ambientControllers.slice(0, index + 1);
3289
+ queueMicrotask(() => {
3290
+ this._ambientControllers = [];
3291
+ });
3292
+ }
3293
+ retrieveParentControllers() {
3294
+ return this._ambientControllers;
3295
+ }
3296
+ /*
3297
+ * Aids controller.use in retrieving controller value when it receives
3298
+ * controller exports, rather than the controller itself
3299
+ */
3300
+ setAmbientChildController(controller) {
3301
+ if (this._ambientChildController === controller)
3302
+ return;
3303
+ this._ambientChildController = controller;
3304
+ queueMicrotask(() => {
3305
+ if (this._ambientChildController === controller)
3306
+ this._ambientChildController = void 0;
3307
+ });
3308
+ }
3309
+ retrieveAmbientChildController() {
3310
+ const controller = this._ambientChildController;
3311
+ this._ambientChildController = void 0;
3312
+ return controller;
3313
+ }
3314
+ /**
3315
+ * Try to resolve a controller, without awaiting it's load
3316
+ */
3317
+ useRefSync(value) {
3318
+ const ambientChildController = this.retrieveAmbientChildController();
3319
+ if (ambientChildController !== void 0)
3320
+ return ambientChildController;
3321
+ const component = Controller.internals.retrieveComponent();
3322
+ const controller = component.manager.internals.resolveExports(value);
3323
+ if (controller !== void 0)
3324
+ return controller;
3325
+ if (isController(value))
3326
+ return value;
3327
+ return void 0;
3328
+ }
3329
+ };
3330
+ var unresolvableExports = [
3331
+ "The value you passed is not a controller and not a controller exports. If ",
3332
+ "your controller exports a literal value, try making your controller export ",
3333
+ "an object instead"
3334
+ ].join("");
3335
+
3336
+ // src/Controller.ts
3337
+ var _a;
3338
+ var _Controller = class _Controller {
3339
+ constructor(component) {
3340
+ this._ready = new Deferred();
3341
+ this._lifecycleDisconnected = [];
3342
+ this.connectedCalled = false;
3343
+ this.willLoadCalled = false;
3344
+ this.didLoadCalled = false;
3345
+ this[_a] = true;
3346
+ this.ready = this._ready.promise;
3347
+ /*
3348
+ * Setting default exports to "this" so that controllers that don't use
3349
+ * exports/proxyExports(), could still be used as if they did
3350
+ * (i.e with controller.use)
3351
+ */
3352
+ this._exports = makeProvisionalValue(this);
3353
+ this._exportWatchers = /* @__PURE__ */ new Set();
3354
+ const resolvedComponent = toControllerHost(
3355
+ component ?? _Controller.internals.retrieveComponent(new.target.name)
3356
+ );
3357
+ Object.defineProperty(this, "component", {
3358
+ writable: false,
3359
+ enumerable: false,
3360
+ configurable: true,
3361
+ value: resolvedComponent
3362
+ });
3363
+ this.component.addController(this);
3364
+ const manager = this.component.manager;
3365
+ this.connected = manager?.connected;
3366
+ this.internals = manager?.internals;
3367
+ _Controller.internals.setParentController(this);
3368
+ if ("hostDestroy" in this)
3369
+ this.component.manager.ensureHasDestroy();
3370
+ if (manager !== void 0)
3371
+ queueMicrotask(() => this.catchUpLifecycle());
3372
+ const controller = this;
3373
+ this._callbacks = {
3374
+ hostConnected: "hostConnected" in this ? [() => controller.hostConnected?.()] : [],
3375
+ hostDisconnected: "hostDisconnected" in this ? [() => controller.hostDisconnected?.()] : [],
3376
+ hostLoad: "hostLoad" in this ? [() => controller.hostLoad?.()] : [],
3377
+ hostLoaded: "hostLoaded" in this ? [() => controller.hostLoaded?.()] : [],
3378
+ hostRender: "hostRender" in this ? [() => controller.hostRender?.()] : [],
3379
+ hostRendered: "hostRendered" in this ? [() => controller.hostRendered?.()] : [],
3380
+ hostUpdate: "hostUpdate" in this ? [() => controller.hostUpdate?.()] : [],
3381
+ hostUpdated: "hostUpdated" in this ? [() => controller.hostUpdated?.()] : [],
3382
+ hostDestroy: "hostDestroy" in this ? [() => controller.hostDestroy?.()] : [],
3383
+ hostLifecycle: "hostLifecycle" in this ? [() => controller.hostLifecycle?.()] : []
3384
+ };
3385
+ }
3386
+ /**
3387
+ * If controller is being added dynamically, after the component
3388
+ * construction, then trigger connected and load right away
3389
+ */
3390
+ catchUpLifecycle() {
3391
+ if (this.connectedCalled)
3392
+ return;
3393
+ this.triggerConnected();
3394
+ const loadWillStillHappen = !this.component.manager.willLoadCalled;
3395
+ if (loadWillStillHappen)
3396
+ return;
3397
+ this.triggerLoad().then(() => {
3398
+ const loadedWillStillHappen = !this.component.manager.didLoadCalled;
3399
+ if (loadedWillStillHappen)
3400
+ return;
3401
+ this.triggerLoaded();
3402
+ }).catch(console.error);
3403
+ }
3404
+ get exports() {
3405
+ return this._exports;
3406
+ }
3407
+ /**
3408
+ * Set controller's exports property (for usage with proxyExports()) and mark
3409
+ * controller as ready (for usage in other controllers). Also, triggers
3410
+ * re-render of the component
3411
+ */
3412
+ set exports(exports) {
3413
+ if (this._exports !== exports) {
3414
+ this._exports = exports;
3415
+ if (this.connectedCalled)
3416
+ this.component.requestUpdate();
3417
+ this._exportWatchers.forEach((callback) => callback(exports));
3418
+ }
3419
+ this._ready.resolve(exports);
3420
+ }
3421
+ setProvisionalExports(exports) {
3422
+ this._exports = makeProvisionalValue(exports);
3423
+ this._exportWatchers.forEach((callback) => callback(this._exports));
3424
+ }
3425
+ watchExports(callback) {
3426
+ const safeCallback = (exports) => safeCall(() => callback(exports));
3427
+ this._exportWatchers.add(safeCallback);
3428
+ return () => void this._exportWatchers.delete(safeCallback);
3429
+ }
3430
+ /**
3431
+ * A flexible utility for making sure a controller is loaded before it's used,
3432
+ * regardless of how or where a controller was defined:
3433
+ *
3434
+ * @example
3435
+ * makeGenericController(async (component, controller) => {
3436
+ * // Await some controller from the component:
3437
+ * await controller.use(component.someController);
3438
+ * // Initialize new controllers
3439
+ * await controller.use(load(importCoreReactiveUtils));
3440
+ * await controller.use(new ViewModelController(component,newWidgetsHomeHomeViewModel));
3441
+ * await controller.use(someController(component));
3442
+ * });
3443
+ *
3444
+ * @remarks
3445
+ * If your controller is not async, and you are not creating it async, then
3446
+ * you are not required to use controller.use - you can use it directly.
3447
+ * Similarly, accessing controllers after componentWillLoad callback does not
3448
+ * require awaiting them as they are guaranteed to be loaded by then.
3449
+ */
3450
+ get use() {
3451
+ _Controller.internals.setAmbientComponent(this.component);
3452
+ return _Controller.internals.use;
3453
+ }
3454
+ /**
3455
+ * Just like controller.use, but returns the controller itself, rather than it's
3456
+ * exports
3457
+ *
3458
+ * Use cases:
3459
+ * - You have a controller and you want to make sure it's loaded before you
3460
+ * try to use it
3461
+ * - Your controller is not using exports, so you wish to access some props on
3462
+ * it directly
3463
+ * - You have a controller exports only, and you want to retrieve the
3464
+ * controller itself. This is useful if you wish to call .watchExports() or
3465
+ * some other method on the controller
3466
+ */
3467
+ get useRef() {
3468
+ _Controller.internals.setAmbientComponent(this.component);
3469
+ return _Controller.internals.useRef;
3470
+ }
3471
+ /**
3472
+ * If you need to set a prop/state without triggering the custom setter you
3473
+ * defined with getSet()/dynamicGetSet()/readonly(), set the value inside
3474
+ * of this function
3475
+ *
3476
+ * @example
3477
+ * @Prop() readOnly = this.manager.readOnly(true);
3478
+ *
3479
+ * someAction(): void {
3480
+ * this.manager.bypassSetter(()=>{
3481
+ * this.readOnly = false;
3482
+ * });
3483
+ * }
3484
+ *
3485
+ */
3486
+ bypassSetter(callback) {
3487
+ _Controller.internals.shouldBypassSetter = true;
3488
+ try {
3489
+ return callback();
3490
+ } finally {
3491
+ _Controller.internals.shouldBypassSetter = false;
3492
+ }
3493
+ }
3494
+ /**
3495
+ * Like bypassSetter, but only bypasses this.manager.readonly(), rather that
3496
+ * all setters set using this.manager.getSet()
3497
+ */
3498
+ bypassReadonly(callback) {
3499
+ _Controller.internals.shouldBypassReadonly = true;
3500
+ try {
3501
+ return callback();
3502
+ } finally {
3503
+ _Controller.internals.shouldBypassReadonly = false;
3504
+ }
3505
+ }
3506
+ /**
3507
+ * Property reads inside of this function will bypass any custom getter you
3508
+ * may have, and read the value directly from what's stored in Stencil.
3509
+ *
3510
+ * This also bypasses reactiveUtils integration - reading a property inside of
3511
+ * bypassGetter won't make that property tracked.
3512
+ *
3513
+ * @example
3514
+ * reactiveUtils.watch(
3515
+ * ()=>{
3516
+ * this.manager.bypassGetter(()=>{
3517
+ * console.log(this.someProp);
3518
+ * });
3519
+ * return this.prop;
3520
+ * },
3521
+ * console.log
3522
+ * )
3523
+ */
3524
+ bypassGetter(callback) {
3525
+ _Controller.internals.shouldBypassGetter = true;
3526
+ try {
3527
+ return callback();
3528
+ } finally {
3529
+ _Controller.internals.shouldBypassGetter = false;
3530
+ }
3531
+ }
3532
+ /**
3533
+ * Like this.manager.getSet(), but can be called on any component's
3534
+ * state/prop from anywhere, rather than just from the default value
3535
+ */
3536
+ dynamicGetSet(name, getSet) {
3537
+ this.genericGetSet(name, getSet);
3538
+ }
3539
+ /**
3540
+ * Like dynamicGetSet, but less type-safe. Useful in cases when trying to set
3541
+ * getters/setters in place where property names & types are not known
3542
+ * statically
3543
+ */
3544
+ genericGetSet(property, getSet) {
3545
+ var _a2, _b;
3546
+ const genericGetSet = getSet;
3547
+ if (genericGetSet.get !== void 0) {
3548
+ (_a2 = this.internals.getters)[property] ?? (_a2[property] = []);
3549
+ this.internals.getters[property].unshift(genericGetSet.get);
3550
+ }
3551
+ if (genericGetSet.set !== void 0) {
3552
+ (_b = this.internals.setters)[property] ?? (_b[property] = []);
3553
+ this.internals.setters[property].unshift(genericGetSet.set);
3554
+ }
3555
+ }
3556
+ // FEATURE: improve typings
3557
+ /**
3558
+ * Dynamically set a watcher for any \@Prop()/\@State() property
3559
+ */
3560
+ watch(property, callback) {
3561
+ var _a2;
3562
+ const type = getMemberType(this.component, property);
3563
+ if (type === void 0)
3564
+ throw new Error(
3565
+ `Trying to watch a non-@Prop, non-@State property "${property}". Either convert it into a @State() or use manager.getSet/dynamicGetSet`
3566
+ );
3567
+ (_a2 = this.internals.allWatchers)[property] ?? (_a2[property] = []);
3568
+ const watchers = this.internals.allWatchers[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
+ /**
3771
+ * When watchers are set, set then into `allWatchers`. When watchers are read
3772
+ * in the setter, read from `enabledWatchers`.
3773
+ * On connectedCallback(), controller manager does `enabledWatchers=allWatchers`.
3774
+ * Reasoning:
3775
+ * - This disables watchers until connected callback (matches behavior of
3776
+ * Stencil's watchers)
3777
+ * - This removes in the setter to check if watchers were enabled already or
3778
+ * not (as getters/setters are hot path, and should be streamlined)
3779
+ */
3780
+ this.enabledWatchers = {};
3781
+ this.allWatchers = {};
3782
+ this.trackKey = (hostsCandidates, onResolved, defaultValue) => {
3783
+ const candidateHosts = Array.isArray(hostsCandidates) ? hostsCandidates : [hostsCandidates];
3784
+ let leftToResolve = candidateHosts.length + 1;
3785
+ const resolved = (resolution) => {
3786
+ leftToResolve -= 1;
3787
+ if (resolution !== void 0)
3788
+ leftToResolve = 0;
3789
+ if (leftToResolve === 0)
3790
+ onResolved(resolution);
3791
+ };
3792
+ candidateHosts.forEach(
3793
+ (host) => this.component.manager.trackPropertyKey(
3794
+ host,
3795
+ (key) => resolved(
3796
+ key === void 0 ? void 0 : {
3797
+ key,
3798
+ host,
3799
+ type: "property",
3800
+ domValue: void 0
3801
+ }
3802
+ ),
3803
+ defaultValue
3804
+ )
3805
+ );
3806
+ this.component.manager.trackPropKey((key, domValue) => {
3807
+ const propType = key === void 0 ? void 0 : getPropType(this.component, key);
3808
+ resolved(
3809
+ key === void 0 ? void 0 : {
3810
+ key,
3811
+ host: this.component,
3812
+ type: propType ?? "prop",
3813
+ domValue: propType === "prop" ? domValue : void 0
3814
+ }
3815
+ );
3816
+ }, defaultValue);
3817
+ return defaultValue;
3818
+ };
3819
+ this.trackPropKey = (onResolved, defaultValue, ignoreDefaultValueMismatch = false) => {
3820
+ if (this._trackedValue !== nothing && this._trackedValue !== defaultValue)
3821
+ this._firePropertyTrackers(void 0, void 0, void 0);
3822
+ if (this._keyTrackers.length === 0)
3823
+ queueMicrotask(() => this._firePropertyTrackers(void 0, void 0, void 0));
3824
+ this._trackedValue = defaultValue;
3825
+ this._keyTrackers.push(
3826
+ (key, value, previousValue) => safeCall(
3827
+ () => onResolved(defaultValue === value || ignoreDefaultValueMismatch ? key : void 0, previousValue)
3828
+ )
3829
+ );
3830
+ return defaultValue;
3831
+ };
3832
+ this._trackedValue = nothing;
3833
+ this._keyTrackers = [];
3834
+ this.getters = {};
3835
+ this.setters = {};
3836
+ this.accessorGetter = {};
3837
+ this.accessorSetter = {};
3838
+ this._exports = /* @__PURE__ */ new WeakMap();
3839
+ Object.defineProperty(this, "component", {
3840
+ writable: false,
3841
+ enumerable: false,
3842
+ configurable: true,
3843
+ value: component
3844
+ });
3845
+ }
3846
+ _firePropertyTrackers(key, value, oldValue) {
3847
+ const trackers = this._keyTrackers;
3848
+ this._trackedValue = nothing;
3849
+ this._keyTrackers = [];
3850
+ trackers.forEach((tracker) => tracker(key, value, oldValue));
3851
+ }
3852
+ /**
3853
+ * Configure a getter or setter for a given \@Prop/\@State
3854
+ *
3855
+ * Note, since props are defined on the prototype, they are shared between all
3856
+ * instances of a component. Thus, instead of passing a reference to the
3857
+ * getter/setter function, you should update the
3858
+ * ComponentInternals.getters/setters properties, and then call getSetProxy
3859
+ * to apply the changes to the prototype
3860
+ */
3861
+ getSetProxy(property, hasGetter, hasSetter) {
3862
+ const classPrototype = Object.getPrototypeOf(this.component);
3863
+ this._getSetProxy(classPrototype, property, hasGetter, hasSetter, "class");
3864
+ const htmlPrototype = Object.getPrototypeOf(this.component.el);
3865
+ if (classPrototype !== htmlPrototype)
3866
+ this._getSetProxy(htmlPrototype, property, hasGetter, hasSetter, "html");
3867
+ }
3868
+ _getSetProxy(prototype, name, hasGetter, hasSetter, type) {
3869
+ const component = this.component;
3870
+ const propType = getMemberType(component, name);
3871
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, name);
3872
+ const tolerateNotFound = type === "html";
3873
+ if (descriptor?.set === void 0 || descriptor.get === void 0)
3874
+ if (descriptor !== void 0 && "value" in descriptor)
3875
+ throw new Error(
3876
+ `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}`
3877
+ );
3878
+ else if (tolerateNotFound)
3879
+ return;
3880
+ else
3881
+ throw new Error(`Unable to find "${name}" property on the ${component.el.tagName} component`);
3882
+ const { get: originalGet, set: originalSet } = descriptor;
3883
+ const isGetterAlreadyOverwritten = customAccessor in originalGet;
3884
+ const isSetterAlreadyOverwritten = customAccessor in originalSet;
3885
+ const shouldOverwriteGet = !isGetterAlreadyOverwritten && hasGetter;
3886
+ const shouldOverwriteSet = !isSetterAlreadyOverwritten && hasSetter;
3887
+ if (!shouldOverwriteGet && !shouldOverwriteSet)
3888
+ return;
3889
+ const finalGetter = shouldOverwriteGet ? function getter() {
3890
+ let value = originalGet.call(this);
3891
+ const component2 = Controller.internals.elementToInstance.get(this);
3892
+ if (Controller.internals.shouldBypassGetter || component2 === void 0)
3893
+ return value;
3894
+ const internals = component2.manager.internals;
3895
+ value = internals.accessorGetter[name](value, name);
3896
+ const getters = internals.getters[name] ?? emptyArray;
3897
+ for (let i = 0; i < getters.length; i++)
3898
+ value = getters[i](value, name);
3899
+ return value;
3900
+ } : originalGet;
3901
+ const finalSetter = shouldOverwriteSet ? function setter(rawNewValue) {
3902
+ const oldValue = originalGet.call(this);
3903
+ let newValue = parsePropertyValue(rawNewValue, propType);
3904
+ const component2 = Controller.internals.elementToInstance.get(this);
3905
+ if (component2 === void 0) {
3906
+ originalSet.call(this, rawNewValue);
3907
+ return;
3908
+ }
3909
+ const internals = component2.manager.internals;
3910
+ if (newValue === oldValue)
3911
+ originalSet.call(this, rawNewValue);
3912
+ else {
3913
+ const setters = Controller.internals.shouldBypassSetter ? emptyArray : internals.setters[name] ?? emptyArray;
3914
+ for (let i = 0; i < setters.length; i++)
3915
+ newValue = setters[i](newValue, oldValue, name);
3916
+ newValue = internals.accessorSetter[name](newValue, oldValue, name);
3917
+ originalSet.call(this, newValue);
3918
+ if (newValue !== oldValue)
3919
+ internals.enabledWatchers[name]?.forEach((watcher) => watcher(newValue, oldValue, name));
3920
+ }
3921
+ if (internals._keyTrackers.length > 0)
3922
+ internals?._firePropertyTrackers(name, rawNewValue, oldValue);
3923
+ } : originalSet;
3924
+ if (shouldOverwriteGet)
3925
+ Object.defineProperty(finalGetter, customAccessor, { value: true });
3926
+ if (shouldOverwriteSet)
3927
+ Object.defineProperty(finalSetter, customAccessor, { value: true });
3928
+ Object.defineProperty(prototype, name, {
3929
+ ...descriptor,
3930
+ get: finalGetter,
3931
+ set: finalSetter
2940
3932
  });
2941
- return result;
3933
+ }
3934
+ /**
3935
+ * Associate an exports object with a controller for reverse lookup in
3936
+ * controller.use
3937
+ */
3938
+ markExports(controller, exports) {
3939
+ if (typeof exports === "object" && exports !== null || typeof exports === "function")
3940
+ this._exports.set(exports, controller);
3941
+ }
3942
+ resolveExports(exports) {
3943
+ if (typeof exports === "object" && exports !== null || typeof exports === "function")
3944
+ return this._exports.get(exports);
3945
+ else
3946
+ return void 0;
3947
+ }
3948
+ };
3949
+ var emptyArray = [];
3950
+ var customAccessor = Symbol("controllersCustomAccessor");
3951
+ var nothing = Symbol("nothing");
3952
+ var accessorPromise = Promise.all([arcadeDefaults.importCoreAccessor(), arcadeDefaults.importCoreAccessorSupportDecorators()]);
3953
+ function reactiveUtilsIntegration(component) {
3954
+ const members = getPropLikeMembers(component);
3955
+ const internals = component.manager.internals;
3956
+ members.forEach((name) => {
3957
+ internals.accessorGetter[name] = defaultGetterSetter;
3958
+ internals.accessorSetter[name] = defaultGetterSetter;
3959
+ internals.getSetProxy(name, true, true);
3960
+ });
3961
+ return async (enabledMembers = members) => {
3962
+ const [Accessor, { subclass, property }] = await accessorPromise;
3963
+ class AccessorSubclass extends Accessor {
3964
+ }
3965
+ const getter = (_value, propertyName) => accessor[propertyName];
3966
+ function setter(newValue, _oldValue, propertyName) {
3967
+ if (accessor !== void 0)
3968
+ accessor[propertyName] = newValue;
3969
+ return newValue;
3970
+ }
3971
+ component.manager.bypassGetter(
3972
+ () => enabledMembers.forEach((name) => {
3973
+ internals.accessorGetter[name] = getter;
3974
+ internals.accessorSetter[name] = setter;
3975
+ property({
3976
+ value: component[name]
3977
+ })(AccessorSubclass.prototype, name);
3978
+ })
3979
+ );
3980
+ const Subclass = subclass(component.el.tagName)(AccessorSubclass);
3981
+ const accessor = new Subclass();
3982
+ };
3983
+ }
3984
+ var defaultGetterSetter = (value) => value;
3985
+
3986
+ // src/ControllerManager.ts
3987
+ var useControllerManager = (component) => new ControllerManager(component);
3988
+ var ControllerManager = class extends GenericController {
3989
+ constructor(component) {
3990
+ const controllers = /* @__PURE__ */ new Set();
3991
+ const controllerHost = {
3992
+ addController: (controller) => {
3993
+ controllers.add(controller);
3994
+ },
3995
+ removeController: (controller) => {
3996
+ controllers.delete(controller);
3997
+ },
3998
+ requestUpdate: () => index.forceUpdate(component)
3999
+ };
4000
+ extendObject(component, controllerHost);
4001
+ super(component);
4002
+ this._connected = new Deferred();
4003
+ this.internals = new ComponentInternals(this.component);
4004
+ this.connected = this._connected.promise;
4005
+ this.hasDestroy = false;
4006
+ this.destroyed = false;
4007
+ this._updatePromise = new Deferred();
4008
+ this._originalLifecycles = {};
4009
+ /**
4010
+ * A magical solution to finding out what property name a given controller
4011
+ * on a given object was assigned to. Note, this does not work for properties
4012
+ * that have \@Prop() or \@State() decorator - for those, use
4013
+ * manager.trackPropKey() instead.
4014
+ *
4015
+ * @example
4016
+ * function trackMe<T>(defaultValue:T, component:BaseComponent):T {
4017
+ * component.manager.trackPropertyKey(component, (key)=>console.log(key), defaultValue);
4018
+ * return defaultValue;
4019
+ * }
4020
+ *
4021
+ * class MyComponent extends BaseComponent {
4022
+ * // Will console log "myProp"
4023
+ * myProp = trackMe('a', this);
4024
+ * }
4025
+ *
4026
+ */
4027
+ this.trackPropertyKey = trackPropertyKey;
4028
+ /**
4029
+ * Like manager.trackPropertyKey(), but for props that have \@State() or \@Prop()
4030
+ * decorator
4031
+ *
4032
+ * @example
4033
+ * function trackMe(component:BaseComponent) {
4034
+ * component.manager.trackPropKey((key)=>console.log(key));
4035
+ * }
4036
+ *
4037
+ * class MyComponent extends BaseComponent {
4038
+ * // Will console log "myProp"
4039
+ * @Prop() myProp = trackMe(this);
4040
+ *
4041
+ * // Will console log "myState"
4042
+ * @State() myState = trackMe(this);
4043
+ * }
4044
+ */
4045
+ this.trackPropKey = this.internals.trackPropKey;
4046
+ /**
4047
+ * A combination of trackPropertyKey() and trackPropKey(). For usage when
4048
+ * you want to track a property, but don't know if it will be defined with the
4049
+ * \@Prop() decorator or not
4050
+ */
4051
+ this.trackKey = this.internals.trackKey;
4052
+ this._readonlySetter = (newValue, _oldValue, property) => {
4053
+ if (Controller.internals.shouldBypassReadonly)
4054
+ return newValue;
4055
+ const isProp = getPropType(this.component, property) === "prop";
4056
+ if (isProp)
4057
+ index.forceUpdate(this.component);
4058
+ throw new Error(
4059
+ `Cannot assign to read-only property "${property}" of ${this.component.el.tagName.toLowerCase()}. Trying to assign "${String(
4060
+ newValue
4061
+ )}"`
4062
+ );
4063
+ };
4064
+ /**
4065
+ * In development, on hot module reload, controller would be re-initialized
4066
+ * with all Props and State values persistent, but properties lost. This unsafe
4067
+ * development-only API lets you set or get data for a controller that would
4068
+ * persist across hot reloads.
4069
+ */
4070
+ this.devOnlySetPersistentControllerData = void 0 ;
4071
+ this.devOnlyGetPersistentControllerData = void 0 ;
4072
+ this.component.manager = this;
4073
+ retrieveComponentMeta(component);
4074
+ this._controllers = controllers;
4075
+ this.exports = void 0;
4076
+ this.hasDestroy = "preserveOnDisconnect" in this.component && typeof this.component.destroy === "function";
4077
+ if (this.hasDestroy)
4078
+ this.watch("preserveOnDisconnect", () => this._preserveOnDisconnectWatcher());
4079
+ this._bindLifecycleMethods();
4080
+ Object.defineProperty(component, "updateComplete", {
4081
+ get: async () => await this._updatePromise.promise
4082
+ });
4083
+ this.internals.reactiveUtilsIntegration = reactiveUtilsIntegration(this.component);
4084
+ Controller.internals.setParentController(void 0);
4085
+ Controller.internals.setAmbientComponent(component);
4086
+ Controller.internals.elementToInstance.set(component.el, component);
4087
+ Controller.internals.elementToInstance.set(component, component);
4088
+ }
4089
+ _bindLifecycleMethods() {
4090
+ const component = this.component;
4091
+ this._originalLifecycles = {
4092
+ connectedCallback: component.connectedCallback,
4093
+ disconnectedCallback: component.disconnectedCallback,
4094
+ componentWillLoad: component.componentWillLoad,
4095
+ componentDidLoad: component.componentDidLoad,
4096
+ componentWillRender: component.componentWillRender,
4097
+ componentDidRender: component.componentDidRender,
4098
+ componentWillUpdate: component.componentWillUpdate,
4099
+ componentDidUpdate: component.componentDidUpdate,
4100
+ destroy: component.destroy
4101
+ };
4102
+ component.connectedCallback = this._connectedCallback.bind(this);
4103
+ component.disconnectedCallback = this._disconnectedCallback.bind(this);
4104
+ component.componentWillLoad = this._componentWillLoad.bind(this);
4105
+ component.componentDidLoad = this._componentDidLoad.bind(this);
4106
+ component.componentWillRender = this._componentWillRender.bind(this);
4107
+ component.componentDidRender = this._componentDidRender.bind(this);
4108
+ component.componentWillUpdate = this._componentWillUpdate.bind(this);
4109
+ component.componentDidUpdate = this._componentDidUpdate.bind(this);
4110
+ if (this.hasDestroy)
4111
+ component.destroy = this.destroy.bind(this);
4112
+ }
4113
+ /**
4114
+ * Throws an error if component does not implement destroy() lifecycle, but
4115
+ * tries to use it.
4116
+ */
4117
+ ensureHasDestroy() {
4118
+ if (!this.hasDestroy)
4119
+ throw new Error(destroyErrorMessage);
4120
+ }
4121
+ /**
4122
+ * Private because this is not supposed to be called by Component directly.
4123
+ * Instead, _bindLifecycleMethods will take care of that. Otherwise, you risk
4124
+ * calling lifecycle methods twice.
4125
+ */
4126
+ _connectedCallback() {
4127
+ if (this.destroyed) {
4128
+ const tagName = this.component.el.tagName.toLowerCase();
4129
+ this.component.el.remove();
4130
+ throw new Error(
4131
+ `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.`
4132
+ );
4133
+ }
4134
+ this.internals.enabledWatchers = this.internals.allWatchers;
4135
+ keyTrackResolve();
4136
+ this._connected.resolve();
4137
+ this._controllers.forEach(
4138
+ (controller) => "triggerConnected" in controller ? controller.triggerConnected() : safeCall(() => controller.hostConnected?.())
4139
+ );
4140
+ this._originalLifecycles.connectedCallback?.call(this.component);
4141
+ }
4142
+ _disconnectedCallback() {
4143
+ if (this.destroyed)
4144
+ return;
4145
+ this._controllers.forEach(
4146
+ (controller) => "triggerDisconnected" in controller ? controller.triggerDisconnected() : safeCall(() => controller.hostDisconnected?.())
4147
+ );
4148
+ this._originalLifecycles.disconnectedCallback?.call(this.component);
4149
+ if (this.hasDestroy)
4150
+ this._preserveOnDisconnectWatcher();
4151
+ }
4152
+ async _componentWillLoad() {
4153
+ await this.internals.reactiveUtilsIntegration();
4154
+ await Promise.allSettled(
4155
+ Array.from(
4156
+ this._controllers,
4157
+ async (controller) => "triggerLoad" in controller ? await controller.triggerLoad() : await safeAsyncCall(async () => await controller.hostLoad?.())
4158
+ )
4159
+ );
4160
+ await this._originalLifecycles.componentWillLoad?.call(this.component);
4161
+ }
4162
+ _componentDidLoad() {
4163
+ this._controllers.forEach(
4164
+ (controller) => "triggerLoaded" in controller ? controller.triggerLoaded() : safeCall(() => controller.hostLoaded?.())
4165
+ );
4166
+ this._originalLifecycles.componentDidLoad?.call(this.component);
4167
+ }
4168
+ async _componentWillRender() {
4169
+ await Promise.allSettled(
4170
+ Array.from(
4171
+ this._controllers,
4172
+ async (controller) => "triggerRender" in controller ? await controller.triggerRender() : await safeAsyncCall(async () => await controller.hostRender?.())
4173
+ )
4174
+ );
4175
+ await this._originalLifecycles.componentWillRender?.call(this.component);
4176
+ }
4177
+ _componentDidRender() {
4178
+ this._controllers.forEach(
4179
+ (controller) => "triggerRendered" in controller ? controller.triggerRendered() : safeCall(() => controller.hostRendered?.())
4180
+ );
4181
+ this._originalLifecycles.componentDidRender?.call(this.component);
4182
+ }
4183
+ async _componentWillUpdate() {
4184
+ await Promise.allSettled(
4185
+ Array.from(
4186
+ this._controllers,
4187
+ async (controller) => "triggerUpdate" in controller ? await controller.triggerUpdate() : await safeAsyncCall(async () => await controller.hostUpdate?.())
4188
+ )
4189
+ );
4190
+ await this._originalLifecycles.componentWillUpdate?.call(this.component);
4191
+ }
4192
+ _componentDidUpdate() {
4193
+ this._controllers.forEach(
4194
+ (controller) => "triggerUpdated" in controller ? controller.triggerUpdated() : safeCall(() => controller.hostUpdated?.())
4195
+ );
4196
+ this._originalLifecycles.componentDidUpdate?.call(this.component);
4197
+ const updatePromise = this._updatePromise;
4198
+ this._updatePromise = new Deferred();
4199
+ updatePromise.resolve(true);
4200
+ }
4201
+ async destroy() {
4202
+ this.ensureHasDestroy();
4203
+ if (this.destroyed)
4204
+ return;
4205
+ if (this.component.el.isConnected) {
4206
+ this.hasDestroy = false;
4207
+ this.component.el.remove();
4208
+ this.hasDestroy = true;
4209
+ }
4210
+ this.destroyed = true;
4211
+ this._controllers.forEach(
4212
+ (controller) => "triggerDestroy" in controller ? controller.triggerDestroy() : safeCall(() => controller.hostDestroy?.())
4213
+ );
4214
+ await this._originalLifecycles.destroy?.call(this.component);
4215
+ }
4216
+ _preserveOnDisconnectWatcher() {
4217
+ if (!this.component.el.isConnected && !this.component.preserveOnDisconnect)
4218
+ void this.destroy().catch(console.error);
4219
+ }
4220
+ /**
4221
+ * Make a @Prop() or @State() readonly (prevent overwriting default value).
4222
+ *
4223
+ * For internal properties, prefer TypeScript's "readonly" modifier instead.
4224
+ *
4225
+ * @example
4226
+ * // Defining readonly prop
4227
+ * @Prop({ reflect: true }) prop = this.manager.readonly('a');
4228
+ *
4229
+ * @example
4230
+ * // Overwriting readonly prop internally
4231
+ * this.manager.bypassReadonly(()=>{
4232
+ * this.prop = 'b';
4233
+ * });
4234
+ *
4235
+ */
4236
+ readonly(value) {
4237
+ return this.getSet(value, { set: this._readonlySetter });
4238
+ }
4239
+ /**
4240
+ * Listen for any component's @State()/@Prop() change, and mutate it's
4241
+ * value before it is set.
4242
+ * This is necessary because Stencil's Compiler does not support get/set for
4243
+ * @State()/@Prop().
4244
+ * For private component properties, you should use regular get/set syntax.
4245
+ *
4246
+ * @example
4247
+ * @Prop() exampleProp = this.manager.getSet(defaultValue,{get,set})
4248
+ * @Prop() someProp = this.manager.getSet(
4249
+ * undefined as string | undefined,
4250
+ * {
4251
+ * get: (value)=>value.trim(),
4252
+ * set: (newValue,oldValue) => newValue.trim() ?? oldValue
4253
+ * }
4254
+ * )
4255
+ *
4256
+ * @remarks
4257
+ * Unlike a native get/set, the get function receives the current attribute
4258
+ * value, and can modify it before returning it (or can disregard the current
4259
+ * value and get it from elsewhere instead).
4260
+ * Similarly, setter is called with the new and old value, and is expected to
4261
+ * return the final new value (or return the old value to undo the change)
4262
+ */
4263
+ getSet(defaultValue, getSet) {
4264
+ return this.component.manager.trackPropKey((name) => {
4265
+ var _a2;
4266
+ if (name === void 0)
4267
+ throw new Error(
4268
+ "Unable to resolve get/set's prop name. Make sure you are using it like @Prop() someProp = this.manager.getSet(defaultValue,{get,set})"
4269
+ );
4270
+ if (getSet.set === this._readonlySetter) {
4271
+ (_a2 = this.internals).readonlyProps ?? (_a2.readonlyProps = /* @__PURE__ */ new Set());
4272
+ this.internals.readonlyProps.add(name);
4273
+ }
4274
+ const genericComponent = this.component;
4275
+ const value = genericComponent[name];
4276
+ if (value != null && value !== defaultValue && typeof getSet.set === "function" && getSet.initialSet !== false) {
4277
+ const newValue = getSet.set(value, defaultValue, name);
4278
+ if (newValue !== value)
4279
+ genericComponent[name] = newValue;
4280
+ }
4281
+ this.genericGetSet(name, getSet);
4282
+ }, defaultValue);
4283
+ }
4284
+ };
4285
+ var destroyErrorMessage = `
4286
+ If the component uses a controller that uses destroy() method, then the
4287
+ component must have the following properties:
4288
+ ${// Don't expose internal code in production, and keep bundle smaller:
4289
+ `preserveOnDisconnect and destroy` }
4290
+ `.trim();
4291
+
4292
+ // src/proxyExports.ts
4293
+ var proxyExports = (Class) => (...args) => {
4294
+ const ambientControllers = Controller.internals.retrieveParentControllers();
4295
+ const instance = new Class(...args);
4296
+ const initialExports = instance.exports;
4297
+ Controller.internals.setParentController(ambientControllers.at(-1));
4298
+ const internals = instance.component.manager.internals;
4299
+ internals.markExports(instance, initialExports);
4300
+ instance.watchExports((exports) => internals.markExports(instance, exports));
4301
+ Controller.internals.setAmbientChildController(instance);
4302
+ const hostCandidates = [instance.component, ...ambientControllers].reverse();
4303
+ return internals.trackKey(
4304
+ hostCandidates,
4305
+ (resolution) => resolution === void 0 ? void 0 : setProxy(instance, resolution.host, resolution.key, initialExports),
4306
+ initialExports
4307
+ );
4308
+ };
4309
+ function setProxy(controller, host, key, initialExports) {
4310
+ const genericHost = host;
4311
+ const controllerValueChanged = genericHost[key] !== controller.exports;
4312
+ const hostValueChanged = genericHost[key] !== initialExports;
4313
+ const controllerUpdatedExports = initialExports !== controller.exports;
4314
+ if (controllerValueChanged && !hostValueChanged && controllerUpdatedExports)
4315
+ genericHost[key] = controller.exports;
4316
+ controller.watchExports(() => {
4317
+ if (genericHost[key] === controller.exports)
4318
+ return;
4319
+ const manager = controller.component.manager;
4320
+ const isReadOnly = manager.internals.readonlyProps?.has(key) === true;
4321
+ if (isReadOnly)
4322
+ manager.bypassReadonly(() => {
4323
+ genericHost[key] = controller.exports;
4324
+ });
4325
+ else
4326
+ genericHost[key] = controller.exports;
4327
+ });
4328
+ }
4329
+
4330
+ // src/functional.ts
4331
+ var makeController = (constructor) => proxy(void 0, constructor);
4332
+ var FunctionalController = class extends Controller {
4333
+ constructor(component, constructor) {
4334
+ super(component);
4335
+ const originalExports = this.exports;
4336
+ try {
4337
+ Controller.internals.setAmbientComponent(this.component);
4338
+ const value = constructor(this.component, this);
4339
+ const constructorChangedExports = this.exports !== originalExports;
4340
+ if (value instanceof Promise) {
4341
+ if (!constructorChangedExports)
4342
+ this.setProvisionalExports(value);
4343
+ const resolved = value.then((result) => {
4344
+ this.exports = result;
4345
+ super.catchUpLifecycle();
4346
+ }).catch((error) => {
4347
+ this._ready.reject(error);
4348
+ console.error(error);
4349
+ });
4350
+ this.onLoad(async () => await resolved);
4351
+ } else {
4352
+ if (!constructorChangedExports || value !== void 0)
4353
+ this.exports = value;
4354
+ queueMicrotask(() => super.catchUpLifecycle());
4355
+ }
4356
+ } catch (error) {
4357
+ this._ready.reject(error);
4358
+ console.error(error);
4359
+ }
4360
+ }
4361
+ /** Noop - will be called in the constructor instead */
4362
+ catchUpLifecycle() {
4363
+ return;
4364
+ }
4365
+ };
4366
+ var proxy = proxyExports(FunctionalController);
4367
+ function useT9n({
4368
+ blocking = false,
4369
+ name
4370
+ } = {}) {
4371
+ return makeController((component, controller) => {
4372
+ controller.onLifecycle(
4373
+ () => startLocaleObserver(
4374
+ component.el,
4375
+ index.getAssetPath("./assets"),
4376
+ ({ t9nLocale, t9nStrings, lang }) => {
4377
+ controller.exports = { ...t9nStrings, _lang: lang, _t9nLocale: t9nLocale };
4378
+ const label = t9nStrings.componentLabel ?? t9nStrings.widgetLabel;
4379
+ if (typeof label === "string" && "label" in component && component.label == null)
4380
+ component.label ?? (component.label = label);
4381
+ },
4382
+ name
4383
+ )
4384
+ );
4385
+ if (blocking)
4386
+ return controller.ready;
4387
+ const locale = getElementLocales(component.el);
4388
+ return { _lang: locale.lang, _t9nLocale: locale.t9nLocale };
4389
+ });
2942
4390
  }
2943
4391
 
2944
4392
  function isMonacoEnvironmentSetup() {
@@ -2981,21 +4429,81 @@ function setupMonacoEnvironment(assetsPath) {
2981
4429
  break;
2982
4430
  }
2983
4431
  // If we have a relative path or we are on same orgin, we can use the default js implementation
2984
- if (!arcadeDefaults.ie(url) || arcadeDefaults.se(url, globalThis.location.href, true)) {
4432
+ if (!arcadeDefaults.isURL(url) || arcadeDefaults.hasSameOrigin(url, globalThis.location.href, true)) {
2985
4433
  return new Worker(url, { name: languageId });
2986
4434
  }
2987
4435
  // For cross orgin, we will load the worker code as a string and manufacture a blob
2988
4436
  const esriRequest = await arcadeDefaults.importRequest();
2989
4437
  const response = await esriRequest(url, {
2990
- responseType: "text"
4438
+ responseType: "text",
2991
4439
  });
2992
4440
  return new Worker(URL.createObjectURL(new Blob([response.data], {
2993
- type: "text/javascript"
4441
+ type: "text/javascript",
2994
4442
  })));
2995
- }
4443
+ },
2996
4444
  };
2997
4445
  }
2998
4446
 
4447
+ const themeConfig = {
4448
+ "arcade-light-theme": {
4449
+ comment: "#606060",
4450
+ constant: "#9809C8",
4451
+ date: "#296389",
4452
+ identifier: "#0000B3",
4453
+ keyword: "#BF4900",
4454
+ number: "#136D3D",
4455
+ string: "#A31515"
4456
+ },
4457
+ "arcade-dark-theme": {
4458
+ comment: "#BFBFBF",
4459
+ constant: "#CDBAEA",
4460
+ date: "#97A6CE",
4461
+ identifier: "#9FD4F3",
4462
+ keyword: "#EEAA5A",
4463
+ number: "#AAD04B",
4464
+ string: "#F2877B"
4465
+ }
4466
+ };
4467
+
4468
+ function setupArcadeTheme() {
4469
+ ["light", "dark"].forEach((theme) => {
4470
+ const base = theme === "light" ? "vs" : "vs-dark";
4471
+ const colors = themeConfig[`arcade-${theme}-theme`];
4472
+ // Defines the light and dark theme based on the calcite theme name
4473
+ arcadeDefaults.editor.defineTheme(base, {
4474
+ base,
4475
+ inherit: true,
4476
+ rules: [
4477
+ { token: "comment.arc", foreground: colors.comment },
4478
+ { token: "constant.arc", foreground: colors.constant },
4479
+ { token: "keyword.arc", foreground: colors.keyword },
4480
+ { token: "identifier.arc", foreground: colors.identifier },
4481
+ { token: "number.arc", foreground: colors.number },
4482
+ { token: "string.arc", foreground: colors.string },
4483
+ ],
4484
+ colors: {},
4485
+ });
4486
+ });
4487
+ }
4488
+ const monacoThemeKeys = ["comment", "keyword", "identifier", "string", "number", "constant"];
4489
+ const colorRulesKeys = [...monacoThemeKeys, "date"];
4490
+ function updateThemeColors(theme, colorRules) {
4491
+ if (colorRules === undefined) {
4492
+ setupArcadeTheme();
4493
+ return;
4494
+ }
4495
+ const base = theme === "light" ? "vs" : "vs-dark";
4496
+ const rules = [];
4497
+ monacoThemeKeys.forEach((key) => {
4498
+ const foreground = colorRules[key];
4499
+ if (!foreground) {
4500
+ return;
4501
+ }
4502
+ rules.push({ token: `${key}.arc`, foreground });
4503
+ });
4504
+ arcadeDefaults.editor.defineTheme(base, { base, inherit: true, rules, colors: {} });
4505
+ }
4506
+
2999
4507
  /**
3000
4508
  * Returns the arcade diagnostic service.
3001
4509
  * Example:
@@ -3025,23 +4533,22 @@ async function getArcadeWorker(uri) {
3025
4533
  }
3026
4534
  /**
3027
4535
  * Request the arcade mode
3028
- * @returns mode for arcade
4536
+ * @returns arcade mode module
3029
4537
  */
3030
4538
  async function getMode() {
3031
- return await Promise.resolve().then(function () { return require('./arcade-mode-55360f90.js'); });
4539
+ return await Promise.resolve().then(function () { return require('./arcade-mode-88678d5f.js'); });
3032
4540
  }
3033
4541
  // Register the language in Monaco
3034
4542
  arcadeDefaults.languages.register({
3035
4543
  id: arcadeDefaults.arcadeDefaults.languageId,
3036
4544
  aliases: ["Arcade", "arcade"],
3037
4545
  extensions: [".arc"],
3038
- mimetypes: ["application/arcade"]
4546
+ mimetypes: ["application/arcade"],
3039
4547
  });
3040
4548
  // An event emitted when a language is first time needed
3041
4549
  arcadeDefaults.languages.onLanguage(arcadeDefaults.arcadeDefaults.languageId, () => {
3042
- // Setup the assets path on the arcadeDefaults
4550
+ setupArcadeTheme();
3043
4551
  arcadeDefaults.arcadeDefaults.setLanguageOptions({ assetsPath: `${getAssetsPath() ?? "."}/arcade-language` });
3044
- // Async import the language mode
3045
4552
  getMode()
3046
4553
  .then((mode) => {
3047
4554
  // Setup the language mode
@@ -3052,13 +4559,15 @@ arcadeDefaults.languages.onLanguage(arcadeDefaults.arcadeDefaults.languageId, ()
3052
4559
  });
3053
4560
  });
3054
4561
 
3055
- 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)}";
4562
+ 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)}";
3056
4563
 
3057
4564
  const ArcgisArcadeApi = class {
3058
4565
  constructor(hostRef) {
3059
4566
  index.registerInstance(this, hostRef);
3060
- this.close = index.createEvent(this, "close", 3);
3061
- this.itemSelected = index.createEvent(this, "itemSelected", 3);
4567
+ this.arcgisClose = index.createEvent(this, "arcgisClose", 3);
4568
+ this.arcgisItemSelected = index.createEvent(this, "arcgisItemSelected", 3);
4569
+ this.manager = useControllerManager(this);
4570
+ this.messages = useT9n();
3062
4571
  this._emitItemSelected = (e) => {
3063
4572
  const item = e.target?.["data-item"];
3064
4573
  if (!item) {
@@ -3067,10 +4576,10 @@ const ArcgisArcadeApi = class {
3067
4576
  const keyEvent = e;
3068
4577
  if (!keyEvent.key || keyEvent.key === "Enter") {
3069
4578
  e.preventDefault();
3070
- this.itemSelected.emit(item.completion.insertText);
4579
+ this.arcgisItemSelected.emit(item.completion.insertText);
3071
4580
  }
3072
4581
  };
3073
- this._emitClose = () => this.close.emit();
4582
+ this._emitClose = () => this.arcgisClose.emit();
3074
4583
  this._emitItemSelectedAndClose = (e) => {
3075
4584
  if (!e.target) {
3076
4585
  return;
@@ -3082,7 +4591,7 @@ const ArcgisArcadeApi = class {
3082
4591
  if (!item) {
3083
4592
  return;
3084
4593
  }
3085
- this.itemSelected.emit(item.completion.insertText);
4594
+ this.arcgisItemSelected.emit(item.completion.insertText);
3086
4595
  }
3087
4596
  };
3088
4597
  this._selectItem = (e) => {
@@ -3098,9 +4607,6 @@ const ArcgisArcadeApi = class {
3098
4607
  this._updateFilterValue = (e) => {
3099
4608
  this._filterValue = e.target?.value ?? "";
3100
4609
  };
3101
- this._lang = "";
3102
- this._t9nLocale = "";
3103
- this._t9nStrings = undefined;
3104
4610
  this._selectedApiItem = undefined;
3105
4611
  this._filterValue = "";
3106
4612
  this._colorizeStyle = "";
@@ -3114,7 +4620,6 @@ const ArcgisArcadeApi = class {
3114
4620
  async componentWillLoad() {
3115
4621
  this._colorizeStyle = generateColorizeStyles();
3116
4622
  this._themeChangedListner = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
3117
- await arcadeDefaults.B(this, index.getAssetPath("./assets"));
3118
4623
  arcadeDefaults.arcadeDefaults.onModelContextDidChange((key) => {
3119
4624
  if (!this.modelId || key !== arcadeDefaults.Uri.parse(this.modelId).toString()) {
3120
4625
  return;
@@ -3124,7 +4629,6 @@ const ArcgisArcadeApi = class {
3124
4629
  await this._updateApiLibrary();
3125
4630
  }
3126
4631
  disconnectedCallback() {
3127
- arcadeDefaults.q(this);
3128
4632
  this._flowObserver?.disconnect();
3129
4633
  this._themeChangedListner?.dispose();
3130
4634
  }
@@ -3169,7 +4673,7 @@ const ArcgisArcadeApi = class {
3169
4673
  // When switching between flow the same reference is reused
3170
4674
  this._flowObserver = new MutationObserver(() => {
3171
4675
  // Get the last panel and try to set focus on the input element
3172
- arcadeDefaults.W(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
4676
+ arcadeDefaults.setFocusOnElement(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
3173
4677
  });
3174
4678
  this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
3175
4679
  }
@@ -3180,14 +4684,14 @@ const ArcgisArcadeApi = class {
3180
4684
  if (!filteredApiItems.length) {
3181
4685
  return null;
3182
4686
  }
3183
- return (index.h("calcite-list-item-group", { heading: category.title }, filteredApiItems.map((apiItem) => (index.h("calcite-list-item", { label: arcadeDefaults.G(apiItem.completion.detail), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": apiItem }, index.h("calcite-action", { slot: "actions-end", text: this._t9nStrings?.expand ?? "Expand", icon: "chevron-right", iconFlipRtl: true, scale: "s", onClick: this._selectItem, "data-item": apiItem }))))));
4687
+ return (index.h("calcite-list-item-group", { heading: category.title }, filteredApiItems.map((apiItem) => (index.h("calcite-list-item", { label: arcadeDefaults.addLTRMark(apiItem.completion.detail), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": apiItem }, index.h("calcite-action", { slot: "actions-end", text: this.messages.expand ?? "Expand", icon: "chevron-right", iconFlipRtl: true, scale: "s", onClick: this._selectItem, "data-item": apiItem }))))));
3184
4688
  }
3185
4689
  renderApiItemFlowItem() {
3186
4690
  const apiItem = this._selectedApiItem;
3187
4691
  if (!apiItem) {
3188
4692
  return null;
3189
4693
  }
3190
- return (index.h("calcite-flow-item", { heading: this._t9nStrings?.constantsandfunctions, beforeBack: this._unselectItem, closable: true, onCalciteFlowItemClose: this._emitClose }, this.hideDocumentationActions ? null : (index.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)), index.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"), index.h("calcite-block", { open: true, heading: arcadeDefaults.G(apiItem.completion.detail) }, index.h("div", { innerHTML: convertMarkdownString(apiItem.completion.documentation) }), apiItem.examples ? (index.h("div", { ref: (e) => {
4694
+ return (index.h("calcite-flow-item", { heading: this.messages.constantsandfunctions, beforeBack: this._unselectItem, closable: true, onCalciteFlowItemClose: this._emitClose }, this.hideDocumentationActions ? null : (index.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)), index.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"), index.h("calcite-block", { open: true, heading: arcadeDefaults.addLTRMark(apiItem.completion.detail) }, index.h("div", { innerHTML: convertMarkdownString(apiItem.completion.documentation) }), apiItem.examples ? (index.h("div", { ref: (e) => {
3191
4695
  if (!e) {
3192
4696
  return;
3193
4697
  }
@@ -3198,10 +4702,10 @@ const ArcgisArcadeApi = class {
3198
4702
  render() {
3199
4703
  const categories = (this._apiLibrary ?? []).map((apiCategory) => this.renderApiCategory(apiCategory));
3200
4704
  const empty = categories.every((g) => !g);
3201
- return (index.h(index.Host, null, index.h("style", null, this._colorizeStyle), index.h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, index.h("calcite-flow-item", { heading: this._t9nStrings?.constantsandfunctions, closable: true, onCalciteFlowItemClose: this._emitClose }, index.h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), this._preparingApi ? (index.h("calcite-loader", { scale: "s", type: "indeterminate", label: this._t9nStrings?.loading ?? "Loading" })) : (index.h("calcite-list", null, empty ? index.h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No items") : categories))), this.renderApiItemFlowItem())));
4705
+ return (index.h(index.Host, null, index.h("style", null, this._colorizeStyle), index.h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, index.h("calcite-flow-item", { heading: this.messages.constantsandfunctions, closable: true, onCalciteFlowItemClose: this._emitClose }, index.h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), this._preparingApi ? (index.h("calcite-loader", { scale: "s", type: "indeterminate", label: this.messages.loading ?? "Loading" })) : (index.h("calcite-list", null, empty ? index.h("div", { class: "notice-container" }, this.messages.noitems ?? "No items") : categories))), this.renderApiItemFlowItem())));
3202
4706
  }
3203
4707
  static get assetsDirs() { return ["assets"]; }
3204
- get _hostElement() { return index.getElement(this); }
4708
+ get el() { return index.getElement(this); }
3205
4709
  };
3206
4710
  ArcgisArcadeApi.style = arcadeApiCss;
3207
4711
 
@@ -3388,7 +4892,7 @@ async function executeScript(editorProfile, script, testContext, console) {
3388
4892
  // Setup an executor with the script
3389
4893
  const arcade = await arcadeDefaults.importArcade();
3390
4894
  const executor = await arcade.createArcadeExecutor(script ?? "", {
3391
- variables: editorProfile?.variables ?? []
4895
+ variables: editorProfile?.variables ?? [],
3392
4896
  });
3393
4897
  // We want to measure the execution time
3394
4898
  const t1 = performance.now();
@@ -3398,7 +4902,7 @@ async function executeScript(editorProfile, script, testContext, console) {
3398
4902
  spatialReference,
3399
4903
  timeZone,
3400
4904
  rawOutput: true,
3401
- console
4905
+ console,
3402
4906
  };
3403
4907
  // Execute the script
3404
4908
  const scriptOutput = await executor.executeAsync(profileVariableInstances, executeContext);
@@ -3422,81 +4926,21 @@ async function executeScript(editorProfile, script, testContext, console) {
3422
4926
  error,
3423
4927
  timeStamp,
3424
4928
  compilationTime: 0,
3425
- executionTime: 0
4929
+ executionTime: 0,
3426
4930
  };
3427
4931
  }
3428
4932
  }
3429
4933
 
3430
- const themeConfig = {
3431
- "arcade-light-theme": {
3432
- comment: "#606060",
3433
- constant: "#9809C8",
3434
- date: "#296389",
3435
- identifier: "#0000B3",
3436
- keyword: "#BF4900",
3437
- number: "#136D3D",
3438
- string: "#A31515"
3439
- },
3440
- "arcade-dark-theme": {
3441
- comment: "#BFBFBF",
3442
- constant: "#CDBAEA",
3443
- date: "#97A6CE",
3444
- identifier: "#9FD4F3",
3445
- keyword: "#EEAA5A",
3446
- number: "#AAD04B",
3447
- string: "#F2877B"
3448
- }
3449
- };
4934
+ 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)}";
3450
4935
 
3451
- function setupArcadeTheme() {
3452
- ["light", "dark"].forEach((theme) => {
3453
- const base = theme === "light" ? "vs" : "vs-dark";
3454
- const colors = themeConfig[`arcade-${theme}-theme`];
3455
- // Defines the light and dark theme based on the calcite theme name
3456
- arcadeDefaults.editor.defineTheme(base, {
3457
- base,
3458
- inherit: true,
3459
- rules: [
3460
- { token: "comment.arc", foreground: colors.comment },
3461
- { token: "constant.arc", foreground: colors.constant },
3462
- { token: "keyword.arc", foreground: colors.keyword },
3463
- { token: "identifier.arc", foreground: colors.identifier },
3464
- { token: "number.arc", foreground: colors.number },
3465
- { token: "string.arc", foreground: colors.string }
3466
- ],
3467
- colors: {}
3468
- });
3469
- });
3470
- }
3471
- const monacoThemeKeys = ["comment", "keyword", "identifier", "string", "number", "constant"];
3472
- const colorRulesKeys = [...monacoThemeKeys, "date"];
3473
- function updateThemeColors(theme, colorRules) {
3474
- if (colorRules === undefined) {
3475
- setupArcadeTheme();
3476
- return;
3477
- }
3478
- const base = theme === "light" ? "vs" : "vs-dark";
3479
- const rules = [];
3480
- monacoThemeKeys.forEach((key) => {
3481
- const foreground = colorRules[key];
3482
- if (!foreground) {
3483
- return;
3484
- }
3485
- rules.push({ token: `${key}.arc`, foreground });
3486
- });
3487
- arcadeDefaults.editor.defineTheme(base, { base, inherit: true, rules, colors: {} });
3488
- }
3489
-
3490
- 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)}";
3491
-
3492
- setupArcadeTheme();
3493
4936
  const ArcgisArcadeEditor = class {
3494
4937
  constructor(hostRef) {
3495
4938
  index.registerInstance(this, hostRef);
3496
- this.scriptChange = index.createEvent(this, "scriptChange", 3);
3497
- this.diagnosticsChange = index.createEvent(this, "diagnosticsChange", 3);
3498
- this._componentReadyDefer = new arcadeDefaults.h();
3499
- this._modelId = arcadeDefaults.U();
4939
+ this.arcgisScriptChange = index.createEvent(this, "arcgisScriptChange", 3);
4940
+ this.arcgisDiagnosticsChange = index.createEvent(this, "arcgisDiagnosticsChange", 3);
4941
+ this.manager = useControllerManager(this);
4942
+ this._componentReadyDefer = new arcadeDefaults.Deferred();
4943
+ this._modelId = arcadeDefaults.generateGuid();
3500
4944
  this._editorProfilePromise = Promise.resolve(undefined);
3501
4945
  this._disposables = [];
3502
4946
  this._executeScript = async () => {
@@ -3539,15 +4983,13 @@ const ArcgisArcadeEditor = class {
3539
4983
  this._openArcadeHelp = () => void window.open(DevelopersWebSitePath, "Arcade Help");
3540
4984
  this._emitScriptChange = (e) => {
3541
4985
  e.stopPropagation();
3542
- this.scriptChange.emit(e.detail);
4986
+ this.arcgisScriptChange.emit(e.detail);
3543
4987
  };
3544
4988
  this._insertAsSnippet = (e) => void this._codeEditorElt?.insertSnippet(e.detail).catch(console.error);
3545
4989
  this._insertAsText = (e) => void this._codeEditorElt?.insertText(e.detail).catch(console.error);
3546
4990
  this._onResultPanelChange = (e) => void (this._resultPanel = e.detail);
3547
4991
  this._onExecutionPanelClose = () => void (this._showExecutionPanel = false);
3548
- this._lang = "";
3549
- this._t9nLocale = "";
3550
- this._t9nStrings = undefined;
4992
+ this.messages = useT9n();
3551
4993
  this._standaloneCodeEditor = undefined;
3552
4994
  this._preparingProfile = false;
3553
4995
  this._editorProfile = undefined;
@@ -3578,7 +5020,7 @@ const ArcgisArcadeEditor = class {
3578
5020
  }
3579
5021
  _snippetChanged() {
3580
5022
  arcadeDefaults.arcadeDefaults.updateApiContextForModel(this._modelId, {
3581
- snippets: this.snippets
5023
+ snippets: this.snippets,
3582
5024
  });
3583
5025
  }
3584
5026
  // #endregion
@@ -3627,11 +5069,11 @@ const ArcgisArcadeEditor = class {
3627
5069
  * @internal
3628
5070
  */
3629
5071
  async updateThemeColors(colorRules) {
3630
- const theme = arcadeDefaults.k(this._hostElement);
5072
+ const theme = arcadeDefaults.getElementTheme(this.el);
3631
5073
  updateThemeColors(theme, colorRules);
3632
5074
  if (colorRules === undefined) {
3633
5075
  colorRulesKeys.forEach((key) => {
3634
- this._hostElement.style.removeProperty(`--arcgis-arcade-editor-${key}`);
5076
+ this.el.style.removeProperty(`--arcgis-arcade-editor-${key}`);
3635
5077
  });
3636
5078
  return;
3637
5079
  }
@@ -3640,7 +5082,7 @@ const ArcgisArcadeEditor = class {
3640
5082
  if (!foreground) {
3641
5083
  return;
3642
5084
  }
3643
- this._hostElement.style.setProperty(`--arcgis-arcade-editor-${key}`, foreground);
5085
+ this.el.style.setProperty(`--arcgis-arcade-editor-${key}`, foreground);
3644
5086
  });
3645
5087
  }
3646
5088
  // #endregion
@@ -3648,14 +5090,13 @@ const ArcgisArcadeEditor = class {
3648
5090
  async componentWillLoad() {
3649
5091
  const assetsPath = index.getAssetPath("./assets");
3650
5092
  // We are a bit in a chicken and egg situation here.
3651
- // Normally, it is the code editor that is responsible for setting up the Monaco environement.
5093
+ // Normally, it is the code editor that is responsible for setting up the Monaco environment.
3652
5094
  // However, we need to setup the environment before the code editor is instantiated because
3653
5095
  // we need to access the arcade language service to get the api library.
3654
5096
  setupMonacoEnvironment(assetsPath);
3655
- // Starts a locale observer. It will load the correct t9n strings for the component
3656
- // when the locale changes. We also pass updateEditorProfile. It will be invoked the first
3657
- // and on each locale change. The profile has to be refreshed on locale change as well.
3658
- await arcadeDefaults.B(this, assetsPath, async () => await this._updateEditorProfile());
5097
+ await this._updateEditorProfile();
5098
+ // The profile has to be refreshed on locale change
5099
+ this.manager.watch("messages", () => void this._updateEditorProfile().catch(console.error));
3659
5100
  }
3660
5101
  async componentDidLoad() {
3661
5102
  // Mark on component as ready.
@@ -3664,7 +5105,7 @@ const ArcgisArcadeEditor = class {
3664
5105
  // Start listening to the validation diagnostics.
3665
5106
  // We are doing this as late as possible
3666
5107
  const diagnosticsService = await getArcadeDiagnosticService();
3667
- this._disposables.push(diagnosticsService.onDiagnosticsChange((event) => !this._preparingProfile && this.diagnosticsChange.emit(event.diagnostics)));
5108
+ this._disposables.push(diagnosticsService.onDiagnosticsChange((event) => !this._preparingProfile && this.arcgisDiagnosticsChange.emit(event.diagnostics)));
3668
5109
  // Get editor instance and add action
3669
5110
  this._standaloneCodeEditor = await this.getEditorInstance();
3670
5111
  this._standaloneCodeEditor?.addAction({
@@ -3678,12 +5119,11 @@ const ArcgisArcadeEditor = class {
3678
5119
  if (this.testData) {
3679
5120
  this._executeScript().catch(console.error);
3680
5121
  }
3681
- }
5122
+ },
3682
5123
  });
3683
5124
  await this._codeEditorElt?.setFocus();
3684
5125
  }
3685
5126
  disconnectedCallback() {
3686
- arcadeDefaults.q(this);
3687
5127
  arcadeDefaults.arcadeDefaults.disposeApiContextForModel(this._modelId);
3688
5128
  arcadeDefaults.arcadeDefaults.disposeEditorProfileForModel(this._modelId);
3689
5129
  while (this._disposables.length) {
@@ -3700,8 +5140,8 @@ const ArcgisArcadeEditor = class {
3700
5140
  try {
3701
5141
  // Set a new profile for the model using the profile definition and the locale.
3702
5142
  await arcadeDefaults.arcadeDefaults.setProfileForModel(this._modelId, this.profile, {
3703
- locale: this._t9nLocale,
3704
- snippets: this.snippets
5143
+ locale: this.messages._t9nLocale,
5144
+ snippets: this.snippets,
3705
5145
  });
3706
5146
  // Get the corresponding editor profile for the model.
3707
5147
  // The editor profile contains the specialized profile for the UI.
@@ -3721,16 +5161,16 @@ const ArcgisArcadeEditor = class {
3721
5161
  if (!this.testData) {
3722
5162
  return null;
3723
5163
  }
3724
- return (index.h("calcite-action-bar", { class: "main-action-bar", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, index.h("calcite-action-group", { scale: "s" }, index.h("calcite-action", { text: this._t9nStrings?.run ?? "Run", "text-enabled": true, icon: "play", scale: "s", loading: this._preparingProfile, onClick: this._executeScript }), this._executionResult ? (index.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)));
5164
+ return (index.h("calcite-action-bar", { class: "main-action-bar", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, index.h("calcite-action-group", { scale: "s" }, index.h("calcite-action", { text: this.messages.run ?? "Run", "text-enabled": true, icon: "play", scale: "s", loading: this._preparingProfile, onClick: this._executeScript }), this._executionResult ? (index.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)));
3725
5165
  }
3726
5166
  //#endregion
3727
5167
  //#region Render Main Panel
3728
5168
  renderMainPanel() {
3729
- return (index.h("arcgis-code-editor", { class: "flex-adjustable", language: arcadeDefaults.arcadeDefaults.languageId, value: this.script ?? "", modelId: this._modelId, options: this.editorOptions, onValueChange: this._emitScriptChange, ref: (e) => (this._codeEditorElt = e) }));
5169
+ return (index.h("arcgis-code-editor", { class: "flex-adjustable", language: arcadeDefaults.arcadeDefaults.languageId, value: this.script ?? "", modelId: this._modelId, options: this.editorOptions, onArcgisValueChange: this._emitScriptChange, ref: (e) => (this._codeEditorElt = e) }));
3730
5170
  }
3731
5171
  //#endregion
3732
5172
  //#region Rendering the Action Bar
3733
- renderAction({ id, label, icon, active, panelName, onClick = this._toggleSidePanel }) {
5173
+ renderAction({ id, label, icon, active, panelName, onClick = this._toggleSidePanel, }) {
3734
5174
  return (index.h(index.Fragment, null, index.h("calcite-action", { id: id, text: label, icon: icon, active: active, onClick: onClick, "data-panel-name": panelName }), !this.sideActionBarExpanded && (index.h("calcite-tooltip", { label: label, "reference-element": id }, index.h("span", null, label)))));
3735
5175
  }
3736
5176
  renderSideActionBar() {
@@ -3739,33 +5179,33 @@ const ArcgisArcadeEditor = class {
3739
5179
  }
3740
5180
  return (index.h("calcite-action-bar", { class: "side-action-bar border-inline-start", expanded: !!this.sideActionBarExpanded, position: "end", onCalciteActionBarToggle: this._toggleSideActionBarExpanded }, index.h("calcite-action-group", null, this.renderAction({
3741
5181
  id: "profile-variables-action",
3742
- label: this._t9nStrings?.profilevariables ?? "Profile variables",
5182
+ label: this.messages.profilevariables ?? "Profile variables",
3743
5183
  icon: "profile-variables",
3744
5184
  active: this.openedSidePanel === "variables",
3745
- panelName: "variables"
5185
+ panelName: "variables",
3746
5186
  }), this.renderAction({
3747
5187
  id: "function-action",
3748
- label: this._t9nStrings?.constantsandfunctions ?? "Constants and functions",
5188
+ label: this.messages.constantsandfunctions ?? "Constants and functions",
3749
5189
  icon: "function",
3750
5190
  active: this.openedSidePanel === "api",
3751
- panelName: "api"
5191
+ panelName: "api",
3752
5192
  }), this.suggestions?.length
3753
5193
  ? this.renderAction({
3754
5194
  id: "suggestions-action",
3755
- label: this._t9nStrings?.suggestions ?? "Suggestions",
5195
+ label: this.messages.suggestions ?? "Suggestions",
3756
5196
  icon: "lightbulb",
3757
5197
  active: this.openedSidePanel === "suggestions",
3758
- panelName: "suggestions"
5198
+ panelName: "suggestions",
3759
5199
  })
3760
5200
  : null, this.hideDocumentationActions
3761
5201
  ? null
3762
5202
  : this.renderAction({
3763
5203
  id: "developer-website-action",
3764
- label: this._t9nStrings?.help ?? "Help",
5204
+ label: this.messages.help ?? "Help",
3765
5205
  icon: "question",
3766
5206
  active: false,
3767
5207
  panelName: "none",
3768
- onClick: this._openArcadeHelp
5208
+ onClick: this._openArcadeHelp,
3769
5209
  }))));
3770
5210
  }
3771
5211
  //#endregion
@@ -3776,11 +5216,11 @@ const ArcgisArcadeEditor = class {
3776
5216
  }
3777
5217
  switch (this.openedSidePanel) {
3778
5218
  case "api":
3779
- return (index.h("arcgis-arcade-api", { class: "side-panel flex-panel border-inline-start", modelId: this._modelId, hideDocumentationActions: this.hideDocumentationActions, onItemSelected: this._insertAsSnippet, onClose: this._toggleSidePanel, "data-panel-name": "none" }));
5219
+ return (index.h("arcgis-arcade-api", { class: "side-panel flex-panel border-inline-start", modelId: this._modelId, hideDocumentationActions: this.hideDocumentationActions, onArcgisItemSelected: this._insertAsSnippet, onArcgisClose: this._toggleSidePanel, "data-panel-name": "none" }));
3780
5220
  case "variables":
3781
- return (index.h("arcgis-arcade-variables", { class: "side-panel flex-panel border-inline-start", loading: this._preparingProfile, modelId: this._modelId, onItemSelected: this._insertAsText, onClose: this._toggleSidePanel, "data-panel-name": "none" }));
5221
+ return (index.h("arcgis-arcade-variables", { class: "side-panel flex-panel border-inline-start", loading: this._preparingProfile, modelId: this._modelId, onArcgisItemSelected: this._insertAsText, onArcgisClose: this._toggleSidePanel, "data-panel-name": "none" }));
3782
5222
  case "suggestions":
3783
- return (index.h("arcgis-arcade-suggestions", { class: "side-panel flex-panel border-inline-start", suggestions: this.suggestions, onItemSelected: this._insertAsText, onClose: this._toggleSidePanel, "data-panel-name": "none" }));
5223
+ return (index.h("arcgis-arcade-suggestions", { class: "side-panel flex-panel border-inline-start", suggestions: this.suggestions, onArcgisItemSelected: this._insertAsText, onArcgisClose: this._toggleSidePanel, "data-panel-name": "none" }));
3784
5224
  default:
3785
5225
  return null;
3786
5226
  }
@@ -3791,7 +5231,7 @@ const ArcgisArcadeEditor = class {
3791
5231
  if (!this._showExecutionPanel) {
3792
5232
  return null;
3793
5233
  }
3794
- return (index.h("arcgis-arcade-results", { class: "flex-adjustable", openedResultPanel: this._resultPanel, loading: this._executingScript, result: this._executionResult, consoleLogs: this._consoleLogs, onOpenedResultPanelChange: this._onResultPanelChange, onClose: this._onExecutionPanelClose }));
5234
+ return (index.h("arcgis-arcade-results", { class: "flex-adjustable", openedResultPanel: this._resultPanel, loading: this._executingScript, result: this._executionResult, consoleLogs: this._consoleLogs, onArcgisOpenedResultPanelChange: this._onResultPanelChange, onArcgisClose: this._onExecutionPanelClose }));
3795
5235
  }
3796
5236
  //#endregion
3797
5237
  //#region Render
@@ -3799,7 +5239,7 @@ const ArcgisArcadeEditor = class {
3799
5239
  return (index.h(index.Host, null, this.renderMainActionBar(), index.h("div", { class: "flex-row flex-adjustable" }, index.h("div", { class: "flex-column flex-adjustable" }, this.renderMainPanel(), this.renderResultsPanel()), this.renderSidePanel(), this.renderSideActionBar())));
3800
5240
  }
3801
5241
  static get assetsDirs() { return ["assets"]; }
3802
- get _hostElement() { return index.getElement(this); }
5242
+ get el() { return index.getElement(this); }
3803
5243
  static get watchers() { return {
3804
5244
  "profile": ["_profileChanged"],
3805
5245
  "testData": ["_testDataChanged"],
@@ -3808,20 +5248,20 @@ const ArcgisArcadeEditor = class {
3808
5248
  };
3809
5249
  ArcgisArcadeEditor.style = arcadeEditorCss;
3810
5250
 
3811
- 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)}";
5251
+ 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)}";
3812
5252
 
3813
5253
  //#region Specialized Constants
3814
5254
  const treeProps = {
3815
5255
  lines: true,
3816
5256
  selectionMode: "none",
3817
5257
  scale: "s",
3818
- onCalciteTreeSelect: (e) => e.target.selectedItems.forEach((itemElt) => (itemElt.selected = false))
5258
+ onCalciteTreeSelect: (e) => e.target.selectedItems.forEach((itemElt) => (itemElt.selected = false)),
3819
5259
  };
3820
5260
  const expandableTreeItemProps = {
3821
5261
  onClick: (e) => {
3822
5262
  const item = e.currentTarget;
3823
5263
  item.expanded = !item.expanded;
3824
- }
5264
+ },
3825
5265
  };
3826
5266
  //#endregion
3827
5267
  //#region Helper Functions
@@ -3840,7 +5280,7 @@ function renderSimpleValue(arcadeResult) {
3840
5280
  case "null":
3841
5281
  return index.h("span", { class: "constant-value" }, arcadeResult.type);
3842
5282
  case "text":
3843
- return index.h("span", { class: "string-value" }, arcadeDefaults.D(arcadeResult.value));
5283
+ return index.h("span", { class: "string-value" }, arcadeDefaults.quoteString(arcadeResult.value));
3844
5284
  case "number":
3845
5285
  return index.h("span", { class: "number-value" }, arcadeResult.value.toString());
3846
5286
  case "boolean":
@@ -3848,9 +5288,9 @@ function renderSimpleValue(arcadeResult) {
3848
5288
  case "date":
3849
5289
  return index.h("span", { class: "date-value" }, formatArcadeResultDate(arcadeResult));
3850
5290
  case "dateOnly":
3851
- return index.h("span", { class: "string-value" }, arcadeDefaults.D(formatArcadeResultDateOnly(arcadeResult)));
5291
+ return index.h("span", { class: "string-value" }, arcadeDefaults.quoteString(formatArcadeResultDateOnly(arcadeResult)));
3852
5292
  case "time":
3853
- return index.h("span", { class: "string-value" }, arcadeDefaults.D(formatArcadeResultTimeOnly(arcadeResult)));
5293
+ return index.h("span", { class: "string-value" }, arcadeDefaults.quoteString(formatArcadeResultTimeOnly(arcadeResult)));
3854
5294
  default:
3855
5295
  return null;
3856
5296
  }
@@ -3870,8 +5310,11 @@ function renderFeatureSetTable(arcadeResult) {
3870
5310
  const ArcgisArcadeResults = class {
3871
5311
  constructor(hostRef) {
3872
5312
  index.registerInstance(this, hostRef);
3873
- this.openedResultPanelChange = index.createEvent(this, "openedResultPanelChange", 3);
3874
- this.close = index.createEvent(this, "close", 3);
5313
+ this.arcgisOpenedResultPanelChange = index.createEvent(this, "arcgisOpenedResultPanelChange", 3);
5314
+ this.arcgisClose = index.createEvent(this, "arcgisClose", 3);
5315
+ this.manager = useControllerManager(this);
5316
+ //#region Private Properties
5317
+ this.messages = useT9n();
3875
5318
  this._switchResultPanel = (e) => {
3876
5319
  if (!e.target) {
3877
5320
  return;
@@ -3882,28 +5325,17 @@ const ArcgisArcadeResults = class {
3882
5325
  }
3883
5326
  this.updateResultPanel(panelName);
3884
5327
  };
3885
- this._emitClose = () => this.close.emit();
3886
- this._lang = "";
3887
- this._t9nLocale = "";
3888
- this._t9nStrings = undefined;
5328
+ this._emitClose = () => this.arcgisClose.emit();
3889
5329
  this.loading = true;
3890
5330
  this.openedResultPanel = "output";
3891
5331
  this.result = undefined;
3892
5332
  this.consoleLogs = undefined;
3893
5333
  }
3894
5334
  //#endregion
3895
- // #region Component lifecycle events
3896
- async componentWillLoad() {
3897
- await arcadeDefaults.B(this, index.getAssetPath("./assets"));
3898
- }
3899
- disconnectedCallback() {
3900
- arcadeDefaults.q(this);
3901
- }
3902
- // #endregion
3903
5335
  //#region Private Methods
3904
5336
  updateResultPanel(resultPanelType) {
3905
5337
  this.openedResultPanel = resultPanelType;
3906
- this.openedResultPanelChange.emit(resultPanelType);
5338
+ this.arcgisOpenedResultPanelChange.emit(resultPanelType);
3907
5339
  }
3908
5340
  //#endregion
3909
5341
  //#region Rendering
@@ -3914,7 +5346,7 @@ const ArcgisArcadeResults = class {
3914
5346
  if (this.loading && !this.consoleLogs?.length) {
3915
5347
  return index.h("calcite-loader", { scale: "s", type: "indeterminate", label: "" });
3916
5348
  }
3917
- return (index.h("div", { class: "console-logs-container ltr-container" }, this.consoleLogs?.length ? (this.consoleLogs.map((log) => index.h("p", null, log))) : (index.h("p", null, this._t9nStrings?.consolemessage))));
5349
+ return (index.h("div", { class: "console-logs-container ltr-container" }, this.consoleLogs?.length ? this.consoleLogs.map((log) => index.h("p", null, log)) : index.h("p", null, this.messages.consolemessage)));
3918
5350
  }
3919
5351
  renderLogPanel() {
3920
5352
  if (this.openedResultPanel !== "log") {
@@ -3924,24 +5356,24 @@ const ArcgisArcadeResults = class {
3924
5356
  return index.h("calcite-loader", { scale: "s", type: "indeterminate", label: "" });
3925
5357
  }
3926
5358
  const iconClass = this.result?.type === "error" ? "color-error" : "color-success";
3927
- return (index.h("calcite-list", null, this.result ? (index.h(index.Fragment, null, index.h("calcite-list-item", { label: arcadeDefaults.Z(this._t9nStrings?.lastexecutionformat, {
3928
- timeStamp: new Intl.DateTimeFormat(this._t9nLocale, {
5359
+ return (index.h("calcite-list", null, this.result ? (index.h(index.Fragment, null, index.h("calcite-list-item", { label: arcadeDefaults.setValuesInString(this.messages.lastexecutionformat, {
5360
+ timeStamp: new Intl.DateTimeFormat(this.messages._t9nLocale, {
3929
5361
  dateStyle: "medium",
3930
- timeStyle: "medium"
3931
- }).format(this.result.timeStamp)
3932
- }) }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), index.h("calcite-list-item", { label: arcadeDefaults.Z(this._t9nStrings?.compilationtimeformat, {
3933
- time: new Intl.NumberFormat(this._t9nLocale, {
5362
+ timeStyle: "medium",
5363
+ }).format(this.result.timeStamp),
5364
+ }) }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), index.h("calcite-list-item", { label: arcadeDefaults.setValuesInString(this.messages.compilationtimeformat, {
5365
+ time: new Intl.NumberFormat(this.messages._t9nLocale, {
3934
5366
  style: "unit",
3935
5367
  unit: "millisecond",
3936
- maximumFractionDigits: 2
3937
- }).format(this.result.compilationTime ?? 0)
3938
- }) }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), index.h("calcite-list-item", { label: arcadeDefaults.Z(this._t9nStrings?.executiontimeformat, {
3939
- time: new Intl.NumberFormat(this._t9nLocale, {
5368
+ maximumFractionDigits: 2,
5369
+ }).format(this.result.compilationTime ?? 0),
5370
+ }) }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), index.h("calcite-list-item", { label: arcadeDefaults.setValuesInString(this.messages.executiontimeformat, {
5371
+ time: new Intl.NumberFormat(this.messages._t9nLocale, {
3940
5372
  style: "unit",
3941
5373
  unit: "millisecond",
3942
- maximumFractionDigits: 2
3943
- }).format(this.result.executionTime ?? 0)
3944
- }) }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })))) : (index.h("calcite-list-item", { label: this._t9nStrings?.runscriptmessage ?? "No output, run the script once." }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: "color-info" })))));
5374
+ maximumFractionDigits: 2,
5375
+ }).format(this.result.executionTime ?? 0),
5376
+ }) }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })))) : (index.h("calcite-list-item", { label: this.messages.runscriptmessage ?? "No output, run the script once." }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: "color-info" })))));
3945
5377
  }
3946
5378
  renderOutputPanel() {
3947
5379
  if (this.openedResultPanel !== "output") {
@@ -3952,8 +5384,8 @@ const ArcgisArcadeResults = class {
3952
5384
  }
3953
5385
  switch (this.result?.type) {
3954
5386
  case "error":
3955
- return (index.h("div", { class: "result-value-simple flex-adjustable" }, arcadeDefaults.Z(this._t9nStrings?.executionerrorformat, {
3956
- message: this.result.value
5387
+ return (index.h("div", { class: "result-value-simple flex-adjustable" }, arcadeDefaults.setValuesInString(this.messages.executionerrorformat, {
5388
+ message: this.result.value,
3957
5389
  })));
3958
5390
  case "null":
3959
5391
  case "unknown":
@@ -3983,14 +5415,14 @@ const ArcgisArcadeResults = class {
3983
5415
  case "knowledgeGraph":
3984
5416
  return (index.h("div", { class: "result-value-simple ltr-container" }, index.h("span", { class: "value-type" }, this.result.type, ":\u00A0"), index.h("span", { class: "string-value" }, this.result.value.url)));
3985
5417
  default:
3986
- return (index.h("div", { class: "result-value-simple flex-adjustable ltr-container" }, this._t9nStrings?.runscriptmessage));
5418
+ return index.h("div", { class: "result-value-simple flex-adjustable ltr-container" }, this.messages.runscriptmessage);
3987
5419
  }
3988
5420
  }
3989
5421
  renderArrayHeader(arcadeResult) {
3990
5422
  const items = arcadeResult.value ?? [];
3991
5423
  const leftoverCount = Math.max(items.length - MaxArrayItems, 0);
3992
- return (index.h(index.Fragment, null, index.h("span", null, `${arcadeResult.type}(${items.length ?? 0})`), leftoverCount > 0 ? (index.h("span", null, "\u00A0", arcadeDefaults.Z(this._t9nStrings?.showingfirstitemsformat, {
3993
- count: MaxArrayItems.toString()
5424
+ return (index.h(index.Fragment, null, index.h("span", null, `${arcadeResult.type}(${items.length ?? 0})`), leftoverCount > 0 ? (index.h("span", null, "\u00A0", arcadeDefaults.setValuesInString(this.messages.showingfirstitemsformat, {
5425
+ count: MaxArrayItems.toString(),
3994
5426
  }))) : null));
3995
5427
  }
3996
5428
  renderArrayTree(items, subtree = false) {
@@ -4035,15 +5467,15 @@ const ArcgisArcadeResults = class {
4035
5467
  }
4036
5468
  }
4037
5469
  renderFeatureSetLabel(arcadeResult) {
4038
- return (index.h("div", { class: "value-type" }, index.h("span", null, arcadeResult.type, ":"), arcadeResult.features.length >= BatchSize ? (index.h("span", null, "\u00A0", arcadeDefaults.Z(this._t9nStrings?.showingfirstitemsformat, {
4039
- count: BatchSize.toString()
5470
+ return (index.h("div", { class: "value-type" }, index.h("span", null, arcadeResult.type, ":"), arcadeResult.features.length >= BatchSize ? (index.h("span", null, "\u00A0", arcadeDefaults.setValuesInString(this.messages.showingfirstitemsformat, {
5471
+ count: BatchSize.toString(),
4040
5472
  }))) : null));
4041
5473
  }
4042
5474
  render() {
4043
- return (index.h(index.Host, null, index.h("header", { class: "flex-row" }, index.h("calcite-action-bar", { class: "flex-adjustable", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, index.h("calcite-action-group", { scale: "s" }, index.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" }), index.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" }), index.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" }))), index.h("calcite-action", { scale: "s", icon: "x", text: this._t9nStrings?.close ?? "", onClick: this._emitClose })), index.h("article", { class: "flex-adjustable" }, this.loading ? (index.h("calcite-loader", { scale: "s", type: "indeterminate", label: "" })) : (index.h("div", { class: "flex-column y-scrollable-container" }, this.renderOutputPanel(), this.renderConsolePanel(), this.renderLogPanel())))));
5475
+ return (index.h(index.Host, null, index.h("header", { class: "flex-row" }, index.h("calcite-action-bar", { class: "flex-adjustable", layout: "horizontal", scale: "s", expanded: true, "expand-disabled": true }, index.h("calcite-action-group", { scale: "s" }, index.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" }), index.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" }), index.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" }))), index.h("calcite-action", { scale: "s", icon: "x", text: this.messages.close ?? "", onClick: this._emitClose })), index.h("article", { class: "flex-adjustable" }, this.loading ? (index.h("calcite-loader", { scale: "s", type: "indeterminate", label: "" })) : (index.h("div", { class: "flex-column y-scrollable-container" }, this.renderOutputPanel(), this.renderConsolePanel(), this.renderLogPanel())))));
4044
5476
  }
4045
5477
  static get assetsDirs() { return ["assets"]; }
4046
- get _hostElement() { return index.getElement(this); }
5478
+ get el() { return index.getElement(this); }
4047
5479
  };
4048
5480
  ArcgisArcadeResults.style = arcadeResultsCss;
4049
5481
 
@@ -4057,13 +5489,15 @@ function isSuggestionGroups(item) {
4057
5489
  return Array.isArray(item[0].suggestions);
4058
5490
  }
4059
5491
 
4060
- 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)}";
5492
+ 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)}";
4061
5493
 
4062
5494
  const ArcgisArcadeSuggestions = class {
4063
5495
  constructor(hostRef) {
4064
5496
  index.registerInstance(this, hostRef);
4065
- this.close = index.createEvent(this, "close", 3);
4066
- this.itemSelected = index.createEvent(this, "itemSelected", 3);
5497
+ this.arcgisClose = index.createEvent(this, "arcgisClose", 3);
5498
+ this.arcgisItemSelected = index.createEvent(this, "arcgisItemSelected", 3);
5499
+ this.manager = useControllerManager(this);
5500
+ this.messages = useT9n();
4067
5501
  this._updateFilterValue = (e) => {
4068
5502
  this._filterValue = e.target?.value ?? "";
4069
5503
  };
@@ -4075,7 +5509,7 @@ const ArcgisArcadeSuggestions = class {
4075
5509
  const keyEvent = e;
4076
5510
  if (!keyEvent.key || keyEvent.key === "Enter") {
4077
5511
  e.preventDefault();
4078
- this.itemSelected.emit(item.code);
5512
+ this.arcgisItemSelected.emit(item.code);
4079
5513
  }
4080
5514
  };
4081
5515
  this._showSuggestionDetail = (e) => {
@@ -4087,14 +5521,11 @@ const ArcgisArcadeSuggestions = class {
4087
5521
  this._selectedSuggestion = item;
4088
5522
  };
4089
5523
  this._emitClose = () => {
4090
- this.close.emit();
5524
+ this.arcgisClose.emit();
4091
5525
  };
4092
5526
  this._beforeBack = async () => {
4093
5527
  this._selectedSuggestion = undefined;
4094
5528
  };
4095
- this._lang = "";
4096
- this._t9nLocale = "";
4097
- this._t9nStrings = undefined;
4098
5529
  this._selectedSuggestion = undefined;
4099
5530
  this._filterValue = "";
4100
5531
  this._colorizeStyle = "";
@@ -4108,12 +5539,10 @@ const ArcgisArcadeSuggestions = class {
4108
5539
  async componentWillLoad() {
4109
5540
  this._colorizeStyle = generateColorizeStyles();
4110
5541
  this._themeChangedListner = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
4111
- await arcadeDefaults.B(this, index.getAssetPath("./assets"));
4112
5542
  }
4113
5543
  disconnectedCallback() {
4114
5544
  this._flowObserver?.disconnect();
4115
5545
  this._themeChangedListner?.dispose();
4116
- arcadeDefaults.q(this);
4117
5546
  }
4118
5547
  // #endregion
4119
5548
  //#region Private Methods
@@ -4131,7 +5560,7 @@ const ArcgisArcadeSuggestions = class {
4131
5560
  // When switching between flow the same reference is reused
4132
5561
  this._flowObserver = new MutationObserver(() => {
4133
5562
  // Get the last panel and try to set focus on the input element
4134
- arcadeDefaults.W(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
5563
+ arcadeDefaults.setFocusOnElement(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
4135
5564
  });
4136
5565
  this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
4137
5566
  }
@@ -4149,29 +5578,29 @@ const ArcgisArcadeSuggestions = class {
4149
5578
  renderSuggestionListItems(suggestions) {
4150
5579
  suggestions = arcadeDefaults.filterCollection(suggestions, "label", this._filterValue);
4151
5580
  if (!suggestions.length) {
4152
- return index.h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No item");
5581
+ return index.h("div", { class: "notice-container" }, this.messages.noitems ?? "No item");
4153
5582
  }
4154
- return suggestions.map((suggestion) => (index.h("calcite-list-item", { label: suggestion.label, description: suggestion.description, onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": suggestion }, index.h("calcite-action", { slot: "actions-end", text: this._t9nStrings?.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showSuggestionDetail, "data-item": suggestion }))));
5583
+ return suggestions.map((suggestion) => (index.h("calcite-list-item", { label: suggestion.label, description: suggestion.description, onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": suggestion }, index.h("calcite-action", { slot: "actions-end", text: this.messages.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showSuggestionDetail, "data-item": suggestion }))));
4155
5584
  }
4156
5585
  renderSuggestionFlowItem() {
4157
5586
  const suggestion = this._selectedSuggestion;
4158
5587
  if (!suggestion) {
4159
5588
  return null;
4160
5589
  }
4161
- return (index.h("calcite-flow-item", { heading: this._t9nStrings?.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose, beforeBack: this._beforeBack }, index.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), index.h("calcite-block", { open: true, heading: suggestion.label, description: suggestion.description }, index.h("div", { innerHTML: convertMarkdownString(suggestion.documentation) }), index.h("pre", null, index.h("code", { ref: (e) => e === undefined ? undefined : void colorizeCodeElement(e, suggestion.code).catch(console.error) })))));
5590
+ return (index.h("calcite-flow-item", { heading: this.messages.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose, beforeBack: this._beforeBack }, index.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), index.h("calcite-block", { open: true, heading: suggestion.label, description: suggestion.description }, index.h("div", { innerHTML: convertMarkdownString(suggestion.documentation) }), index.h("pre", null, index.h("code", { ref: (e) => e === undefined ? undefined : void colorizeCodeElement(e, suggestion.code).catch(console.error) })))));
4162
5591
  }
4163
5592
  render() {
4164
- return (index.h(index.Host, null, index.h("style", null, this._colorizeStyle), index.h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, index.h("calcite-flow-item", { heading: this._t9nStrings?.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose }, index.h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), index.h("calcite-list", null, this.renderSuggestionGroups())), this.renderSuggestionFlowItem())));
5593
+ return (index.h(index.Host, null, index.h("style", null, this._colorizeStyle), index.h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, index.h("calcite-flow-item", { heading: this.messages.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose }, index.h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), index.h("calcite-list", null, this.renderSuggestionGroups())), this.renderSuggestionFlowItem())));
4165
5594
  }
4166
5595
  static get assetsDirs() { return ["assets"]; }
4167
- get _hostElement() { return index.getElement(this); }
5596
+ get el() { return index.getElement(this); }
4168
5597
  static get watchers() { return {
4169
5598
  "suggestions": ["suggestionsPropChanged"]
4170
5599
  }; }
4171
5600
  };
4172
5601
  ArcgisArcadeSuggestions.style = arcadeSuggestionsCss;
4173
5602
 
4174
- 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%}";
5603
+ 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%}";
4175
5604
 
4176
5605
  function stopEnterPropagation(e) {
4177
5606
  if (e.key === "Enter") {
@@ -4181,8 +5610,10 @@ function stopEnterPropagation(e) {
4181
5610
  const ArcgisArcadeVariables = class {
4182
5611
  constructor(hostRef) {
4183
5612
  index.registerInstance(this, hostRef);
4184
- this.close = index.createEvent(this, "close", 3);
4185
- this.itemSelected = index.createEvent(this, "itemSelected", 3);
5613
+ this.arcgisClose = index.createEvent(this, "arcgisClose", 3);
5614
+ this.arcgisItemSelected = index.createEvent(this, "arcgisItemSelected", 3);
5615
+ this.manager = useControllerManager(this);
5616
+ this.messages = useT9n();
4186
5617
  this._updateFilterValue = (e) => {
4187
5618
  this._filterValue = e.target.value;
4188
5619
  };
@@ -4191,7 +5622,7 @@ const ArcgisArcadeVariables = class {
4191
5622
  this._filterValue = "";
4192
5623
  };
4193
5624
  this._emitClose = () => {
4194
- this.close.emit();
5625
+ this.arcgisClose.emit();
4195
5626
  };
4196
5627
  this._backToTop = () => {
4197
5628
  this._flowItemRenderers = [];
@@ -4204,7 +5635,7 @@ const ArcgisArcadeVariables = class {
4204
5635
  const keyEvent = e;
4205
5636
  if (!keyEvent.key || keyEvent.key === "Enter") {
4206
5637
  e.preventDefault();
4207
- this.itemSelected.emit(variable.snippet);
5638
+ this.arcgisItemSelected.emit(variable.snippet);
4208
5639
  }
4209
5640
  };
4210
5641
  this._showCollectionPanel = (e) => {
@@ -4215,9 +5646,6 @@ const ArcgisArcadeVariables = class {
4215
5646
  e.stopPropagation();
4216
5647
  this.addPanelRenderer(this.collectionBasedVariableRenderer(collectionVariable));
4217
5648
  };
4218
- this._lang = "";
4219
- this._t9nLocale = "";
4220
- this._t9nStrings = undefined;
4221
5649
  this._mutationCounter = 1;
4222
5650
  this._flowItemRenderers = [];
4223
5651
  this._filterValue = "";
@@ -4228,12 +5656,7 @@ const ArcgisArcadeVariables = class {
4228
5656
  this._flowItemRenderers = [];
4229
5657
  }
4230
5658
  //#endregion
4231
- // #region Component lifecycle events
4232
- async componentWillLoad() {
4233
- await arcadeDefaults.B(this, index.getAssetPath("./assets"));
4234
- }
4235
5659
  disconnectedCallback() {
4236
- arcadeDefaults.q(this);
4237
5660
  this._flowObserver?.disconnect();
4238
5661
  }
4239
5662
  // #endregion
@@ -4258,7 +5681,7 @@ const ArcgisArcadeVariables = class {
4258
5681
  // When switching between flow the same reference is reused
4259
5682
  this._flowObserver = new MutationObserver(() => {
4260
5683
  // Get the last panel and try to set focus on the input element
4261
- arcadeDefaults.W(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
5684
+ arcadeDefaults.setFocusOnElement(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
4262
5685
  });
4263
5686
  this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
4264
5687
  }
@@ -4287,15 +5710,15 @@ const ArcgisArcadeVariables = class {
4287
5710
  });
4288
5711
  loading = true;
4289
5712
  }
4290
- return (index.h("calcite-flow-item", { heading: this._t9nStrings?.profilevariables, description: collection.breadcrumb, beforeBack: this._beforeBack, closable: true, onCalciteFlowItemClose: this._emitClose }, index.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 }), index.h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), loading ? (index.h("calcite-loader", { scale: "s", type: "indeterminate", label: this._t9nStrings?.loading ?? "Loading" })) : (index.h("calcite-list", null, this.renderEditorVariables(collection)))));
5713
+ return (index.h("calcite-flow-item", { heading: this.messages.profilevariables, description: collection.breadcrumb, beforeBack: this._beforeBack, closable: true, onCalciteFlowItemClose: this._emitClose }, index.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 }), index.h("calcite-input", { value: this._filterValue, icon: "magnifying-glass", clearable: true, onCalciteInputInput: this._updateFilterValue, class: "sticky", scale: "m" }), loading ? (index.h("calcite-loader", { scale: "s", type: "indeterminate", label: this.messages.loading ?? "Loading" })) : (index.h("calcite-list", null, this.renderEditorVariables(collection)))));
4291
5714
  };
4292
5715
  }
4293
5716
  renderEditorVariables(collection) {
4294
5717
  // Filter the variables. Skip group, we will filter the children later on.
4295
- const filterExpression = arcadeDefaults.K(this._filterValue);
5718
+ const filterExpression = arcadeDefaults.createFilterExpression(this._filterValue);
4296
5719
  const filteredVariables = collection.variables.filter((variable) => variable.passFilter(filterExpression));
4297
5720
  if (!filteredVariables.length) {
4298
- return index.h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No item");
5721
+ return index.h("div", { class: "notice-container" }, this.messages.noitems ?? "No item");
4299
5722
  }
4300
5723
  return filteredVariables.map((variable) => this.renderEditorVariable(variable));
4301
5724
  }
@@ -4305,18 +5728,18 @@ const ArcgisArcadeVariables = class {
4305
5728
  // Group is a collection but we represent it differently
4306
5729
  return (index.h("calcite-list-item-group", { heading: variable.getLabel() }, this.renderEditorVariables(variable)));
4307
5730
  default:
4308
- return (index.h("calcite-list-item", { label: variable.getLabel(), description: variable.getDescription(), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": variable }, variable.isCollection ? (index.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 ? index.h("calcite-icon", { icon: variable.icon, scale: "s", slot: "content-start" }) : null));
5731
+ return (index.h("calcite-list-item", { label: variable.getLabel(), description: variable.getDescription(), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": variable }, variable.isCollection ? (index.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 ? index.h("calcite-icon", { icon: variable.icon, scale: "s", slot: "content-start" }) : null));
4309
5732
  }
4310
5733
  }
4311
5734
  render() {
4312
5735
  const profile = arcadeDefaults.arcadeDefaults.getEditorProfileForModel(this.modelId ?? "");
4313
5736
  if (!this.loading && !profile?.variables.length) {
4314
- return (index.h("calcite-flow", null, index.h("calcite-flow-item", { heading: this._t9nStrings?.profilevariables, closable: true, onCalciteFlowItemClose: this._emitClose }, index.h("div", { class: "notice-container" }, this._t9nStrings?.noprofilevariablesmessage ?? ""))));
5737
+ return (index.h("calcite-flow", null, index.h("calcite-flow-item", { heading: this.messages.profilevariables, closable: true, onCalciteFlowItemClose: this._emitClose }, index.h("div", { class: "notice-container" }, this.messages.noprofilevariablesmessage ?? ""))));
4315
5738
  }
4316
5739
  return (index.h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, this.collectionBasedVariableRenderer(profile, true)(), this._flowItemRenderers.map((renderer) => renderer())));
4317
5740
  }
4318
5741
  static get assetsDirs() { return ["assets"]; }
4319
- get _hostElement() { return index.getElement(this); }
5742
+ get el() { return index.getElement(this); }
4320
5743
  static get watchers() { return {
4321
5744
  "modelId": ["modelIdPropChanged"]
4322
5745
  }; }
@@ -4334,20 +5757,20 @@ const EditorOptionsDefaults = {
4334
5757
  renderLineHighlight: "none",
4335
5758
  suggest: {
4336
5759
  snippetsPreventQuickSuggestions: false,
4337
- showWords: false
5760
+ showWords: false,
4338
5761
  },
4339
5762
  tabSize: 2,
4340
- useShadowDOM: true
5763
+ useShadowDOM: true,
4341
5764
  };
4342
5765
  const ArcgisCodeEditor = class {
4343
5766
  constructor(hostRef) {
4344
5767
  index.registerInstance(this, hostRef);
4345
- this.valueChange = index.createEvent(this, "valueChange", 3);
4346
- this._componentReadyDefer = new arcadeDefaults.h();
5768
+ this.arcgisValueChange = index.createEvent(this, "arcgisValueChange", 3);
5769
+ this._componentReadyDefer = new arcadeDefaults.Deferred();
4347
5770
  this._disposables = [];
4348
5771
  this.value = undefined;
4349
5772
  this.language = undefined;
4350
- this.modelId = arcadeDefaults.U();
5773
+ this.modelId = arcadeDefaults.generateGuid();
4351
5774
  this.options = undefined;
4352
5775
  }
4353
5776
  valuePropChange(newValue) {
@@ -4475,7 +5898,7 @@ const ArcgisCodeEditor = class {
4475
5898
  ...(this.options ?? {}),
4476
5899
  model,
4477
5900
  fixedOverflowWidgets: true,
4478
- scrollBeyondLastLine: false
5901
+ scrollBeyondLastLine: false,
4479
5902
  });
4480
5903
  this._disposables.push(this._editorInstance);
4481
5904
  // Set the value now to trigger a diagnostic again
@@ -4486,10 +5909,10 @@ const ArcgisCodeEditor = class {
4486
5909
  // Listen to the Monaco Editor content change event and propagate
4487
5910
  this._editorInstance.onDidChangeModelContent(() => {
4488
5911
  const script = this._editorInstance?.getValue() ?? "";
4489
- this.valueChange.emit(script);
5912
+ this.arcgisValueChange.emit(script);
4490
5913
  });
4491
5914
  // Detect if the host element or its ancestors got a theme attribute mutation
4492
- this._themeObserver = arcadeDefaults.x(this._hostElt, ["class"], () => this.updateTheme());
5915
+ this._themeObserver = arcadeDefaults.observeAncestorsMutation(this._hostElt, ["class"], () => this.updateTheme());
4493
5916
  // Update the theme of the Monaco Editor
4494
5917
  this.updateTheme();
4495
5918
  // Creates a resize observer to re-layout the editor on size changing
@@ -4502,7 +5925,7 @@ const ArcgisCodeEditor = class {
4502
5925
  while (this._disposables.length) {
4503
5926
  this._disposables.pop()?.dispose();
4504
5927
  }
4505
- this._themeObserver?.disconnect();
5928
+ this._themeObserver?.remove();
4506
5929
  }
4507
5930
  //#endregion
4508
5931
  // #region Private methods API
@@ -4520,7 +5943,7 @@ const ArcgisCodeEditor = class {
4520
5943
  // This is called the first time and subsequently by the Mutation Observer
4521
5944
  // Figure out the theme by walking the ancestor path.
4522
5945
  // If no theme is found then default to light.
4523
- const theme = arcadeDefaults.k(this._hostElt) === "light" ? "vs" : "vs-dark";
5946
+ const theme = arcadeDefaults.getElementTheme(this._hostElt) === "light" ? "vs" : "vs-dark";
4524
5947
  if (theme === this._currentTheme) {
4525
5948
  return;
4526
5949
  }
@@ -4545,7 +5968,7 @@ const ArcgisCodeEditor = class {
4545
5968
  contextMenuOrder: 1,
4546
5969
  // Method that will be executed when the action is triggered.
4547
5970
  // @param editor The editor instance is passed in as a convenience
4548
- run: async () => await zoomInFn?.run()
5971
+ run: async () => await zoomInFn?.run(),
4549
5972
  });
4550
5973
  this._editorInstance?.addAction({
4551
5974
  id: "editor.action.fontZoomOut",
@@ -4553,7 +5976,7 @@ const ArcgisCodeEditor = class {
4553
5976
  keybindings: [arcadeDefaults.KeyMod.CtrlCmd | arcadeDefaults.KeyCode.Minus],
4554
5977
  contextMenuGroupId: "zooming",
4555
5978
  contextMenuOrder: 2,
4556
- run: async () => await zoomOutFn?.run()
5979
+ run: async () => await zoomOutFn?.run(),
4557
5980
  });
4558
5981
  }
4559
5982
  //#endregion