@arcgis/coding-components 4.30.0-next.5 → 4.30.0-next.50

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 (139) hide show
  1. package/dist/arcgis-coding-components/arcgis-coding-components.css +1 -1
  2. package/dist/arcgis-coding-components/arcgis-coding-components.esm.js +2 -2
  3. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ar.json +25 -0
  4. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.bg.json +25 -0
  5. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.bs.json +25 -0
  6. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ca.json +25 -0
  7. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.cs.json +25 -0
  8. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.da.json +25 -0
  9. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.de.json +25 -0
  10. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.el.json +25 -0
  11. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.en.json +25 -0
  12. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.es.json +25 -0
  13. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.et.json +25 -0
  14. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.fi.json +25 -0
  15. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.fr.json +25 -0
  16. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.he.json +25 -0
  17. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.hr.json +25 -0
  18. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.hu.json +25 -0
  19. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.id.json +25 -0
  20. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.it.json +25 -0
  21. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ja.json +25 -0
  22. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ko.json +25 -0
  23. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.lt.json +25 -0
  24. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.lv.json +25 -0
  25. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.nb.json +25 -0
  26. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.nl.json +25 -0
  27. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.pl.json +25 -0
  28. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.pt-BR.json +25 -0
  29. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.pt-PT.json +25 -0
  30. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ro.json +25 -0
  31. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.ru.json +25 -0
  32. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.sk.json +25 -0
  33. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.sl.json +25 -0
  34. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.sr.json +25 -0
  35. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.sv.json +25 -0
  36. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.th.json +25 -0
  37. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.tr.json +25 -0
  38. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.uk.json +25 -0
  39. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.vi.json +25 -0
  40. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.zh-CN.json +25 -0
  41. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.zh-HK.json +25 -0
  42. package/dist/arcgis-coding-components/assets/arcade-language/api/arcade-api.t9n.zh-TW.json +25 -0
  43. package/dist/arcgis-coding-components/assets/code-editor/arcade.worker.js +1 -1
  44. package/dist/arcgis-coding-components/assets/code-editor/css.worker.js +1 -1
  45. package/dist/arcgis-coding-components/assets/code-editor/editor.worker.js +1 -1
  46. package/dist/arcgis-coding-components/assets/code-editor/html.worker.js +1 -1
  47. package/dist/arcgis-coding-components/assets/code-editor/json.worker.js +1 -1
  48. package/dist/arcgis-coding-components/assets/code-editor/ts.worker.js +1 -1
  49. package/dist/arcgis-coding-components/index.esm.js +2 -2
  50. package/dist/arcgis-coding-components/{p-cebf794f.js → p-2c805689.js} +2 -2
  51. package/dist/arcgis-coding-components/{p-7d7f1240.js → p-50055c43.js} +2 -2
  52. package/dist/arcgis-coding-components/{p-06d44cef.js → p-60888738.js} +3 -3
  53. package/dist/arcgis-coding-components/{p-2e3aede1.js → p-7c5bb70b.js} +2 -2
  54. package/dist/arcgis-coding-components/{p-551af1f6.js → p-8c564c76.js} +2 -2
  55. package/dist/arcgis-coding-components/p-ab00671b.js +68 -0
  56. package/dist/arcgis-coding-components/p-b62b3ecc.js +7 -0
  57. package/dist/arcgis-coding-components/{p-fd3fa4a0.js → p-bda60780.js} +2 -2
  58. package/dist/arcgis-coding-components/{p-32911b21.js → p-bf81a3f3.js} +2 -2
  59. package/dist/arcgis-coding-components/{p-0f11c91b.js → p-c3aa0ba1.js} +2 -2
  60. package/dist/arcgis-coding-components/{p-a4e27a58.js → p-d220236c.js} +1 -1
  61. package/dist/arcgis-coding-components/p-f11a8755.entry.js +6 -0
  62. package/dist/cjs/{arcade-defaults-204e7ccd.js → arcade-defaults-57e26a09.js} +483 -173
  63. package/dist/cjs/{arcade-mode-4100f9e4.js → arcade-mode-3b27569b.js} +45 -51
  64. package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +1702 -283
  65. package/dist/cjs/arcgis-coding-components.cjs.js +3 -3
  66. package/dist/cjs/{css-bfbeba2f.js → css-c4174c97.js} +1 -1
  67. package/dist/cjs/{cssMode-76b5efe0.js → cssMode-11d4382b.js} +3 -3
  68. package/dist/cjs/{html-5cb5408f.js → html-f41bd48d.js} +3 -3
  69. package/dist/cjs/{htmlMode-22c5689f.js → htmlMode-59c5586b.js} +3 -3
  70. package/dist/cjs/{index-a37bcea1.js → index-999a3012.js} +40 -4
  71. package/dist/cjs/index.cjs.js +3 -3
  72. package/dist/cjs/{javascript-ec61b6c4.js → javascript-00a4972f.js} +4 -4
  73. package/dist/cjs/{jsonMode-ceded417.js → jsonMode-3550388e.js} +3 -3
  74. package/dist/cjs/loader.cjs.js +3 -3
  75. package/dist/cjs/{tsMode-d4f8e205.js → tsMode-b6cf29ec.js} +3 -3
  76. package/dist/cjs/{typescript-0d60800f.js → typescript-2704ab9d.js} +3 -3
  77. package/dist/components/arcade-api.js +21 -32
  78. package/dist/components/arcade-contribution.js +71 -12
  79. package/dist/components/arcade-defaults.js +78 -73
  80. package/dist/components/arcade-mode.js +44 -50
  81. package/dist/components/arcade-results.js +47 -60
  82. package/dist/components/arcade-suggestions.js +23 -33
  83. package/dist/components/arcade-variables.js +22 -36
  84. package/dist/components/arcgis-arcade-api.js +1 -1
  85. package/dist/components/arcgis-arcade-editor.js +59 -147
  86. package/dist/components/arcgis-arcade-results.js +1 -1
  87. package/dist/components/arcgis-arcade-suggestions.js +1 -1
  88. package/dist/components/arcgis-arcade-variables.js +1 -1
  89. package/dist/components/arcgis-assets.d.ts +1 -1
  90. package/dist/components/arcgis-assets.js +1 -1
  91. package/dist/components/arcgis-code-editor.js +1 -1
  92. package/dist/components/chunk-27DTPISK.js +1438 -0
  93. package/dist/components/code-editor.js +71 -75
  94. package/dist/components/fields.js +40 -44
  95. package/dist/components/index.js +1 -1
  96. package/dist/components/index2.js +314 -3
  97. package/dist/components/markdown.js +9 -11
  98. package/dist/components/useT9n.js +11 -0
  99. package/dist/components/utilities.js +3 -3
  100. package/dist/esm/{arcade-defaults-a8eba8cf.js → arcade-defaults-c102be00.js} +472 -160
  101. package/dist/esm/{arcade-mode-b8fed895.js → arcade-mode-c4dd84f5.js} +45 -51
  102. package/dist/esm/arcgis-arcade-api_6.entry.js +1702 -283
  103. package/dist/esm/arcgis-coding-components.js +4 -4
  104. package/dist/esm/{css-d802bf2b.js → css-be9f2148.js} +1 -1
  105. package/dist/esm/{cssMode-e68d14c9.js → cssMode-5bfb9fcd.js} +3 -3
  106. package/dist/esm/{html-b1eb86e6.js → html-e4052e46.js} +3 -3
  107. package/dist/esm/{htmlMode-1211bc87.js → htmlMode-39da10b5.js} +3 -3
  108. package/dist/esm/{index-916b1135.js → index-507ff821.js} +40 -4
  109. package/dist/esm/index.js +3 -3
  110. package/dist/esm/{javascript-f1cc1f09.js → javascript-2698ff38.js} +4 -4
  111. package/dist/esm/{jsonMode-85d9cded.js → jsonMode-01c45b94.js} +3 -3
  112. package/dist/esm/loader.js +4 -4
  113. package/dist/esm/{tsMode-61fedc4b.js → tsMode-4ee78489.js} +3 -3
  114. package/dist/esm/{typescript-49d6ec3c.js → typescript-5e150a72.js} +3 -3
  115. package/dist/loader/cdn.js +1 -1
  116. package/dist/loader/index.cjs.js +1 -1
  117. package/dist/loader/index.es2017.js +1 -1
  118. package/dist/loader/index.js +1 -1
  119. package/dist/types/components/arcade-api/arcade-api.d.ts +6 -7
  120. package/dist/types/components/arcade-editor/arcade-editor.d.ts +18 -11
  121. package/dist/types/components/arcade-results/arcade-results.d.ts +6 -9
  122. package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +7 -8
  123. package/dist/types/components/arcade-variables/arcade-variables.d.ts +6 -8
  124. package/dist/types/components/code-editor/code-editor.d.ts +23 -13
  125. package/dist/types/components.d.ts +57 -35
  126. package/dist/types/controllers/useT9n.d.ts +1 -0
  127. package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stencil.config.d.ts +3 -0
  128. package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/internal/arcade-editor/arcade-editor.stories.d.ts +34 -0
  129. package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/internal/code-editor/code-editor.stories.d.ts +6 -0
  130. package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/stories/reference/stories/arcade-editor.stories.d.ts +9 -0
  131. package/dist/types/data/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
  132. package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/support/sass-json-importer.d.ts +19 -0
  133. package/dist/types/data/actions-runner-1/_work/arcgis-web-components/arcgis-web-components/packages/coding-packages/coding-components/.stencil/support/stencil-monaco-plugins.d.ts +6 -0
  134. package/dist/types/utils/arcade-monaco/arcade-language-features.d.ts +1 -1
  135. package/dist/types/utils/profile/types.d.ts +1 -1
  136. package/package.json +20 -19
  137. package/dist/arcgis-coding-components/p-a331eda4.entry.js +0 -6
  138. package/dist/arcgis-coding-components/p-d0f4a5d4.js +0 -68
  139. package/dist/arcgis-coding-components/p-e311f720.js +0 -7
@@ -0,0 +1,1438 @@
1
+ /*!
2
+ * All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
+ * See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
+ * v4.30.0-next.50
5
+ */
6
+ // src/framework.ts
7
+ function retrieveComponentMembers(component, isLit) {
8
+ if (isLit) {
9
+ const elementProperties = getLitProperties(component);
10
+ component.manager.internals.members = Object.fromEntries(
11
+ Array.from(elementProperties, ([name, { state, type }]) => [
12
+ name,
13
+ [
14
+ state ? 32 /* State */ : type === Number ? 2 /* Number */ : type === Boolean ? 4 /* Boolean */ : 1 /* String */
15
+ ]
16
+ ])
17
+ );
18
+ } else {
19
+ const constructor = component.constructor;
20
+ const members = constructor.__registerControllers?.(component) ?? void 0;
21
+ constructor.__registerControllers = void 0;
22
+ if (typeof members !== "object")
23
+ throw new Error(
24
+ "Failed to retrieve internal component meta. Make sure you have the useComponentsControllers() Rollup Plugin for Stencil Controllers configured in your Stencil config."
25
+ );
26
+ component.manager.internals.members = members;
27
+ }
28
+ }
29
+ var getLitProperties = (component) => component.constructor.elementProperties;
30
+ function parsePropertyValue(value, type = 8 /* Any */) {
31
+ const isComplex = value == null || typeof value === "object" || typeof value === "function";
32
+ if (isComplex)
33
+ return value;
34
+ if ((type & 4 /* Boolean */) !== 0)
35
+ return value === "false" ? false : value === "" || !!value;
36
+ else if ((type & 2 /* Number */) !== 0)
37
+ return Number.parseFloat(value);
38
+ else if ((type & 1 /* String */) !== 0)
39
+ return String(value);
40
+ else
41
+ return value;
42
+ }
43
+ var makeMemberFilter = (filter) => (component) => {
44
+ const members = component.manager.internals.members;
45
+ return Object.entries(members ?? {}).filter(([_name, [propType]]) => (propType & filter) !== 0).map(([name]) => name);
46
+ };
47
+ var getPropLikeMembers = makeMemberFilter(63 /* PropLike */);
48
+ var getMemberType = (component, name) => component.manager.internals.members?.[name]?.[0];
49
+ function getPropType(component, name) {
50
+ const type = getMemberType(component, name);
51
+ if (type === void 0)
52
+ return void 0;
53
+ else if (type & 32 /* State */)
54
+ return "state";
55
+ else
56
+ return "prop";
57
+ }
58
+
59
+ // src/types.ts
60
+ var controllerSymbol = Symbol("controller");
61
+
62
+ // src/utils.ts
63
+ function extendObject(base, extend) {
64
+ Object.entries(extend).forEach(([key, value]) => {
65
+ if (key in base)
66
+ throw new Error(`Unable to extend object because property "${key}" is already defined`);
67
+ const thisBase = base;
68
+ thisBase[key] = value;
69
+ });
70
+ return base;
71
+ }
72
+ var isController = (value) => typeof value === "object" && value !== null && (controllerSymbol in value || "hostConnected" in value || "hostDisconnected" in value || "hostUpdate" in value || "hostUpdated" in value);
73
+
74
+ // ../components-utils/dist/index.js
75
+ var Deferred = class {
76
+ /**
77
+ * Creates a new deferred promise.
78
+ */
79
+ constructor() {
80
+ this.resolve = () => void 0;
81
+ this.reject = () => void 0;
82
+ this.promise = new Promise((resolve, reject) => {
83
+ this.resolve = resolve;
84
+ this.reject = reject;
85
+ });
86
+ }
87
+ };
88
+ function inTargetElement(element, targetElement) {
89
+ let currentElement = element;
90
+ while (currentElement) {
91
+ if (currentElement === targetElement) {
92
+ return true;
93
+ }
94
+ if (!currentElement.parentNode) {
95
+ return false;
96
+ }
97
+ if (currentElement.parentNode instanceof ShadowRoot) {
98
+ currentElement = currentElement.parentNode.host;
99
+ } else {
100
+ currentElement = currentElement.parentNode;
101
+ }
102
+ }
103
+ return false;
104
+ }
105
+ function observeAncestorsMutation(element, attributeFilter, callback) {
106
+ const { subscribe } = observe(attributeFilter);
107
+ return subscribe((mutations) => {
108
+ const matched = mutations.some((mutation) => inTargetElement(element, mutation.target));
109
+ if (matched)
110
+ callback();
111
+ });
112
+ }
113
+ var observers = {};
114
+ function observe(attributeFilter) {
115
+ const attributes = attributeFilter.join(",");
116
+ const previousObserver = observers[attributes];
117
+ if (previousObserver !== void 0)
118
+ return previousObserver;
119
+ const subscribers = /* @__PURE__ */ new Set();
120
+ const mutationObserver = new MutationObserver((mutations) => subscribers.forEach((callback) => callback(mutations)));
121
+ mutationObserver.observe(document.documentElement, {
122
+ attributes: true,
123
+ attributeFilter,
124
+ subtree: true
125
+ });
126
+ const observer = {
127
+ subscribe(callback) {
128
+ subscribers.add(callback);
129
+ return {
130
+ remove: () => {
131
+ subscribers.delete(callback);
132
+ if (subscribers.size === 0) {
133
+ mutationObserver.disconnect();
134
+ observers[attributes] = void 0;
135
+ }
136
+ }
137
+ };
138
+ }
139
+ };
140
+ observers[attributes] = observer;
141
+ return observer;
142
+ }
143
+ function closestElement(base, selector) {
144
+ let currentElement = base;
145
+ while (currentElement) {
146
+ const element = currentElement.closest(selector);
147
+ if (element) {
148
+ return element;
149
+ }
150
+ const rootElement = currentElement.getRootNode();
151
+ if (rootElement === document) {
152
+ return null;
153
+ }
154
+ currentElement = rootElement.host;
155
+ }
156
+ return null;
157
+ }
158
+ function getElementAttribute(el, prop, fallbackValue) {
159
+ const closest = closestElement(el, `[${prop}]`);
160
+ return closest?.getAttribute(prop) ?? fallbackValue;
161
+ }
162
+ function safeCall(callback) {
163
+ try {
164
+ return callback?.();
165
+ } catch (error) {
166
+ console.error(error, callback);
167
+ }
168
+ return void 0;
169
+ }
170
+ async function safeAsyncCall(callback) {
171
+ try {
172
+ return await callback();
173
+ } catch (error) {
174
+ console.error(error, callback);
175
+ }
176
+ return void 0;
177
+ }
178
+ var camelToKebab = (string) => string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : "-"}${upper.toLowerCase()}`);
179
+ var upperBeforeLower = /[A-Z]+(?![a-z])|[A-Z]/gu;
180
+ var capitalize = (string) => string.charAt(0).toUpperCase() + string.slice(1);
181
+ var camelToHuman = (string) => capitalize(string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : " "}${upper}`));
182
+ var supportedLocales = /* @__PURE__ */ new Set([
183
+ "ar",
184
+ "bg",
185
+ "bs",
186
+ "ca",
187
+ "cs",
188
+ "da",
189
+ "de",
190
+ "el",
191
+ "en",
192
+ "es",
193
+ "et",
194
+ "fi",
195
+ "fr",
196
+ "he",
197
+ "hr",
198
+ "hu",
199
+ "id",
200
+ "it",
201
+ "ja",
202
+ "ko",
203
+ "lt",
204
+ "lv",
205
+ "nl",
206
+ "nb",
207
+ "pl",
208
+ "pt-BR",
209
+ "pt-PT",
210
+ "ro",
211
+ "ru",
212
+ "sk",
213
+ "sl",
214
+ "sr",
215
+ "sv",
216
+ "th",
217
+ "tr",
218
+ "uk",
219
+ "vi",
220
+ "zh-CN",
221
+ "zh-HK",
222
+ "zh-TW"
223
+ ]);
224
+ var defaultLocale = "en";
225
+ async function fetchT9NStringsBundle(locale, assetsPath, prefix = "") {
226
+ const path = `${assetsPath}/${prefix}`;
227
+ const filePath = `${path}${locale}.json`;
228
+ t9nStringsCache[filePath] ?? (t9nStringsCache[filePath] = fetchBundle(locale, path));
229
+ return await t9nStringsCache[filePath];
230
+ }
231
+ var t9nStringsCache = {};
232
+ async function fetchBundle(locale, path) {
233
+ const filePath = `${path}${locale}.json`;
234
+ try {
235
+ const response = await fetch(filePath);
236
+ if (response.ok)
237
+ return await response.json();
238
+ } catch (error) {
239
+ console.error(error);
240
+ return fallbackBundle;
241
+ }
242
+ if (locale === defaultLocale)
243
+ return fallbackBundle;
244
+ return await fetchBundle(defaultLocale, path);
245
+ }
246
+ var fallbackBundle = new Proxy(
247
+ {},
248
+ {
249
+ get: (_target, property) => camelToHuman(property.toString())
250
+ }
251
+ );
252
+ function getElementLocales(element) {
253
+ const lang = getElementAttribute(element, "lang", navigator.language || defaultLocale);
254
+ if (supportedLocales.has(lang)) {
255
+ return { lang, t9nLocale: lang };
256
+ }
257
+ const rootCode = lang.slice(0, 2);
258
+ return { lang, t9nLocale: supportedLocales.has(rootCode) ? rootCode : defaultLocale };
259
+ }
260
+ function startLocaleObserver(element, assetsPath, onUpdated, assetName) {
261
+ let result = void 0;
262
+ const callback = () => void updateComponentLocateState(element, assetsPath, assetName).then((newResult) => {
263
+ if (result?.lang !== newResult.lang || result.t9nLocale !== newResult.t9nLocale || result.t9nStrings !== newResult.t9nStrings)
264
+ onUpdated(newResult);
265
+ result = newResult;
266
+ }).catch(console.error);
267
+ callback();
268
+ return observeAncestorsMutation(element, ["lang"], callback);
269
+ }
270
+ async function updateComponentLocateState(element, assetsPath, assetName = element.tagName.toLowerCase().replace("arcgis-", "")) {
271
+ const { lang, t9nLocale } = getElementLocales(element);
272
+ const t9nAssetsPath = `${assetsPath}/${assetName}/t9n`;
273
+ const prefix = `${assetName}.t9n.`;
274
+ const t9nStrings = await fetchT9NStringsBundle(t9nLocale, t9nAssetsPath, prefix);
275
+ return { lang, t9nLocale, t9nStrings };
276
+ }
277
+
278
+ // src/ControllerInternals.ts
279
+ var ControllerInternals = class {
280
+ constructor() {
281
+ this._ambientControllers = [];
282
+ /**
283
+ * The type definition has to be duplicated due to the
284
+ * "'use' is referenced directly or indirectly in its own type annotation."
285
+ * error
286
+ */
287
+ this.use = async (value, watchExports) => {
288
+ const controller = this.useRefSync(value);
289
+ if (controller === void 0) {
290
+ if (typeof watchExports === "function") {
291
+ const error = new Error(
292
+ `Unable to resolve a controller from the provided value, so can't watch it's exports. ${unresolvableExports}`
293
+ );
294
+ console.error(error);
295
+ }
296
+ return value;
297
+ }
298
+ await controller.ready;
299
+ if (typeof watchExports === "function") {
300
+ if (controller.watchExports === void 0)
301
+ throw new Error(`The controller must implement watchExports method to support watching exports`);
302
+ const unsubscribe = controller.watchExports(
303
+ (exports) => watchExports(exports, unsubscribe)
304
+ );
305
+ }
306
+ return controller.exports;
307
+ };
308
+ this.useRef = async (value) => {
309
+ const controller = this.useRefSync(value);
310
+ if (controller === void 0)
311
+ throw new Error(`Unable to resolve a controller from the provided value. ${unresolvableExports}`);
312
+ await controller.ready;
313
+ return controller;
314
+ };
315
+ this.shouldBypassSetter = false;
316
+ this.shouldBypassGetter = false;
317
+ this.shouldBypassReadonly = false;
318
+ /**
319
+ * A map from component instance or component element to component instance.
320
+ * To get from component instance or component element to component element,
321
+ * you can just use the .el property
322
+ */
323
+ this.elementToInstance = /* @__PURE__ */ new WeakMap();
324
+ }
325
+ /*
326
+ * Allow controllers to implicitly retrieve which component they are in, to
327
+ * improve DX (avoids the need to pass "this" explicitly for each controller)
328
+ */
329
+ setAmbientComponent(component) {
330
+ if (this._ambientComponent === component)
331
+ return;
332
+ this._ambientComponent = component;
333
+ queueMicrotask(() => {
334
+ if (this._ambientComponent === component)
335
+ this._ambientComponent = void 0;
336
+ });
337
+ }
338
+ retrieveComponent(name) {
339
+ if (this._ambientComponent === void 0)
340
+ throw new Error(
341
+ [
342
+ `Unable to find out which component ${name || "this"} controller `,
343
+ "belongs to. This might happen if you tried to create a controller ",
344
+ "outside the component. If so, please wrap your controller ",
345
+ "definition in an arrow function, ",
346
+ "`const myController = ()=>makeController(...);` and call that",
347
+ "function inside the component `my = myController();`, or ",
348
+ "define your controller using makeGenericController/GenericController ",
349
+ "instead.\n",
350
+ "If you wish to use a controller inside an async controller, ",
351
+ "make sure you are using controller.use.\n",
352
+ "You might also have multiple instances of Controllers loaded"
353
+ ].join("\n")
354
+ );
355
+ return this._ambientComponent;
356
+ }
357
+ /*
358
+ * Aids proxyExports() in knowing who is it's host
359
+ */
360
+ setParentController(controller) {
361
+ if (controller === void 0) {
362
+ this._ambientControllers = [];
363
+ return;
364
+ }
365
+ const index = this._ambientControllers.indexOf(controller);
366
+ this._ambientControllers = index === -1 ? [...this._ambientControllers, controller] : this._ambientControllers.slice(0, index + 1);
367
+ queueMicrotask(() => {
368
+ this._ambientControllers = [];
369
+ });
370
+ }
371
+ retrieveParentControllers() {
372
+ return this._ambientControllers;
373
+ }
374
+ /*
375
+ * Aids controller.use in retrieving controller value when it receives
376
+ * controller exports, rather than the controller itself
377
+ */
378
+ setAmbientChildController(controller) {
379
+ if (this._ambientChildController === controller)
380
+ return;
381
+ this._ambientChildController = controller;
382
+ queueMicrotask(() => {
383
+ if (this._ambientChildController === controller)
384
+ this._ambientChildController = void 0;
385
+ });
386
+ }
387
+ retrieveAmbientChildController() {
388
+ const controller = this._ambientChildController;
389
+ this._ambientChildController = void 0;
390
+ return controller;
391
+ }
392
+ /**
393
+ * Try to resolve a controller, without awaiting it's load
394
+ */
395
+ useRefSync(value) {
396
+ const ambientChildController = this.retrieveAmbientChildController();
397
+ if (ambientChildController !== void 0)
398
+ return ambientChildController;
399
+ const component = Controller.internals.retrieveComponent();
400
+ const controller = component.manager.internals.resolveExports(value);
401
+ if (controller !== void 0)
402
+ return controller;
403
+ if (isController(value))
404
+ return value;
405
+ return void 0;
406
+ }
407
+ };
408
+ var unresolvableExports = [
409
+ "The value you passed is not a controller and not a controller exports. If ",
410
+ "your controller exports a literal value, try making your controller export ",
411
+ "an object instead"
412
+ ].join("");
413
+
414
+ // src/Controller.ts
415
+ var _a;
416
+ var _Controller = class _Controller {
417
+ constructor(component) {
418
+ this._ready = new Deferred();
419
+ this._lifecycleDisconnected = [];
420
+ this.connectedCalled = false;
421
+ this.willLoadCalled = false;
422
+ this.didLoadCalled = false;
423
+ this[_a] = true;
424
+ this.ready = this._ready.promise;
425
+ /*
426
+ * Setting default exports to "this" so that controllers that don't use
427
+ * exports/proxyExports(), could still be used as if they did
428
+ * (i.e with controller.use)
429
+ */
430
+ this._exports = makeProvisionalValue(this);
431
+ this._exportWatchers = /* @__PURE__ */ new Set();
432
+ const resolvedComponent = toControllerHost(
433
+ component ?? _Controller.internals.retrieveComponent(new.target.name)
434
+ );
435
+ Object.defineProperty(this, "component", {
436
+ writable: false,
437
+ enumerable: false,
438
+ configurable: true,
439
+ value: resolvedComponent
440
+ });
441
+ this.component.addController(this);
442
+ _Controller.internals.setParentController(this);
443
+ if ("hostDestroy" in this)
444
+ this.component.manager.ensureHasDestroy();
445
+ const manager = this.component.manager;
446
+ const isInControllerManager = manager === void 0;
447
+ if (!isInControllerManager)
448
+ queueMicrotask(() => this.catchUpLifecycle());
449
+ const controller = isInControllerManager ? {} : this;
450
+ this._callbacks = {
451
+ hostConnected: "hostConnected" in controller ? [() => controller.hostConnected?.()] : [],
452
+ hostDisconnected: "hostDisconnected" in controller ? [() => controller.hostDisconnected?.()] : [],
453
+ hostLoad: "hostLoad" in controller ? [() => controller.hostLoad?.()] : [],
454
+ hostLoaded: "hostLoaded" in controller ? [() => controller.hostLoaded?.()] : [],
455
+ hostUpdate: "hostUpdate" in controller ? [() => controller.hostUpdate?.()] : [],
456
+ hostUpdated: "hostUpdated" in controller ? [() => controller.hostUpdated?.()] : [],
457
+ hostDestroy: "hostDestroy" in controller ? [() => controller.hostDestroy?.()] : [],
458
+ hostLifecycle: "hostLifecycle" in controller ? [() => controller.hostLifecycle?.()] : []
459
+ };
460
+ }
461
+ /**
462
+ * If controller is being added dynamically, after the component
463
+ * construction, then trigger connected and load right away
464
+ */
465
+ catchUpLifecycle() {
466
+ if (this.connectedCalled)
467
+ return;
468
+ this.triggerConnected();
469
+ const loadWillStillHappen = !this.component.manager.willLoadCalled;
470
+ if (loadWillStillHappen)
471
+ return;
472
+ this.triggerLoad().then(() => {
473
+ const loadedWillStillHappen = !this.component.manager.didLoadCalled;
474
+ if (loadedWillStillHappen)
475
+ return;
476
+ this.triggerLoaded();
477
+ }).catch(console.error);
478
+ }
479
+ get exports() {
480
+ return this._exports;
481
+ }
482
+ /**
483
+ * Set controller's exports property (for usage with proxyExports()) and mark
484
+ * controller as ready (for usage in other controllers). Also, triggers
485
+ * re-render of the component
486
+ */
487
+ set exports(exports) {
488
+ if (this._exports !== exports) {
489
+ this._exports = exports;
490
+ if (this.connectedCalled)
491
+ this.component.requestUpdate();
492
+ this._exportWatchers.forEach((callback) => callback(exports));
493
+ }
494
+ this._ready.resolve(exports);
495
+ }
496
+ setProvisionalExports(exports) {
497
+ this._exports = makeProvisionalValue(exports);
498
+ this._exportWatchers.forEach((callback) => callback(this._exports));
499
+ }
500
+ watchExports(callback) {
501
+ const safeCallback = (exports) => safeCall(() => callback(exports));
502
+ this._exportWatchers.add(safeCallback);
503
+ return () => void this._exportWatchers.delete(safeCallback);
504
+ }
505
+ /**
506
+ * A flexible utility for making sure a controller is loaded before it's used,
507
+ * regardless of how or where a controller was defined:
508
+ *
509
+ * @example
510
+ * makeGenericController(async (component, controller) => {
511
+ * // Await some controller from the component:
512
+ * await controller.use(component.someController);
513
+ * // Initialize new controllers
514
+ * await controller.use(load(importCoreReactiveUtils));
515
+ * await controller.use(new ViewModelController(component,newWidgetsHomeHomeViewModel));
516
+ * await controller.use(someController(component));
517
+ * });
518
+ *
519
+ * @remarks
520
+ * If your controller is not async, and you are not creating it async, then
521
+ * you are not required to use controller.use - you can use it directly.
522
+ * Similarly, accessing controllers after componentWillLoad callback does not
523
+ * require awaiting them as they are guaranteed to be loaded by then.
524
+ */
525
+ get use() {
526
+ _Controller.internals.setAmbientComponent(this.component);
527
+ return _Controller.internals.use;
528
+ }
529
+ /**
530
+ * Just like controller.use, but returns the controller itself, rather than it's
531
+ * exports
532
+ *
533
+ * Use cases:
534
+ * - You have a controller and you want to make sure it's loaded before you
535
+ * try to use it
536
+ * - Your controller is not using exports, so you wish to access some props on
537
+ * it directly
538
+ * - You have a controller exports only, and you want to retrieve the
539
+ * controller itself. This is useful if you wish to call .watchExports() or
540
+ * some other method on the controller
541
+ */
542
+ get useRef() {
543
+ _Controller.internals.setAmbientComponent(this.component);
544
+ return _Controller.internals.useRef;
545
+ }
546
+ /**
547
+ * If you need to set a prop/state without triggering the custom setter you
548
+ * defined with getSet()/dynamicGetSet()/readonly(), set the value inside
549
+ * of this function
550
+ *
551
+ * @example
552
+ * @Prop() readOnly = this.manager.readOnly(true);
553
+ *
554
+ * someAction(): void {
555
+ * this.manager.bypassSetter(()=>{
556
+ * this.readOnly = false;
557
+ * });
558
+ * }
559
+ *
560
+ */
561
+ bypassSetter(callback) {
562
+ _Controller.internals.shouldBypassSetter = true;
563
+ try {
564
+ return callback();
565
+ } finally {
566
+ _Controller.internals.shouldBypassSetter = false;
567
+ }
568
+ }
569
+ /**
570
+ * Like bypassSetter, but only bypasses this.manager.readonly(), rather that
571
+ * all setters set using this.manager.getSet()
572
+ */
573
+ bypassReadonly(callback) {
574
+ _Controller.internals.shouldBypassReadonly = true;
575
+ try {
576
+ return callback();
577
+ } finally {
578
+ _Controller.internals.shouldBypassReadonly = false;
579
+ }
580
+ }
581
+ /**
582
+ * Property reads inside of this function will bypass any custom getter you
583
+ * may have, and read the value directly from what's stored in Stencil/Lit.
584
+ *
585
+ * This also bypasses reactiveUtils integration - reading a property inside of
586
+ * bypassGetter won't make that property tracked.
587
+ *
588
+ * @example
589
+ * reactiveUtils.watch(
590
+ * ()=>{
591
+ * this.manager.bypassGetter(()=>{
592
+ * console.log(this.someProp);
593
+ * });
594
+ * return this.prop;
595
+ * },
596
+ * console.log
597
+ * )
598
+ */
599
+ bypassGetter(callback) {
600
+ _Controller.internals.shouldBypassGetter = true;
601
+ try {
602
+ return callback();
603
+ } finally {
604
+ _Controller.internals.shouldBypassGetter = false;
605
+ }
606
+ }
607
+ /**
608
+ * Like this.manager.getSet(), but can be called on any component's
609
+ * state/prop from anywhere, rather than just from the default value
610
+ */
611
+ dynamicGetSet(name, getSet) {
612
+ this.genericGetSet(name, getSet);
613
+ }
614
+ /**
615
+ * Like dynamicGetSet, but less type-safe. Useful in cases when trying to set
616
+ * getters/setters in place where property names & types are not known
617
+ * statically
618
+ */
619
+ genericGetSet(property, getSet) {
620
+ var _a2, _b;
621
+ const genericGetSet = getSet;
622
+ const internals = this.component.manager.internals;
623
+ if (genericGetSet.get !== void 0) {
624
+ (_a2 = internals.getters)[property] ?? (_a2[property] = []);
625
+ internals.getters[property].unshift(genericGetSet.get);
626
+ }
627
+ if (genericGetSet.set !== void 0) {
628
+ (_b = internals.setters)[property] ?? (_b[property] = []);
629
+ internals.setters[property].unshift(genericGetSet.set);
630
+ }
631
+ }
632
+ // FEATURE: improve typings
633
+ /**
634
+ * Dynamically set a watcher for any reactive property
635
+ */
636
+ watch(property, callback) {
637
+ var _a2;
638
+ const type = getMemberType(this.component, property);
639
+ if (type === void 0)
640
+ throw new Error(
641
+ `Trying to watch a non-@property, non-@state property "${property}". Either convert it into a @state() or use get/set syntax`
642
+ );
643
+ const internals = this.component.manager.internals;
644
+ (_a2 = internals.allWatchers)[property] ?? (_a2[property] = []);
645
+ const watchers = internals.allWatchers[property];
646
+ const genericCallback = callback;
647
+ const safeCallback = (newValue, oldValue, propertyName) => safeCall(() => genericCallback(newValue, oldValue, propertyName));
648
+ watchers.push(safeCallback);
649
+ return () => {
650
+ const index = watchers.indexOf(safeCallback);
651
+ if (index !== -1)
652
+ watchers.splice(index, 1);
653
+ };
654
+ }
655
+ // Register a lifecycle callback
656
+ onConnected(callback) {
657
+ this._callbacks.hostConnected.push(callback);
658
+ }
659
+ onDisconnected(callback) {
660
+ this._callbacks.hostDisconnected.push(callback);
661
+ }
662
+ onLoad(callback) {
663
+ this._callbacks.hostLoad.push(callback);
664
+ }
665
+ onLoaded(callback) {
666
+ this._callbacks.hostLoaded.push(callback);
667
+ }
668
+ onUpdate(callback) {
669
+ this._callbacks.hostUpdate.push(callback);
670
+ }
671
+ onUpdated(callback) {
672
+ this._callbacks.hostUpdated.push(callback);
673
+ }
674
+ onDestroy(callback) {
675
+ this.component.manager.ensureHasDestroy();
676
+ this._callbacks.hostDestroy.push(callback);
677
+ }
678
+ onLifecycle(callback) {
679
+ this._callbacks.hostLifecycle.push(callback);
680
+ if (this.connectedCalled && this.component.el.isConnected)
681
+ this._callLifecycle(callback);
682
+ }
683
+ // Call each lifecycle hook
684
+ triggerConnected() {
685
+ this._callbacks.hostConnected.forEach(safeCall);
686
+ this.triggerLifecycle();
687
+ this.connectedCalled = true;
688
+ }
689
+ triggerDisconnected() {
690
+ this._callbacks.hostDisconnected.forEach(safeCall);
691
+ this._lifecycleDisconnected.forEach(safeCall);
692
+ this._lifecycleDisconnected = [];
693
+ }
694
+ async triggerLoad() {
695
+ if (this.willLoadCalled)
696
+ return;
697
+ this.willLoadCalled = true;
698
+ if (this._callbacks.hostLoad.length > 0)
699
+ await Promise.allSettled(this._callbacks.hostLoad.map(safeAsyncCall));
700
+ this._ready.resolve(this._exports);
701
+ }
702
+ triggerLoaded() {
703
+ if (this.didLoadCalled)
704
+ return;
705
+ this._callbacks.hostLoaded.forEach(safeCall);
706
+ this.didLoadCalled = true;
707
+ }
708
+ triggerUpdate() {
709
+ this._callbacks.hostUpdate.forEach(safeCall);
710
+ }
711
+ triggerUpdated() {
712
+ this._callbacks.hostUpdated.forEach(safeCall);
713
+ }
714
+ triggerDestroy() {
715
+ this._callbacks.hostDestroy.forEach(safeCall);
716
+ }
717
+ triggerLifecycle() {
718
+ this._callbacks.hostLifecycle.forEach((callback) => this._callLifecycle(callback));
719
+ }
720
+ _callLifecycle(callback) {
721
+ _Controller.internals.setAmbientComponent(this.component);
722
+ const cleanupRaw = safeCall(callback);
723
+ const cleanup = Array.isArray(cleanupRaw) ? cleanupRaw : [cleanupRaw];
724
+ cleanup.forEach((cleanup2) => {
725
+ if (typeof cleanup2 === "function")
726
+ this._lifecycleDisconnected.push(cleanup2);
727
+ else if (typeof cleanup2 === "object" && typeof cleanup2.remove === "function")
728
+ this._lifecycleDisconnected.push(cleanup2.remove);
729
+ });
730
+ }
731
+ };
732
+ _a = controllerSymbol;
733
+ _Controller.internals = new ControllerInternals();
734
+ var Controller = _Controller;
735
+ var GenericController = class extends Controller {
736
+ // Redundant constructor needed to improve typing
737
+ constructor(component) {
738
+ super(component);
739
+ }
740
+ // Overriding super's watch only to improve typing
741
+ watch(property, callback) {
742
+ return super.watch(
743
+ property,
744
+ callback
745
+ );
746
+ }
747
+ dynamicGetSet(property, getSet) {
748
+ super.genericGetSet(property, getSet);
749
+ }
750
+ };
751
+ function makeProvisionalValue(base) {
752
+ if (typeof base !== "object" && typeof base !== "function" || base === null)
753
+ return base;
754
+ const proxy2 = new Proxy(base, {
755
+ get(target, prop, receiver) {
756
+ if (cyclical.has(prop) && prop in target && target[prop] === proxy2)
757
+ return void 0;
758
+ if (prop in target || prop in Promise.prototype || typeof prop === "symbol")
759
+ return typeof target === "function" ? target[prop] : Reflect.get(target, prop, receiver);
760
+ console.error(`Trying to access "${prop.toString()}" on the controller before it's loaded. ${accessBeforeLoad}`);
761
+ return void 0;
762
+ },
763
+ set(target, prop, newValue, receiver) {
764
+ console.error(`Trying to set "${prop.toString()}" on the controller before it's loaded. ${accessBeforeLoad}`);
765
+ return Reflect.set(target, prop, newValue, receiver);
766
+ }
767
+ });
768
+ return proxy2;
769
+ }
770
+ var cyclical = /* @__PURE__ */ new Set(["exports", "_exports"]);
771
+ var accessBeforeLoad = "" ;
772
+ function toControllerHost(component) {
773
+ if ("addController" in component)
774
+ return component;
775
+ else
776
+ throw new Error(
777
+ "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"
778
+ );
779
+ }
780
+
781
+ // src/proxyExports.ts
782
+ var proxyExports = (Class) => (...args) => {
783
+ const ambientControllers = Controller.internals.retrieveParentControllers();
784
+ const instance = new Class(...args);
785
+ const initialExports = instance.exports;
786
+ Controller.internals.setParentController(ambientControllers.at(-1));
787
+ const internals = instance.component.manager.internals;
788
+ internals.markExports(instance, initialExports);
789
+ instance.watchExports((exports) => internals.markExports(instance, exports));
790
+ Controller.internals.setAmbientChildController(instance);
791
+ const hostCandidates = [instance.component, ...ambientControllers].reverse();
792
+ return internals.trackKey(
793
+ hostCandidates,
794
+ (resolution) => resolution === void 0 ? void 0 : setProxy(instance, resolution.host, resolution.key, initialExports),
795
+ initialExports
796
+ );
797
+ };
798
+ function setProxy(controller, host, key, initialExports) {
799
+ const genericHost = host;
800
+ const controllerValueChanged = genericHost[key] !== controller.exports;
801
+ const hostValueChanged = genericHost[key] !== initialExports;
802
+ const controllerUpdatedExports = initialExports !== controller.exports;
803
+ if (controllerValueChanged && !hostValueChanged && controllerUpdatedExports)
804
+ genericHost[key] = controller.exports;
805
+ controller.watchExports(() => {
806
+ if (genericHost[key] === controller.exports)
807
+ return;
808
+ const manager = controller.component.manager;
809
+ const isReadOnly = manager.internals.readonlyProps?.has(key) === true;
810
+ if (isReadOnly)
811
+ manager.bypassReadonly(() => {
812
+ genericHost[key] = controller.exports;
813
+ });
814
+ else
815
+ genericHost[key] = controller.exports;
816
+ });
817
+ }
818
+
819
+ // src/functional.ts
820
+ var makeController = (constructor) => proxy(void 0, constructor);
821
+ var FunctionalController = class extends Controller {
822
+ constructor(component, constructor) {
823
+ super(component);
824
+ const originalExports = this.exports;
825
+ try {
826
+ Controller.internals.setAmbientComponent(this.component);
827
+ const value = constructor(this.component, this);
828
+ const constructorChangedExports = this.exports !== originalExports;
829
+ if (value instanceof Promise) {
830
+ if (!constructorChangedExports)
831
+ this.setProvisionalExports(value);
832
+ const resolved = value.then((result) => {
833
+ this.exports = result;
834
+ super.catchUpLifecycle();
835
+ }).catch((error) => {
836
+ this._ready.reject(error);
837
+ console.error(error);
838
+ });
839
+ this.onLoad(async () => await resolved);
840
+ } else {
841
+ if (!constructorChangedExports || value !== void 0)
842
+ this.exports = value;
843
+ queueMicrotask(() => super.catchUpLifecycle());
844
+ }
845
+ } catch (error) {
846
+ this._ready.reject(error);
847
+ console.error(error);
848
+ }
849
+ }
850
+ /** Noop - will be called in the constructor instead */
851
+ catchUpLifecycle() {
852
+ return;
853
+ }
854
+ };
855
+ var proxy = proxyExports(FunctionalController);
856
+
857
+ // src/trackPropertyKey.ts
858
+ function trackPropertyKey(object, onResolved, defaultValue) {
859
+ const keys = Object.keys(object);
860
+ const keyCount = keys.length;
861
+ if (keyTrackMap === void 0)
862
+ queueMicrotask(keyTrackResolve);
863
+ keyTrackMap ?? (keyTrackMap = /* @__PURE__ */ new Map());
864
+ let pendingTrackers = keyTrackMap.get(object);
865
+ if (pendingTrackers === void 0) {
866
+ pendingTrackers = { callbacks: [], keyCount };
867
+ keyTrackMap.set(object, pendingTrackers);
868
+ }
869
+ if (pendingTrackers.keyCount !== keyCount) {
870
+ pendingTrackers.callbacks.forEach((resolve) => resolve(keys));
871
+ pendingTrackers.callbacks = [];
872
+ pendingTrackers.keyCount = keyCount;
873
+ }
874
+ pendingTrackers.callbacks.push((keys2) => {
875
+ const callback = (key2) => safeCall(() => onResolved(key2));
876
+ const key = keys2[keyCount];
877
+ if (key === void 0)
878
+ callback(void 0);
879
+ else if (object[key] === defaultValue)
880
+ callback(key);
881
+ else
882
+ callback(void 0);
883
+ });
884
+ return defaultValue;
885
+ }
886
+ var keyTrackMap = void 0;
887
+ function keyTrackResolve() {
888
+ Array.from(keyTrackMap?.entries() ?? []).forEach(([object, { callbacks }]) => {
889
+ const keys = Object.keys(object);
890
+ callbacks.forEach((commit) => commit(keys));
891
+ });
892
+ keyTrackMap = void 0;
893
+ }
894
+
895
+ // src/ComponentInternals.ts
896
+ var ComponentInternals = class {
897
+ constructor(component) {
898
+ /**
899
+ * When watchers are set, set then into `allWatchers`. When watchers are read
900
+ * in the setter, read from `enabledWatchers`.
901
+ * On connectedCallback(), controller manager does `enabledWatchers=allWatchers`.
902
+ * Reasoning:
903
+ * - This disables watchers until connected callback (matches behavior of
904
+ * Stencil's watchers)
905
+ * - This removes in the setter to check if watchers were enabled already or
906
+ * not (as getters/setters are hot path, and should be streamlined)
907
+ */
908
+ this.enabledWatchers = {};
909
+ this.allWatchers = {};
910
+ this.trackKey = (hostsCandidates, onResolved, defaultValue) => {
911
+ const candidateHosts = Array.isArray(hostsCandidates) ? hostsCandidates : [hostsCandidates];
912
+ let leftToResolve = candidateHosts.length + 1;
913
+ const resolved = (resolution) => {
914
+ leftToResolve -= 1;
915
+ if (resolution !== void 0)
916
+ leftToResolve = 0;
917
+ if (leftToResolve === 0)
918
+ onResolved(resolution);
919
+ };
920
+ candidateHosts.forEach(
921
+ (host) => this.component.manager.trackPropertyKey(
922
+ host,
923
+ (key) => resolved(
924
+ key === void 0 ? void 0 : {
925
+ key,
926
+ host,
927
+ type: "property",
928
+ domValue: void 0
929
+ }
930
+ ),
931
+ defaultValue
932
+ )
933
+ );
934
+ this.component.manager.trackPropKey((key, domValue) => {
935
+ const propType = key === void 0 ? void 0 : getPropType(this.component, key);
936
+ resolved(
937
+ key === void 0 ? void 0 : {
938
+ key,
939
+ host: this.component,
940
+ type: propType ?? "prop",
941
+ domValue: propType === "prop" ? domValue : void 0
942
+ }
943
+ );
944
+ }, defaultValue);
945
+ return defaultValue;
946
+ };
947
+ this.trackPropKey = (onResolved, defaultValue) => {
948
+ if (this._trackedValue !== nothing && this._trackedValue !== defaultValue)
949
+ this._firePropertyTrackers(void 0, void 0, void 0);
950
+ if (this._keyTrackers.length === 0)
951
+ queueMicrotask(() => this._firePropertyTrackers(void 0, void 0, void 0));
952
+ this._trackedValue = defaultValue;
953
+ this._keyTrackers.push(
954
+ (key, value, previousValue) => safeCall(() => onResolved(defaultValue === value ? key : void 0, previousValue))
955
+ );
956
+ return defaultValue;
957
+ };
958
+ this._trackedValue = nothing;
959
+ this._keyTrackers = [];
960
+ this.getters = {};
961
+ this.setters = {};
962
+ this.accessorGetter = {};
963
+ this.accessorSetter = {};
964
+ this._exports = /* @__PURE__ */ new WeakMap();
965
+ Object.defineProperty(this, "component", {
966
+ writable: false,
967
+ enumerable: false,
968
+ configurable: true,
969
+ value: component
970
+ });
971
+ }
972
+ _firePropertyTrackers(key, value, oldValue) {
973
+ const trackers = this._keyTrackers;
974
+ this._trackedValue = nothing;
975
+ this._keyTrackers = [];
976
+ trackers.forEach((tracker) => tracker(key, value, oldValue));
977
+ }
978
+ /**
979
+ * Configure a getter or setter for a given \@Prop/\@State
980
+ *
981
+ * Note, since props are defined on the prototype, they are shared between all
982
+ * instances of a component. Thus, instead of passing a reference to the
983
+ * getter/setter function, you should update the
984
+ * ComponentInternals.getters/setters properties, and then call getSetProxy
985
+ * to apply the changes to the prototype
986
+ */
987
+ getSetProxy(property, hasGetter, hasSetter) {
988
+ const component = this.component;
989
+ const classPrototype = component.constructor.prototype;
990
+ this._getSetProxy(classPrototype, property, hasGetter, hasSetter, "class");
991
+ if (component.manager.isLit)
992
+ return;
993
+ const htmlPrototype = component.el.constructor.prototype;
994
+ if (classPrototype !== htmlPrototype)
995
+ this._getSetProxy(htmlPrototype, property, hasGetter, hasSetter, "html");
996
+ }
997
+ _getSetProxy(prototype, name, hasGetter, hasSetter, type) {
998
+ const component = this.component;
999
+ const propType = getMemberType(component, name);
1000
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, name);
1001
+ const tolerateNotFound = type === "html";
1002
+ if (descriptor?.set === void 0 || descriptor.get === void 0)
1003
+ if (descriptor !== void 0 && "value" in descriptor)
1004
+ throw new Error(
1005
+ `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}`
1006
+ );
1007
+ else if (tolerateNotFound)
1008
+ return;
1009
+ else
1010
+ throw new Error(`Unable to find "${name}" property on the ${component.el.tagName} component`);
1011
+ const { get: originalGet, set: originalSet } = descriptor;
1012
+ const isGetterAlreadyOverwritten = customAccessor in originalGet;
1013
+ const isSetterAlreadyOverwritten = customAccessor in originalSet;
1014
+ const shouldOverwriteGet = !isGetterAlreadyOverwritten && hasGetter;
1015
+ const shouldOverwriteSet = !isSetterAlreadyOverwritten && hasSetter;
1016
+ if (!shouldOverwriteGet && !shouldOverwriteSet)
1017
+ return;
1018
+ const finalGetter = shouldOverwriteGet ? function getter() {
1019
+ let value = originalGet.call(this);
1020
+ const component2 = Controller.internals.elementToInstance.get(this);
1021
+ if (Controller.internals.shouldBypassGetter || component2 === void 0)
1022
+ return value;
1023
+ const internals = component2.manager.internals;
1024
+ value = internals.accessorGetter[name](value, name);
1025
+ const getters = internals.getters[name] ?? emptyArray;
1026
+ for (let i = 0; i < getters.length; i++)
1027
+ value = getters[i](value, name);
1028
+ return value;
1029
+ } : originalGet;
1030
+ const finalSetter = shouldOverwriteSet ? function setter(rawNewValue) {
1031
+ const oldValue = originalGet.call(this);
1032
+ const component2 = Controller.internals.elementToInstance.get(this);
1033
+ if (component2 === void 0) {
1034
+ originalSet.call(this, rawNewValue);
1035
+ return;
1036
+ }
1037
+ let newValue = component2.manager.isLit ? rawNewValue : parsePropertyValue(rawNewValue, propType);
1038
+ const internals = component2.manager.internals;
1039
+ if (newValue === oldValue)
1040
+ originalSet.call(this, rawNewValue);
1041
+ else {
1042
+ const setters = Controller.internals.shouldBypassSetter ? emptyArray : internals.setters[name] ?? emptyArray;
1043
+ for (let i = 0; i < setters.length; i++)
1044
+ newValue = setters[i](newValue, oldValue, name);
1045
+ newValue = internals.accessorSetter[name](newValue, oldValue, name);
1046
+ originalSet.call(this, newValue);
1047
+ if (newValue !== oldValue)
1048
+ internals.enabledWatchers[name]?.forEach((watcher) => watcher(newValue, oldValue, name));
1049
+ }
1050
+ if (internals._keyTrackers.length > 0)
1051
+ internals?._firePropertyTrackers(name, rawNewValue, oldValue);
1052
+ } : originalSet;
1053
+ if (shouldOverwriteGet)
1054
+ Object.defineProperty(finalGetter, customAccessor, { value: true });
1055
+ if (shouldOverwriteSet)
1056
+ Object.defineProperty(finalSetter, customAccessor, { value: true });
1057
+ Object.defineProperty(prototype, name, {
1058
+ ...descriptor,
1059
+ get: finalGetter,
1060
+ set: finalSetter
1061
+ });
1062
+ }
1063
+ /**
1064
+ * Associate an exports object with a controller for reverse lookup in
1065
+ * controller.use
1066
+ */
1067
+ markExports(controller, exports) {
1068
+ if (typeof exports === "object" && exports !== null || typeof exports === "function")
1069
+ this._exports.set(exports, controller);
1070
+ }
1071
+ resolveExports(exports) {
1072
+ if (typeof exports === "object" && exports !== null || typeof exports === "function")
1073
+ return this._exports.get(exports);
1074
+ else
1075
+ return void 0;
1076
+ }
1077
+ };
1078
+ var emptyArray = [];
1079
+ var customAccessor = Symbol("controllersCustomAccessor");
1080
+ var nothing = Symbol("nothing");
1081
+
1082
+ // src/ControllerManager.ts
1083
+ var useControllerManager = (component, forceUpdate) => new ControllerManager(component, forceUpdate);
1084
+ var ControllerManager = class extends GenericController {
1085
+ constructor(component, forceUpdate) {
1086
+ const isLit = "addController" in component;
1087
+ const controllers = /* @__PURE__ */ new Set();
1088
+ function addController(controller) {
1089
+ controllers.add(controller);
1090
+ if (isLit && !(controllerSymbol in controller) && component.el.isConnected)
1091
+ controller.hostConnected?.();
1092
+ }
1093
+ const removeController = (controller) => void controllers.delete(controller);
1094
+ if (!isLit) {
1095
+ const update = forceUpdate ?? component.constructor.__forceUpdate;
1096
+ const controllerHost = {
1097
+ addController,
1098
+ removeController,
1099
+ requestUpdate: () => update(component)
1100
+ };
1101
+ extendObject(component, controllerHost);
1102
+ }
1103
+ super(component);
1104
+ this.internals = new ComponentInternals(this.component);
1105
+ this.destroyed = false;
1106
+ this._updatePromise = new Deferred();
1107
+ this._originalLifecycles = {};
1108
+ /**
1109
+ * A magical solution to finding out what property name a given controller
1110
+ * on a given object was assigned to. Note, this does not work for properties
1111
+ * that have \@Prop() or \@State() decorator - for those, use
1112
+ * manager.trackPropKey() instead.
1113
+ *
1114
+ * @example
1115
+ * function trackMe<T>(defaultValue:T, component:BaseComponent):T {
1116
+ * component.manager.trackPropertyKey(component, (key)=>console.log(key), defaultValue);
1117
+ * return defaultValue;
1118
+ * }
1119
+ *
1120
+ * class MyComponent extends BaseComponent {
1121
+ * // Will console log "myProp"
1122
+ * myProp = trackMe('a', this);
1123
+ * }
1124
+ *
1125
+ */
1126
+ this.trackPropertyKey = trackPropertyKey;
1127
+ /**
1128
+ * Like manager.trackPropertyKey(), but for props that have \@State() or \@Prop()
1129
+ * decorator
1130
+ *
1131
+ * @example
1132
+ * function trackMe(component:BaseComponent) {
1133
+ * component.manager.trackPropKey((key)=>console.log(key));
1134
+ * }
1135
+ *
1136
+ * class MyComponent extends BaseComponent {
1137
+ * // Will console log "myProp"
1138
+ * @Prop() myProp = trackMe(this);
1139
+ *
1140
+ * // Will console log "myState"
1141
+ * @State() myState = trackMe(this);
1142
+ * }
1143
+ */
1144
+ this.trackPropKey = this.internals.trackPropKey;
1145
+ /**
1146
+ * A combination of trackPropertyKey() and trackPropKey(). For usage when
1147
+ * you want to track a property, but don't know if it will be defined with the
1148
+ * \@Prop() decorator or not
1149
+ */
1150
+ this.trackKey = this.internals.trackKey;
1151
+ this._readonlySetter = (newValue, oldValue, property) => {
1152
+ if (Controller.internals.shouldBypassReadonly)
1153
+ return newValue;
1154
+ const component = this.component;
1155
+ const isProp = getPropType(component, property) === "prop";
1156
+ if (isProp) {
1157
+ if (this.isLit) {
1158
+ const details = getLitProperties(component).get(property);
1159
+ if (details && details?.attribute !== false)
1160
+ component.el.setAttribute(
1161
+ typeof details.attribute === "string" ? details.attribute : camelToKebab(property),
1162
+ // Not using converter.toAttribute to keep this unlikely case simpler
1163
+ String(oldValue)
1164
+ );
1165
+ } else
1166
+ component.requestUpdate();
1167
+ }
1168
+ throw new Error(
1169
+ `Cannot assign to read-only property "${property}" of ${component.el.tagName.toLowerCase()}. Trying to assign "${String(
1170
+ newValue
1171
+ )}"`
1172
+ );
1173
+ };
1174
+ /**
1175
+ * In development, on hot module reload, controller would be re-initialized
1176
+ * with all Props and State values persistent, but properties lost. This unsafe
1177
+ * development-only API lets you set or get data for a controller that would
1178
+ * persist across hot reloads.
1179
+ */
1180
+ this.devOnlySetPersistentControllerData = void 0 ;
1181
+ this.devOnlyGetPersistentControllerData = void 0 ;
1182
+ if (isLit) {
1183
+ component.addController = addController;
1184
+ component.removeController = removeController;
1185
+ }
1186
+ this.isLit = isLit;
1187
+ this.component.manager = this;
1188
+ retrieveComponentMembers(component, isLit);
1189
+ this._controllers = controllers;
1190
+ this.exports = void 0;
1191
+ this.hasDestroy = "autoDestroyDisabled" in this.component && typeof this.component.destroy === "function";
1192
+ if (this.hasDestroy)
1193
+ this.watch("autoDestroyDisabled", () => this._autoDestroyDisabledWatcher());
1194
+ this._bindLifecycleMethods();
1195
+ if (!isLit)
1196
+ Object.defineProperty(component, "updateComplete", {
1197
+ get: async () => await this._updatePromise.promise
1198
+ });
1199
+ const members = getPropLikeMembers(component);
1200
+ const internals = component.manager.internals;
1201
+ members.forEach((name) => {
1202
+ internals.accessorGetter[name] = defaultGetterSetter;
1203
+ internals.accessorSetter[name] = defaultGetterSetter;
1204
+ internals.getSetProxy(name, true, true);
1205
+ });
1206
+ Controller.internals.setParentController(void 0);
1207
+ Controller.internals.setAmbientComponent(component);
1208
+ Controller.internals.elementToInstance.set(component.el, component);
1209
+ Controller.internals.elementToInstance.set(component, component);
1210
+ }
1211
+ _bindLifecycleMethods() {
1212
+ const component = this.component;
1213
+ const isLit = this.isLit;
1214
+ this._originalLifecycles = {
1215
+ // These callbacks will be called by Lit, so we don't have to
1216
+ connectedCallback: isLit ? void 0 : component.connectedCallback,
1217
+ disconnectedCallback: isLit ? void 0 : component.disconnectedCallback,
1218
+ componentWillLoad: isLit ? void 0 : component.componentWillLoad,
1219
+ componentDidLoad: isLit ? void 0 : component.componentDidLoad,
1220
+ componentWillUpdate: isLit ? void 0 : component.componentWillUpdate,
1221
+ componentDidUpdate: isLit ? void 0 : component.componentDidUpdate,
1222
+ destroy: component.destroy
1223
+ };
1224
+ if (!isLit) {
1225
+ component.connectedCallback = this.hostConnected.bind(this);
1226
+ component.disconnectedCallback = this.hostDisconnected.bind(this);
1227
+ component.componentWillLoad = this.hostLoad.bind(this);
1228
+ component.componentDidLoad = this.hostLoaded.bind(this);
1229
+ component.componentWillUpdate = this.hostUpdate.bind(this);
1230
+ component.componentDidUpdate = this.hostUpdated.bind(this);
1231
+ }
1232
+ if (this.hasDestroy)
1233
+ component.destroy = this.destroy.bind(this);
1234
+ }
1235
+ /**
1236
+ * Throws an error if component does not implement destroy() lifecycle, but
1237
+ * tries to use it.
1238
+ */
1239
+ ensureHasDestroy() {
1240
+ if (!this.hasDestroy)
1241
+ throw new Error(destroyErrorMessage);
1242
+ }
1243
+ /**
1244
+ * Private because this is not supposed to be called by Component directly.
1245
+ * Instead, _bindLifecycleMethods will take care of that. Otherwise, you risk
1246
+ * calling lifecycle methods twice.
1247
+ */
1248
+ hostConnected() {
1249
+ if (this.destroyed) {
1250
+ const tagName = this.component.el.tagName.toLowerCase();
1251
+ this.component.el.remove();
1252
+ throw new Error(
1253
+ `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.`
1254
+ );
1255
+ }
1256
+ if (this._autoDestroyTimeout !== void 0)
1257
+ clearTimeout(this._autoDestroyTimeout);
1258
+ this.internals.enabledWatchers = this.internals.allWatchers;
1259
+ keyTrackResolve();
1260
+ this._controllers.forEach(
1261
+ (controller) => "triggerConnected" in controller ? controller.triggerConnected() : safeCall(() => controller.hostConnected?.())
1262
+ );
1263
+ this._originalLifecycles.connectedCallback?.call(this.component);
1264
+ }
1265
+ hostDisconnected() {
1266
+ if (this.destroyed)
1267
+ return;
1268
+ this._controllers.forEach(
1269
+ (controller) => "triggerDisconnected" in controller ? controller.triggerDisconnected() : safeCall(() => controller.hostDisconnected?.())
1270
+ );
1271
+ this._originalLifecycles.disconnectedCallback?.call(this.component);
1272
+ if (this.hasDestroy)
1273
+ this._autoDestroyDisabledWatcher();
1274
+ }
1275
+ // REFACTOR: don't force async if there are no async load controllers?
1276
+ async hostLoad() {
1277
+ if (typeof this.internals.reactiveUtilsIntegration === "function")
1278
+ await this.internals.reactiveUtilsIntegration();
1279
+ await Promise.allSettled(
1280
+ Array.from(
1281
+ this._controllers,
1282
+ async (controller) => "triggerLoad" in controller ? await controller.triggerLoad() : await safeAsyncCall(async () => await controller.hostLoad?.())
1283
+ )
1284
+ );
1285
+ await this._originalLifecycles.componentWillLoad?.call(this.component);
1286
+ }
1287
+ hostLoaded() {
1288
+ this._controllers.forEach(
1289
+ (controller) => "triggerLoaded" in controller ? controller.triggerLoaded() : safeCall(() => controller.hostLoaded?.())
1290
+ );
1291
+ this._originalLifecycles.componentDidLoad?.call(this.component);
1292
+ }
1293
+ hostUpdate() {
1294
+ this._controllers.forEach(
1295
+ (controller) => "triggerUpdate" in controller ? controller.triggerUpdate() : safeCall(() => controller.hostUpdate?.())
1296
+ );
1297
+ void this._originalLifecycles.componentWillUpdate?.call(this.component);
1298
+ }
1299
+ hostUpdated() {
1300
+ this._controllers.forEach(
1301
+ (controller) => "triggerUpdated" in controller ? controller.triggerUpdated() : safeCall(() => controller.hostUpdated?.())
1302
+ );
1303
+ this._originalLifecycles.componentDidUpdate?.call(this.component);
1304
+ if (!this.isLit) {
1305
+ const updatePromise = this._updatePromise;
1306
+ this._updatePromise = new Deferred();
1307
+ updatePromise.resolve(true);
1308
+ }
1309
+ }
1310
+ async destroy() {
1311
+ this.ensureHasDestroy();
1312
+ if (this.destroyed)
1313
+ return;
1314
+ if (this.component.el.isConnected) {
1315
+ this.hasDestroy = false;
1316
+ try {
1317
+ this.component.el.remove();
1318
+ } finally {
1319
+ this.hasDestroy = true;
1320
+ }
1321
+ }
1322
+ this._autoDestroyTimeout = void 0;
1323
+ this.destroyed = true;
1324
+ this._controllers.forEach(
1325
+ (controller) => "triggerDestroy" in controller ? controller.triggerDestroy() : safeCall(() => controller.hostDestroy?.())
1326
+ );
1327
+ this._controllers.clear();
1328
+ await this._originalLifecycles.destroy?.call(this.component);
1329
+ }
1330
+ _autoDestroyDisabledWatcher() {
1331
+ if (!this.component.el.isConnected && !this.component.autoDestroyDisabled) {
1332
+ if (this._autoDestroyTimeout !== void 0)
1333
+ clearTimeout(this._autoDestroyTimeout);
1334
+ const destroy = () => void this.destroy().catch(console.error);
1335
+ this._autoDestroyTimeout = setTimeout(destroy, autoDestroyOnDisconnectTimeout);
1336
+ }
1337
+ }
1338
+ // REFACTOR: replace this with a readonly:true option in @property()
1339
+ /**
1340
+ * Make a @Prop() or @State() readonly (prevent overwriting default value).
1341
+ *
1342
+ * For internal properties, prefer TypeScript's "readonly" modifier instead.
1343
+ *
1344
+ * @example
1345
+ * // Defining readonly prop
1346
+ * @Prop({ reflect: true }) prop = this.manager.readonly('a');
1347
+ *
1348
+ * @example
1349
+ * // Overwriting readonly prop internally
1350
+ * this.manager.bypassReadonly(()=>{
1351
+ * this.prop = 'b';
1352
+ * });
1353
+ *
1354
+ */
1355
+ readonly(value) {
1356
+ return this.getSet(value, { set: this._readonlySetter });
1357
+ }
1358
+ // REFACTOR: remove this in Lit in favor of native get/set
1359
+ /**
1360
+ * Listen for any component's @State()/@Prop() change, and mutate it's
1361
+ * value before it is set.
1362
+ * This is necessary because Stencil's Compiler does not support get/set for
1363
+ * @State()/@Prop().
1364
+ * For private component properties, you should use regular get/set syntax.
1365
+ *
1366
+ * @example
1367
+ * @Prop() exampleProp = this.manager.getSet(defaultValue,{get,set})
1368
+ * @Prop() someProp = this.manager.getSet(
1369
+ * undefined as string | undefined,
1370
+ * {
1371
+ * get: (value)=>value.trim(),
1372
+ * set: (newValue,oldValue) => newValue.trim() ?? oldValue
1373
+ * }
1374
+ * )
1375
+ *
1376
+ * @remarks
1377
+ * Unlike a native get/set, the get function receives the current attribute
1378
+ * value, and can modify it before returning it (or can disregard the current
1379
+ * value and get it from elsewhere instead).
1380
+ * Similarly, setter is called with the new and old value, and is expected to
1381
+ * return the final new value (or return the old value to undo the change)
1382
+ */
1383
+ getSet(defaultValue, getSet) {
1384
+ return this.component.manager.trackPropKey((name) => {
1385
+ var _a;
1386
+ if (name === void 0)
1387
+ throw new Error(
1388
+ "Unable to resolve get/set's prop name. Make sure you are using it like @Prop() someProp = this.manager.getSet(defaultValue,{get,set})"
1389
+ );
1390
+ if (getSet.set === this._readonlySetter) {
1391
+ (_a = this.internals).readonlyProps ?? (_a.readonlyProps = /* @__PURE__ */ new Set());
1392
+ this.internals.readonlyProps.add(name);
1393
+ }
1394
+ const genericComponent = this.component;
1395
+ const value = genericComponent[name];
1396
+ if (value != null && value !== defaultValue && typeof getSet.set === "function" && getSet.initialSet !== false) {
1397
+ const newValue = getSet.set(value, defaultValue, name);
1398
+ if (newValue !== value)
1399
+ genericComponent[name] = newValue;
1400
+ }
1401
+ this.genericGetSet(name, getSet);
1402
+ }, defaultValue);
1403
+ }
1404
+ };
1405
+ var destroyErrorMessage = `
1406
+ If the component uses a controller that uses destroy() method, then the
1407
+ component must have the following properties:
1408
+ ${// Don't expose internal code in production, and keep bundle smaller:
1409
+ `autoDestroyDisabled and destroy` }
1410
+ `.trim();
1411
+ var autoDestroyOnDisconnectTimeout = 1e3;
1412
+ var defaultGetterSetter = (value) => value;
1413
+
1414
+ // src/useT9n.ts
1415
+ var makeT9nController = (getAssetPath) => ({ blocking = false, name } = {}) => (
1416
+ // eslint-disable-next-line @typescript-eslint/promise-function-async
1417
+ makeController((component, controller) => {
1418
+ controller.onLifecycle(
1419
+ () => startLocaleObserver(
1420
+ component.el,
1421
+ getAssetPath("./assets"),
1422
+ ({ t9nLocale, t9nStrings, lang }) => {
1423
+ controller.exports = { ...t9nStrings, _lang: lang, _t9nLocale: t9nLocale };
1424
+ const label = t9nStrings.componentLabel ?? t9nStrings.widgetLabel;
1425
+ if (typeof label === "string" && "label" in component && component.label == null)
1426
+ component.label ?? (component.label = label);
1427
+ },
1428
+ name
1429
+ )
1430
+ );
1431
+ if (blocking)
1432
+ return controller.ready;
1433
+ const locale = getElementLocales(component.el);
1434
+ return { _lang: locale.lang, _t9nLocale: locale.t9nLocale };
1435
+ })
1436
+ );
1437
+
1438
+ export { makeT9nController as m, useControllerManager as u };