@arcgis/coding-components 4.30.0-next.7 → 4.30.0-next.71

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 (182) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +2 -4
  3. package/dist/arcgis-coding-components/arcgis-coding-components.css +1 -1
  4. package/dist/arcgis-coding-components/arcgis-coding-components.esm.js +2 -2
  5. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ar.json +25 -0
  6. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.bg.json +25 -0
  7. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.bs.json +25 -0
  8. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ca.json +25 -0
  9. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.cs.json +25 -0
  10. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.da.json +25 -0
  11. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.de.json +25 -0
  12. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.el.json +25 -0
  13. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.en.json +25 -0
  14. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.es.json +25 -0
  15. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.et.json +25 -0
  16. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.fi.json +25 -0
  17. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.fr.json +25 -0
  18. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.he.json +25 -0
  19. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.hr.json +25 -0
  20. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.hu.json +25 -0
  21. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.id.json +25 -0
  22. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.it.json +25 -0
  23. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ja.json +25 -0
  24. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ko.json +25 -0
  25. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.lt.json +25 -0
  26. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.lv.json +25 -0
  27. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.nb.json +25 -0
  28. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.nl.json +25 -0
  29. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.pl.json +25 -0
  30. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.pt-BR.json +25 -0
  31. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.pt-PT.json +25 -0
  32. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ro.json +25 -0
  33. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ru.json +25 -0
  34. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.sk.json +25 -0
  35. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.sl.json +25 -0
  36. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.sr.json +25 -0
  37. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.sv.json +25 -0
  38. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.th.json +25 -0
  39. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.tr.json +25 -0
  40. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.uk.json +25 -0
  41. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.vi.json +25 -0
  42. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.zh-CN.json +25 -0
  43. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.zh-HK.json +25 -0
  44. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.zh-TW.json +25 -0
  45. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ar.json +2 -0
  46. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.bg.json +2 -0
  47. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.bs.json +2 -0
  48. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ca.json +2 -0
  49. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.cs.json +2 -0
  50. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.da.json +2 -0
  51. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.de.json +2 -0
  52. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.el.json +2 -0
  53. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.es.json +2 -0
  54. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.et.json +2 -0
  55. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.fi.json +2 -0
  56. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.fr.json +2 -0
  57. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.he.json +2 -0
  58. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.hr.json +2 -0
  59. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.hu.json +2 -0
  60. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.id.json +2 -0
  61. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.it.json +2 -0
  62. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ja.json +2 -0
  63. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ko.json +2 -0
  64. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.lt.json +2 -0
  65. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.lv.json +2 -0
  66. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.nb.json +2 -0
  67. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.nl.json +2 -0
  68. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.pl.json +2 -0
  69. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.pt-BR.json +2 -0
  70. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.pt-PT.json +2 -0
  71. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ro.json +2 -0
  72. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.ru.json +2 -0
  73. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sk.json +2 -0
  74. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sl.json +2 -0
  75. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sr.json +2 -0
  76. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.sv.json +2 -0
  77. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.th.json +2 -0
  78. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.tr.json +2 -0
  79. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.uk.json +2 -0
  80. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.vi.json +2 -0
  81. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.zh-CN.json +2 -0
  82. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.zh-HK.json +2 -0
  83. package/dist/arcgis-coding-components/assets/arcade-language/t9n/profile.t9n.zh-TW.json +2 -0
  84. package/dist/arcgis-coding-components/assets/code-editor/arcade.worker.js +2 -2
  85. package/dist/arcgis-coding-components/assets/code-editor/css.worker.js +1 -1
  86. package/dist/arcgis-coding-components/assets/code-editor/editor.worker.js +1 -1
  87. package/dist/arcgis-coding-components/assets/code-editor/html.worker.js +1 -1
  88. package/dist/arcgis-coding-components/assets/code-editor/json.worker.js +1 -1
  89. package/dist/arcgis-coding-components/assets/code-editor/ts.worker.js +1 -1
  90. package/dist/arcgis-coding-components/index.esm.js +2 -2
  91. package/dist/arcgis-coding-components/{p-7d529ae0.js → p-063a025b.js} +3 -3
  92. package/dist/arcgis-coding-components/{p-1b2a100f.js → p-07f363ba.js} +1 -1
  93. package/dist/arcgis-coding-components/p-09be08b9.js +68 -0
  94. package/dist/arcgis-coding-components/{p-7d8a653c.js → p-40c7de90.js} +2 -2
  95. package/dist/arcgis-coding-components/p-78df1d2f.js +7 -0
  96. package/dist/arcgis-coding-components/{p-43ca4ff8.js → p-7a03c214.js} +2 -2
  97. package/dist/arcgis-coding-components/p-88548ea1.entry.js +6 -0
  98. package/dist/arcgis-coding-components/{p-19e41297.js → p-93a07954.js} +2 -2
  99. package/dist/arcgis-coding-components/{p-3ad3b485.js → p-ab5bb57b.js} +3 -3
  100. package/dist/arcgis-coding-components/{p-d15b541d.js → p-c085a0af.js} +2 -2
  101. package/dist/arcgis-coding-components/{p-53a0b083.js → p-c301d376.js} +3 -3
  102. package/dist/arcgis-coding-components/{p-41f5c613.js → p-ca4f8a77.js} +2 -2
  103. package/dist/cjs/{arcade-defaults-85d2771a.js → arcade-defaults-d4681815.js} +620 -248
  104. package/dist/cjs/{arcade-mode-d675c5ea.js → arcade-mode-1bee51ae.js} +45 -51
  105. package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +1560 -289
  106. package/dist/cjs/arcgis-coding-components.cjs.js +3 -3
  107. package/dist/cjs/{css-5e66f5d3.js → css-8c80bb2e.js} +1 -1
  108. package/dist/cjs/{cssMode-b94f6c97.js → cssMode-942065fb.js} +3 -3
  109. package/dist/cjs/{html-b264fb71.js → html-cabb489e.js} +3 -3
  110. package/dist/cjs/{htmlMode-14366ebc.js → htmlMode-915886ac.js} +3 -3
  111. package/dist/cjs/{index-6542b576.js → index-cd2104b5.js} +40 -4
  112. package/dist/cjs/index.cjs.js +3 -3
  113. package/dist/cjs/{javascript-40266757.js → javascript-3ae42af9.js} +4 -4
  114. package/dist/cjs/{jsonMode-241f2a4a.js → jsonMode-b6aa8f04.js} +3 -3
  115. package/dist/cjs/loader.cjs.js +3 -3
  116. package/dist/cjs/{tsMode-066b04bf.js → tsMode-7db5819d.js} +3 -3
  117. package/dist/cjs/{typescript-9ac6fd5a.js → typescript-457225f9.js} +3 -3
  118. package/dist/components/arcade-api.js +21 -32
  119. package/dist/components/arcade-contribution.js +72 -13
  120. package/dist/components/arcade-defaults.js +131 -149
  121. package/dist/components/arcade-mode.js +44 -50
  122. package/dist/components/arcade-results.js +47 -60
  123. package/dist/components/arcade-suggestions.js +23 -33
  124. package/dist/components/arcade-variables.js +22 -36
  125. package/dist/components/arcgis-arcade-api.js +1 -1
  126. package/dist/components/arcgis-arcade-editor.js +60 -150
  127. package/dist/components/arcgis-arcade-results.js +1 -1
  128. package/dist/components/arcgis-arcade-suggestions.js +1 -1
  129. package/dist/components/arcgis-arcade-variables.js +1 -1
  130. package/dist/components/arcgis-assets.d.ts +1 -1
  131. package/dist/components/arcgis-assets.js +1 -1
  132. package/dist/components/arcgis-code-editor.js +1 -1
  133. package/dist/components/chunk-63RMNUHL.js +1275 -0
  134. package/dist/components/code-editor.js +70 -78
  135. package/dist/components/fields.js +45 -45
  136. package/dist/components/index.js +1 -1
  137. package/dist/components/index2.js +389 -3
  138. package/dist/components/markdown.js +9 -11
  139. package/dist/components/useT9n.js +35 -0
  140. package/dist/components/utilities.js +3 -3
  141. package/dist/esm/{arcade-defaults-ef372fd5.js → arcade-defaults-0328d43a.js} +603 -235
  142. package/dist/esm/{arcade-mode-04d65df2.js → arcade-mode-30a3c186.js} +45 -51
  143. package/dist/esm/arcgis-arcade-api_6.entry.js +1560 -289
  144. package/dist/esm/arcgis-coding-components.js +4 -4
  145. package/dist/esm/{css-50e0f632.js → css-2a675679.js} +1 -1
  146. package/dist/esm/{cssMode-0740511f.js → cssMode-d741b7f4.js} +3 -3
  147. package/dist/esm/{html-9d2b157c.js → html-50d0ec6a.js} +3 -3
  148. package/dist/esm/{htmlMode-fd1c3eea.js → htmlMode-4cb80be7.js} +3 -3
  149. package/dist/esm/{index-7f8b9422.js → index-64f782ac.js} +40 -4
  150. package/dist/esm/index.js +3 -3
  151. package/dist/esm/{javascript-014d6512.js → javascript-5607dae6.js} +4 -4
  152. package/dist/esm/{jsonMode-ccac7c7d.js → jsonMode-e9cfe47d.js} +3 -3
  153. package/dist/esm/loader.js +4 -4
  154. package/dist/esm/{tsMode-cfa861b3.js → tsMode-1be1ce42.js} +3 -3
  155. package/dist/esm/{typescript-9c1ebeca.js → typescript-2d04f7b3.js} +3 -3
  156. package/dist/loader/cdn.js +1 -1
  157. package/dist/loader/index.cjs.js +1 -1
  158. package/dist/loader/index.es2017.js +1 -1
  159. package/dist/loader/index.js +1 -1
  160. package/dist/types/components/arcade-api/arcade-api.d.ts +6 -7
  161. package/dist/types/components/arcade-editor/arcade-editor.d.ts +18 -12
  162. package/dist/types/components/arcade-results/arcade-results.d.ts +6 -9
  163. package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +7 -8
  164. package/dist/types/components/arcade-variables/arcade-variables.d.ts +6 -8
  165. package/dist/types/components/code-editor/code-editor.d.ts +23 -13
  166. package/dist/types/components.d.ts +57 -35
  167. package/dist/types/controllers/useT9n.d.ts +1 -0
  168. package/dist/types/data/arcgis-web-compoments/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stencil.config.d.ts +3 -0
  169. package/dist/types/data/arcgis-web-compoments/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 +27 -0
  170. package/dist/types/data/arcgis-web-compoments/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/internal/arcade-editor/editorContext.d.ts +11 -0
  171. package/dist/types/data/arcgis-web-compoments/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
  172. package/dist/types/data/arcgis-web-compoments/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
  173. package/dist/types/data/arcgis-web-compoments/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/support/sass-inline-url-importer.d.ts +9 -0
  174. package/dist/types/data/arcgis-web-compoments/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/support/sass-json-importer.d.ts +19 -0
  175. package/dist/types/data/arcgis-web-compoments/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/support/stencil-monaco-plugins.d.ts +6 -0
  176. package/dist/types/utils/arcade-monaco/arcade-language-features.d.ts +1 -1
  177. package/dist/types/utils/profile/types.d.ts +15 -13
  178. package/dist/types/utils/profile/utils.d.ts +1 -3
  179. package/package.json +21 -21
  180. package/dist/arcgis-coding-components/p-1927140d.js +0 -68
  181. package/dist/arcgis-coding-components/p-6aa84514.js +0 -7
  182. package/dist/arcgis-coding-components/p-c4f70a58.entry.js +0 -6
@@ -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.7
4
+ * v4.30.0-next.71
5
5
  */
6
6
  'use strict';
7
7
 
8
8
  Object.defineProperty(exports, '__esModule', { value: true });
9
9
 
10
- const index = require('./index-6542b576.js');
11
- const arcadeDefaults = require('./arcade-defaults-85d2771a.js');
10
+ const index = require('./index-cd2104b5.js');
11
+ const arcadeDefaults = require('./arcade-defaults-d4681815.js');
12
12
 
13
13
  async function colorizeCode(code) {
14
14
  return await arcadeDefaults.editor.colorize(code, "arcade", { tabSize: 2 });
@@ -2921,25 +2921,1313 @@ 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/framework.ts
2943
+ function retrieveComponentMembers(component, isLit) {
2944
+ if (isLit) {
2945
+ const elementProperties = getLitProperties(component);
2946
+ component.manager.internals.members = Object.fromEntries(
2947
+ Array.from(elementProperties, ([name, { state, type }]) => [
2948
+ name,
2949
+ [
2950
+ state ? 32 /* State */ : type === Number ? 2 /* Number */ : type === Boolean ? 4 /* Boolean */ : 1 /* String */
2951
+ ]
2952
+ ])
2953
+ );
2954
+ } else {
2955
+ const constructor = component.constructor;
2956
+ const members = constructor.__registerControllers?.(component) ?? void 0;
2957
+ constructor.__registerControllers = void 0;
2958
+ if (typeof members !== "object")
2959
+ throw new Error(
2960
+ "Failed to retrieve internal component meta. Make sure you have the useComponentsControllers() Rollup Plugin for Stencil Controllers configured in your Stencil config."
2961
+ );
2962
+ component.manager.internals.members = members;
2963
+ }
2964
+ }
2965
+ var getLitProperties = (component) => component.constructor.elementProperties;
2966
+ function parsePropertyValue(value, type = 8 /* Any */) {
2967
+ const isComplex = value == null || typeof value === "object" || typeof value === "function";
2968
+ if (isComplex)
2969
+ return value;
2970
+ if ((type & 4 /* Boolean */) !== 0)
2971
+ return value === "false" ? false : value === "" || !!value;
2972
+ else if ((type & 2 /* Number */) !== 0)
2973
+ return Number.parseFloat(value);
2974
+ else if ((type & 1 /* String */) !== 0)
2975
+ return String(value);
2976
+ else
2977
+ return value;
2978
+ }
2979
+ var makeMemberFilter = (filter) => (component) => {
2980
+ const members = component.manager.internals.members;
2981
+ return Object.entries(members ?? {}).filter(([_name, [propType]]) => (propType & filter) !== 0).map(([name]) => name);
2982
+ };
2983
+ var getPropLikeMembers = makeMemberFilter(63 /* PropLike */);
2984
+ var getMemberType = (component, name) => component.manager.internals.members?.[name]?.[0];
2985
+ function getPropType(component, name) {
2986
+ const type = getMemberType(component, name);
2987
+ if (type === void 0)
2988
+ return void 0;
2989
+ else if (type & 32 /* State */)
2990
+ return "state";
2991
+ else
2992
+ return "prop";
2993
+ }
2994
+
2995
+ // src/types.ts
2996
+ var controllerSymbol = Symbol("controller");
2997
+
2998
+ // src/utils.ts
2999
+ var isController = (value) => typeof value === "object" && value !== null && (controllerSymbol in value || "hostConnected" in value || "hostDisconnected" in value || "hostUpdate" in value || "hostUpdated" in value);
3000
+
3001
+ // src/ControllerInternals.ts
3002
+ var ControllerInternals = class {
3003
+ constructor() {
3004
+ this._ambientControllers = [];
3005
+ /**
3006
+ * The type definition has to be duplicated due to the
3007
+ * "'use' is referenced directly or indirectly in its own type annotation."
3008
+ * error
3009
+ */
3010
+ this.use = async (value, watchExports) => {
3011
+ const controller = this.useRefSync(value);
3012
+ if (controller === void 0) {
3013
+ if (typeof watchExports === "function") {
3014
+ const error = new Error(
3015
+ `Unable to resolve a controller from the provided value, so can't watch it's exports. ${unresolvableExports}`
3016
+ );
3017
+ console.error(error);
3018
+ }
3019
+ return value;
3020
+ }
3021
+ await controller.ready;
3022
+ if (typeof watchExports === "function") {
3023
+ if (controller.watchExports === void 0)
3024
+ throw new Error(`The controller must implement watchExports method to support watching exports`);
3025
+ const unsubscribe = controller.watchExports(
3026
+ (exports) => watchExports(exports, unsubscribe)
3027
+ );
3028
+ }
3029
+ return controller.exports;
3030
+ };
3031
+ this.useRef = async (value) => {
3032
+ const controller = this.useRefSync(value);
3033
+ if (controller === void 0)
3034
+ throw new Error(`Unable to resolve a controller from the provided value. ${unresolvableExports}`);
3035
+ await controller.ready;
3036
+ return controller;
3037
+ };
3038
+ this.useRefSync = (value) => {
3039
+ const ambientChildController = this.retrieveAmbientChildController();
3040
+ if (ambientChildController !== void 0)
3041
+ return ambientChildController;
3042
+ const component = Controller.internals.retrieveComponent();
3043
+ const controller = component.manager.internals.resolveExports(value);
3044
+ if (controller !== void 0)
3045
+ return controller;
3046
+ if (isController(value))
3047
+ return value;
3048
+ return void 0;
3049
+ };
3050
+ this.shouldBypassSetter = false;
3051
+ this.shouldBypassGetter = false;
3052
+ this.shouldBypassReadonly = false;
3053
+ /**
3054
+ * A map from component instance or component element to component instance.
3055
+ * To get from component instance or component element to component element,
3056
+ * you can just use the .el property
3057
+ */
3058
+ this.elementToInstance = /* @__PURE__ */ new WeakMap();
3059
+ }
3060
+ /*
3061
+ * Allow controllers to implicitly retrieve which component they are in, to
3062
+ * improve DX (avoids the need to pass "this" explicitly for each controller)
3063
+ */
3064
+ setAmbientComponent(component) {
3065
+ if (this._ambientComponent === component)
3066
+ return;
3067
+ this._ambientComponent = component;
3068
+ queueMicrotask(() => {
3069
+ if (this._ambientComponent === component)
3070
+ this._ambientComponent = void 0;
3071
+ });
3072
+ }
3073
+ retrieveComponent(name) {
3074
+ if (this._ambientComponent === void 0)
3075
+ throw new Error(
3076
+ [
3077
+ `Unable to find out which component ${name || "this"} controller `,
3078
+ "belongs to. This might happen if you tried to create a controller ",
3079
+ "outside the component. If so, please wrap your controller ",
3080
+ "definition in an arrow function, ",
3081
+ "`const myController = ()=>makeController(...);` and call that",
3082
+ "function inside the component `my = myController();`, or ",
3083
+ "define your controller using makeGenericController/GenericController ",
3084
+ "instead.\n",
3085
+ "If you wish to use a controller inside an async controller, ",
3086
+ "make sure you are using controller.use.\n",
3087
+ "You might also have multiple instances of Controllers loaded"
3088
+ ].join("\n")
3089
+ );
3090
+ return this._ambientComponent;
3091
+ }
3092
+ /*
3093
+ * Aids proxyExports() in knowing who is it's host
3094
+ */
3095
+ setParentController(controller) {
3096
+ if (controller === void 0) {
3097
+ this._ambientControllers = [];
3098
+ return;
3099
+ }
3100
+ const index = this._ambientControllers.indexOf(controller);
3101
+ this._ambientControllers = index === -1 ? [...this._ambientControllers, controller] : this._ambientControllers.slice(0, index + 1);
3102
+ queueMicrotask(() => {
3103
+ this._ambientControllers = [];
3104
+ });
3105
+ }
3106
+ retrieveParentControllers() {
3107
+ return this._ambientControllers;
3108
+ }
3109
+ /*
3110
+ * Aids controller.use in retrieving controller value when it receives
3111
+ * controller exports, rather than the controller itself
3112
+ */
3113
+ setAmbientChildController(controller) {
3114
+ if (this._ambientChildController === controller)
3115
+ return;
3116
+ this._ambientChildController = controller;
3117
+ queueMicrotask(() => {
3118
+ if (this._ambientChildController === controller)
3119
+ this._ambientChildController = void 0;
2940
3120
  });
2941
- return result;
3121
+ }
3122
+ retrieveAmbientChildController() {
3123
+ const controller = this._ambientChildController;
3124
+ this._ambientChildController = void 0;
3125
+ return controller;
3126
+ }
3127
+ };
3128
+ var unresolvableExports = [
3129
+ "The value you passed is not a controller and not a controller exports. If ",
3130
+ "your controller exports a literal value, try making your controller export ",
3131
+ "an object instead"
3132
+ ].join("");
3133
+
3134
+ // src/Controller.ts
3135
+ var _a;
3136
+ var _Controller = class _Controller {
3137
+ constructor(component) {
3138
+ this._callbacks = {
3139
+ hostConnected: [],
3140
+ hostDisconnected: [],
3141
+ hostLoad: [],
3142
+ hostLoaded: [],
3143
+ hostUpdate: [],
3144
+ hostUpdated: [],
3145
+ hostDestroy: [],
3146
+ hostLifecycle: []
3147
+ };
3148
+ this._ready = new arcadeDefaults.Deferred();
3149
+ this._lifecycleDisconnected = [];
3150
+ this.connectedCalled = false;
3151
+ this.willLoadCalled = false;
3152
+ this.didLoadCalled = false;
3153
+ this[_a] = true;
3154
+ this.ready = this._ready.promise;
3155
+ /*
3156
+ * Setting default exports to "this" so that controllers that don't use
3157
+ * exports/proxyExports(), could still be used as if they did
3158
+ * (i.e with controller.use)
3159
+ */
3160
+ this._exports = makeProvisionalValue(this);
3161
+ this._exportWatchers = /* @__PURE__ */ new Set();
3162
+ const resolvedComponent = toControllerHost(
3163
+ component ?? _Controller.internals.retrieveComponent(new.target.name)
3164
+ );
3165
+ Object.defineProperty(this, "component", {
3166
+ writable: false,
3167
+ enumerable: false,
3168
+ configurable: true,
3169
+ value: resolvedComponent
3170
+ });
3171
+ this.component.addController(this);
3172
+ _Controller.internals.setParentController(this);
3173
+ if ("hostDestroy" in this)
3174
+ this.component.manager.ensureHasDestroy();
3175
+ const manager = this.component.manager;
3176
+ const isInControllerManager = manager === void 0;
3177
+ if (!isInControllerManager)
3178
+ queueMicrotask(() => this.catchUpLifecycle());
3179
+ }
3180
+ /**
3181
+ * If controller is being added dynamically, after the component
3182
+ * construction, then trigger connected and load right away
3183
+ */
3184
+ catchUpLifecycle() {
3185
+ const { manager } = this.component;
3186
+ const connectedWillStillHappen = !manager.connectedCalled;
3187
+ if (!connectedWillStillHappen && !this.connectedCalled)
3188
+ this.triggerConnected();
3189
+ const loadWillStillHappen = !manager.willLoadCalled;
3190
+ if (loadWillStillHappen)
3191
+ return;
3192
+ this.triggerLoad().then(() => {
3193
+ const loadedWillStillHappen = !manager.didLoadCalled;
3194
+ if (loadedWillStillHappen)
3195
+ return;
3196
+ this.triggerLoaded();
3197
+ }).catch(console.error);
3198
+ }
3199
+ get exports() {
3200
+ return this._exports;
3201
+ }
3202
+ /**
3203
+ * Set controller's exports property (for usage with proxyExports()) and mark
3204
+ * controller as ready (for usage in other controllers). Also, triggers
3205
+ * re-render of the component
3206
+ */
3207
+ set exports(exports) {
3208
+ if (this._exports !== exports) {
3209
+ this._exports = exports;
3210
+ if (this.connectedCalled)
3211
+ this.component.requestUpdate();
3212
+ this._exportWatchers.forEach(arcadeDefaults.safeCall);
3213
+ }
3214
+ this._ready.resolve(exports);
3215
+ }
3216
+ setProvisionalExports(exports) {
3217
+ this._exports = makeProvisionalValue(exports);
3218
+ this._exportWatchers.forEach(arcadeDefaults.safeCall);
3219
+ }
3220
+ watchExports(callback) {
3221
+ const safeCallback = () => callback(this._exports);
3222
+ this._exportWatchers.add(safeCallback);
3223
+ return () => void this._exportWatchers.delete(safeCallback);
3224
+ }
3225
+ /**
3226
+ * A flexible utility for making sure a controller is loaded before it's used,
3227
+ * regardless of how or where a controller was defined:
3228
+ *
3229
+ * @example
3230
+ * makeGenericController(async (component, controller) => {
3231
+ * // Await some controller from the component:
3232
+ * await controller.use(component.someController);
3233
+ * // Initialize new controllers
3234
+ * await controller.use(load(importCoreReactiveUtils));
3235
+ * await controller.use(new ViewModelController(component,newWidgetsHomeHomeViewModel));
3236
+ * await controller.use(someController(component));
3237
+ * });
3238
+ *
3239
+ * @remarks
3240
+ * If your controller is not async, and you are not creating it async, then
3241
+ * you are not required to use controller.use - you can use it directly.
3242
+ * Similarly, accessing controllers after componentWillLoad callback does not
3243
+ * require awaiting them as they are guaranteed to be loaded by then.
3244
+ */
3245
+ get use() {
3246
+ _Controller.internals.setAmbientComponent(this.component);
3247
+ return _Controller.internals.use;
3248
+ }
3249
+ /**
3250
+ * Just like controller.use, but returns the controller itself, rather than it's
3251
+ * exports
3252
+ *
3253
+ * Use cases:
3254
+ * - You have a controller and you want to make sure it's loaded before you
3255
+ * try to use it
3256
+ * - Your controller is not using exports, so you wish to access some props on
3257
+ * it directly
3258
+ * - You have a controller exports only, and you want to retrieve the
3259
+ * controller itself. This is useful if you wish to call .watchExports() or
3260
+ * some other method on the controller
3261
+ */
3262
+ get useRef() {
3263
+ _Controller.internals.setAmbientComponent(this.component);
3264
+ return _Controller.internals.useRef;
3265
+ }
3266
+ /**
3267
+ * Like useRef, but doesn't wait for the controller to get ready
3268
+ */
3269
+ get useRefSync() {
3270
+ _Controller.internals.setAmbientComponent(this.component);
3271
+ return _Controller.internals.useRefSync;
3272
+ }
3273
+ /**
3274
+ * If you need to set a prop/state without triggering the custom setter you
3275
+ * defined with getSet()/dynamicGetSet()/readonly(), set the value inside
3276
+ * of this function
3277
+ *
3278
+ * @example
3279
+ * @Prop() readOnly = this.manager.readOnly(true);
3280
+ *
3281
+ * someAction(): void {
3282
+ * this.manager.bypassSetter(()=>{
3283
+ * this.readOnly = false;
3284
+ * });
3285
+ * }
3286
+ *
3287
+ */
3288
+ bypassSetter(callback) {
3289
+ _Controller.internals.shouldBypassSetter = true;
3290
+ try {
3291
+ return callback();
3292
+ } finally {
3293
+ _Controller.internals.shouldBypassSetter = false;
3294
+ }
3295
+ }
3296
+ /**
3297
+ * Like bypassSetter, but only bypasses this.manager.readonly(), rather that
3298
+ * all setters set using this.manager.getSet()
3299
+ */
3300
+ bypassReadonly(callback) {
3301
+ _Controller.internals.shouldBypassReadonly = true;
3302
+ try {
3303
+ return callback();
3304
+ } finally {
3305
+ _Controller.internals.shouldBypassReadonly = false;
3306
+ }
3307
+ }
3308
+ /**
3309
+ * Property reads inside of this function will bypass any custom getter you
3310
+ * may have, and read the value directly from what's stored in Stencil/Lit.
3311
+ *
3312
+ * This also bypasses reactiveUtils integration - reading a property inside of
3313
+ * bypassGetter won't make that property tracked.
3314
+ *
3315
+ * @example
3316
+ * reactiveUtils.watch(
3317
+ * ()=>{
3318
+ * this.manager.bypassGetter(()=>{
3319
+ * console.log(this.someProp);
3320
+ * });
3321
+ * return this.prop;
3322
+ * },
3323
+ * console.log
3324
+ * )
3325
+ */
3326
+ bypassGetter(callback) {
3327
+ _Controller.internals.shouldBypassGetter = true;
3328
+ try {
3329
+ return callback();
3330
+ } finally {
3331
+ _Controller.internals.shouldBypassGetter = false;
3332
+ }
3333
+ }
3334
+ /**
3335
+ * Like this.manager.getSet(), but can be called on any component's
3336
+ * state/prop from anywhere, rather than just from the default value
3337
+ */
3338
+ dynamicGetSet(name, getSet) {
3339
+ this.genericGetSet(name, getSet);
3340
+ }
3341
+ /**
3342
+ * Like dynamicGetSet, but less type-safe. Useful in cases when trying to set
3343
+ * getters/setters in place where property names & types are not known
3344
+ * statically
3345
+ */
3346
+ genericGetSet(property, getSet) {
3347
+ var _a2, _b;
3348
+ const genericGetSet = getSet;
3349
+ const internals = this.component.manager.internals;
3350
+ if (typeof genericGetSet.get === "function") {
3351
+ (_a2 = internals.getters)[property] ?? (_a2[property] = []);
3352
+ internals.getters[property].unshift(genericGetSet.get);
3353
+ }
3354
+ const set = genericGetSet.set === "ignore" ? ignoreSet : genericGetSet.set;
3355
+ if (set) {
3356
+ (_b = internals.setters)[property] ?? (_b[property] = []);
3357
+ internals.setters[property].unshift(set);
3358
+ }
3359
+ }
3360
+ // FEATURE: improve typings
3361
+ /**
3362
+ * Dynamically set a watcher for any reactive property
3363
+ */
3364
+ watch(property, callback) {
3365
+ var _a2;
3366
+ const type = getMemberType(this.component, property);
3367
+ if (type === void 0)
3368
+ throw new Error(
3369
+ `Trying to watch a non-@property, non-@state property "${property}". Either convert it into a @state() or use get/set syntax`
3370
+ );
3371
+ const internals = this.component.manager.internals;
3372
+ (_a2 = internals.allWatchers)[property] ?? (_a2[property] = []);
3373
+ const watchers = internals.allWatchers[property];
3374
+ const genericCallback = callback;
3375
+ const safeCallback = (newValue, oldValue, propertyName) => arcadeDefaults.safeCall(genericCallback, null, newValue, oldValue, propertyName);
3376
+ watchers.push(safeCallback);
3377
+ return () => {
3378
+ const index = watchers.indexOf(safeCallback);
3379
+ if (index !== -1)
3380
+ watchers.splice(index, 1);
3381
+ };
3382
+ }
3383
+ controllerRemoved() {
3384
+ if (this.component.el.isConnected)
3385
+ this.triggerDisconnected();
3386
+ this.triggerDestroy();
3387
+ }
3388
+ // Register a lifecycle callback
3389
+ onConnected(callback) {
3390
+ this._callbacks.hostConnected.push(callback);
3391
+ }
3392
+ onDisconnected(callback) {
3393
+ this._callbacks.hostDisconnected.push(callback);
3394
+ }
3395
+ onLoad(callback) {
3396
+ this._callbacks.hostLoad.push(callback);
3397
+ }
3398
+ onLoaded(callback) {
3399
+ this._callbacks.hostLoaded.push(callback);
3400
+ }
3401
+ onUpdate(callback) {
3402
+ this._callbacks.hostUpdate.push(callback);
3403
+ }
3404
+ onUpdated(callback) {
3405
+ this._callbacks.hostUpdated.push(callback);
3406
+ }
3407
+ onDestroy(callback) {
3408
+ this.component.manager.ensureHasDestroy();
3409
+ this._callbacks.hostDestroy.push(callback);
3410
+ }
3411
+ onLifecycle(callback) {
3412
+ this._callbacks.hostLifecycle.push(callback);
3413
+ if (this.connectedCalled && this.component.el.isConnected)
3414
+ this._callLifecycle(callback);
3415
+ }
3416
+ // Call each lifecycle hook
3417
+ triggerConnected() {
3418
+ const genericController = this;
3419
+ if (genericController.hostConnected)
3420
+ arcadeDefaults.safeCall(genericController.hostConnected, genericController);
3421
+ this._callbacks.hostConnected.forEach(arcadeDefaults.safeCall);
3422
+ this.triggerLifecycle();
3423
+ this.connectedCalled = true;
3424
+ }
3425
+ triggerDisconnected() {
3426
+ const genericController = this;
3427
+ if (genericController.hostDisconnected)
3428
+ arcadeDefaults.safeCall(genericController.hostDisconnected, genericController);
3429
+ this._callbacks.hostDisconnected.forEach(arcadeDefaults.safeCall);
3430
+ this._lifecycleDisconnected.forEach(arcadeDefaults.safeCall);
3431
+ this._lifecycleDisconnected = [];
3432
+ }
3433
+ async triggerLoad() {
3434
+ if (this.willLoadCalled)
3435
+ return;
3436
+ this.willLoadCalled = true;
3437
+ const genericController = this;
3438
+ if (genericController.hostLoad)
3439
+ await arcadeDefaults.safeAsyncCall(genericController.hostLoad, genericController);
3440
+ if (this._callbacks.hostLoad.length > 0)
3441
+ await Promise.allSettled(this._callbacks.hostLoad.map(arcadeDefaults.safeAsyncCall));
3442
+ this._ready.resolve(this._exports);
3443
+ }
3444
+ triggerLoaded() {
3445
+ if (this.didLoadCalled)
3446
+ return;
3447
+ const genericController = this;
3448
+ if (genericController.hostLoaded)
3449
+ arcadeDefaults.safeCall(genericController.hostLoaded, genericController);
3450
+ this._callbacks.hostLoaded.forEach(arcadeDefaults.safeCall);
3451
+ this.didLoadCalled = true;
3452
+ }
3453
+ triggerUpdate() {
3454
+ const genericController = this;
3455
+ if (genericController.hostUpdate)
3456
+ arcadeDefaults.safeCall(genericController.hostUpdate, genericController);
3457
+ this._callbacks.hostUpdate.forEach(arcadeDefaults.safeCall);
3458
+ }
3459
+ triggerUpdated() {
3460
+ const genericController = this;
3461
+ if (genericController.hostUpdated)
3462
+ arcadeDefaults.safeCall(genericController.hostUpdated, genericController);
3463
+ this._callbacks.hostUpdated.forEach(arcadeDefaults.safeCall);
3464
+ }
3465
+ triggerDestroy() {
3466
+ const genericController = this;
3467
+ if (genericController.hostDestroy)
3468
+ arcadeDefaults.safeCall(genericController.hostDestroy, genericController);
3469
+ this._callbacks.hostDestroy.forEach(arcadeDefaults.safeCall);
3470
+ }
3471
+ triggerLifecycle() {
3472
+ const genericController = this;
3473
+ if (genericController.hostLifecycle)
3474
+ this._callLifecycle(() => genericController.hostLifecycle());
3475
+ this._callbacks.hostLifecycle.forEach((callback) => this._callLifecycle(callback));
3476
+ }
3477
+ _callLifecycle(callback) {
3478
+ _Controller.internals.setAmbientComponent(this.component);
3479
+ const cleanupRaw = arcadeDefaults.safeCall(callback);
3480
+ const cleanup = Array.isArray(cleanupRaw) ? cleanupRaw : [cleanupRaw];
3481
+ cleanup.forEach((cleanup2) => {
3482
+ if (typeof cleanup2 === "function")
3483
+ this._lifecycleDisconnected.push(cleanup2);
3484
+ else if (typeof cleanup2 === "object" && typeof cleanup2.remove === "function")
3485
+ this._lifecycleDisconnected.push(cleanup2.remove);
3486
+ });
3487
+ }
3488
+ };
3489
+ _a = controllerSymbol;
3490
+ _Controller.internals = new ControllerInternals();
3491
+ var Controller = _Controller;
3492
+ var GenericController = class extends Controller {
3493
+ // Redundant constructor needed to improve typing
3494
+ constructor(component) {
3495
+ super(component);
3496
+ }
3497
+ // Overriding super's watch only to improve typing
3498
+ watch(property, callback) {
3499
+ return super.watch(
3500
+ property,
3501
+ callback
3502
+ );
3503
+ }
3504
+ dynamicGetSet(property, getSet) {
3505
+ super.genericGetSet(property, getSet);
3506
+ }
3507
+ };
3508
+ function makeProvisionalValue(base) {
3509
+ if (typeof base !== "object" && typeof base !== "function" || base === null)
3510
+ return base;
3511
+ const proxy2 = new Proxy(base, {
3512
+ get(target, prop, receiver) {
3513
+ if (cyclical.has(prop) && prop in target && target[prop] === proxy2)
3514
+ return void 0;
3515
+ if (prop in target || prop in Promise.prototype || typeof prop === "symbol")
3516
+ return typeof target === "function" ? target[prop] : Reflect.get(target, prop, receiver);
3517
+ console.error(`Trying to access "${prop.toString()}" on the controller before it's loaded. ${accessBeforeLoad}`);
3518
+ return void 0;
3519
+ },
3520
+ set(target, prop, newValue, receiver) {
3521
+ console.error(`Trying to set "${prop.toString()}" on the controller before it's loaded. ${accessBeforeLoad}`);
3522
+ return Reflect.set(target, prop, newValue, receiver);
3523
+ }
3524
+ });
3525
+ return proxy2;
3526
+ }
3527
+ var cyclical = /* @__PURE__ */ new Set(["exports", "_exports"]);
3528
+ var accessBeforeLoad = "" ;
3529
+ function toControllerHost(component) {
3530
+ if ("addController" in component)
3531
+ return component;
3532
+ else
3533
+ throw new Error(
3534
+ "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"
3535
+ );
2942
3536
  }
3537
+ var ignoreSet = (_, value) => value;
3538
+ function trackPropertyKey(object, onResolved, defaultValue) {
3539
+ const keys = Object.keys(object);
3540
+ const keyCount = keys.length;
3541
+ if (keyTrackMap === void 0)
3542
+ queueMicrotask(keyTrackResolve);
3543
+ keyTrackMap ?? (keyTrackMap = /* @__PURE__ */ new Map());
3544
+ let pendingTrackers = keyTrackMap.get(object);
3545
+ if (pendingTrackers === void 0) {
3546
+ pendingTrackers = { callbacks: [], keyCount };
3547
+ keyTrackMap.set(object, pendingTrackers);
3548
+ }
3549
+ if (pendingTrackers.keyCount !== keyCount) {
3550
+ pendingTrackers.callbacks.forEach((resolve) => resolve(keys));
3551
+ pendingTrackers.callbacks = [];
3552
+ pendingTrackers.keyCount = keyCount;
3553
+ }
3554
+ pendingTrackers.callbacks.push((keys2) => {
3555
+ const callback = (key2) => arcadeDefaults.safeCall(onResolved, null, key2);
3556
+ const key = keys2[keyCount];
3557
+ if (key === void 0)
3558
+ callback(void 0);
3559
+ else if (object[key] === defaultValue)
3560
+ callback(key);
3561
+ else
3562
+ callback(void 0);
3563
+ });
3564
+ return defaultValue;
3565
+ }
3566
+ var keyTrackMap = void 0;
3567
+ function keyTrackResolve() {
3568
+ Array.from(keyTrackMap?.entries() ?? []).forEach(([object, { callbacks }]) => {
3569
+ const keys = Object.keys(object);
3570
+ callbacks.forEach((commit) => commit(keys));
3571
+ });
3572
+ keyTrackMap = void 0;
3573
+ }
3574
+ var ComponentInternals = class {
3575
+ constructor(component) {
3576
+ /**
3577
+ * When watchers are set, set then into `allWatchers`. When watchers are read
3578
+ * in the setter, read from `enabledWatchers`.
3579
+ * On connectedCallback(), controller manager does `enabledWatchers=allWatchers`.
3580
+ * Reasoning:
3581
+ * - This disables watchers until connected callback (matches behavior of
3582
+ * Stencil's watchers)
3583
+ * - This removes in the setter to check if watchers were enabled already or
3584
+ * not (as getters/setters are hot path, and should be streamlined)
3585
+ */
3586
+ this.enabledWatchers = {};
3587
+ this.allWatchers = {};
3588
+ this.trackKey = (hostsCandidates, onResolved, defaultValue) => {
3589
+ const candidateHosts = Array.isArray(hostsCandidates) ? hostsCandidates : [hostsCandidates];
3590
+ let leftToResolve = candidateHosts.length + 1;
3591
+ const resolved = (resolution) => {
3592
+ leftToResolve -= 1;
3593
+ if (resolution !== void 0)
3594
+ leftToResolve = 0;
3595
+ if (leftToResolve === 0)
3596
+ onResolved(resolution);
3597
+ };
3598
+ candidateHosts.forEach(
3599
+ (host) => this.component.manager.trackPropertyKey(
3600
+ host,
3601
+ (key) => resolved(
3602
+ key === void 0 ? void 0 : {
3603
+ key,
3604
+ host,
3605
+ type: "property",
3606
+ domValue: void 0
3607
+ }
3608
+ ),
3609
+ defaultValue
3610
+ )
3611
+ );
3612
+ this.component.manager.trackPropKey((key, domValue) => {
3613
+ const propType = key === void 0 ? void 0 : getPropType(this.component, key);
3614
+ resolved(
3615
+ key === void 0 ? void 0 : {
3616
+ key,
3617
+ host: this.component,
3618
+ type: propType ?? "prop",
3619
+ domValue: propType === "prop" ? domValue : void 0
3620
+ }
3621
+ );
3622
+ }, defaultValue);
3623
+ return defaultValue;
3624
+ };
3625
+ this.trackPropKey = (onResolved, defaultValue) => {
3626
+ if (this._trackedValue !== nothing && this._trackedValue !== defaultValue)
3627
+ this._firePropertyTrackers(void 0, void 0, void 0);
3628
+ if (this._keyTrackers.length === 0)
3629
+ queueMicrotask(() => this._firePropertyTrackers(void 0, void 0, void 0));
3630
+ this._trackedValue = defaultValue;
3631
+ this._keyTrackers.push(
3632
+ (key, value, previousValue) => arcadeDefaults.safeCall(onResolved, void 0, defaultValue === value ? key : void 0, previousValue)
3633
+ );
3634
+ return defaultValue;
3635
+ };
3636
+ this._trackedValue = nothing;
3637
+ this._keyTrackers = [];
3638
+ this.getters = {};
3639
+ this.setters = {};
3640
+ this.accessorGetter = {};
3641
+ this.accessorSetter = {};
3642
+ this.reactiveUtilsIntegrations = /* @__PURE__ */ new Set();
3643
+ this._exports = /* @__PURE__ */ new WeakMap();
3644
+ Object.defineProperty(this, "component", {
3645
+ writable: false,
3646
+ enumerable: false,
3647
+ configurable: true,
3648
+ value: component
3649
+ });
3650
+ }
3651
+ _firePropertyTrackers(key, value, oldValue) {
3652
+ const trackers = this._keyTrackers;
3653
+ this._trackedValue = nothing;
3654
+ this._keyTrackers = [];
3655
+ trackers.forEach((tracker) => tracker(key, value, oldValue));
3656
+ }
3657
+ /**
3658
+ * Configure a getter or setter for a given \@Prop/\@State
3659
+ *
3660
+ * Note, since props are defined on the prototype, they are shared between all
3661
+ * instances of a component. Thus, instead of passing a reference to the
3662
+ * getter/setter function, you should update the
3663
+ * ComponentInternals.getters/setters properties, and then call getSetProxy
3664
+ * to apply the changes to the prototype
3665
+ */
3666
+ getSetProxy(property, hasGetter, hasSetter) {
3667
+ const component = this.component;
3668
+ const classPrototype = component.constructor.prototype;
3669
+ this._getSetProxy(classPrototype, property, hasGetter, hasSetter, "class");
3670
+ if (component.manager.isLit)
3671
+ return;
3672
+ const htmlPrototype = component.el.constructor.prototype;
3673
+ if (classPrototype !== htmlPrototype)
3674
+ this._getSetProxy(htmlPrototype, property, hasGetter, hasSetter, "html");
3675
+ }
3676
+ _getSetProxy(prototype, name, hasGetter, hasSetter, type) {
3677
+ const component = this.component;
3678
+ const propType = getMemberType(component, name);
3679
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, name);
3680
+ const tolerateNotFound = type === "html";
3681
+ if (descriptor?.set === void 0 || descriptor.get === void 0)
3682
+ if (descriptor !== void 0 && "value" in descriptor)
3683
+ throw new Error(
3684
+ `getSet() should only be used on @Prop/@property/@State/@state properties. For internal component properties, use regular get/set syntax. Tried to use it on "${name}" in ${component.el.tagName}`
3685
+ );
3686
+ else if (tolerateNotFound)
3687
+ return;
3688
+ else
3689
+ throw new Error(`Unable to find "${name}" property on the ${component.el.tagName} component`);
3690
+ const { get: originalGet, set: originalSet } = descriptor;
3691
+ const isGetterAlreadyOverwritten = customAccessor in originalGet;
3692
+ const isSetterAlreadyOverwritten = customAccessor in originalSet;
3693
+ const shouldOverwriteGet = !isGetterAlreadyOverwritten && hasGetter;
3694
+ const shouldOverwriteSet = !isSetterAlreadyOverwritten && hasSetter;
3695
+ if (!shouldOverwriteGet && !shouldOverwriteSet)
3696
+ return;
3697
+ const finalGetter = shouldOverwriteGet ? function getter() {
3698
+ let value = originalGet.call(this);
3699
+ const component2 = Controller.internals.elementToInstance.get(this);
3700
+ if (Controller.internals.shouldBypassGetter || component2 === void 0)
3701
+ return value;
3702
+ const internals = component2.manager.internals;
3703
+ value = internals.accessorGetter[name](value, name);
3704
+ const getters = internals.getters[name] ?? emptyArray;
3705
+ for (let i = 0; i < getters.length; i++)
3706
+ value = getters[i](value, name);
3707
+ return value;
3708
+ } : originalGet;
3709
+ const finalSetter = shouldOverwriteSet ? function setter(rawNewValue) {
3710
+ const oldValue = originalGet.call(this);
3711
+ const component2 = Controller.internals.elementToInstance.get(this);
3712
+ if (component2 === void 0) {
3713
+ originalSet.call(this, rawNewValue);
3714
+ return;
3715
+ }
3716
+ let newValue = component2.manager.isLit ? rawNewValue : parsePropertyValue(rawNewValue, propType);
3717
+ const internals = component2.manager.internals;
3718
+ if (newValue === oldValue)
3719
+ originalSet.call(this, rawNewValue);
3720
+ else {
3721
+ const setters = Controller.internals.shouldBypassSetter ? emptyArray : internals.setters[name] ?? emptyArray;
3722
+ for (let i = 0; i < setters.length; i++) {
3723
+ newValue = setters[i](newValue, oldValue, name);
3724
+ if (newValue === oldValue)
3725
+ break;
3726
+ }
3727
+ newValue = internals.accessorSetter[name](newValue, oldValue, name);
3728
+ originalSet.call(this, newValue);
3729
+ if (newValue !== oldValue)
3730
+ internals.enabledWatchers[name]?.forEach((watcher) => watcher(newValue, oldValue, name));
3731
+ }
3732
+ if (internals._keyTrackers.length > 0)
3733
+ internals?._firePropertyTrackers(name, rawNewValue, oldValue);
3734
+ } : originalSet;
3735
+ if (shouldOverwriteGet)
3736
+ Object.defineProperty(finalGetter, customAccessor, { value: true });
3737
+ if (shouldOverwriteSet)
3738
+ Object.defineProperty(finalSetter, customAccessor, { value: true });
3739
+ Object.defineProperty(prototype, name, {
3740
+ ...descriptor,
3741
+ get: finalGetter,
3742
+ set: finalSetter
3743
+ });
3744
+ }
3745
+ /**
3746
+ * Associate an exports object with a controller for reverse lookup in
3747
+ * controller.use
3748
+ */
3749
+ markExports(controller, exports) {
3750
+ if (typeof exports === "object" && exports !== null || typeof exports === "function")
3751
+ this._exports.set(exports, controller);
3752
+ }
3753
+ resolveExports(exports) {
3754
+ if (typeof exports === "object" && exports !== null || typeof exports === "function")
3755
+ return this._exports.get(exports);
3756
+ else
3757
+ return void 0;
3758
+ }
3759
+ };
3760
+ var emptyArray = [];
3761
+ var customAccessor = Symbol("controllersCustomAccessor");
3762
+ var nothing = Symbol("nothing");
3763
+ var useControllerManager = (component, forceUpdate) => new ControllerManager(component, forceUpdate);
3764
+ var ControllerManager = class extends GenericController {
3765
+ constructor(component, forceUpdate) {
3766
+ const isLit = "addController" in component;
3767
+ const controllers = /* @__PURE__ */ new Set();
3768
+ function addController(controller) {
3769
+ controllers.add(controller);
3770
+ if (isLit && !(controllerSymbol in controller) && component.el.isConnected)
3771
+ controller.hostConnected?.();
3772
+ }
3773
+ function removeController(controller) {
3774
+ void controllers.delete(controller);
3775
+ controller.controllerRemoved?.();
3776
+ }
3777
+ const controllerHost = component;
3778
+ controllerHost.addController = addController;
3779
+ controllerHost.removeController = removeController;
3780
+ if (!isLit) {
3781
+ const update = forceUpdate ?? component.constructor.__forceUpdate;
3782
+ controllerHost.requestUpdate = () => update(component);
3783
+ }
3784
+ super(component);
3785
+ this.internals = new ComponentInternals(this.component);
3786
+ this.destroyed = false;
3787
+ this._updatePromise = new arcadeDefaults.Deferred();
3788
+ this._originalLifecycles = {};
3789
+ /**
3790
+ * A magical solution to finding out what property name a given controller
3791
+ * on a given object was assigned to. Note, this does not work for properties
3792
+ * that have \@Prop() or \@State() decorator - for those, use
3793
+ * manager.trackPropKey() instead.
3794
+ *
3795
+ * @example
3796
+ * function trackMe<T>(defaultValue:T, component:BaseComponent):T {
3797
+ * component.manager.trackPropertyKey(component, (key)=>console.log(key), defaultValue);
3798
+ * return defaultValue;
3799
+ * }
3800
+ *
3801
+ * class MyComponent extends BaseComponent {
3802
+ * // Will console log "myProp"
3803
+ * myProp = trackMe('a', this);
3804
+ * }
3805
+ *
3806
+ */
3807
+ this.trackPropertyKey = trackPropertyKey;
3808
+ /**
3809
+ * Like manager.trackPropertyKey(), but for props that have \@State() or \@Prop()
3810
+ * decorator
3811
+ *
3812
+ * @example
3813
+ * function trackMe(component:BaseComponent) {
3814
+ * component.manager.trackPropKey((key)=>console.log(key));
3815
+ * }
3816
+ *
3817
+ * class MyComponent extends BaseComponent {
3818
+ * // Will console log "myProp"
3819
+ * @Prop() myProp = trackMe(this);
3820
+ *
3821
+ * // Will console log "myState"
3822
+ * @State() myState = trackMe(this);
3823
+ * }
3824
+ */
3825
+ this.trackPropKey = this.internals.trackPropKey;
3826
+ /**
3827
+ * A combination of trackPropertyKey() and trackPropKey(). For usage when
3828
+ * you want to track a property, but don't know if it will be defined with the
3829
+ * \@Prop() decorator or not
3830
+ */
3831
+ this.trackKey = this.internals.trackKey;
3832
+ this._readonlySetter = (newValue, oldValue, property) => {
3833
+ if (Controller.internals.shouldBypassReadonly)
3834
+ return newValue;
3835
+ const component = this.component;
3836
+ const isProp = getPropType(component, property) === "prop";
3837
+ if (isProp) {
3838
+ if (this.isLit) {
3839
+ const details = getLitProperties(component).get(property);
3840
+ if (details && details?.attribute !== false)
3841
+ component.el.setAttribute(
3842
+ typeof details.attribute === "string" ? details.attribute : arcadeDefaults.camelToKebab(property),
3843
+ // Not using converter.toAttribute to keep this unlikely case simpler
3844
+ String(oldValue)
3845
+ );
3846
+ } else
3847
+ component.requestUpdate();
3848
+ }
3849
+ throw new Error(
3850
+ `Cannot assign to read-only property "${property}" of ${component.el.tagName.toLowerCase()}. Trying to assign "${String(
3851
+ newValue
3852
+ )}"`
3853
+ );
3854
+ };
3855
+ /**
3856
+ * In development, on hot module reload, controller would be re-initialized
3857
+ * with all Props and State values persistent, but properties lost. This unsafe
3858
+ * development-only API lets you set or get data for a controller that would
3859
+ * persist across hot reloads.
3860
+ */
3861
+ this.devOnlySetPersistentControllerData = void 0 ;
3862
+ this.devOnlyGetPersistentControllerData = void 0 ;
3863
+ this.isLit = isLit;
3864
+ this.component.manager = this;
3865
+ retrieveComponentMembers(component, isLit);
3866
+ this._controllers = controllers;
3867
+ this.exports = void 0;
3868
+ this.hasDestroy = "autoDestroyDisabled" in this.component && typeof this.component.destroy === "function";
3869
+ if (this.hasDestroy)
3870
+ this.watch("autoDestroyDisabled", () => this._autoDestroyDisabledWatcher());
3871
+ this._bindLifecycleMethods();
3872
+ if (!isLit)
3873
+ Object.defineProperty(component, "updateComplete", {
3874
+ get: async () => await this._updatePromise.promise
3875
+ });
3876
+ const members = getPropLikeMembers(component);
3877
+ const internals = component.manager.internals;
3878
+ members.forEach((name) => {
3879
+ internals.accessorGetter[name] = defaultGetterSetter;
3880
+ internals.accessorSetter[name] = defaultGetterSetter;
3881
+ internals.getSetProxy(name, true, true);
3882
+ });
3883
+ Controller.internals.setParentController(void 0);
3884
+ Controller.internals.setAmbientComponent(component);
3885
+ Controller.internals.elementToInstance.set(component.el, component);
3886
+ Controller.internals.elementToInstance.set(component, component);
3887
+ }
3888
+ _bindLifecycleMethods() {
3889
+ const component = this.component;
3890
+ const isLit = this.isLit;
3891
+ this._originalLifecycles = {
3892
+ // These component's callbacks will be called by Lit, so we don't have to
3893
+ connectedCallback: isLit ? void 0 : component.connectedCallback,
3894
+ disconnectedCallback: isLit ? void 0 : component.disconnectedCallback,
3895
+ componentWillLoad: isLit ? void 0 : component.componentWillLoad,
3896
+ componentDidLoad: isLit ? void 0 : component.componentDidLoad,
3897
+ componentWillUpdate: isLit ? void 0 : component.componentWillUpdate,
3898
+ componentDidUpdate: isLit ? void 0 : component.componentDidUpdate,
3899
+ destroy: component.destroy
3900
+ };
3901
+ const hostConnected = this._connectedCallback.bind(this);
3902
+ const hostDisconnected = this._disconnectedCallback.bind(this);
3903
+ const hostUpdate = this._update.bind(this);
3904
+ const hostUpdated = this._updated.bind(this);
3905
+ if (isLit)
3906
+ component.constructor.prototype.addController.call(component, {
3907
+ // Lit will call these callbacks
3908
+ hostConnected,
3909
+ hostDisconnected,
3910
+ hostUpdate,
3911
+ hostUpdated
3912
+ });
3913
+ else {
3914
+ component.connectedCallback = hostConnected;
3915
+ component.disconnectedCallback = hostDisconnected;
3916
+ component.componentWillLoad = this._load.bind(this);
3917
+ component.componentDidLoad = this._loaded.bind(this);
3918
+ component.componentWillUpdate = hostUpdate;
3919
+ component.componentDidUpdate = hostUpdated;
3920
+ }
3921
+ if (this.hasDestroy)
3922
+ component.destroy = this.destroy.bind(this);
3923
+ }
3924
+ /**
3925
+ * Throws an error if component does not implement destroy() lifecycle, but
3926
+ * tries to use it.
3927
+ */
3928
+ ensureHasDestroy() {
3929
+ if (!this.hasDestroy)
3930
+ throw new Error(destroyErrorMessage);
3931
+ }
3932
+ /**
3933
+ * Private because this is not supposed to be called by Component directly.
3934
+ * Instead, _bindLifecycleMethods will take care of that. Otherwise, you risk
3935
+ * calling lifecycle methods twice.
3936
+ */
3937
+ _connectedCallback() {
3938
+ if (this.destroyed) {
3939
+ const tagName = this.component.el.tagName.toLowerCase();
3940
+ this.component.el.remove();
3941
+ throw new Error(
3942
+ `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 autoDestroyDisabled prop.`
3943
+ );
3944
+ }
3945
+ if (this._autoDestroyTimeout !== void 0)
3946
+ clearTimeout(this._autoDestroyTimeout);
3947
+ this.internals.enabledWatchers = this.internals.allWatchers;
3948
+ keyTrackResolve();
3949
+ this._controllers.forEach(
3950
+ (controller) => "triggerConnected" in controller ? controller.triggerConnected() : arcadeDefaults.safeCall(controller.hostConnected, controller)
3951
+ );
3952
+ this._originalLifecycles.connectedCallback?.call(this.component);
3953
+ }
3954
+ _disconnectedCallback() {
3955
+ if (this.destroyed)
3956
+ return;
3957
+ this._controllers.forEach(
3958
+ (controller) => "triggerDisconnected" in controller ? controller.triggerDisconnected() : arcadeDefaults.safeCall(controller.hostDisconnected, controller)
3959
+ );
3960
+ this._originalLifecycles.disconnectedCallback?.call(this.component);
3961
+ if (this.hasDestroy)
3962
+ this._autoDestroyDisabledWatcher();
3963
+ }
3964
+ async _load() {
3965
+ const integrations = this.internals.reactiveUtilsIntegrations;
3966
+ if (integrations.size > 0) {
3967
+ for (const controller of integrations) {
3968
+ if ("triggerLoad" in controller)
3969
+ await controller.triggerLoad();
3970
+ else
3971
+ await arcadeDefaults.safeAsyncCall(controller.hostLoad, controller);
3972
+ }
3973
+ }
3974
+ await Promise.allSettled(
3975
+ Array.from(
3976
+ this._controllers,
3977
+ async (controller) => integrations.has(controller) ? void 0 : "triggerLoad" in controller ? await controller.triggerLoad() : await arcadeDefaults.safeAsyncCall(controller.hostLoad, controller)
3978
+ )
3979
+ );
3980
+ await this._originalLifecycles.componentWillLoad?.call(this.component);
3981
+ }
3982
+ _loaded() {
3983
+ this._controllers.forEach(
3984
+ (controller) => "triggerLoaded" in controller ? controller.triggerLoaded() : arcadeDefaults.safeCall(controller.hostLoaded, controller)
3985
+ );
3986
+ this._originalLifecycles.componentDidLoad?.call(this.component);
3987
+ }
3988
+ _update() {
3989
+ this._controllers.forEach(
3990
+ (controller) => "triggerUpdate" in controller ? controller.triggerUpdate() : arcadeDefaults.safeCall(controller.hostUpdate, controller)
3991
+ );
3992
+ void this._originalLifecycles.componentWillUpdate?.call(this.component);
3993
+ }
3994
+ _updated() {
3995
+ this._controllers.forEach(
3996
+ (controller) => "triggerUpdated" in controller ? controller.triggerUpdated() : arcadeDefaults.safeCall(controller.hostUpdated, controller)
3997
+ );
3998
+ this._originalLifecycles.componentDidUpdate?.call(this.component);
3999
+ if (!this.isLit) {
4000
+ const updatePromise = this._updatePromise;
4001
+ this._updatePromise = new arcadeDefaults.Deferred();
4002
+ updatePromise.resolve(true);
4003
+ }
4004
+ }
4005
+ async destroy() {
4006
+ this.ensureHasDestroy();
4007
+ if (this.destroyed)
4008
+ return;
4009
+ if (this.component.el.isConnected) {
4010
+ this.hasDestroy = false;
4011
+ try {
4012
+ this.component.el.remove();
4013
+ } finally {
4014
+ this.hasDestroy = true;
4015
+ }
4016
+ }
4017
+ this._autoDestroyTimeout = void 0;
4018
+ this.destroyed = true;
4019
+ this._controllers.forEach(
4020
+ (controller) => "triggerDestroy" in controller ? controller.triggerDestroy() : arcadeDefaults.safeCall(controller.hostDestroy, controller)
4021
+ );
4022
+ this._controllers.clear();
4023
+ await this._originalLifecycles.destroy?.call(this.component);
4024
+ }
4025
+ _autoDestroyDisabledWatcher() {
4026
+ if (!this.component.el.isConnected && !this.component.autoDestroyDisabled) {
4027
+ if (this._autoDestroyTimeout !== void 0)
4028
+ clearTimeout(this._autoDestroyTimeout);
4029
+ const destroy = () => void this.destroy().catch(console.error);
4030
+ this._autoDestroyTimeout = arcadeDefaults.devToolsAwareTimeout(destroy, autoDestroyOnDisconnectTimeout);
4031
+ }
4032
+ }
4033
+ // REFACTOR: replace this with a readonly:true option in @property()
4034
+ /**
4035
+ * Make a @Prop() or @State() readonly (prevent overwriting default value).
4036
+ *
4037
+ * For internal properties, prefer TypeScript's "readonly" modifier instead.
4038
+ *
4039
+ * @example
4040
+ * // Defining readonly prop
4041
+ * @Prop({ reflect: true }) prop = this.manager.readonly('a');
4042
+ *
4043
+ * @example
4044
+ * // Overwriting readonly prop internally
4045
+ * this.manager.bypassReadonly(()=>{
4046
+ * this.prop = 'b';
4047
+ * });
4048
+ *
4049
+ */
4050
+ readonly(value) {
4051
+ return this.getSet(value, { set: this._readonlySetter });
4052
+ }
4053
+ // REFACTOR: remove this in Lit in favor of native get/set
4054
+ /**
4055
+ * Listen for any component's @State()/@Prop() change, and mutate it's
4056
+ * value before it is set.
4057
+ * This is necessary because Stencil's Compiler does not support get/set for
4058
+ * @State()/@Prop().
4059
+ * For private component properties, you should use regular get/set syntax.
4060
+ *
4061
+ * @example
4062
+ * @Prop() exampleProp = this.manager.getSet(defaultValue,{get,set})
4063
+ * @Prop() someProp = this.manager.getSet(
4064
+ * undefined as string | undefined,
4065
+ * {
4066
+ * get: (value)=>value.trim(),
4067
+ * set: (newValue,oldValue) => newValue.trim() ?? oldValue
4068
+ * }
4069
+ * )
4070
+ *
4071
+ * @remarks
4072
+ * Unlike a native get/set, the get function receives the current attribute
4073
+ * value, and can modify it before returning it (or can disregard the current
4074
+ * value and get it from elsewhere instead).
4075
+ * Similarly, setter is called with the new and old value, and is expected to
4076
+ * return the final new value (or return the old value to undo the change)
4077
+ */
4078
+ getSet(defaultValue, getSet) {
4079
+ return this.component.manager.trackPropKey((name) => {
4080
+ var _a2;
4081
+ if (name === void 0)
4082
+ throw new Error(
4083
+ "Unable to resolve get/set's prop name. Make sure you are using it like @Prop() someProp = this.manager.getSet(defaultValue,{get,set})"
4084
+ );
4085
+ if (getSet.set === this._readonlySetter) {
4086
+ (_a2 = this.internals).readonlyProps ?? (_a2.readonlyProps = /* @__PURE__ */ new Set());
4087
+ this.internals.readonlyProps.add(name);
4088
+ }
4089
+ const genericComponent = this.component;
4090
+ const value = genericComponent[name];
4091
+ const isStencilHotReload = "production" !== "production" ;
4092
+ const initialSet = getSet.initialSet ?? true;
4093
+ if (value != null && value !== defaultValue && typeof getSet.set === "function" && initialSet && !isStencilHotReload) {
4094
+ const newValue = getSet.set(value, defaultValue, name);
4095
+ if (newValue !== value)
4096
+ if (this.isLit)
4097
+ genericComponent[name] = newValue;
4098
+ else {
4099
+ let firstConnected = true;
4100
+ this.onConnected(() => {
4101
+ if (!firstConnected)
4102
+ return;
4103
+ firstConnected = true;
4104
+ this.bypassSetter(() => {
4105
+ genericComponent[name] = newValue;
4106
+ });
4107
+ });
4108
+ }
4109
+ }
4110
+ this.genericGetSet(name, getSet);
4111
+ }, defaultValue);
4112
+ }
4113
+ };
4114
+ var destroyErrorMessage = `
4115
+ If the component uses a controller that uses destroy() method, then the
4116
+ component must have the following properties:
4117
+ ${// Don't expose internal code in production, and keep bundle smaller:
4118
+ `autoDestroyDisabled and destroy` }
4119
+ `.trim();
4120
+ var autoDestroyOnDisconnectTimeout = 1e3;
4121
+ var defaultGetterSetter = (value) => value;
4122
+
4123
+ // src/proxyExports.ts
4124
+ var proxyExports = (Class) => (...args) => {
4125
+ const ambientControllers = Controller.internals.retrieveParentControllers();
4126
+ const instance = new Class(...args);
4127
+ const initialExports = instance.exports;
4128
+ Controller.internals.setParentController(ambientControllers.at(-1));
4129
+ const internals = instance.component.manager.internals;
4130
+ internals.markExports(instance, initialExports);
4131
+ instance.watchExports((exports) => internals.markExports(instance, exports));
4132
+ Controller.internals.setAmbientChildController(instance);
4133
+ const hostCandidates = [instance.component, ...ambientControllers].reverse();
4134
+ return internals.trackKey(
4135
+ hostCandidates,
4136
+ (resolution) => resolution === void 0 ? void 0 : setProxy(instance, resolution, initialExports),
4137
+ initialExports
4138
+ );
4139
+ };
4140
+ function setProxy(controller, { host, key, type }, initialExports) {
4141
+ const genericHost = host;
4142
+ const controllerValueChanged = genericHost[key] !== controller.exports;
4143
+ const hostValueChanged = genericHost[key] !== initialExports;
4144
+ const controllerUpdatedExports = initialExports !== controller.exports;
4145
+ if (controllerValueChanged && !hostValueChanged && controllerUpdatedExports)
4146
+ genericHost[key] = controller.exports;
4147
+ const isProxyExportsOnComponent = host === controller.component;
4148
+ if (isProxyExportsOnComponent && type === "prop") {
4149
+ const internals = controller.component.manager.internals;
4150
+ if (hostValueChanged)
4151
+ internals.markExports(controller, genericHost[key]);
4152
+ controller.component.manager.watch(key, (value) => {
4153
+ if (value !== controller.exports)
4154
+ internals.markExports(controller, value);
4155
+ });
4156
+ }
4157
+ controller.watchExports(() => {
4158
+ if (genericHost[key] === controller.exports)
4159
+ return;
4160
+ const manager = controller.component.manager;
4161
+ const isReadOnly = manager.internals.readonlyProps?.has(key) === true;
4162
+ if (isReadOnly)
4163
+ manager.bypassReadonly(() => {
4164
+ genericHost[key] = controller.exports;
4165
+ });
4166
+ else
4167
+ genericHost[key] = controller.exports;
4168
+ });
4169
+ }
4170
+
4171
+ // src/functional.ts
4172
+ var makeController = (constructor) => proxy(void 0, constructor);
4173
+ var FunctionalController = class extends Controller {
4174
+ constructor(component, constructor) {
4175
+ super(component);
4176
+ const originalExports = this.exports;
4177
+ try {
4178
+ Controller.internals.setAmbientComponent(this.component);
4179
+ const value = constructor(this.component, this);
4180
+ const constructorChangedExports = this.exports !== originalExports;
4181
+ if (value instanceof Promise) {
4182
+ if (!constructorChangedExports)
4183
+ this.setProvisionalExports(value);
4184
+ const resolved = value.then((result) => {
4185
+ this.exports = result;
4186
+ super.catchUpLifecycle();
4187
+ }).catch((error) => {
4188
+ this._ready.reject(error);
4189
+ console.error(error);
4190
+ });
4191
+ this.onLoad(async () => await resolved);
4192
+ } else {
4193
+ if (!constructorChangedExports || value !== void 0)
4194
+ this.exports = value;
4195
+ queueMicrotask(() => super.catchUpLifecycle());
4196
+ }
4197
+ } catch (error) {
4198
+ this._ready.reject(error);
4199
+ console.error(error);
4200
+ }
4201
+ }
4202
+ /** Noop - will be called in the constructor instead */
4203
+ catchUpLifecycle() {
4204
+ return;
4205
+ }
4206
+ };
4207
+ var proxy = proxyExports(FunctionalController);
4208
+
4209
+ var makeT9nController = (getAssetPath) => ({ blocking = false, name } = {}) => (
4210
+ // eslint-disable-next-line @typescript-eslint/promise-function-async
4211
+ makeController((component, controller) => {
4212
+ controller.onLifecycle(
4213
+ () => arcadeDefaults.startLocaleObserver(
4214
+ component.el,
4215
+ getAssetPath("./assets"),
4216
+ ({ t9nLocale, t9nStrings, lang }) => {
4217
+ controller.exports = { ...t9nStrings, _lang: lang, _t9nLocale: t9nLocale };
4218
+ const label = t9nStrings.componentLabel ?? t9nStrings.widgetLabel;
4219
+ if (typeof label === "string" && "label" in component && component.label == null)
4220
+ component.label ?? (component.label = label);
4221
+ },
4222
+ name
4223
+ )
4224
+ );
4225
+ if (blocking)
4226
+ return controller.ready;
4227
+ const locale = arcadeDefaults.getElementLocales(component.el);
4228
+ return { _lang: locale.lang, _t9nLocale: locale.t9nLocale };
4229
+ })
4230
+ );
2943
4231
 
2944
4232
  function isMonacoEnvironmentSetup() {
2945
4233
  return !!window.MonacoEnvironment?.getWorkerUrl;
@@ -2981,21 +4269,81 @@ function setupMonacoEnvironment(assetsPath) {
2981
4269
  break;
2982
4270
  }
2983
4271
  // 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)) {
4272
+ if (!arcadeDefaults.isURL(url) || arcadeDefaults.hasSameOrigin(url, globalThis.location.href, true)) {
2985
4273
  return new Worker(url, { name: languageId });
2986
4274
  }
2987
4275
  // For cross orgin, we will load the worker code as a string and manufacture a blob
2988
4276
  const esriRequest = await arcadeDefaults.importRequest();
2989
4277
  const response = await esriRequest(url, {
2990
- responseType: "text"
4278
+ responseType: "text",
2991
4279
  });
2992
4280
  return new Worker(URL.createObjectURL(new Blob([response.data], {
2993
- type: "text/javascript"
4281
+ type: "text/javascript",
2994
4282
  })));
2995
- }
4283
+ },
2996
4284
  };
2997
4285
  }
2998
4286
 
4287
+ const themeConfig = {
4288
+ "arcade-light-theme": {
4289
+ comment: "#606060",
4290
+ constant: "#9809C8",
4291
+ date: "#296389",
4292
+ identifier: "#0000B3",
4293
+ keyword: "#BF4900",
4294
+ number: "#136D3D",
4295
+ string: "#A31515"
4296
+ },
4297
+ "arcade-dark-theme": {
4298
+ comment: "#BFBFBF",
4299
+ constant: "#CDBAEA",
4300
+ date: "#97A6CE",
4301
+ identifier: "#9FD4F3",
4302
+ keyword: "#EEAA5A",
4303
+ number: "#AAD04B",
4304
+ string: "#F2877B"
4305
+ }
4306
+ };
4307
+
4308
+ function setupArcadeTheme() {
4309
+ ["light", "dark"].forEach((theme) => {
4310
+ const base = theme === "light" ? "vs" : "vs-dark";
4311
+ const colors = themeConfig[`arcade-${theme}-theme`];
4312
+ // Defines the light and dark theme based on the calcite theme name
4313
+ arcadeDefaults.editor.defineTheme(base, {
4314
+ base,
4315
+ inherit: true,
4316
+ rules: [
4317
+ { token: "comment.arc", foreground: colors.comment },
4318
+ { token: "constant.arc", foreground: colors.constant },
4319
+ { token: "keyword.arc", foreground: colors.keyword },
4320
+ { token: "identifier.arc", foreground: colors.identifier },
4321
+ { token: "number.arc", foreground: colors.number },
4322
+ { token: "string.arc", foreground: colors.string },
4323
+ ],
4324
+ colors: {},
4325
+ });
4326
+ });
4327
+ }
4328
+ const monacoThemeKeys = ["comment", "keyword", "identifier", "string", "number", "constant"];
4329
+ const colorRulesKeys = [...monacoThemeKeys, "date"];
4330
+ function updateThemeColors(theme, colorRules) {
4331
+ if (colorRules === undefined) {
4332
+ setupArcadeTheme();
4333
+ return;
4334
+ }
4335
+ const base = theme === "light" ? "vs" : "vs-dark";
4336
+ const rules = [];
4337
+ monacoThemeKeys.forEach((key) => {
4338
+ const foreground = colorRules[key];
4339
+ if (!foreground) {
4340
+ return;
4341
+ }
4342
+ rules.push({ token: `${key}.arc`, foreground });
4343
+ });
4344
+ arcadeDefaults.editor.defineTheme(base, { base, inherit: true, rules, colors: {} });
4345
+ }
4346
+
2999
4347
  /**
3000
4348
  * Returns the arcade diagnostic service.
3001
4349
  * Example:
@@ -3025,23 +4373,22 @@ async function getArcadeWorker(uri) {
3025
4373
  }
3026
4374
  /**
3027
4375
  * Request the arcade mode
3028
- * @returns mode for arcade
4376
+ * @returns arcade mode module
3029
4377
  */
3030
4378
  async function getMode() {
3031
- return await Promise.resolve().then(function () { return require('./arcade-mode-d675c5ea.js'); });
4379
+ return await Promise.resolve().then(function () { return require('./arcade-mode-1bee51ae.js'); });
3032
4380
  }
3033
4381
  // Register the language in Monaco
3034
4382
  arcadeDefaults.languages.register({
3035
4383
  id: arcadeDefaults.arcadeDefaults.languageId,
3036
4384
  aliases: ["Arcade", "arcade"],
3037
4385
  extensions: [".arc"],
3038
- mimetypes: ["application/arcade"]
4386
+ mimetypes: ["application/arcade"],
3039
4387
  });
3040
4388
  // An event emitted when a language is first time needed
3041
4389
  arcadeDefaults.languages.onLanguage(arcadeDefaults.arcadeDefaults.languageId, () => {
3042
- // Setup the assets path on the arcadeDefaults
4390
+ setupArcadeTheme();
3043
4391
  arcadeDefaults.arcadeDefaults.setLanguageOptions({ assetsPath: `${getAssetsPath() ?? "."}/arcade-language` });
3044
- // Async import the language mode
3045
4392
  getMode()
3046
4393
  .then((mode) => {
3047
4394
  // Setup the language mode
@@ -3052,13 +4399,17 @@ arcadeDefaults.languages.onLanguage(arcadeDefaults.arcadeDefaults.languageId, ()
3052
4399
  });
3053
4400
  });
3054
4401
 
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)}";
4402
+ const useT9n = makeT9nController(index.getAssetPath);
4403
+
4404
+ 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)}:host calcite-list-item-group{background-color:var(--calcite-color-foreground-2)}";
3056
4405
 
3057
4406
  const ArcgisArcadeApi = class {
3058
4407
  constructor(hostRef) {
3059
4408
  index.registerInstance(this, hostRef);
3060
- this.close = index.createEvent(this, "close", 3);
3061
- this.itemSelected = index.createEvent(this, "itemSelected", 3);
4409
+ this.arcgisClose = index.createEvent(this, "arcgisClose", 3);
4410
+ this.arcgisItemSelected = index.createEvent(this, "arcgisItemSelected", 3);
4411
+ this.manager = useControllerManager(this);
4412
+ this.messages = useT9n();
3062
4413
  this._emitItemSelected = (e) => {
3063
4414
  const item = e.target?.["data-item"];
3064
4415
  if (!item) {
@@ -3067,10 +4418,10 @@ const ArcgisArcadeApi = class {
3067
4418
  const keyEvent = e;
3068
4419
  if (!keyEvent.key || keyEvent.key === "Enter") {
3069
4420
  e.preventDefault();
3070
- this.itemSelected.emit(item.completion.insertText);
4421
+ this.arcgisItemSelected.emit(item.completion.insertText);
3071
4422
  }
3072
4423
  };
3073
- this._emitClose = () => this.close.emit();
4424
+ this._emitClose = () => this.arcgisClose.emit();
3074
4425
  this._emitItemSelectedAndClose = (e) => {
3075
4426
  if (!e.target) {
3076
4427
  return;
@@ -3082,7 +4433,7 @@ const ArcgisArcadeApi = class {
3082
4433
  if (!item) {
3083
4434
  return;
3084
4435
  }
3085
- this.itemSelected.emit(item.completion.insertText);
4436
+ this.arcgisItemSelected.emit(item.completion.insertText);
3086
4437
  }
3087
4438
  };
3088
4439
  this._selectItem = (e) => {
@@ -3098,9 +4449,6 @@ const ArcgisArcadeApi = class {
3098
4449
  this._updateFilterValue = (e) => {
3099
4450
  this._filterValue = e.target?.value ?? "";
3100
4451
  };
3101
- this._lang = "";
3102
- this._t9nLocale = "";
3103
- this._t9nStrings = undefined;
3104
4452
  this._selectedApiItem = undefined;
3105
4453
  this._filterValue = "";
3106
4454
  this._colorizeStyle = "";
@@ -3114,7 +4462,6 @@ const ArcgisArcadeApi = class {
3114
4462
  async componentWillLoad() {
3115
4463
  this._colorizeStyle = generateColorizeStyles();
3116
4464
  this._themeChangedListner = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
3117
- await arcadeDefaults.B(this, index.getAssetPath("./assets"));
3118
4465
  arcadeDefaults.arcadeDefaults.onModelContextDidChange((key) => {
3119
4466
  if (!this.modelId || key !== arcadeDefaults.Uri.parse(this.modelId).toString()) {
3120
4467
  return;
@@ -3124,7 +4471,6 @@ const ArcgisArcadeApi = class {
3124
4471
  await this._updateApiLibrary();
3125
4472
  }
3126
4473
  disconnectedCallback() {
3127
- arcadeDefaults.q(this);
3128
4474
  this._flowObserver?.disconnect();
3129
4475
  this._themeChangedListner?.dispose();
3130
4476
  }
@@ -3169,7 +4515,7 @@ const ArcgisArcadeApi = class {
3169
4515
  // When switching between flow the same reference is reused
3170
4516
  this._flowObserver = new MutationObserver(() => {
3171
4517
  // 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");
4518
+ arcadeDefaults.setFocusOnElement(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
3173
4519
  });
3174
4520
  this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
3175
4521
  }
@@ -3180,14 +4526,14 @@ const ArcgisArcadeApi = class {
3180
4526
  if (!filteredApiItems.length) {
3181
4527
  return null;
3182
4528
  }
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 }))))));
4529
+ 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
4530
  }
3185
4531
  renderApiItemFlowItem() {
3186
4532
  const apiItem = this._selectedApiItem;
3187
4533
  if (!apiItem) {
3188
4534
  return null;
3189
4535
  }
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) => {
4536
+ 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
4537
  if (!e) {
3192
4538
  return;
3193
4539
  }
@@ -3198,10 +4544,10 @@ const ArcgisArcadeApi = class {
3198
4544
  render() {
3199
4545
  const categories = (this._apiLibrary ?? []).map((apiCategory) => this.renderApiCategory(apiCategory));
3200
4546
  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())));
4547
+ 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
4548
  }
3203
4549
  static get assetsDirs() { return ["assets"]; }
3204
- get _hostElement() { return index.getElement(this); }
4550
+ get el() { return index.getElement(this); }
3205
4551
  };
3206
4552
  ArcgisArcadeApi.style = arcadeApiCss;
3207
4553
 
@@ -3388,7 +4734,7 @@ async function executeScript(editorProfile, script, testContext, console) {
3388
4734
  // Setup an executor with the script
3389
4735
  const arcade = await arcadeDefaults.importArcade();
3390
4736
  const executor = await arcade.createArcadeExecutor(script ?? "", {
3391
- variables: editorProfile?.variables ?? []
4737
+ variables: editorProfile?.variables ?? [],
3392
4738
  });
3393
4739
  // We want to measure the execution time
3394
4740
  const t1 = performance.now();
@@ -3398,7 +4744,7 @@ async function executeScript(editorProfile, script, testContext, console) {
3398
4744
  spatialReference,
3399
4745
  timeZone,
3400
4746
  rawOutput: true,
3401
- console
4747
+ console,
3402
4748
  };
3403
4749
  // Execute the script
3404
4750
  const scriptOutput = await executor.executeAsync(profileVariableInstances, executeContext);
@@ -3422,81 +4768,21 @@ async function executeScript(editorProfile, script, testContext, console) {
3422
4768
  error,
3423
4769
  timeStamp,
3424
4770
  compilationTime: 0,
3425
- executionTime: 0
4771
+ executionTime: 0,
3426
4772
  };
3427
4773
  }
3428
4774
  }
3429
4775
 
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
- };
3450
-
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)}";
4776
+ 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}";
3491
4777
 
3492
- setupArcadeTheme();
3493
4778
  const ArcgisArcadeEditor = class {
3494
4779
  constructor(hostRef) {
3495
4780
  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();
4781
+ this.arcgisScriptChange = index.createEvent(this, "arcgisScriptChange", 3);
4782
+ this.arcgisDiagnosticsChange = index.createEvent(this, "arcgisDiagnosticsChange", 3);
4783
+ this.manager = useControllerManager(this);
4784
+ this._componentReadyDefer = new arcadeDefaults.Deferred();
4785
+ this._modelId = arcadeDefaults.generateGuid();
3500
4786
  this._editorProfilePromise = Promise.resolve(undefined);
3501
4787
  this._disposables = [];
3502
4788
  this._executeScript = async () => {
@@ -3537,18 +4823,16 @@ const ArcgisArcadeEditor = class {
3537
4823
  }
3538
4824
  };
3539
4825
  this._openArcadeHelp = () => void window.open(DevelopersWebSitePath, "Arcade Help");
3540
- this._emitScriptChange = (e) => {
4826
+ this._onCodeEditorValueChange = (e) => {
3541
4827
  e.stopPropagation();
3542
- this.scriptChange.emit(e.detail);
4828
+ this.script = e.detail;
4829
+ this.arcgisScriptChange.emit(e.detail);
3543
4830
  };
3544
4831
  this._insertAsSnippet = (e) => void this._codeEditorElt?.insertSnippet(e.detail).catch(console.error);
3545
4832
  this._insertAsText = (e) => void this._codeEditorElt?.insertText(e.detail).catch(console.error);
3546
4833
  this._onResultPanelChange = (e) => void (this._resultPanel = e.detail);
3547
4834
  this._onExecutionPanelClose = () => void (this._showExecutionPanel = false);
3548
- this._lang = "";
3549
- this._t9nLocale = "";
3550
- this._t9nStrings = undefined;
3551
- this._standaloneCodeEditor = undefined;
4835
+ this.messages = useT9n();
3552
4836
  this._preparingProfile = false;
3553
4837
  this._editorProfile = undefined;
3554
4838
  this._showExecutionPanel = false;
@@ -3566,6 +4850,10 @@ const ArcgisArcadeEditor = class {
3566
4850
  this.sideActionBarExpanded = false;
3567
4851
  this.openedSidePanel = "none";
3568
4852
  this.editorOptions = undefined;
4853
+ this.editorInstance = this.manager.getSet(undefined, {
4854
+ get: () => this._codeEditorElt?.editorInstance,
4855
+ set: "ignore",
4856
+ });
3569
4857
  }
3570
4858
  _profileChanged() {
3571
4859
  this._updateEditorProfile().catch(console.error);
@@ -3578,18 +4866,17 @@ const ArcgisArcadeEditor = class {
3578
4866
  }
3579
4867
  _snippetChanged() {
3580
4868
  arcadeDefaults.arcadeDefaults.updateApiContextForModel(this._modelId, {
3581
- snippets: this.snippets
4869
+ snippets: this.snippets,
3582
4870
  });
3583
4871
  }
3584
4872
  // #endregion
3585
4873
  // #region Public methods API
3586
4874
  /**
3587
- * Returns the current script.
3588
- * @returns {Promise<string>}
4875
+ * @deprecated Use `script` property instead.
3589
4876
  */
3590
4877
  async getScript() {
3591
4878
  await this._componentReadyDefer.promise;
3592
- return await this._codeEditorElt?.getValue();
4879
+ return this._codeEditorElt?.value;
3593
4880
  }
3594
4881
  /**
3595
4882
  * Set the focus on the element.
@@ -3600,12 +4887,11 @@ const ArcgisArcadeEditor = class {
3600
4887
  }
3601
4888
  /**
3602
4889
  * @internal
3603
- * Returns the editor instance.
3604
- * @returns {Promise<IStandaloneCodeEditor>} - The monaco editor instance
4890
+ * @deprecated Use `editorInstance` property instead.
3605
4891
  */
3606
4892
  async getEditorInstance() {
3607
4893
  await this._componentReadyDefer.promise;
3608
- return await this._codeEditorElt?.getEditorInstance();
4894
+ return this._codeEditorElt?.editorInstance;
3609
4895
  }
3610
4896
  /**
3611
4897
  * Returns the Arcade result for the script for the provided test data.
@@ -3627,11 +4913,11 @@ const ArcgisArcadeEditor = class {
3627
4913
  * @internal
3628
4914
  */
3629
4915
  async updateThemeColors(colorRules) {
3630
- const theme = arcadeDefaults.k(this._hostElement);
4916
+ const theme = arcadeDefaults.getElementTheme(this.el);
3631
4917
  updateThemeColors(theme, colorRules);
3632
4918
  if (colorRules === undefined) {
3633
4919
  colorRulesKeys.forEach((key) => {
3634
- this._hostElement.style.removeProperty(`--arcgis-arcade-editor-${key}`);
4920
+ this.el.style.removeProperty(`--arcgis-arcade-editor-${key}`);
3635
4921
  });
3636
4922
  return;
3637
4923
  }
@@ -3640,7 +4926,7 @@ const ArcgisArcadeEditor = class {
3640
4926
  if (!foreground) {
3641
4927
  return;
3642
4928
  }
3643
- this._hostElement.style.setProperty(`--arcgis-arcade-editor-${key}`, foreground);
4929
+ this.el.style.setProperty(`--arcgis-arcade-editor-${key}`, foreground);
3644
4930
  });
3645
4931
  }
3646
4932
  // #endregion
@@ -3648,14 +4934,13 @@ const ArcgisArcadeEditor = class {
3648
4934
  async componentWillLoad() {
3649
4935
  const assetsPath = index.getAssetPath("./assets");
3650
4936
  // 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.
4937
+ // Normally, it is the code editor that is responsible for setting up the Monaco environment.
3652
4938
  // However, we need to setup the environment before the code editor is instantiated because
3653
4939
  // we need to access the arcade language service to get the api library.
3654
4940
  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());
4941
+ await this._updateEditorProfile();
4942
+ // The profile has to be refreshed on locale change
4943
+ this.manager.watch("messages", () => void this._updateEditorProfile().catch(console.error));
3659
4944
  }
3660
4945
  async componentDidLoad() {
3661
4946
  // Mark on component as ready.
@@ -3664,10 +4949,9 @@ const ArcgisArcadeEditor = class {
3664
4949
  // Start listening to the validation diagnostics.
3665
4950
  // We are doing this as late as possible
3666
4951
  const diagnosticsService = await getArcadeDiagnosticService();
3667
- this._disposables.push(diagnosticsService.onDiagnosticsChange((event) => !this._preparingProfile && this.diagnosticsChange.emit(event.diagnostics)));
4952
+ this._disposables.push(diagnosticsService.onDiagnosticsChange((event) => !this._preparingProfile && this.arcgisDiagnosticsChange.emit(event.diagnostics)));
3668
4953
  // Get editor instance and add action
3669
- this._standaloneCodeEditor = await this.getEditorInstance();
3670
- this._standaloneCodeEditor?.addAction({
4954
+ this.editorInstance?.addAction({
3671
4955
  // An unique identifier for the action.
3672
4956
  id: "run-script",
3673
4957
  label: "Run Arcade Expression",
@@ -3678,12 +4962,11 @@ const ArcgisArcadeEditor = class {
3678
4962
  if (this.testData) {
3679
4963
  this._executeScript().catch(console.error);
3680
4964
  }
3681
- }
4965
+ },
3682
4966
  });
3683
4967
  await this._codeEditorElt?.setFocus();
3684
4968
  }
3685
4969
  disconnectedCallback() {
3686
- arcadeDefaults.q(this);
3687
4970
  arcadeDefaults.arcadeDefaults.disposeApiContextForModel(this._modelId);
3688
4971
  arcadeDefaults.arcadeDefaults.disposeEditorProfileForModel(this._modelId);
3689
4972
  while (this._disposables.length) {
@@ -3700,8 +4983,8 @@ const ArcgisArcadeEditor = class {
3700
4983
  try {
3701
4984
  // Set a new profile for the model using the profile definition and the locale.
3702
4985
  await arcadeDefaults.arcadeDefaults.setProfileForModel(this._modelId, this.profile, {
3703
- locale: this._t9nLocale,
3704
- snippets: this.snippets
4986
+ locale: this.messages._t9nLocale,
4987
+ snippets: this.snippets,
3705
4988
  });
3706
4989
  // Get the corresponding editor profile for the model.
3707
4990
  // The editor profile contains the specialized profile for the UI.
@@ -3721,16 +5004,16 @@ const ArcgisArcadeEditor = class {
3721
5004
  if (!this.testData) {
3722
5005
  return null;
3723
5006
  }
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)));
5007
+ 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
5008
  }
3726
5009
  //#endregion
3727
5010
  //#region Render Main Panel
3728
5011
  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) }));
5012
+ return (index.h("arcgis-code-editor", { class: "flex-adjustable", language: arcadeDefaults.arcadeDefaults.languageId, value: this.script ?? "", modelId: this._modelId, options: this.editorOptions, onArcgisValueChange: this._onCodeEditorValueChange, ref: (e) => (this._codeEditorElt = e) }));
3730
5013
  }
3731
5014
  //#endregion
3732
5015
  //#region Rendering the Action Bar
3733
- renderAction({ id, label, icon, active, panelName, onClick = this._toggleSidePanel }) {
5016
+ renderAction({ id, label, icon, active, panelName, onClick = this._toggleSidePanel, }) {
3734
5017
  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
5018
  }
3736
5019
  renderSideActionBar() {
@@ -3739,33 +5022,33 @@ const ArcgisArcadeEditor = class {
3739
5022
  }
3740
5023
  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
5024
  id: "profile-variables-action",
3742
- label: this._t9nStrings?.profilevariables ?? "Profile variables",
5025
+ label: this.messages.profilevariables ?? "Profile variables",
3743
5026
  icon: "profile-variables",
3744
5027
  active: this.openedSidePanel === "variables",
3745
- panelName: "variables"
5028
+ panelName: "variables",
3746
5029
  }), this.renderAction({
3747
5030
  id: "function-action",
3748
- label: this._t9nStrings?.constantsandfunctions ?? "Constants and functions",
5031
+ label: this.messages.constantsandfunctions ?? "Constants and functions",
3749
5032
  icon: "function",
3750
5033
  active: this.openedSidePanel === "api",
3751
- panelName: "api"
5034
+ panelName: "api",
3752
5035
  }), this.suggestions?.length
3753
5036
  ? this.renderAction({
3754
5037
  id: "suggestions-action",
3755
- label: this._t9nStrings?.suggestions ?? "Suggestions",
5038
+ label: this.messages.suggestions ?? "Suggestions",
3756
5039
  icon: "lightbulb",
3757
5040
  active: this.openedSidePanel === "suggestions",
3758
- panelName: "suggestions"
5041
+ panelName: "suggestions",
3759
5042
  })
3760
5043
  : null, this.hideDocumentationActions
3761
5044
  ? null
3762
5045
  : this.renderAction({
3763
5046
  id: "developer-website-action",
3764
- label: this._t9nStrings?.help ?? "Help",
5047
+ label: this.messages.help ?? "Help",
3765
5048
  icon: "question",
3766
5049
  active: false,
3767
5050
  panelName: "none",
3768
- onClick: this._openArcadeHelp
5051
+ onClick: this._openArcadeHelp,
3769
5052
  }))));
3770
5053
  }
3771
5054
  //#endregion
@@ -3776,11 +5059,11 @@ const ArcgisArcadeEditor = class {
3776
5059
  }
3777
5060
  switch (this.openedSidePanel) {
3778
5061
  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" }));
5062
+ 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
5063
  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" }));
5064
+ 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
5065
  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" }));
5066
+ 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
5067
  default:
3785
5068
  return null;
3786
5069
  }
@@ -3791,7 +5074,7 @@ const ArcgisArcadeEditor = class {
3791
5074
  if (!this._showExecutionPanel) {
3792
5075
  return null;
3793
5076
  }
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 }));
5077
+ 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
5078
  }
3796
5079
  //#endregion
3797
5080
  //#region Render
@@ -3799,7 +5082,7 @@ const ArcgisArcadeEditor = class {
3799
5082
  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
5083
  }
3801
5084
  static get assetsDirs() { return ["assets"]; }
3802
- get _hostElement() { return index.getElement(this); }
5085
+ get el() { return index.getElement(this); }
3803
5086
  static get watchers() { return {
3804
5087
  "profile": ["_profileChanged"],
3805
5088
  "testData": ["_testDataChanged"],
@@ -3808,20 +5091,20 @@ const ArcgisArcadeEditor = class {
3808
5091
  };
3809
5092
  ArcgisArcadeEditor.style = arcadeEditorCss;
3810
5093
 
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)}";
5094
+ 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
5095
 
3813
5096
  //#region Specialized Constants
3814
5097
  const treeProps = {
3815
5098
  lines: true,
3816
5099
  selectionMode: "none",
3817
5100
  scale: "s",
3818
- onCalciteTreeSelect: (e) => e.target.selectedItems.forEach((itemElt) => (itemElt.selected = false))
5101
+ onCalciteTreeSelect: (e) => e.target.selectedItems.forEach((itemElt) => (itemElt.selected = false)),
3819
5102
  };
3820
5103
  const expandableTreeItemProps = {
3821
5104
  onClick: (e) => {
3822
5105
  const item = e.currentTarget;
3823
5106
  item.expanded = !item.expanded;
3824
- }
5107
+ },
3825
5108
  };
3826
5109
  //#endregion
3827
5110
  //#region Helper Functions
@@ -3840,7 +5123,7 @@ function renderSimpleValue(arcadeResult) {
3840
5123
  case "null":
3841
5124
  return index.h("span", { class: "constant-value" }, arcadeResult.type);
3842
5125
  case "text":
3843
- return index.h("span", { class: "string-value" }, arcadeDefaults.D(arcadeResult.value));
5126
+ return index.h("span", { class: "string-value" }, arcadeDefaults.quoteString(arcadeResult.value));
3844
5127
  case "number":
3845
5128
  return index.h("span", { class: "number-value" }, arcadeResult.value.toString());
3846
5129
  case "boolean":
@@ -3848,9 +5131,9 @@ function renderSimpleValue(arcadeResult) {
3848
5131
  case "date":
3849
5132
  return index.h("span", { class: "date-value" }, formatArcadeResultDate(arcadeResult));
3850
5133
  case "dateOnly":
3851
- return index.h("span", { class: "string-value" }, arcadeDefaults.D(formatArcadeResultDateOnly(arcadeResult)));
5134
+ return index.h("span", { class: "string-value" }, arcadeDefaults.quoteString(formatArcadeResultDateOnly(arcadeResult)));
3852
5135
  case "time":
3853
- return index.h("span", { class: "string-value" }, arcadeDefaults.D(formatArcadeResultTimeOnly(arcadeResult)));
5136
+ return index.h("span", { class: "string-value" }, arcadeDefaults.quoteString(formatArcadeResultTimeOnly(arcadeResult)));
3854
5137
  default:
3855
5138
  return null;
3856
5139
  }
@@ -3870,8 +5153,11 @@ function renderFeatureSetTable(arcadeResult) {
3870
5153
  const ArcgisArcadeResults = class {
3871
5154
  constructor(hostRef) {
3872
5155
  index.registerInstance(this, hostRef);
3873
- this.openedResultPanelChange = index.createEvent(this, "openedResultPanelChange", 3);
3874
- this.close = index.createEvent(this, "close", 3);
5156
+ this.arcgisOpenedResultPanelChange = index.createEvent(this, "arcgisOpenedResultPanelChange", 3);
5157
+ this.arcgisClose = index.createEvent(this, "arcgisClose", 3);
5158
+ this.manager = useControllerManager(this);
5159
+ //#region Private Properties
5160
+ this.messages = useT9n();
3875
5161
  this._switchResultPanel = (e) => {
3876
5162
  if (!e.target) {
3877
5163
  return;
@@ -3882,28 +5168,17 @@ const ArcgisArcadeResults = class {
3882
5168
  }
3883
5169
  this.updateResultPanel(panelName);
3884
5170
  };
3885
- this._emitClose = () => this.close.emit();
3886
- this._lang = "";
3887
- this._t9nLocale = "";
3888
- this._t9nStrings = undefined;
5171
+ this._emitClose = () => this.arcgisClose.emit();
3889
5172
  this.loading = true;
3890
5173
  this.openedResultPanel = "output";
3891
5174
  this.result = undefined;
3892
5175
  this.consoleLogs = undefined;
3893
5176
  }
3894
5177
  //#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
5178
  //#region Private Methods
3904
5179
  updateResultPanel(resultPanelType) {
3905
5180
  this.openedResultPanel = resultPanelType;
3906
- this.openedResultPanelChange.emit(resultPanelType);
5181
+ this.arcgisOpenedResultPanelChange.emit(resultPanelType);
3907
5182
  }
3908
5183
  //#endregion
3909
5184
  //#region Rendering
@@ -3914,7 +5189,7 @@ const ArcgisArcadeResults = class {
3914
5189
  if (this.loading && !this.consoleLogs?.length) {
3915
5190
  return index.h("calcite-loader", { scale: "s", type: "indeterminate", label: "" });
3916
5191
  }
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))));
5192
+ 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
5193
  }
3919
5194
  renderLogPanel() {
3920
5195
  if (this.openedResultPanel !== "log") {
@@ -3924,24 +5199,24 @@ const ArcgisArcadeResults = class {
3924
5199
  return index.h("calcite-loader", { scale: "s", type: "indeterminate", label: "" });
3925
5200
  }
3926
5201
  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, {
5202
+ return (index.h("calcite-list", null, this.result ? (index.h(index.Fragment, null, index.h("calcite-list-item", { label: arcadeDefaults.setValuesInString(this.messages.lastexecutionformat, {
5203
+ timeStamp: new Intl.DateTimeFormat(this.messages._t9nLocale, {
3929
5204
  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, {
5205
+ timeStyle: "medium",
5206
+ }).format(this.result.timeStamp),
5207
+ }) }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), index.h("calcite-list-item", { label: arcadeDefaults.setValuesInString(this.messages.compilationtimeformat, {
5208
+ time: new Intl.NumberFormat(this.messages._t9nLocale, {
3934
5209
  style: "unit",
3935
5210
  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, {
5211
+ maximumFractionDigits: 2,
5212
+ }).format(this.result.compilationTime ?? 0),
5213
+ }) }, index.h("calcite-icon", { slot: "content-start", icon: "information", scale: "s", class: iconClass })), index.h("calcite-list-item", { label: arcadeDefaults.setValuesInString(this.messages.executiontimeformat, {
5214
+ time: new Intl.NumberFormat(this.messages._t9nLocale, {
3940
5215
  style: "unit",
3941
5216
  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" })))));
5217
+ maximumFractionDigits: 2,
5218
+ }).format(this.result.executionTime ?? 0),
5219
+ }) }, 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
5220
  }
3946
5221
  renderOutputPanel() {
3947
5222
  if (this.openedResultPanel !== "output") {
@@ -3952,8 +5227,8 @@ const ArcgisArcadeResults = class {
3952
5227
  }
3953
5228
  switch (this.result?.type) {
3954
5229
  case "error":
3955
- return (index.h("div", { class: "result-value-simple flex-adjustable" }, arcadeDefaults.Z(this._t9nStrings?.executionerrorformat, {
3956
- message: this.result.value
5230
+ return (index.h("div", { class: "result-value-simple flex-adjustable" }, arcadeDefaults.setValuesInString(this.messages.executionerrorformat, {
5231
+ message: this.result.value,
3957
5232
  })));
3958
5233
  case "null":
3959
5234
  case "unknown":
@@ -3983,14 +5258,14 @@ const ArcgisArcadeResults = class {
3983
5258
  case "knowledgeGraph":
3984
5259
  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
5260
  default:
3986
- return (index.h("div", { class: "result-value-simple flex-adjustable ltr-container" }, this._t9nStrings?.runscriptmessage));
5261
+ return index.h("div", { class: "result-value-simple flex-adjustable ltr-container" }, this.messages.runscriptmessage);
3987
5262
  }
3988
5263
  }
3989
5264
  renderArrayHeader(arcadeResult) {
3990
5265
  const items = arcadeResult.value ?? [];
3991
5266
  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()
5267
+ 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, {
5268
+ count: MaxArrayItems.toString(),
3994
5269
  }))) : null));
3995
5270
  }
3996
5271
  renderArrayTree(items, subtree = false) {
@@ -4035,15 +5310,15 @@ const ArcgisArcadeResults = class {
4035
5310
  }
4036
5311
  }
4037
5312
  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()
5313
+ 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, {
5314
+ count: BatchSize.toString(),
4040
5315
  }))) : null));
4041
5316
  }
4042
5317
  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())))));
5318
+ 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
5319
  }
4045
5320
  static get assetsDirs() { return ["assets"]; }
4046
- get _hostElement() { return index.getElement(this); }
5321
+ get el() { return index.getElement(this); }
4047
5322
  };
4048
5323
  ArcgisArcadeResults.style = arcadeResultsCss;
4049
5324
 
@@ -4057,13 +5332,15 @@ function isSuggestionGroups(item) {
4057
5332
  return Array.isArray(item[0].suggestions);
4058
5333
  }
4059
5334
 
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)}";
5335
+ 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)}:host calcite-list-item-group{background-color:var(--calcite-color-foreground-2)}";
4061
5336
 
4062
5337
  const ArcgisArcadeSuggestions = class {
4063
5338
  constructor(hostRef) {
4064
5339
  index.registerInstance(this, hostRef);
4065
- this.close = index.createEvent(this, "close", 3);
4066
- this.itemSelected = index.createEvent(this, "itemSelected", 3);
5340
+ this.arcgisClose = index.createEvent(this, "arcgisClose", 3);
5341
+ this.arcgisItemSelected = index.createEvent(this, "arcgisItemSelected", 3);
5342
+ this.manager = useControllerManager(this);
5343
+ this.messages = useT9n();
4067
5344
  this._updateFilterValue = (e) => {
4068
5345
  this._filterValue = e.target?.value ?? "";
4069
5346
  };
@@ -4075,7 +5352,7 @@ const ArcgisArcadeSuggestions = class {
4075
5352
  const keyEvent = e;
4076
5353
  if (!keyEvent.key || keyEvent.key === "Enter") {
4077
5354
  e.preventDefault();
4078
- this.itemSelected.emit(item.code);
5355
+ this.arcgisItemSelected.emit(item.code);
4079
5356
  }
4080
5357
  };
4081
5358
  this._showSuggestionDetail = (e) => {
@@ -4087,14 +5364,11 @@ const ArcgisArcadeSuggestions = class {
4087
5364
  this._selectedSuggestion = item;
4088
5365
  };
4089
5366
  this._emitClose = () => {
4090
- this.close.emit();
5367
+ this.arcgisClose.emit();
4091
5368
  };
4092
5369
  this._beforeBack = async () => {
4093
5370
  this._selectedSuggestion = undefined;
4094
5371
  };
4095
- this._lang = "";
4096
- this._t9nLocale = "";
4097
- this._t9nStrings = undefined;
4098
5372
  this._selectedSuggestion = undefined;
4099
5373
  this._filterValue = "";
4100
5374
  this._colorizeStyle = "";
@@ -4107,13 +5381,11 @@ const ArcgisArcadeSuggestions = class {
4107
5381
  // #region Component lifecycle events
4108
5382
  async componentWillLoad() {
4109
5383
  this._colorizeStyle = generateColorizeStyles();
4110
- this._themeChangedListner = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
4111
- await arcadeDefaults.B(this, index.getAssetPath("./assets"));
5384
+ this._themeChangedListener = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
4112
5385
  }
4113
5386
  disconnectedCallback() {
4114
5387
  this._flowObserver?.disconnect();
4115
- this._themeChangedListner?.dispose();
4116
- arcadeDefaults.q(this);
5388
+ this._themeChangedListener?.dispose();
4117
5389
  }
4118
5390
  // #endregion
4119
5391
  //#region Private Methods
@@ -4131,7 +5403,7 @@ const ArcgisArcadeSuggestions = class {
4131
5403
  // When switching between flow the same reference is reused
4132
5404
  this._flowObserver = new MutationObserver(() => {
4133
5405
  // 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");
5406
+ arcadeDefaults.setFocusOnElement(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
4135
5407
  });
4136
5408
  this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
4137
5409
  }
@@ -4149,29 +5421,29 @@ const ArcgisArcadeSuggestions = class {
4149
5421
  renderSuggestionListItems(suggestions) {
4150
5422
  suggestions = arcadeDefaults.filterCollection(suggestions, "label", this._filterValue);
4151
5423
  if (!suggestions.length) {
4152
- return index.h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No item");
5424
+ return index.h("div", { class: "notice-container" }, this.messages.noitems ?? "No item");
4153
5425
  }
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 }))));
5426
+ 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
5427
  }
4156
5428
  renderSuggestionFlowItem() {
4157
5429
  const suggestion = this._selectedSuggestion;
4158
5430
  if (!suggestion) {
4159
5431
  return null;
4160
5432
  }
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) })))));
5433
+ 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
5434
  }
4163
5435
  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())));
5436
+ 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
5437
  }
4166
5438
  static get assetsDirs() { return ["assets"]; }
4167
- get _hostElement() { return index.getElement(this); }
5439
+ get el() { return index.getElement(this); }
4168
5440
  static get watchers() { return {
4169
5441
  "suggestions": ["suggestionsPropChanged"]
4170
5442
  }; }
4171
5443
  };
4172
5444
  ArcgisArcadeSuggestions.style = arcadeSuggestionsCss;
4173
5445
 
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%}";
5446
+ 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%}:host calcite-list-item-group{background-color:var(--calcite-color-foreground-2)}";
4175
5447
 
4176
5448
  function stopEnterPropagation(e) {
4177
5449
  if (e.key === "Enter") {
@@ -4181,8 +5453,10 @@ function stopEnterPropagation(e) {
4181
5453
  const ArcgisArcadeVariables = class {
4182
5454
  constructor(hostRef) {
4183
5455
  index.registerInstance(this, hostRef);
4184
- this.close = index.createEvent(this, "close", 3);
4185
- this.itemSelected = index.createEvent(this, "itemSelected", 3);
5456
+ this.arcgisClose = index.createEvent(this, "arcgisClose", 3);
5457
+ this.arcgisItemSelected = index.createEvent(this, "arcgisItemSelected", 3);
5458
+ this.manager = useControllerManager(this);
5459
+ this.messages = useT9n();
4186
5460
  this._updateFilterValue = (e) => {
4187
5461
  this._filterValue = e.target.value;
4188
5462
  };
@@ -4191,7 +5465,7 @@ const ArcgisArcadeVariables = class {
4191
5465
  this._filterValue = "";
4192
5466
  };
4193
5467
  this._emitClose = () => {
4194
- this.close.emit();
5468
+ this.arcgisClose.emit();
4195
5469
  };
4196
5470
  this._backToTop = () => {
4197
5471
  this._flowItemRenderers = [];
@@ -4204,7 +5478,7 @@ const ArcgisArcadeVariables = class {
4204
5478
  const keyEvent = e;
4205
5479
  if (!keyEvent.key || keyEvent.key === "Enter") {
4206
5480
  e.preventDefault();
4207
- this.itemSelected.emit(variable.snippet);
5481
+ this.arcgisItemSelected.emit(variable.snippet);
4208
5482
  }
4209
5483
  };
4210
5484
  this._showCollectionPanel = (e) => {
@@ -4215,9 +5489,6 @@ const ArcgisArcadeVariables = class {
4215
5489
  e.stopPropagation();
4216
5490
  this.addPanelRenderer(this.collectionBasedVariableRenderer(collectionVariable));
4217
5491
  };
4218
- this._lang = "";
4219
- this._t9nLocale = "";
4220
- this._t9nStrings = undefined;
4221
5492
  this._mutationCounter = 1;
4222
5493
  this._flowItemRenderers = [];
4223
5494
  this._filterValue = "";
@@ -4228,12 +5499,7 @@ const ArcgisArcadeVariables = class {
4228
5499
  this._flowItemRenderers = [];
4229
5500
  }
4230
5501
  //#endregion
4231
- // #region Component lifecycle events
4232
- async componentWillLoad() {
4233
- await arcadeDefaults.B(this, index.getAssetPath("./assets"));
4234
- }
4235
5502
  disconnectedCallback() {
4236
- arcadeDefaults.q(this);
4237
5503
  this._flowObserver?.disconnect();
4238
5504
  }
4239
5505
  // #endregion
@@ -4258,7 +5524,7 @@ const ArcgisArcadeVariables = class {
4258
5524
  // When switching between flow the same reference is reused
4259
5525
  this._flowObserver = new MutationObserver(() => {
4260
5526
  // 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");
5527
+ arcadeDefaults.setFocusOnElement(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
4262
5528
  });
4263
5529
  this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
4264
5530
  }
@@ -4287,15 +5553,15 @@ const ArcgisArcadeVariables = class {
4287
5553
  });
4288
5554
  loading = true;
4289
5555
  }
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)))));
5556
+ 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
5557
  };
4292
5558
  }
4293
5559
  renderEditorVariables(collection) {
4294
5560
  // Filter the variables. Skip group, we will filter the children later on.
4295
- const filterExpression = arcadeDefaults.K(this._filterValue);
5561
+ const filterExpression = arcadeDefaults.createFilterExpression(this._filterValue);
4296
5562
  const filteredVariables = collection.variables.filter((variable) => variable.passFilter(filterExpression));
4297
5563
  if (!filteredVariables.length) {
4298
- return index.h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No item");
5564
+ return index.h("div", { class: "notice-container" }, this.messages.noitems ?? "No item");
4299
5565
  }
4300
5566
  return filteredVariables.map((variable) => this.renderEditorVariable(variable));
4301
5567
  }
@@ -4305,18 +5571,18 @@ const ArcgisArcadeVariables = class {
4305
5571
  // Group is a collection but we represent it differently
4306
5572
  return (index.h("calcite-list-item-group", { heading: variable.getLabel() }, this.renderEditorVariables(variable)));
4307
5573
  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));
5574
+ 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
5575
  }
4310
5576
  }
4311
5577
  render() {
4312
5578
  const profile = arcadeDefaults.arcadeDefaults.getEditorProfileForModel(this.modelId ?? "");
4313
5579
  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 ?? ""))));
5580
+ 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
5581
  }
4316
5582
  return (index.h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, this.collectionBasedVariableRenderer(profile, true)(), this._flowItemRenderers.map((renderer) => renderer())));
4317
5583
  }
4318
5584
  static get assetsDirs() { return ["assets"]; }
4319
- get _hostElement() { return index.getElement(this); }
5585
+ get el() { return index.getElement(this); }
4320
5586
  static get watchers() { return {
4321
5587
  "modelId": ["modelIdPropChanged"]
4322
5588
  }; }
@@ -4334,74 +5600,74 @@ const EditorOptionsDefaults = {
4334
5600
  renderLineHighlight: "none",
4335
5601
  suggest: {
4336
5602
  snippetsPreventQuickSuggestions: false,
4337
- showWords: false
5603
+ showWords: false,
4338
5604
  },
4339
5605
  tabSize: 2,
4340
- useShadowDOM: true
5606
+ useShadowDOM: true,
4341
5607
  };
4342
5608
  const ArcgisCodeEditor = class {
4343
5609
  constructor(hostRef) {
4344
5610
  index.registerInstance(this, hostRef);
4345
- this.valueChange = index.createEvent(this, "valueChange", 3);
4346
- this._componentReadyDefer = new arcadeDefaults.h();
5611
+ this.arcgisValueChange = index.createEvent(this, "arcgisValueChange", 3);
5612
+ this.arcgisSelectionChange = index.createEvent(this, "arcgisSelectionChange", 3);
5613
+ this.manager = useControllerManager(this);
5614
+ this._componentReadyDefer = new arcadeDefaults.Deferred();
4347
5615
  this._disposables = [];
4348
- this.value = undefined;
5616
+ this.value = this.manager.getSet("", {
5617
+ set: (newValue) => {
5618
+ newValue ?? (newValue = "");
5619
+ if (!this._editorInstance) {
5620
+ return newValue;
5621
+ }
5622
+ const model = this._editorInstance.getModel();
5623
+ if (!model) {
5624
+ return newValue;
5625
+ }
5626
+ if (model.getValue() === newValue) {
5627
+ return newValue;
5628
+ }
5629
+ // Set the value and preserve the undo stack
5630
+ const range = model.getFullModelRange();
5631
+ this._editorInstance.executeEdits("", [{ range, text: newValue, forceMoveMarkers: true }]);
5632
+ this._editorInstance.pushUndoStop();
5633
+ return newValue;
5634
+ },
5635
+ });
4349
5636
  this.language = undefined;
4350
- this.modelId = arcadeDefaults.U();
5637
+ this.modelId = arcadeDefaults.generateGuid();
4351
5638
  this.options = undefined;
4352
- }
4353
- valuePropChange(newValue) {
4354
- if (!this._editorInstance) {
4355
- return;
4356
- }
4357
- this._editorInstance.setValue(newValue ?? "");
5639
+ this.editorInstance = this.manager.getSet(undefined, {
5640
+ get: () => this._editorInstance,
5641
+ set: (_value, prevValue) => prevValue,
5642
+ });
4358
5643
  }
4359
5644
  languagePropChange() {
4360
- if (!this._editorInstance) {
4361
- return;
4362
- }
4363
5645
  this.updateModel();
4364
5646
  }
4365
5647
  modelIdPropChange() {
4366
- if (!this._editorInstance) {
4367
- return;
4368
- }
4369
5648
  this.updateModel();
4370
5649
  }
4371
5650
  optionsPropChange(newValue) {
4372
- if (!this._editorInstance || !newValue) {
5651
+ if (!newValue) {
4373
5652
  return;
4374
5653
  }
4375
- this._editorInstance.updateOptions(newValue);
5654
+ this._editorInstance?.updateOptions(newValue);
4376
5655
  }
4377
5656
  //#endregion
4378
5657
  // #region Public methods API
4379
5658
  /**
4380
- * Gets the current value in the editor.
4381
- * @returns {Promise<string>}
5659
+ * @deprecated Use `value` property instead.
4382
5660
  */
4383
5661
  async getValue() {
4384
5662
  await this._componentReadyDefer.promise;
4385
- return this._editorInstance?.getValue() ?? "";
5663
+ return this.value;
4386
5664
  }
4387
5665
  /**
4388
- * Sets the new value in the editor. Use this method instead of setting the value
4389
- * on the model to preserve undo/redo stack.
4390
- * @param text
4391
- * @returns {Promise<void>}
5666
+ * @deprecated Use `value` property instead.
4392
5667
  */
4393
5668
  async setValue(text) {
4394
5669
  await this._componentReadyDefer.promise;
4395
- if (!this._editorInstance) {
4396
- return;
4397
- }
4398
- const model = this._editorInstance.getModel();
4399
- if (!model) {
4400
- return;
4401
- }
4402
- const range = model.getFullModelRange();
4403
- this._editorInstance.executeEdits("", [{ range, text: text ?? "", forceMoveMarkers: true }]);
4404
- this._editorInstance.pushUndoStop();
5670
+ this.value = text ?? "";
4405
5671
  }
4406
5672
  /**
4407
5673
  * Inserts a text at the current position in the editor.
@@ -4436,8 +5702,7 @@ const ArcgisCodeEditor = class {
4436
5702
  }
4437
5703
  /**
4438
5704
  * @internal
4439
- * Returns the editor instance.
4440
- * @returns {Promise<IStandaloneCodeEditor>} - The monaco editor instance
5705
+ * @deprecated Use `editorInstance` property instead.
4441
5706
  */
4442
5707
  async getEditorInstance() {
4443
5708
  await this._componentReadyDefer.promise;
@@ -4468,33 +5733,33 @@ const ArcgisCodeEditor = class {
4468
5733
  // Create the model without the value.
4469
5734
  // Since it's not yet attached to the editor the diagnostic service will not process it.
4470
5735
  // We will set the value after the editor has been created to trigger the diagnostic again.
4471
- const model = arcadeDefaults.editor.createModel("", this.language, this.getUri());
5736
+ const model = arcadeDefaults.editor.createModel(this.value, this.language, this.getUri());
4472
5737
  // Create the editor for the host element.
4473
5738
  // This will not trigger a diagnostic.
4474
- this._editorInstance = arcadeDefaults.editor.create(this._hostElt, {
5739
+ this._editorInstance = arcadeDefaults.editor.create(this.el, {
4475
5740
  ...(this.options ?? {}),
4476
5741
  model,
4477
5742
  fixedOverflowWidgets: true,
4478
- scrollBeyondLastLine: false
5743
+ scrollBeyondLastLine: false,
4479
5744
  });
4480
5745
  this._disposables.push(this._editorInstance);
4481
- // Set the value now to trigger a diagnostic again
4482
- model.setValue(this.value ?? "");
4483
- // Now we can set are component as ready
5746
+ // Now we indicate that the component is ready
4484
5747
  this._componentReadyDefer.resolve();
4485
5748
  this._editorInstance.updateOptions(EditorOptionsDefaults);
4486
- // Listen to the Monaco Editor content change event and propagate
4487
5749
  this._editorInstance.onDidChangeModelContent(() => {
4488
- const script = this._editorInstance?.getValue() ?? "";
4489
- this.valueChange.emit(script);
5750
+ this.value = this._editorInstance?.getValue() ?? "";
5751
+ this.arcgisValueChange.emit(this.value);
5752
+ });
5753
+ this._editorInstance.onDidChangeCursorSelection((e) => {
5754
+ this.arcgisSelectionChange.emit({ selection: e.selection, model: this._editorInstance?.getModel() });
4490
5755
  });
4491
5756
  // Detect if the host element or its ancestors got a theme attribute mutation
4492
- this._themeObserver = arcadeDefaults.x(this._hostElt, ["class"], () => this.updateTheme());
5757
+ this._themeObserver = arcadeDefaults.observeAncestorsMutation(this.el, ["class"], () => this.updateTheme());
4493
5758
  // Update the theme of the Monaco Editor
4494
5759
  this.updateTheme();
4495
5760
  // Creates a resize observer to re-layout the editor on size changing
4496
5761
  const resizeObserver = new ResizeObserver(() => this._editorInstance?.layout());
4497
- resizeObserver.observe(this._hostElt);
5762
+ resizeObserver.observe(this.el);
4498
5763
  // Add common actions to the Monaco Editor's context menu and command palette
4499
5764
  this.addCommonEditorActions();
4500
5765
  }
@@ -4502,7 +5767,14 @@ const ArcgisCodeEditor = class {
4502
5767
  while (this._disposables.length) {
4503
5768
  this._disposables.pop()?.dispose();
4504
5769
  }
4505
- this._themeObserver?.disconnect();
5770
+ this._themeObserver?.remove();
5771
+ }
5772
+ componentShouldUpdate(_newVal, _oldVal, propName) {
5773
+ if (propName === "value" || propName === "language" || propName === "modelId" || propName === "options") {
5774
+ // These are properties that we directly pass to the editor
5775
+ return false;
5776
+ }
5777
+ return true;
4506
5778
  }
4507
5779
  //#endregion
4508
5780
  // #region Private methods API
@@ -4511,7 +5783,7 @@ const ArcgisCodeEditor = class {
4511
5783
  return;
4512
5784
  }
4513
5785
  this._editorInstance.getModel()?.dispose();
4514
- this._editorInstance.setModel(arcadeDefaults.editor.createModel(this.value ?? "", this.language, this.getUri()));
5786
+ this._editorInstance.setModel(arcadeDefaults.editor.createModel(this.value, this.language, this.getUri()));
4515
5787
  }
4516
5788
  getUri() {
4517
5789
  return this.modelId ? arcadeDefaults.Uri.parse(this.modelId) : arcadeDefaults.Uri.parse("");
@@ -4520,7 +5792,7 @@ const ArcgisCodeEditor = class {
4520
5792
  // This is called the first time and subsequently by the Mutation Observer
4521
5793
  // Figure out the theme by walking the ancestor path.
4522
5794
  // If no theme is found then default to light.
4523
- const theme = arcadeDefaults.k(this._hostElt) === "light" ? "vs" : "vs-dark";
5795
+ const theme = arcadeDefaults.getElementTheme(this.el) === "light" ? "vs" : "vs-dark";
4524
5796
  if (theme === this._currentTheme) {
4525
5797
  return;
4526
5798
  }
@@ -4545,7 +5817,7 @@ const ArcgisCodeEditor = class {
4545
5817
  contextMenuOrder: 1,
4546
5818
  // Method that will be executed when the action is triggered.
4547
5819
  // @param editor The editor instance is passed in as a convenience
4548
- run: async () => await zoomInFn?.run()
5820
+ run: async () => await zoomInFn?.run(),
4549
5821
  });
4550
5822
  this._editorInstance?.addAction({
4551
5823
  id: "editor.action.fontZoomOut",
@@ -4553,7 +5825,7 @@ const ArcgisCodeEditor = class {
4553
5825
  keybindings: [arcadeDefaults.KeyMod.CtrlCmd | arcadeDefaults.KeyCode.Minus],
4554
5826
  contextMenuGroupId: "zooming",
4555
5827
  contextMenuOrder: 2,
4556
- run: async () => await zoomOutFn?.run()
5828
+ run: async () => await zoomOutFn?.run(),
4557
5829
  });
4558
5830
  }
4559
5831
  //#endregion
@@ -4562,9 +5834,8 @@ const ArcgisCodeEditor = class {
4562
5834
  return index.h(index.Host, null);
4563
5835
  }
4564
5836
  static get assetsDirs() { return ["assets"]; }
4565
- get _hostElt() { return index.getElement(this); }
5837
+ get el() { return index.getElement(this); }
4566
5838
  static get watchers() { return {
4567
- "value": ["valuePropChange"],
4568
5839
  "language": ["languagePropChange"],
4569
5840
  "modelId": ["modelIdPropChange"],
4570
5841
  "options": ["optionsPropChange"]