PageSourceSearch

https://malaji71-prompteador.hf.space/assets/i18n-CMo5lpzy.js

js malaji71-prompteador.hf.space collected 2026-10-03 17:05:37 UTC 276,161 bytes, 9,065 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Index-B6k2WpQm.js","./index-BvBk1Iap.js","./index-CrbFh6qt.css","./Block-Bx3BikCN.js","./ScrollFade.svelte_svelte_type_style_lang-Xm-PLg9E.js","./snippet-Bl5YVoCg.js","./ScrollFade-BXTrLZiw.css","./utils.svelte-CYLB_jIA.js","./clone-DaB-S2nH.js","./index-Lz7fsHFt.js","./StreamingBar.svelte_svelte_type_style_lang-CdFIGsJa.js","./html-CdUEtR5E.js","./index-C7e-J7CF.js","./StreamingBar-M0OJiclA.css","./Clear-Dgs5UhTO.js","./Index.svelte_svelte_type_style_lang-C97CbKPo.js","./Index-D0q0pAfU.css","./Index-CVv5Ke0n.css","./Index-DWC_ST0U.js","./BlockLabel-oGSqUii_.js","./Empty-CHa-gxv7.js","./Image-C3F5KG1F.js","./IconButtonWrapper-Ba0GidgU.js","./FullscreenButton-CNmhk6nd.js","./Maximize-B_43ylTs.js","./Index-KYyPl9cR.css","./StaticAudio-DGaZb-fW.js","./DownloadLink-KvrFKyMn.js","./ShareButton-Dz0y1C1K.js","./Download-pFhUaTl4.js","./Music-D0NN2hV9.js","./MinimalAudioPlayer-Cdqg8MIC.js","./MinimalAudioPlayer-B6PFUF9w.css","./VolumeLevels-DHAc0pUL.js","./Play-CWcFSzc7.js","./Undo-BxcJDM8E.js","./StaticAudio-BZBUSA4E.css","./Example-hTHSlRG1.js","./Example-DQklQyrP.css","./index-D65tv47j.js","./Upload-CPeZiqam.js","./actions-Cit_UA5S.js","./Upload-B9AbOy1B.css","./ModifyUpload-B5K-5Hqx.js","./Edit-Dr58YXBX.js","./StreamingBar-bVF1kkqe.js","./record.esm-BVY9RaAH.js","./Spinner-BrK-6emq.js","./UploadText-BSD1IoCI.js","./index-MzKMzM4L.css","./Index-m58JVqMG.js","./Index-CI0xDggI.js","./__vite-browser-external-CVaeKfQx.js","./Index-DIRpB5DY.js","./Button-CH2w4_A4.js","./Image-CDw5qb5O.js","./misc-ByVveAau.js","./Image-DQfoGqtb.css","./Button-CoUFCYL9.css","./ImagePreview-CAbFrrhc.css","./Index-DuFh5Mes.js","./input-C317uaXR.js","./Check-BlnBgjLT.js","./Copy-DFFray7x.js","./File-_cC4Z_uD.js","./MarkdownCode-Cg7CjFvQ.js","./prism-python-CbXMXbdR.js","./MarkdownCode-BFC2oRGU.css","./event-modifiers-DanhKw3_.js","./Trash-CGTLExrZ.js","./Index-uA5k4uH0.css","./Example-KB5oRY7o.js","./Example-bEuOGW3l.css","./Index-BHwo3edq.js","./Info-BrkJhX6_.js","./Checkbox-BwK0lQJ8.js","./Checkbox-CJBAs2gn.css","./Example-ugztAPLa.js","./Example-Bq3fAzQx.css","./Index-CcMpJndr.js","./BlockTitle-7XQ-8ENg.js","./index-DnoGeqVF.js","./Index-Cd1I_K0a.css","./Example-obvXP67p.js","./Example-ZgyKzkPU.css","./Index-BuAoQXgO.js","./Code-C9UfsaaR.js","./Code-DSw5753G.css","./Code-DMRxApdQ.js","./Example-CCEyD4GV.js","./Example-BpLG3o2o.css","./Index-Dt4t8F3U.js","./tinycolor-NLEY4io3.js","./Index-CbmayjvD.css","./Index-BsVOYSj7.js","./index-BJk8VOjP.js","./Example-DL_4juBu.js","./Example-B0qjHn8W.css","./Index-CxOOE7R5.js","./DropdownArrow-Dw1NZKCM.js","./dsv-BhAd467f.js","./Index--t1xH8ZO.css","./Index-N-hoPZP9.js","./key-BV46G5Fv.js","./Textbox-v-cNeNHQ.js","./Send-Ee555fP_.js","./Square-B6INQV79.js","./Textbox-DbZXQzbK.css","./Example-a64hbcxE.js","./size-Cu4PabCL.js","./Example-BlSzJhEn.css","./Index-9MMRKKEp.css","./Example-BA64u5Sp.js","./Index-6_Y9ygNz.js","./Index-1AccPlNI.css","./Example-BIlLUrfo.js","./Example-B67Cdnj0.css","./Index-BAJ5KXXp.js","./Plus-CFoCxzu1.js","./Dropdown-DUCTuRQm.js","./window-BGXjFJtG.js","./Dropdown-_c0K7TyY.css","./Index-v1iUT5Sq.css","./Example-ml6sVHU8.css","./Index-CBNBXH2C.js","./Index-dUn14qUu.css","./Index-CKqdXlH-.js","./Index-CR7_W0IB.css","./Example-t0cB3HBf.js","./Index-CnMXw2NO.js","./Example-CI1jJDZu.js","./Example-CHp_DfzD.css","./Index-Tozf4a30.js","./FileUpload-9lL-iwhh.js","./FileUpload-DhzRhTM7.css","./Example-BCn1Ltli.js","./Example-Bm-XFf-B.css","./Index-DZsFFtsx.js","./Index-CL7x-fxw.css","./Index-Dvxi9axQ.js","./BaseForm-0cuxY3Cw.js","./BaseForm-B79fGGKa.css","./Gallery-DaBd1NXs.js","./Video-B3xDM6GN.js","./Video-BNtsM6tz.css","./Gallery-DU7oBqxe.css","./Example-BgRaJ5Hk.js","./Example-Cq74O62D.css","./Index-CGOALv4G.js","./Webcam-rWLs1V82.js","./ImageUploader-79Z_jqCu.css","./Index-BlyT2RM2.css","./Example-BDoLBXEz.css","./Index-QSoBFEc3.js","./Index-ipOE50af.css","./Index-DS7IaHHH.js","./color-Tpcfv14B.js","./Index-DxNvd7lC.css","./HTML-Cns4Rn3B.js","./HTML-Czz-mkVb.css","./Example-BEiY6GLN.js","./Example-1AHPPrE3.css","./Index-DKemNWiC.js","./Index-Bdoky1Bb.css","./ImagePreview-CCH9abCE.js","./Example-C7SZxPdR.js","./Index-ClljYZ7y.js","./Example-C5ywtI19.js","./Example-b2fpUOu4.css","./Index-8FtW5e5c.js","./ArrowUp-D6YcMimJ.js","./Index-EIiVYsEh.css","./Example-CwgO_twd.js","./Example-YdVSiIuW.css","./Index-9ldVfY2_.js","./select-k8gDf_61.js","./dispatch-tQmgj1It.js","./Index-BebY3ZUz.css","./Example-igKOU0iw.js","./JSON-BER32Vo9.js","./JSON-DCdmtE2W.css","./Example-BmdzPZC6.css","./Index-AvMR-Z-Q.js","./Index-DMFg_noi.js","./LineChart-BOORCIAk.js","./Index-CwrN3-r3.css","./Example-YwgBtWi1.js","./Example-CNix_cQb.css","./Index-TKDXb_h_.js","./Index.svelte_svelte_type_style_lang-BiKot9ba.js","./Index-BEAewkRY.css","./ScrollFade-BJkuhu7T.js","./Model3D-CWtA1JFE.js","./Model3D-C7UzhPnn.css","./Example-qy-BJ3UM.js","./Example-BcEr-euO.css","./Index-VR1jY_B8.js","./Index-amT-rIdI.css","./Example-BqGmQLY6.js","./Example-DCuDV3ni.css","./Index-DiVjWtzo.js","./Index-BcxwxuuF.css","./Example-CjtGxran.js","./Index-DgDgGRDA.js","./Index-qjglRoiX.css","./Index-My9wgKRU.js","./Example-7kC6V8Ah.js","./Example-C-YjHQke.js","./Example-CilajK2g.css","./Index-BVPgEV5I.js","./Index-D6Y3g9po.css","./Example-jxpEXkTh.js","./Example-D6QAAQGU.css","./Index-Dtsvb4cq.js","./Index-CNeZGhVI.css","./Plot-B28lJT0D.js","./Index-9LSEPVH5.js","./Example-GBtWCYGT.js","./Example-l4VocDuK.css","./Index-CKPl_BKA.js","./Index-BiXBvr9o.css","./Index-DbuJYMQk.js","./Index-BnASDwkz.css","./Index-DL_2b7d7.js","./Index-Dhk15SNf.css","./Example-Bzun0EwA.js","./Example-DEZCrt3g.css","./Index-D3Ps12Zs.js","./Index-Dk23IKH5.css","./Index-D_ICCRmo.js","./index-Bzj-ruDk.js","./state.svelte-CCPBiyik.js","./Index-CHpEZTbG.js","./Walkthrough.svelte_svelte_type_style_lang-Bq8jBNe2.js","./Walkthrough-CTImcoqj.css","./Index-D2fA4viL.css","./Index-DjI-Ei2E.js","./Index-m_Bbn_W3.js","./Index-B51SJCw-.js","./Index-C_TyKbH0.js","./Index-DCXyjWeM.css","./Index-DrpT8pjh.js","./Index-Dm9eNXb9.css","./VideoPreview-B9h4wUga.js","./VideoPreview-CMRZnztY.css","./Example-CTYifxHH.js","./Example-Bqpu_FoT.css","./index-DZgoAkOA.js","./index-BcUNcoUa.css","./Example-LogrIR8y.js","./Example-mgLMZyqj.css","./Index-AgZJDK0R.js","./Index-DOcbyfJN.css"])))=>i.map(i=>d[i]);
2import { L as current_batch, b4 as resume_effect, b5 as destroy_effect, b6 as pause_effect, ao as create_text, b7 as branch, b8 as move_effect, b9 as should_defer_append, h as hydrating, i as hydrate_node, p as block, E as EFFECT_TRANSPARENT, e as hydrate_next, ba as read_hydration_instruction, aI as HYDRATION_START_ELSE, aJ as skip_nodes, s as set_hydrate_node, ar as set_hydrating, w as get$1, aB as internal_set, bb as EACH_IS_CONTROLLED, ad as derived_safe_equal, $ as is_array, bc as array_from, D as DEV, bd as EACH_ITEM_REACTIVE, be as EACH_ITEM_IMMUTABLE, a3 as mutable_source, aF as source, bf as EACH_INDEX_REACTIVE, bg as EFFECT_OFFSCREEN, bh as INERT, O as queue_micro_task, bi as EACH_IS_ANIMATED, bj as clear_text_content, j as get_next_sibling, g as get_first_child, C as COMMENT_NODE, bk as HYDRATION_END, bl as managed, A as effect, bm as select_multiple_invalid_value, Q as is, N as teardown, J as listen_to_event_and_reset_event, P as previous_batch, bn as LOADING_ATTR_SYMBOL, aP as flatten, bo as ATTACHMENT_KEY, bp as NAMESPACE_HTML, ag as get_prototype_of, bq as is_capture_event, br as create_event, aj as delegate, al as autofocus, bs as normalize_attribute, aG as UNINITIALIZED, bt as can_delegate_event, bu as get_descriptors, bv as add_form_reset_listener, bw as hydration_attribute_changed, B as render_effect, z as untrack, bx as STATE_SYMBOL, by as component_context, ai as user_pre_effect, y as user_effect, bz as run_all, bA as run, G as deep_read_state, bB as derived$1, b1 as noop, I as safe_not_equal, x as set$1, bC as define_property, aM as get_descriptor, bD as props_invali
2d_value, bE as PROPS_IS_UPDATED, v as proxy, b as active_effect, bF as DESTROYED, bG as PROPS_IS_BINDABLE, bH as PROPS_IS_IMMUTABLE, bI as PROPS_IS_LAZY_INITIAL, bJ as is_destroying_effect, b0 as is_function, bK as LEGACY_PROPS, aN as update, bL as set_active_effect, bM as props_rest_readonly, bN as legacy_mode_flag, bO as PROPS_IS_RUNES, bP as enable_legacy_mode_flag, bQ as enable_async_mode_flag, R as push, a1 as legacy_pre_effect, a2 as legacy_pre_effect_reset, t as template_effect, a as append, T as pop, W as from_html, U as flushSync, X as sibling, V as child, a0 as set_text, a5 as user_derived, at as to_array, Y as reset, a8 as next, af as __vitePreload } from './index-BvBk1Iap.js';
3
4/** @import { Effect, TemplateNode } from '#client' */
5
6/**
7 * @typedef {{ effect: Effect, fragment: DocumentFragment }} Branch
8 */
9
10/**
11 * @template Key
12 */
13class BranchManager {
14	/** @type {TemplateNode} */
15	anchor;
16
17	/** @type {Map<Batch, Key>} */
18	#batches = new Map();
19
20	/**
21	 * Map of keys to effects that are currently rendered in the DOM.
22	 * These effects are visible and actively part of the document tree.
23	 * Example:
24	 * ```
25	 * {#if condition}
26	 * 	foo
27	 * {:else}
28	 * 	bar
29	 * {/if}
30	 * ```
31	 * Can result in the entries `true->Effect` and `false->Effect`
32	 * @type {Map<Key, Effect>}
33	 */
34	#onscreen = new Map();
35
36	/**
37	 * Similar to #onscreen with respect to the keys, but contains branches that are not yet
38	 * in the DOM, because their insertion is deferred.
39	 * @type {Map<Key, Branch>}
40	 */
41	#offscreen = new Map();
42
43	/**
44	 * Keys of effects that are currently outroing
45	 * @type {Set<Key>}
46	 */
47	#outroing = new Set();
48
49	/**
50	 * Whether to pause (i.e. outro) on change, or destroy immediately.
51	 * This is necessary for `<svelte:element>`
52	 */
53	#transition = true;
54
55	/**
56	 * @param {TemplateNode} anchor
57	 * @param {boolean} transition
58	 */
59	constructor(anchor, transition = true) {
60		this.anchor = anchor;
61		this.#transition = transition;
62	}
63
64	#commit = () => {
65		var batch = /** @type {Batch} */ (current_batch);
66
67		// if this batch was made obsolete, bail
68		if (!this.#batches.has(batch)) return;
69
70		var key = /** @type {Key} */ (this.#batches.get(batch));
71
72		var onscreen = this.#onscreen.get(key);
73
74		if (onscreen) {
75			// effect is already in the DOM — abort any current outro
76			resume_effect(onscreen);
77			this.#outroing.delete(key);
78		} else {
79			// effect is currently offscreen. put it in the DOM
80			var offscreen = this.#offscreen.get(key);
81
82			if (offscreen) {
83				this.#onscreen.set(key, offscreen.effect);
84				this.#offscreen.delete(key);
85
86				// remove the anchor...
87				/** @type {TemplateNode} */ (offscreen.fragment.lastChild).remove();
88
89				// ...and append the fragment
90				this.anchor.before(offscreen.fragment);
91				onscreen = offscreen.effect;
92			}
93		}
94
95		for (const [b, k] of this.#batches) {
96			this.#batches.delete(b);
97
98			if (b === batch) {
99				// keep values for newer batches
100				break;
101			}
102
103			const offscreen = this.#offscreen.get(k);
104
105			if (offscreen) {
106				// for older batches, destroy offscreen effects
107				// as they will never be committed
108				destroy_effect(offscreen.effect);
109				this.#offscreen.delete(k);
110			}
111		}
112
113		// outro/destroy all onscreen effects...
114		for (const [k, effect] of this.#onscreen) {
115			// ...except the one that was just committed
116			//    or those that are already outroing (else the transition is aborted and the effect destroyed right away)
117			if (k === key || this.#outroing.has(k)) continue;
118
119			const on_destroy = () => {
120				const keys = Array.from(this.#batches.values());
121
122				if (keys.includes(k)) {
123					// keep the effect offscreen, as another batch will need it
124					var fragment = document.createDocumentFragment();
125					move_effect(effect, fragment);
126
127					fragment.append(create_text()); // TODO can we avoid this?
128
129					this.#offscreen.set(k, { effect, fragment });
130				} else {
131					destroy_effect(effect);
132				}
133
134				this.#outroing.delete(k);
135				this.#onscreen.delete(k);
136			};
137
138			if (this.#transition || !onscreen) {
139				this.#outroing.add(k);
140				pause_effect(effect, on_destroy, false);
141			} else {
142				on_destroy();
143			}
144		}
145	};
146
147	/**
148	 * @param {Batch} batch
149	 */
150	#discard = (batch) => {
151		this.#batches.delete(batch);
152
153		const keys = Array.from(this.#batches.values());
154
155		for (const [k, branch] of this.#offscreen) {
156			if (!keys.includes(k)) {
157				destroy_effect(branch.effect);
158				this.#offscreen.delete(k);
159			}
160		}
161	};
162
163	/**
164	 *
165	 * @param {any} key
166	 * @param {null | ((target: TemplateNode) => void)} fn
167	 */
168	ensure(key, fn) {
169		var batch = /** @type {Batch} */ (current_batch);
170		var defer = should_defer_append();
171
172		if (fn && !this.#onscreen.has(key) && !this.#offscreen.has(key)) {
173			if (defer) {
174				var fragment = document.createDocumentFragment();
175				var target = create_text();
176
177				fragment.append(target);
178
179				this.#offscreen.set(key, {
180					effect: branch(() => fn(target)),
181					fragment
182				});
183			} else {
184				this.#onscreen.set(
185					key,
186					branch(() => fn(this.anchor))
187				);
188			}
189		}
190
191		this.#batches.set(batch, key);
192
193		if (defer) {
194			for (const [k, effect] of this.#onscreen) {
195				if (k === key) {
196					batch.skipped_effects.delete(effect);
197				} else {
198					batch.skipped_effects.add(effect);
199				}
200			}
201
202			for (const [k, branch] of this.#offscreen) {
203				if (k === key) {
204					batch.skipped_effects.delete(branch.effect);
205				} else {
206					batch.skipped_effects.add(branch.effect);
207				}
208			}
209
210			batch.oncommit(this.#commit);
211			batch.ondiscard(this.#discard);
212		} else {
213			if (hydrating) {
214				this.anchor = hydrate_node;
215			}
216
217			this.#commit();
218		}
219	}
220}
221
222/** @import { TemplateNode } from '#client' */
223
224// TODO reinstate https://github.com/sveltejs/svelte/pull/15250
225
226/**
227 * @param {TemplateNode} node
228 * @param {(branch: (fn: (anchor: Node) => void, flag?: boolean) => void) => void} fn
229 * @param {boolean} [elseif] True if this is an `{:else if ...}` block rather than an `{#if ...}`, as that affects which transitions are considered 'local'
230 * @returns {void}
231 */
232function if_block(node, fn, elseif = false) {
233	if (hydrating) {
234		hydrate_next();
235	}
236
237	var branches = new BranchManager(node);
238	var flags = elseif ? EFFECT_TRANSPARENT : 0;
239
240	/**
241	 * @param {boolean} condition,
242	 * @param {null | ((anchor: Node) => void)} fn
243	 */
244	function update_branch(condition, fn) {
245		if (hydrating) {
246			const is_else = read_hydration_instruction(node) === HYDRATION_START_ELSE;
247
248			if (condition === is_else) {
249				// Hydration mismatch: remove everything inside the anchor and start fresh.
250				// This could happen with `{#if browser}...{/if}`, for example
251				var anchor = skip_nodes();
252
253				set_hydrate_node(anchor);
254				branches.anchor = anchor;
255
256				set_hydrating(false);
257				branches.ensure(condition, fn);
258				set_hydrating(true);
259
260				return;
261			}
262		}
263
264		branches.ensure(condition, fn);
265	}
266
267	block(() => {
268		var has_branch = false;
269
270		fn((fn, flag = true) => {
271			has_branch = true;
272			update_branch(flag, fn);
273		});
274
275		if (!has_branch) {
276			update_branch(false, null);
277		}
278	}, flags);
279}
280
281/** @import { EachItem, EachOutroGroup, EachState, Effect, EffectNodes, MaybeSource, Source, TemplateNode, TransitionManager, Value } from '#client' */
282/** @import { Batch } from '../../reactivity/batch.js'; */
283
284// When making substantive changes to this file, validate them with the each block stress test:
285// https://svelte.dev/playground/1972b2cf46564476ad8c8c6405b23b7b
286// This test also exists in this repo, as `packages/svelte/tests/manual/each-stress-test`
287
288/**
289 * @param {any} _
290 * @param {number} i
291 */
292function index(_, i) {
293	return i;
294}
295
296/**
297 * Pause multiple effects simultaneously, and coordinate their
298 * subsequent destruction. Used in each blocks
299 * @param {EachState} state
300 * @param {Effect[]} to_destroy
301 * @param {null | Node} controlled_anchor
302 */
303function pause_effects(state, to_destroy, controlled_anchor) {
304	/** @type {TransitionManager[]} */
305	var transitions = [];
306	var length = to_destroy.length;
307
308	/** @type {EachOutroGroup} */
309	var group;
310	var remaining = to_destroy.length;
311
312	for (var i = 0; i < length; i++) {
313		let effect = to_destroy[i];
314
315		pause_effect(
316			effect,
317			() => {
318				if (group) {
319					group.pending.delete(effect);
320					group.done.add(effect);
321
322					if (group.pending.size === 0) {
323						var groups = /** @type {Set<EachOutroGroup>} */ (state.outrogroups);
324
325						destroy_effects(array_from(group.done));
326						groups.delete(group);
327
328						if (groups.size === 0) {
329							state.outrogroups = null;
330						}
331					}
332				} else {
333					remaining -= 1;
334				}
335			},
336			false
337		);
338	}
339
340	if (remaining === 0) {
341		// If we're in a controlled each block (i.e. the block is the only child of an
342		// element), and we are removing all items, _and_ there are no out transitions,
343		// we can use the fast path — emptying the element and replacing the anchor
344		var fast_path = transitions.length === 0 && controlled_anchor !== null;
345
346		if (fast_path) {
347			var anchor = /** @type {Element} */ (controlled_anchor);
348			var parent_node = /** @type {Element} */ (anchor.parentNode);
349
350			clear_text_content(parent_node);
351			parent_node.append(anchor);
352
353			state.items.clear();
354		}
355
356		destroy_effects(to_destroy, !fast_path);
357	} else {
358		group = {
359			pending: new Set(to_destroy),
360			done: new Set()
361		};
362
363		(state.outrogroups ??= new Set()).add(group);
364	}
365}
366
367/**
368 * @param {Effect[]} to_destroy
369 * @param {boolean} remove_dom
370 */
371function destroy_effects(to_destroy, remove_dom = true) {
372	// TODO only destroy effects if no pending batch needs them. otherwise,
373	// just re-add the `EFFECT_OFFSCREEN` flag
374	for (var i = 0; i < to_destroy.length; i++) {
375		destroy_effect(to_destroy[i], remove_dom);
376	}
377}
378
379/** @type {TemplateNode} */
380var offscreen_anchor;
381
382/**
383 * @template V
384 * @param {Element | Comment} node The next sibling node, or the parent node if this is a 'controlled' block
385 * @param {number} flags
386 * @param {() => V[]} get_collection
387 * @param {(value: V, index: number) => any} get_key
388 * @param {(anchor: Node, item: MaybeSource<V>, index: MaybeSource<number>) => void} render_fn
389 * @param {null | ((anchor: Node) => void)} fallback_fn
390 * @returns {void}
391 */
392function each(node, flags, get_collection, get_key, render_fn, fallback_fn = null) {
393	var anchor = node;
394
395	/** @type {Map<any, EachItem>} */
396	var items = new Map();
397
398	var is_controlled = (flags & EACH_IS_CONTROLLED) !== 0;
399
400	if (is_controlled) {
401		var parent_node = /** @type {Element} */ (node);
402
403		anchor = hydrating
404			? set_hydrate_node(get_first_child(parent_node))
405			: parent_node.appendChild(create_text());
406	}
407
408	if (hydrating) {
409		hydrate_next();
410	}
411
412	/** @type {Effect | null} */
413	var fallback = null;
414
415	// TODO: ideally we could use derived for runes mode but because of the ability
416	// to use a store which can be mutated, we can't do that here as mutating a store
417	// will still result in the collection array being the same from the store
418	var each_array = derived_safe_equal(() => {
419		var collection = get_collection();
420
421		return is_array(collection) ? collection : collection == null ? [] : array_from(collection);
422	});
423
424	/** @type {V[]} */
425	var array;
426
427	var first_run = true;
428
429	function commit() {
430		state.fallback = fallback;
431		reconcile(state, array, anchor, flags, get_key);
432
433		if (fallback !== null) {
434			if (array.length === 0) {
435				if ((fallback.f & EFFECT_OFFSCREEN) === 0) {
436					resume_effect(fallback);
437				} else {
438					fallback.f ^= EFFECT_OFFSCREEN;
439					move(fallback, null, anchor);
440				}
441			} else {
442				pause_effect(fallback, () => {
443					// TODO only null out if no pending batch needs it,
444					// otherwise re-add `fallback.fragment` and move the
445					// effect into it
446					fallback = null;
447				});
448			}
449		}
450	}
451
452	var effect = block(() => {
453		array = /** @type {V[]} */ (get$1(each_array));
454		var length = array.length;
455
456		/** `true` if there was a hydration mismatch. Needs to be a `let` or else it isn't treeshaken out */
457		let mismatch = false;
458
459		if (hydrating) {
460			var is_else = read_hydration_instruction(anchor) === HYDRATION_START_ELSE;
461
462			if (is_else !== (length === 0)) {
463				// hydration mismatch — remove the server-rendered DOM and start over
464				anchor = skip_nodes();
465
466				set_hydrate_node(anchor);
467				set_hydrating(false);
468				mismatch = true;
469			}
470		}
471
472		var keys = new Set();
473		var batch = /** @type {Batch} */ (current_batch);
474		var defer = should_defer_append();
475
476		for (var index = 0; index < length; index += 1) {
477			if (
478				hydrating &&
479				hydrate_node.nodeType === COMMENT_NODE &&
480				/** @type {Comment} */ (hydrate_node).data === HYDRATION_END
481			) {
482				// The server rendered fewer items than expected,
483				// so break out and continue appending non-hydrated items
484				anchor = /** @type {Comment} */ (hydrate_node);
485				mismatch = true;
486				set_hydrating(false);
487			}
488
489			var value = array[index];
490			var key = get_key(value, index);
491
492			var item = first_run ? null : items.get(key);
493
494			if (item) {
495				// update before reconciliation, to trigger any async updates
496				if (item.v) internal_set(item.v, value);
497				if (item.i) internal_set(item.i, index);
498
499				if (defer) {
500					batch.skipped_effects.delete(item.e);
501				}
502			} else {
503				item = create_item(
504					items,
505					first_run ? anchor : (offscreen_anchor ??= create_text()),
506					value,
507					key,
508					index,
509					render_fn,
510					flags,
511					get_collection
512				);
513
514				if (!first_run) {
515					item.e.f |= EFFECT_OFFSCREEN;
516				}
517
518				items.set(key, item);
519			}
520
521			keys.add(key);
522		}
523
524		if (length === 0 && fallback_fn && !fallback) {
525			if (first_run) {
526				fallback = branch(() => fallback_fn(anchor));
527			} else {
528				fallback = branch(() => fallback_fn((offscreen_anchor ??= create_text())));
529				fallback.f |= EFFECT_OFFSCREEN;
530			}
531		}
532
533		// remove excess nodes
534		if (hydrating && length > 0) {
535			set_hydrate_node(skip_nodes());
536		}
537
538		if (!first_run) {
539			if (defer) {
540				for (const [key, item] of items) {
541					if (!keys.has(key)) {
542						batch.skipped_effects.add(item.e);
543					}
544				}
545
546				batch.oncommit(commit);
547				batch.ondiscard(() => {
548					// TODO presumably we need to do something here?
549				});
550			} else {
551				commit();
552			}
553		}
554
555		if (mismatch) {
556			// continue in hydration mode
557			set_hydrating(true);
558		}
559
560		// When we mount the each block for the first time, the collection won't be
561		// connected to this effect as the effect hasn't finished running yet and its deps
562		// won't be assigned. However, it's possible that when reconciling the each block
563		// that a mutation occurred and it's made the collection MAYBE_DIRTY, so reading the
564		// collection again can provide consistency to the reactive graph again as the deriveds
565		// will now be `CLEAN`.
566		get$1(each_array);
567	});
568
569	/** @type {EachState} */
570	var state = { effect, items, outrogroups: null, fallback };
571
572	first_run = false;
573
574	if (hydrating) {
575		anchor = hydrate_node;
576	}
577}
578
579/**
580 * Add, remove, or reorder items output by an each block as its input changes
581 * @template V
582 * @param {EachState} state
583 * @param {Array<V>} array
584 * @param {Element | Comment | Text} anchor
585 * @param {number} flags
586 * @param {(value: V, index: number) => any} get_key
587 * @returns {void}
588 */
589function reconcile(state, array, anchor, flags, get_key) {
590	var is_animated = (flags & EACH_IS_ANIMATED) !== 0;
591
592	var length = array.length;
593	var items = state.items;
594	var current = state.effect.first;
595
596	/** @type {undefined | Set<Effect>} */
597	var seen;
598
599	/** @type {Effect | null} */
600	var prev = null;
601
602	/** @type {undefined | Set<Effect>} */
603	var to_animate;
604
605	/** @type {Effect[]} */
606	var matched = [];
607
608	/** @type {Effect[]} */
609	var stashed = [];
610
611	/** @type {V} */
612	var value;
613
614	/** @type {any} */
615	var key;
616
617	/** @type {Effect | undefined} */
618	var effect;
619
620	/** @type {number} */
621	var i;
622
623	if (is_animated) {
624		for (i = 0; i < length; i += 1) {
625			value = array[i];
626			key = get_key(value, i);
627			effect = /** @type {EachItem} */ (items.get(key)).e;
628
629			// offscreen == coming in now, no animation in that case,
630			// else this would happen https://github.com/sveltejs/svelte/issues/17181
631			if ((effect.f & EFFECT_OFFSCREEN) === 0) {
632				effect.nodes?.a?.measure();
633				(to_animate ??= new Set()).add(effect);
634			}
635		}
636	}
637
638	for (i = 0; i < length; i += 1) {
639		value = array[i];
640		key = get_key(value, i);
641
642		effect = /** @type {EachItem} */ (items.get(key)).e;
643
644		if (state.outrogroups !== null) {
645			for (const group of state.outrogroups) {
646				group.pending.delete(effect);
647				group.done.delete(effect);
648			}
649		}
650
651		if ((effect.f & EFFECT_OFFSCREEN) !== 0) {
652			effect.f ^= EFFECT_OFFSCREEN;
653
654			if (effect === current) {
655				move(effect, null, anchor);
656			} else {
657				var next = prev ? prev.next : current;
658
659				if (effect === state.effect.last) {
660					state.effect.last = effect.prev;
661				}
662
663				if (effect.prev) effect.prev.next = effect.next;
664				if (effect.next) effect.next.prev = effect.prev;
665				link(state, prev, effect);
666				link(state, effect, next);
667
668				move(effect, next, anchor);
669				prev = effect;
670
671				matched = [];
672				stashed = [];
673
674				current = prev.next;
675				continue;
676			}
677		}
678
679		if ((effect.f & INERT) !== 0) {
680			resume_effect(effect);
681			if (is_animated) {
682				effect.nodes?.a?.unfix();
683				(to_animate ??= new Set()).delete(effect);
684			}
685		}
686
687		if (effect !== current) {
688			if (seen !== undefined && seen.has(effect)) {
689				if (matched.length < stashed.length) {
690					// more efficient to move later items to the front
691					var start = stashed[0];
692					var j;
693
694					prev = start.prev;
695
696					var a = matched[0];
697					var b = matched[matched.length - 1];
698
699					for (j = 0; j < matched.length; j += 1) {
700						move(matched[j], start, anchor);
701					}
702
703					for (j = 0; j < stashed.length; j += 1) {
704						seen.delete(stashed[j]);
705					}
706
707					link(state, a.prev, b.next);
708					link(state, prev, a);
709					link(state, b, start);
710
711					current = start;
712					prev = b;
713					i -= 1;
714
715					matched = [];
716					stashed = [];
717				} else {
718					// more efficient to move earlier items to the back
719					seen.delete(effect);
720					move(effect, current, anchor);
721
722					link(state, effect.prev, effect.next);
723					link(state, effect, prev === null ? state.effect.first : prev.next);
724					link(state, prev, effect);
725
726					prev = effect;
727				}
728
729				continue;
730			}
731
732			matched = [];
733			stashed = [];
734
735			while (current !== null && current !== effect) {
736				(seen ??= new Set()).add(current);
737				stashed.push(current);
738				current = current.next;
739			}
740
741			if (current === null) {
742				continue;
743			}
744		}
745
746		if ((effect.f & EFFECT_OFFSCREEN) === 0) {
747			matched.push(effect);
748		}
749
750		prev = effect;
751		current = effect.next;
752	}
753
754	if (state.outrogroups !== null) {
755		for (const group of state.outrogroups) {
756			if (group.pending.size === 0) {
757				destroy_effects(array_from(group.done));
758				state.outrogroups?.delete(group);
759			}
760		}
761
762		if (state.outrogroups.size === 0) {
763			state.outrogroups = null;
764		}
765	}
766
767	if (current !== null || seen !== undefined) {
768		/** @type {Effect[]} */
769		var to_destroy = [];
770
771		if (seen !== undefined) {
772			for (effect of seen) {
773				if ((effect.f & INERT) === 0) {
774					to_destroy.push(effect);
775				}
776			}
777		}
778
779		while (current !== null) {
780			// If the each block isn't inert, then inert effects are currently outroing and will be removed once the transition is finished
781			if ((current.f & INERT) === 0 && current !== state.fallback) {
782				to_destroy.push(current);
783			}
784
785			current = current.next;
786		}
787
788		var destroy_length = to_destroy.length;
789
790		if (destroy_length > 0) {
791			var controlled_anchor = (flags & EACH_IS_CONTROLLED) !== 0 && length === 0 ? anchor : null;
792
793			if (is_animated) {
794				for (i = 0; i < destroy_length; i += 1) {
795					to_destroy[i].nodes?.a?.measure();
796				}
797
798				for (i = 0; i < destroy_length; i += 1) {
799					to_destroy[i].nodes?.a?.fix();
800				}
801			}
802
803			pause_effects(state, to_destroy, controlled_anchor);
804		}
805	}
806
807	if (is_animated) {
808		queue_micro_task(() => {
809			if (to_animate === undefined) return;
810			for (effect of to_animate) {
811				effect.nodes?.a?.apply();
812			}
813		});
814	}
815}
816
817/**
818 * @template V
819 * @param {Map<any, EachItem>} items
820 * @param {Node} anchor
821 * @param {V} value
822 * @param {unknown} key
823 * @param {number} index
824 * @param {(anchor: Node, item: V | Source<V>, index: number | Value<number>, collection: () => V[]) => void} render_fn
825 * @param {number} flags
826 * @param {() => V[]} get_collection
827 * @returns {EachItem}
828 */
829function create_item(items, anchor, value, key, index, render_fn, flags, get_collection) {
830	var v =
831		(flags & EACH_ITEM_REACTIVE) !== 0
832			? (flags & EACH_ITEM_IMMUTABLE) === 0
833				? mutable_source(value, false, false)
834				: source(value)
835			: null;
836
837	var i = (flags & EACH_INDEX_REACTIVE) !== 0 ? source(index) : null;
838
839	if (DEV && v) {
840		// For tracing purposes, we need to link the source signal we create with the
841		// collection + index so that tracing works as intended
842		v.trace = () => {
843			// eslint-disable-next-line @typescript-eslint/no-unused-expressions
844			get_collection()[i?.v ?? index];
845		};
846	}
847
848	return {
849		v,
850		i,
851		e: branch(() => {
852			render_fn(anchor, v ?? value, i ?? index, get_collection);
853
854			return () => {
855				items.delete(key);
856			};
857		})
858	};
859}
860
861/**
862 * @param {Effect} effect
863 * @param {Effect | null} next
864 * @param {Text | Element | Comment} anchor
865 */
866function move(effect, next, anchor) {
867	if (!effect.nodes) return;
868
869	var node = effect.nodes.start;
870	var end = effect.nodes.end;
871
872	var dest =
873		next && (next.f & EFFECT_OFFSCREEN) === 0
874			? /** @type {EffectNodes} */ (next.nodes).start
875			: anchor;
876
877	while (node !== null) {
878		var next_node = /** @type {TemplateNode} */ (get_next_sibling(node));
879		dest.before(node);
880
881		if (node === end) {
882			return;
883		}
884
885		node = next_node;
886	}
887}
888
889/**
890 * @param {EachState} state
891 * @param {Effect | null} prev
892 * @param {Effect | null} next
893 */
894function link(state, prev, next) {
895	if (prev === null) {
896		state.effect.first = next;
897	} else {
898		prev.next = next;
899	}
900
901	if (next === null) {
902		state.effect.last = prev;
903	} else {
904		next.prev = prev;
905	}
906}
907
908/**
909 * @param {Comment} anchor
910 * @param {Record<string, any>} $$props
911 * @param {string} name
912 * @param {Record<string, unknown>} slot_props
913 * @param {null | ((anchor: Comment) => void)} fallback_fn
914 */
915function slot(anchor, $$props, name, slot_props, fallback_fn) {
916	if (hydrating) {
917		hydrate_next();
918	}
919
920	var slot_fn = $$props.$$slots?.[name];
921	// Interop: Can use snippets to fill slots
vendor: 4,364 bytes, lines 922-1103
922	var is_interop = false;
923	if (slot_fn === true) {
924		slot_fn = $$props[name === 'default' ? 'children' : name];
925		is_interop = true;
926	}
927
928	if (slot_fn === undefined) ; else {
929		slot_fn(anchor, is_interop ? () => slot_props : slot_props);
930	}
931}
932
933/** @import { Effect } from '#client' */
934
935// TODO in 6.0 or 7.0, when we remove legacy mode, we can simplify this by
936// getting rid of the block/branch stuff and just letting the effect rip.
937// see https://github.com/sveltejs/svelte/pull/15962
938
939/**
940 * @param {Element} node
941 * @param {() => (node: Element) => void} get_fn
942 */
943function attach(node, get_fn) {
944	/** @type {false | undefined | ((node: Element) => void)} */
945	var fn = undefined;
946
947	/** @type {Effect | null} */
948	var e;
949
950	managed(() => {
951		if (fn !== (fn = get_fn())) {
952			if (e) {
953				destroy_effect(e);
954				e = null;
955			}
956
957			if (fn) {
958				e = branch(() => {
959					effect(() => /** @type {(node: Element) => void} */ (fn)(node));
960				});
961			}
962		}
963	});
964}
965
966function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx$1(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
967
968/**
969 * Small wrapper around clsx to preserve Svelte's (weird) handling of falsy values.
970 * TODO Svelte 6 revisit this, and likely turn all falsy values into the empty string (what clsx also does)
971 * @param  {any} value
972 */
973function clsx(value) {
974	if (typeof value === 'object') {
975		return clsx$1(value);
976	} else {
977		return value ?? '';
978	}
979}
980
981const whitespace = [...' \t\n\r\f\u00a0\u000b\ufeff'];
982
983/**
984 * @param {any} value
985 * @param {string | null} [hash]
986 * @param {Record<string, boolean>} [directives]
987 * @returns {string | null}
988 */
989function to_class(value, hash, directives) {
990	var classname = value == null ? '' : '' + value;
991
992	if (hash) {
993		classname = classname ? classname + ' ' + hash : hash;
994	}
995
996	if (directives) {
997		for (var key in directives) {
998			if (directives[key]) {
999				classname = classname ? classname + ' ' + key : key;
1000			} else if (classname.length) {
1001				var len = key.length;
1002				var a = 0;
1003
1004				while ((a = classname.indexOf(key, a)) >= 0) {
1005					var b = a + len;
1006
1007					if (
1008						(a === 0 || whitespace.includes(classname[a - 1])) &&
1009						(b === classname.length || whitespace.includes(classname[b]))
1010					) {
1011						classname = (a === 0 ? '' : classname.substring(0, a)) + classname.substring(b + 1);
1012					} else {
1013						a = b;
1014					}
1015				}
1016			}
1017		}
1018	}
1019
1020	return classname === '' ? null : classname;
1021}
1022
1023/**
1024 *
1025 * @param {Record<string,any>} styles
1026 * @param {boolean} important
1027 */
1028function append_styles(styles, important = false) {
1029	var separator = important ? ' !important;' : ';';
1030	var css = '';
1031
1032	for (var key in styles) {
1033		var value = styles[key];
1034		if (value != null && value !== '') {
1035			css += ' ' + key + ': ' + value + separator;
1036		}
1037	}
1038
1039	return css;
1040}
1041
1042/**
1043 * @param {string} name
1044 * @returns {string}
1045 */
1046function to_css_name(name) {
1047	if (name[0] !== '-' || name[1] !== '-') {
1048		return name.toLowerCase();
1049	}
1050	return name;
1051}
1052
1053/**
1054 * @param {any} value
1055 * @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [styles]
1056 * @returns {string | null}
1057 */
1058function to_style(value, styles) {
1059	if (styles) {
1060		var new_style = '';
1061
1062		/** @type {Record<string,any> | undefined} */
1063		var normal_styles;
1064
1065		/** @type {Record<string,any> | undefined} */
1066		var important_styles;
1067
1068		if (Array.isArray(styles)) {
1069			normal_styles = styles[0];
1070			important_styles = styles[1];
1071		} else {
1072			normal_styles = styles;
1073		}
1074
1075		if (value) {
1076			value = String(value)
1077				.replaceAll(/\s*\/\*.*?\*\/\s*/g, '')
1078				.trim();
1079
1080			/** @type {boolean | '"' | "'"} */
1081			var in_str = false;
1082			var in_apo = 0;
1083			var in_comment = false;
1084
1085			var reserved_names = [];
1086
1087			if (normal_styles) {
1088				reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
1089			}
1090			if (important_styles) {
1091				reserved_names.push(...Object.keys(important_styles).map(to_css_name));
1092			}
1093
1094			var start_index = 0;
1095			var name_index = -1;
1096
1097			const len = value.length;
1098			for (var i = 0; i < len; i++) {
1099				var c = value[i];
1100
1101				if (in_comment) {
1102					if (c === '/' && value[i - 1] === '*') {
1103						in_comment = false;
1104					}
1105				} else if (in_str) {
1106					if (in_str === c) {
1107						in_str = false;
1108					}
1109				} else if (c === '/' && value[i + 1] === '*') {
1110					in_comment = true;
1111				} else if (c === '"' || c === "'") {
1112					in_str = c;
1113				} else if (c === '(') {
1114					in_apo++;
1115				} else if (c === ')') {
1116					in_apo--;
1117				}
1118
1119				if (!in_comment && in_str === false && in_apo === 0) {
1120					if (c === ':' && name_index === -1) {
1121						name_index = i;
1122					} else if (c === ';' || i === len - 1) {
1123						if (name_index !== -1) {
1124							var name = to_css_name(value.substring(start_index, name_index).trim());
1125
1126							if (!reserved_names.includes(name)) {
1127								if (c !== ';') {
1128									i++;
1129								}
1130
1131								var property = value.substring(start_index, i).trim();
1132								new_style += ' ' + property + ';';
1133							}
1134						}
1135
1136						start_index = i + 1;
1137						name_index = -1;
1138					}
1139				}
1140			}
1141		}
1142
1143		if (normal_styles) {
1144			new_style += append_styles(normal_styles);
1145		}
1146
1147		if (important_styles) {
1148			new_style += append_styles(important_styles, true);
1149		}
1150
1151		new_style = new_style.trim();
1152		return new_style === '' ? null : new_style;
1153	}
1154
1155	return value == null ? null : String(value);
1156}
1157
1158/**
1159 * @param {Element} dom
1160 * @param {boolean | number} is_html
1161 * @param {string | null} value
1162 * @param {string} [hash]
1163 * @param {Record<string, any>} [prev_classes]
1164 * @param {Record<string, any>} [next_classes]
1165 * @returns {Record<string, boolean> | undefined}
1166 */
1167function set_class(dom, is_html, value, hash, prev_classes, next_classes) {
1168	// @ts-expect-error need to add __className to patched prototype
1169	var prev = dom.__className;
1170
1171	if (
1172		hydrating ||
1173		prev !== value ||
1174		prev === undefined // for edge case of `class={undefined}`
1175	) {
1176		var next_class_name = to_class(value, hash, next_classes);
1177
1178		if (!hydrating || next_class_name !== dom.getAttribute('class')) {
1179			// Removing the attribute when the value is only an empty string causes
1180			// performance issues vs simply making the className an empty string. So
1181			// we should only remove the class if the value is nullish
1182			// and there no hash/directives :
1183			if (next_class_name == null) {
1184				dom.removeAttribute('class');
1185			} else if (is_html) {
1186				dom.className = next_class_name;
1187			} else {
1188				dom.setAttribute('class', next_class_name);
1189			}
1190		}
1191
1192		// @ts-expect-error need to add __className to patched prototype
1193		dom.__className = value;
1194	} else if (next_classes && prev_classes !== next_classes) {
1195		for (var key in next_classes) {
1196			var is_present = !!next_classes[key];
1197
1198			if (prev_classes == null || is_present !== !!prev_classes[key]) {
1199				dom.classList.toggle(key, is_present);
1200			}
1201		}
1202	}
1203
1204	return next_classes;
1205}
1206
1207/**
1208 * @param {Element & ElementCSSInlineStyle} dom
1209 * @param {Record<string, any>} prev
1210 * @param {Record<string, any>} next
1211 * @param {string} [priority]
1212 */
1213function update_styles(dom, prev = {}, next, priority) {
1214	for (var key in next) {
1215		var value = next[key];
1216
1217		if (prev[key] !== value) {
1218			if (next[key] == null) {
1219				dom.style.removeProperty(key);
1220			} else {
1221				dom.style.setProperty(key, value, priority);
1222			}
1223		}
1224	}
1225}
1226
1227/**
1228 * @param {Element & ElementCSSInlineStyle} dom
1229 * @param {string | null} value
1230 * @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [prev_styles]
1231 * @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [next_styles]
1232 */
1233function set_style(dom, value, prev_styles, next_styles) {
1234	// @ts-expect-error
1235	var prev = dom.__style;
1236
1237	if (hydrating || prev !== value) {
1238		var next_style_attr = to_style(value, next_styles);
1239
1240		if (!hydrating || next_style_attr !== dom.getAttribute('style')) {
1241			if (next_style_attr == null) {
1242				dom.removeAttribute('style');
1243			} else {
1244				dom.style.cssText = next_style_attr;
1245			}
1246		}
1247
1248		// @ts-expect-error
1249		dom.__style = value;
1250	} else if (next_styles) {
1251		if (Array.isArray(next_styles)) {
1252			update_styles(dom, prev_styles?.[0], next_styles[0]);
1253			update_styles(dom, prev_styles?.[1], next_styles[1], 'important');
1254		} else {
1255			update_styles(dom, prev_styles, next_styles);
1256		}
1257	}
1258
1259	return next_styles;
1260}
1261
1262/**
1263 * Selects the correct option(s) (depending on whether this is a multiple select)
1264 * @template V
1265 * @param {HTMLSelectElement} select
1266 * @param {V} value
1267 * @param {boolean} mounting
1268 */
1269function select_option(select, value, mounting = false) {
1270	if (select.multiple) {
1271		// If value is null or undefined, keep the selection as is
1272		if (value == undefined) {
1273			return;
1274		}
1275
1276		// If not an array, warn and keep the selection as is
1277		if (!is_array(value)) {
1278			return select_multiple_invalid_value();
1279		}
1280
1281		// Otherwise, update the selection
1282		for (var option of select.options) {
1283			option.selected = value.includes(get_option_value(option));
1284		}
1285
1286		return;
1287	}
1288
1289	for (option of select.options) {
1290		var option_value = get_option_value(option);
1291		if (is(option_value, value)) {
1292			option.selected = true;
1293			return;
1294		}
1295	}
1296
1297	if (!mounting || value !== undefined) {
1298		select.selectedIndex = -1; // no option should be selected
1299	}
1300}
1301
1302/**
1303 * Selects the correct option(s) if `value` is given,
1304 * and then sets up a mutation observer to sync the
1305 * current selection to the dom when it changes. Such
1306 * changes could for example occur when options are
1307 * inside an `#each` block.
1308 * @param {HTMLSelectElement} select
1309 */
1310function init_select(select) {
1311	var observer = new MutationObserver(() => {
1312		// @ts-ignore
1313		select_option(select, select.__value);
1314		// Deliberately don't update the potential binding value,
1315		// the model should be preserved unless explicitly changed
1316	});
1317
1318	observer.observe(select, {
1319		// Listen to option element changes
1320		childList: true,
1321		subtree: true, // because of <optgroup>
1322		// Listen to option element value attribute changes
1323		// (doesn't get notified of select value changes,
1324		// because that property is not reflected as an attribute)
1325		attributes: true,
1326		attributeFilter: ['value']
1327	});
1328
1329	teardown(() => {
1330		observer.disconnect();
1331	});
1332}
1333
1334/**
1335 * @param {HTMLSelectElement} select
1336 * @param {() => unknown} get
1337 * @param {(value: unknown) => void} set
1338 * @returns {void}
1339 */
1340function bind_select_value(select, get, set = get) {
1341	var batches = new WeakSet();
1342	var mounting = true;
1343
1344	listen_to_event_and_reset_event(select, 'change', (is_reset) => {
1345		var query = is_reset ? '[selected]' : ':checked';
1346		/** @type {unknown} */
1347		var value;
1348
1349		if (select.multiple) {
1350			value = [].map.call(select.querySelectorAll(query), get_option_value);
1351		} else {
1352			/** @type {HTMLOptionElement | null} */
1353			var selected_option =
1354				select.querySelector(query) ??
1355				// will fall back to first non-disabled option if no option is selected
1356				select.querySelector('option:not([disabled])');
1357			value = selected_option && get_option_value(selected_option);
1358		}
1359
1360		set(value);
1361
1362		if (current_batch !== null) {
1363			batches.add(current_batch);
1364		}
1365	});
1366
1367	// Needs to be an effect, not a render_effect, so that in case of each loops the logic runs after the each block has updated
1368	effect(() => {
1369		var value = get();
1370
1371		if (select === document.activeElement) {
1372			// we need both, because in non-async mode, render effects run before previous_batch is set
1373			var batch = /** @type {Batch} */ (previous_batch ?? current_batch);
1374
1375			// Don't update the <select> if it is focused. We can get here if, for example,
1376			// an update is deferred because of async work depending on the select:
1377			//
1378			// <select bind:value={selected}>...</select>
1379			// <p>{await find(selected)}</p>
1380			if (batches.has(batch)) {
1381				return;
1382			}
1383		}
1384
1385		select_option(select, value, mounting);
1386
1387		// Mounting and value undefined -> take selection from dom
1388		if (mounting && value === undefined) {
1389			/** @type {HTMLOptionElement | null} */
1390			var selected_option = select.querySelector(':checked');
1391			if (selected_option !== null) {
1392				value = get_option_value(selected_option);
1393				set(value);
1394			}
1395		}
1396
1397		// @ts-ignore
1398		select.__value = value;
1399		mounting = false;
1400	});
1401
1402	init_select(select);
1403}
1404
1405/** @param {HTMLOptionElement} option */
1406function get_option_value(option) {
1407	// __value only exists if the <option> has a value attribute
1408	if ('__value' in option) {
1409		return option.__value;
1410	} else {
1411		return option.value;
1412	}
1413}
1414
1415/** @import { Effect } from '#client' */
1416
1417const CLASS = Symbol('class');
1418const STYLE = Symbol('style');
1419
1420const IS_CUSTOM_ELEMENT = Symbol('is custom element');
1421const IS_HTML = Symbol('is html');
1422
1423/**
1424 * The value/checked attribute in the template actually corresponds to the defaultValue property, so we need
1425 * to remove it upon hydration to avoid a bug when someone resets the form value.
1426 * @param {HTMLInputElement} input
1427 * @returns {void}
1428 */
1429function remove_input_defaults(input) {
1430	if (!hydrating) return;
1431
1432	var already_removed = false;
1433
1434	// We try and remove the default attributes later, rather than sync during hydration.
1435	// Doing it sync during hydration has a negative impact on performance, but deferring the
1436	// work in an idle task alleviates this greatly. If a form reset event comes in before
1437	// the idle callback, then we ensure the input defaults are cleared just before.
1438	var remove_defaults = () => {
1439		if (already_removed) return;
1440		already_removed = true;
1441
1442		// Remove the attributes but preserve the values
1443		if (input.hasAttribute('value')) {
1444			var value = input.value;
1445			set_attribute(input, 'value', null);
1446			input.value = value;
1447		}
1448
1449		if (input.hasAttribute('checked')) {
1450			var checked = input.checked;
1451			set_attribute(input, 'checked', null);
1452			input.checked = checked;
1453		}
1454	};
1455
1456	// @ts-expect-error
1457	input.__on_r = remove_defaults;
1458	queue_micro_task(remove_defaults);
1459	add_form_reset_listener();
1460}
1461
1462/**
1463 * @param {Element} element
1464 * @param {any} value
1465 */
1466function set_value(element, value) {
1467	var attributes = get_attributes(element);
1468
1469	if (
1470		attributes.value ===
1471			(attributes.value =
1472				// treat null and undefined the same for the initial value
1473				value ?? undefined) ||
1474		// @ts-expect-error
1475		// `progress` elements always need their value set when it's `0`
1476		(element.value === value && (value !== 0 || element.nodeName !== 'PROGRESS'))
1477	) {
1478		return;
1479	}
1480
1481	// @ts-expect-error
1482	element.value = value ?? '';
1483}
1484
1485/**
1486 * @param {Element} element
1487 * @param {boolean} checked
1488 */
1489function set_checked(element, checked) {
1490	var attributes = get_attributes(element);
1491
1492	if (
1493		attributes.checked ===
1494		(attributes.checked =
1495			// treat null and undefined the same for the initial value
1496			checked ?? undefined)
1497	) {
1498		return;
1499	}
1500
1501	// @ts-expect-error
1502	element.checked = checked;
1503}
1504
1505/**
1506 * Sets the `selected` attribute on an `option` element.
1507 * Not set through the property because that doesn't reflect to the DOM,
1508 * which means it wouldn't be taken into account when a form is reset.
1509 * @param {HTMLOptionElement} element
1510 * @param {boolean} selected
1511 */
1512function set_selected(element, selected) {
1513	if (selected) {
1514		// The selected option could've changed via user selection, and
1515		// setting the value without this check would set it back.
1516		if (!element.hasAttribute('selected')) {
1517			element.setAttribute('selected', '');
1518		}
1519	} else {
1520		element.removeAttribute('selected');
1521	}
1522}
1523
1524/**
1525 * @param {Element} element
1526 * @param {string} attribute
1527 * @param {string | null} value
1528 * @param {boolean} [skip_warning]
1529 */
1530function set_attribute(element, attribute, value, skip_warning) {
1531	var attributes = get_attributes(element);
1532
1533	if (hydrating) {
1534		attributes[attribute] = element.getAttribute(attribute);
1535
1536		if (
1537			attribute === 'src' ||
1538			attribute === 'srcset' ||
1539			(attribute === 'href' && element.nodeName === 'LINK')
1540		) {
1541			if (!skip_warning) {
1542				check_src_in_dev_hydration(element, attribute, value ?? '');
1543			}
1544
1545			// If we reset these attributes, they would result in another network request, which we want to avoid.
1546			// We assume they are the same between client and server as checking if they are equal is expensive
1547			// (we can't just compare the strings as they can be different between client and server but result in the
1548			// same url, so we would need to create hidden anchor elements to compare them)
1549			return;
1550		}
1551	}
1552
1553	if (attributes[attribute] === (attributes[attribute] = value)) return;
1554
1555	if (attribute === 'loading') {
1556		// @ts-expect-error
1557		element[LOADING_ATTR_SYMBOL] = value;
1558	}
1559
1560	if (value == null) {
1561		element.removeAttribute(attribute);
1562	} else if (typeof value !== 'string' && get_setters(element).includes(attribute)) {
1563		// @ts-ignore
1564		element[attribute] = value;
1565	} else {
1566		element.setAttribute(attribute, value);
1567	}
1568}
1569
1570/**
1571 * Spreads attributes onto a DOM element, taking into account the currently set attributes
1572 * @param {Element & ElementCSSInlineStyle} element
1573 * @param {Record<string | symbol, any> | undefined} prev
1574 * @param {Record<string | symbol, any>} next New attributes - this function mutates this object
1575 * @param {string} [css_hash]
1576 * @param {boolean} [should_remove_defaults]
1577 * @param {boolean} [skip_warning]
1578 * @returns {Record<string, any>}
1579 */
1580function set_attributes(
1581	element,
1582	prev,
1583	next,
1584	css_hash,
1585	should_remove_defaults = false,
1586	skip_warning = false
1587) {
1588	if (hydrating && should_remove_defaults && element.tagName === 'INPUT') {
1589		var input = /** @type {HTMLInputElement} */ (element);
1590		var attribute = input.type === 'checkbox' ? 'defaultChecked' : 'defaultValue';
1591
1592		if (!(attribute in next)) {
1593			remove_input_defaults(input);
1594		}
1595	}
1596
1597	var attributes = get_attributes(element);
1598
1599	var is_custom_element = attributes[IS_CUSTOM_ELEMENT];
1600	var preserve_attribute_case = !attributes[IS_HTML];
1601
1602	// If we're hydrating but the custom element is from Svelte, and it already scaffolded,
1603	// then it might run block logic in hydration mode, which we have to prevent.
1604	let is_hydrating_custom_element = hydrating && is_custom_element;
1605	if (is_hydrating_custom_element) {
1606		set_hydrating(false);
1607	}
1608
1609	var current = prev || {};
1610	var is_option_element = element.tagName === 'OPTION';
1611
1612	for (var key in prev) {
1613		if (!(key in next)) {
1614			next[key] = null;
1615		}
1616	}
1617
1618	if (next.class) {
1619		next.class = clsx(next.class);
1620	} else if (css_hash || next[CLASS]) {
1621		next.class = null; /* force call to set_class() */
1622	}
1623
1624	if (next[STYLE]) {
1625		next.style ??= null; /* force call to set_style() */
1626	}
1627
1628	var setters = get_setters(element);
1629
1630	// since key is captured we use const
1631	for (const key in next) {
1632		// let instead of var because referenced in a closure
1633		let value = next[key];
1634
1635		// Up here because we want to do this for the initial value, too, even if it's undefined,
1636		// and this wouldn't be reached in case of undefined because of the equality check below
1637		if (is_option_element && key === 'value' && value == null) {
1638			// The <option> element is a special case because removing the value attribute means
1639			// the value is set to the text content of the option element, and setting the value
1640			// to null or undefined means the value is set to the string "null" or "undefined".
1641			// To align with how we handle this case in non-spread-scenarios, this logic is needed.
1642			// There's a super-edge-case bug here that is left in in favor of smaller code size:
1643			// Because of the "set missing props to null" logic above, we can't differentiate
1644			// between a missing value and an explicitly set value of null or undefined. That means
1645			// that once set, the value attribute of an <option> element can't be removed. This is
1646			// a very rare edge case, and removing the attribute altogether isn't possible either
1647			// for the <option value={undefined}> case, so we're not losing any functionality here.
1648			// @ts-ignore
1649			element.value = element.__value = '';
1650			current[key] = value;
1651			continue;
1652		}
1653
1654		if (key === 'class') {
1655			var is_html = element.namespaceURI === 'http://www.w3.org/1999/xhtml';
1656			set_class(element, is_html, value, css_hash, prev?.[CLASS], next[CLASS]);
1657			current[key] = value;
1658			current[CLASS] = next[CLASS];
1659			continue;
1660		}
1661
1662		if (key === 'style') {
1663			set_style(element, value, prev?.[STYLE], next[STYLE]);
1664			current[key] = value;
1665			current[STYLE] = next[STYLE];
1666			continue;
1667		}
1668
1669		var prev_value = current[key];
1670
1671		// Skip if value is unchanged, unless it's `undefined` and the element still has the attribute
1672		if (value === prev_value && !(value === undefined && element.hasAttribute(key))) {
1673			continue;
1674		}
1675
1676		current[key] = value;
1677
1678		var prefix = key[0] + key[1]; // this is faster than key.slice(0, 2)
1679		if (prefix === '$$') continue;
1680
1681		if (prefix === 'on') {
1682			/** @type {{ capture?: true }} */
1683			const opts = {};
1684			const event_handle_key = '$$' + key;
1685			let event_name = key.slice(2);
1686			var delegated = can_delegate_event(event_name);
1687
1688			if (is_capture_event(event_name)) {
1689				event_name = event_name.slice(0, -7);
1690				opts.capture = true;
1691			}
1692
1693			if (!delegated && prev_value) {
1694				// Listening to same event but different handler -> our handle function below takes care of this
1695				// If we were to remove and add listeners in this case, it could happen that the event is "swallowed"
1696				// (the browser seems to not know yet that a new one exists now) and doesn't reach the handler
1697				// https://github.com/sveltejs/svelte/issues/11903
1698				if (value != null) continue;
1699
1700				element.removeEventListener(event_name, current[event_handle_key], opts);
1701				current[event_handle_key] = null;
1702			}
1703
1704			if (value != null) {
1705				if (!delegated) {
1706					/**
1707					 * @this {any}
1708					 * @param {Event} evt
1709					 */
1710					function handle(evt) {
1711						current[key].call(this, evt);
1712					}
1713
1714					current[event_handle_key] = create_event(event_name, element, handle, opts);
1715				} else {
1716					// @ts-ignore
1717					element[`__${event_name}`] = value;
1718					delegate([event_name]);
1719				}
1720			} else if (delegated) {
1721				// @ts-ignore
1722				element[`__${event_name}`] = undefined;
1723			}
1724		} else if (key === 'style') {
1725			// avoid using the setter
1726			set_attribute(element, key, value);
1727		} else if (key === 'autofocus') {
1728			autofocus(/** @type {HTMLElement} */ (element), Boolean(value));
1729		} else if (!is_custom_element && (key === '__value' || (key === 'value' && value != null))) {
1730			// @ts-ignore We're not running this for custom elements because __value is actually
1731			// how Lit stores the current value on the element, and messing with that would break things.
1732			element.value = element.__value = value;
1733		} else if (key === 'selected' && is_option_element) {
1734			set_selected(/** @type {HTMLOptionElement} */ (element), value);
1735		} else {
1736			var name = key;
1737			if (!preserve_attribute_case) {
1738				name = normalize_attribute(name);
1739			}
1740
1741			var is_default = name === 'defaultValue' || name === 'defaultChecked';
1742
1743			if (value == null && !is_custom_element && !is_default) {
1744				attributes[key] = null;
1745
1746				if (name === 'value' || name === 'checked') {
1747					// removing value/checked also removes defaultValue/defaultChecked — preserve
1748					let input = /** @type {HTMLInputElement} */ (element);
1749					const use_default = prev === undefined;
1750					if (name === 'value') {
1751						let previous = input.defaultValue;
1752						input.removeAttribute(name);
1753						input.defaultValue = previous;
1754						// @ts-ignore
1755						input.value = input.__value = use_default ? previous : null;
1756					} else {
1757						let previous = input.defaultChecked;
1758						input.removeAttribute(name);
1759						input.defaultChecked = previous;
1760						input.checked = use_default ? previous : false;
1761					}
1762				} else {
1763					element.removeAttribute(key);
1764				}
1765			} else if (
1766				is_default ||
1767				(setters.includes(name) && (is_custom_element || typeof value !== 'string'))
1768			) {
1769				// @ts-ignore
1770				element[name] = value;
1771				// remove it from attributes's cache
1772				if (name in attributes) attributes[name] = UNINITIALIZED;
1773			} else if (typeof value !== 'function') {
1774				set_attribute(element, name, value, skip_warning);
1775			}
1776		}
1777	}
1778
1779	if (is_hydrating_custom_element) {
1780		set_hydrating(true);
1781	}
1782
1783	return current;
1784}
1785
1786/**
1787 * @param {Element & ElementCSSInlineStyle} element
1788 * @param {(...expressions: any) => Record<string | symbol, any>} fn
1789 * @param {Array<() => any>} sync
1790 * @param {Array<() => Promise<any>>} async
1791 * @param {Array<Promise<void>>} blockers
1792 * @param {string} [css_hash]
1793 * @param {boolean} [should_remove_defaults]
1794 * @param {boolean} [skip_warning]
1795 */
1796function attribute_effect(
1797	element,
1798	fn,
1799	sync = [],
1800	async = [],
1801	blockers = [],
1802	css_hash,
1803	should_remove_defaults = false,
1804	skip_warning = false
1805) {
1806	flatten(blockers, sync, async, (values) => {
1807		/** @type {Record<string | symbol, any> | undefined} */
1808		var prev = undefined;
1809
1810		/** @type {Record<symbol, Effect>} */
1811		var effects = {};
1812
1813		var is_select = element.nodeName === 'SELECT';
1814		var inited = false;
1815
1816		managed(() => {
1817			var next = fn(...values.map(get$1));
1818			/** @type {Record<string | symbol, any>} */
1819			var current = set_attributes(
1820				element,
1821				prev,
1822				next,
1823				css_hash,
1824				should_remove_defaults,
1825				skip_warning
1826			);
1827
1828			if (inited && is_select && 'value' in next) {
1829				select_option(/** @type {HTMLSelectElement} */ (element), next.value);
1830			}
1831
1832			for (let symbol of Object.getOwnPropertySymbols(effects)) {
1833				if (!next[symbol]) destroy_effect(effects[symbol]);
1834			}
1835
1836			for (let symbol of Object.getOwnPropertySymbols(next)) {
1837				var n = next[symbol];
1838
1839				if (symbol.description === ATTACHMENT_KEY && (!prev || n !== prev[symbol])) {
1840					if (effects[symbol]) destroy_effect(effects[symbol]);
1841					effects[symbol] = branch(() => attach(element, () => n));
1842				}
1843
1844				current[symbol] = n;
1845			}
1846
1847			prev = current;
1848		});
1849
1850		if (is_select) {
1851			var select = /** @type {HTMLSelectElement} */ (element);
1852
1853			effect(() => {
1854				select_option(select, /** @type {Record<string | symbol, any>} */ (prev).value, true);
1855				init_select(select);
1856			});
1857		}
1858
1859		inited = true;
1860	});
1861}
1862
1863/**
1864 *
1865 * @param {Element} element
1866 */
1867function get_attributes(element) {
1868	return /** @type {Record<string | symbol, unknown>} **/ (
1869		// @ts-expect-error
1870		element.__attributes ??= {
1871			[IS_CUSTOM_ELEMENT]: element.nodeName.includes('-'),
1872			[IS_HTML]: element.namespaceURI === NAMESPACE_HTML
1873		}
1874	);
1875}
1876
1877/** @type {Map<string, string[]>} */
1878var setters_cache = new Map();
1879
1880/** @param {Element} element */
1881function get_setters(element) {
1882	var cache_key = element.getAttribute('is') || element.nodeName;
1883	var setters = setters_cache.get(cache_key);
1884	if (setters) return setters;
1885	setters_cache.set(cache_key, (setters = []));
1886
1887	var descriptors;
1888	var proto = element; // In the case of custom elements there might be setters on the instance
1889	var element_proto = Element.prototype;
1890
1891	// Stop at Element, from there on there's only unnecessary setters we're not interested in
1892	// Do not use contructor.name here as that's unreliable in some browser environments
1893	while (element_proto !== proto) {
1894		descriptors = get_descriptors(proto);
1895
1896		for (var key in descriptors) {
1897			if (descriptors[key].set) {
1898				setters.push(key);
1899			}
1900		}
1901
1902		proto = get_prototype_of(proto);
1903	}
1904
1905	return setters;
1906}
1907
1908/**
1909 * @param {any} element
1910 * @param {string} attribute
1911 * @param {string} value
1912 */
1913function check_src_in_dev_hydration(element, attribute, value) {
1914	if (!DEV) return;
1915	if (attribute === 'srcset' && srcset_url_equal(element, value)) return;
1916	if (src_url_equal(element.getAttribute(attribute) ?? '', value)) return;
1917
1918	hydration_attribute_changed(
1919		attribute,
1920		element.outerHTML.replace(element.innerHTML, element.innerHTML && '...'),
1921		String(value)
1922	);
1923}
1924
1925/**
1926 * @param {string} element_src
1927 * @param {string} url
1928 * @returns {boolean}
1929 */
1930function src_url_equal(element_src, url) {
1931	if (element_src === url) return true;
1932	return new URL(element_src, document.baseURI).href === new URL(url, document.baseURI).href;
1933}
1934
1935/** @param {string} srcset */
1936function split_srcset(srcset) {
1937	return srcset.split(',').map((src) =>
1937 src.trim().split(' ').filter(Boolean));
1938}
1939
1940/**
1941 * @param {HTMLSourceElement | HTMLImageElement} element
1942 * @param {string} srcset
1943 * @returns {boolean}
1944 */
1945function srcset_url_equal(element, srcset) {
1946	var element_urls = split_srcset(element.srcset);
1947	var urls = split_srcset(srcset);
1948
1949	return (
1950		urls.length === element_urls.length &&
1951		urls.every(
1952			([url, width], i) =>
1953				width === element_urls[i][1] &&
1954				// We need to test both ways because Vite will create an a full URL with
1955				// `new URL(asset, import.meta.url).href` for the client when `base: './'`, and the
1956				// relative URLs inside srcset are not automatically resolved to absolute URLs by
1957				// browsers (in contrast to img.src). This means both SSR and DOM code could
1958				// contain relative or absolute URLs.
1959				(src_url_equal(element_urls[i][0], url) || src_url_equal(url, element_urls[i][0]))
1960		)
1961	);
1962}
1963
1964/**
1965 * @param {any} bound_value
1966 * @param {Element} element_or_component
1967 * @returns {boolean}
1968 */
1969function is_bound_this(bound_value, element_or_component) {
1970	return (
1971		bound_value === element_or_component || bound_value?.[STATE_SYMBOL] === element_or_component
1972	);
1973}
1974
1975/**
1976 * @param {any} element_or_component
1977 * @param {(value: unknown, ...parts: unknown[]) => void} update
1978 * @param {(...parts: unknown[]) => unknown} get_value
1979 * @param {() => unknown[]} [get_parts] Set if the this binding is used inside an each block,
1980 * 										returns all the parts of the each block context that are used in the expression
1981 * @returns {void}
1982 */
1983function bind_this(element_or_component = {}, update, get_value, get_parts) {
1984	effect(() => {
1985		/** @type {unknown[]} */
1986		var old_parts;
1987
1988		/** @type {unknown[]} */
1989		var parts;
1990
1991		render_effect(() => {
1992			old_parts = parts;
1993			// We only track changes to the parts, not the value itself to avoid unnecessary reruns.
1994			parts = get_parts?.() || [];
1995
1996			untrack(() => {
1997				if (element_or_component !== get_value(...parts)) {
1998					update(element_or_component, ...parts);
1999					// If this is an effect rerun (cause: each block context changes), then nullify the binding at
2000					// the previous position if it isn't already taken over by a different effect.
2001					if (old_parts && is_bound_this(get_value(...old_parts), element_or_component)) {
2002						update(null, ...old_parts);
2003					}
2004				}
2005			});
2006		});
2007
2008		return () => {
2009			// We cannot use effects in the teardown phase, we we use a microtask instead.
2010			queue_micro_task(() => {
2011				if (parts && is_bound_this(get_value(...parts), element_or_component)) {
2012					update(null, ...parts);
2013				}
2014			});
2015		};
2016	});
2017
2018	return element_or_component;
2019}
2020
2021/** @import { ComponentContextLegacy } from '#client' */
2022
2023/**
2024 * Legacy-mode only: Call `onMount` callbacks and set up `beforeUpdate`/`afterUpdate` effects
2025 * @param {boolean} [immutable]
2026 */
2027function init$1(immutable = false) {
2028	const context = /** @type {ComponentContextLegacy} */ (component_context);
2029
2030	const callbacks = context.l.u;
2031	if (!callbacks) return;
2032
2033	let props = () => deep_read_state(context.s);
2034
2035	if (immutable) {
2036		let version = 0;
2037		let prev = /** @type {Record<string, any>} */ ({});
2038
2039		// In legacy immutable mode, before/afterUpdate only fire if the object identity of a prop changes
2040		const d = derived$1(() => {
2041			let changed = false;
2042			const props = context.s;
2043			for (const key in props) {
2044				if (props[key] !== prev[key]) {
2045					prev[key] = props[key];
2046					changed = true;
2047				}
2048			}
2049			if (changed) version++;
2050			return version;
2051		});
2052
2053		props = () => get$1(d);
2054	}
2055
2056	// beforeUpdate
2057	if (callbacks.b.length) {
2058		user_pre_effect(() => {
2059			observe_all(context, props);
2060			run_all(callbacks.b);
2061		});
2062	}
2063
2064	// onMount (must run before afterUpdate)
2065	user_effect(() => {
2066		const fns = untrack(() => callbacks.m.map(run));
2067		return () => {
2068			for (const fn of fns) {
2069				if (typeof fn === 'function') {
2070					fn();
2071				}
2072			}
2073		};
2074	});
2075
2076	// afterUpdate
2077	if (callbacks.a.length) {
2078		user_effect(() => {
2079			observe_all(context, props);
2080			run_all(callbacks.a);
2081		});
2082	}
2083}
2084
2085/**
2086 * Invoke the getter of all signals associated with a component
2087 * so they can be registered to the effect this function is called 
2087in.
2088 * @param {ComponentContextLegacy} context
2089 * @param {(() => void)} props
2090 */
2091function observe_all(context, props) {
2092	if (context.l.s) {
2093		for (const signal of context.l.s) get$1(signal);
2094	}
2095
2096	props();
2097}
2098
2099/** @import { Readable } from './public' */
2100
2101/**
2102 * @template T
2103 * @param {Readable<T> | null | undefined} store
2104 * @param {(value: T) => void} run
2105 * @param {(value: T) => void} [invalidate]
2106 * @returns {() => void}
2107 */
2108function subscribe_to_store(store, run, invalidate) {
2109	if (store == null) {
2110		// @ts-expect-error
2111		run(undefined);
2112
2113		// @ts-expect-error
2114		if (invalidate) invalidate(undefined);
2115
2116		return noop;
2117	}
2118
2119	// Svelte store takes a private second argument
2120	// StartStopNotifier could mutate state, and we want to silence the corresponding validation error
2121	const unsub = untrack(() =>
2122		store.subscribe(
2123			run,
2124			// @ts-expect-error
2125			invalidate
2126		)
2127	);
2128
2129	// Also support RxJS
2130	// @ts-expect-error TODO fix this in the types?
2131	return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
2132}
2133
2134/** @import { Readable, StartStopNotifier, Subscriber, Unsubscriber, Updater, Writable } from '../public.js' */
2135/** @import { Stores, StoresValues, SubscribeInvalidateTuple } from '../private.js' */
2136
2137/**
2138 * @type {Array<SubscribeInvalidateTuple<any> | any>}
2139 */
2140const subscriber_queue = [];
2141
2142/**
2143 * Creates a `Readable` store that allows reading by subscription.
2144 *
2145 * @template T
2146 * @param {T} [value] initial value
2147 * @param {StartStopNotifier<T>} [start]
2148 * @returns {Readable<T>}
2149 */
2150function readable(value, start) {
2151	return {
2152		subscribe: writable(value, start).subscribe
2153	};
2154}
2155
2156/**
2157 * Create a `Writable` store that allows both updating and reading by subscription.
2158 *
2159 * @template T
2160 * @param {T} [value] initial value
2161 * @param {StartStopNotifier<T>} [start]
2162 * @returns {Writable<T>}
2163 */
2164function writable(value, start = noop) {
2165	/** @type {Unsubscriber | null} */
2166	let stop = null;
2167
2168	/** @type {Set<SubscribeInvalidateTuple<T>>} */
2169	const subscribers = new Set();
2170
2171	/**
2172	 * @param {T} new_value
2173	 * @returns {void}
2174	 */
2175	function set(new_value) {
2176		if (safe_not_equal(value, new_value)) {
2177			value = new_value;
2178			if (stop) {
2179				// store is ready
2180				const run_queue = !subscriber_queue.length;
2181				for (const subscriber of subscribers) {
2182					subscriber[1]();
2183					subscriber_queue.push(subscriber, value);
2184				}
2185				if (run_queue) {
2186					for (let i = 0; i < subscriber_queue.length; i += 2) {
2187						subscriber_queue[i][0](subscriber_queue[i + 1]);
2188					}
2189					subscriber_queue.length = 0;
2190				}
2191			}
2192		}
2193	}
2194
2195	/**
2196	 * @param {Updater<T>} fn
2197	 * @returns {void}
2198	 */
2199	function update(fn) {
2200		set(fn(/** @type {T} */ (value)));
2201	}
2202
2203	/**
2204	 * @param {Subscriber<T>} run
2205	 * @param {() => void} [invalidate]
2206	 * @returns {Unsubscriber}
2207	 */
2208	function subscribe(run, invalidate = noop) {
2209		/** @type {SubscribeInvalidateTuple<T>} */
2210		const subscriber = [run, invalidate];
2211		subscribers.add(subscriber);
2212		if (subscribers.size === 1) {
2213			stop = start(set, update) || noop;
2214		}
2215		run(/** @type {T} */ (value));
2216		return () => {
2217			subscribers.delete(subscriber);
2218			if (subscribers.size === 0 && stop) {
2219				stop();
2220				stop = null;
2221			}
2222		};
2223	}
2224	return { set, update, subscribe };
2225}
2226
2227/**
2228 * Derived value store by synchronizing one or more readable stores and
2229 * applying an aggregation function over its input values.
2230 *
2231 * @template {Stores} S
2232 * @template T
2233 * @overload
2234 * @param {S} stores
2235 * @param {(values: StoresValues<S>, set: (value: T) => void, update: (fn: Updater<T>) => void) => Unsubscriber | void} fn
2236 * @param {T} [initial_value]
2237 * @returns {Readable<T>}
2238 */
2239/**
2240 * Derived value store by synchronizing one or more readable stores and
2241 * applying an aggregation function over its input values.
2242 *
2243 * @template {Stores} S
2244 * @template T
2245 * @overload
2246 * @param {S} stores
2247 * @param {(values: StoresValues<S>) => T} fn
2248 * @param {T} [initial_value]
2249 * @returns {Readable<T>}
2250 */
2251/**
2252 * @template {Stores} S
2253 * @template T
2254 * @param {S} stores
2255 * @param {Function} fn
2256 * @param {T} [initial_value]
2257 * @returns {Readable<T>}
2258 */
2259function derived(stores, fn, initial_value) {
2260	const single = !Array.isArray(stores);
2261	/** @type {Array<Readable<any>>} */
2262	const stores_array = single ? [stores] : stores;
2263	if (!stores_array.every(Boolean)) {
2264		throw new Error('derived() expects stores as input, got a falsy value');
2265	}
2266	const auto = fn.length < 2;
2267	return readable(initial_value, (set, update) => {
2268		let started = false;
2269		/** @type {T[]} */
2270		const values = [];
2271		let pending = 0;
2272		let cleanup = noop;
2273		const sync = () => {
2274			if (pending) {
2275				return;
2276			}
2277			cleanup();
2278			const result = fn(single ? values[0] : values, set, update);
2279			if (auto) {
2280				set(result);
2281			} else {
2282				cleanup = typeof result === 'function' ? result : noop;
2283			}
2284		};
2285		const unsubscribers = stores_array.map((store, i) =>
2286			subscribe_to_store(
2287				store,
2288				(value) => {
2289					values[i] = value;
2290					pending &= ~(1 << i);
2291					if (started) {
2292						sync();
2293					}
2294				},
2295				() => {
2296					pending |= 1 << i;
2297				}
2298			)
2299		);
2300		started = true;
2301		sync();
2302		return function stop() {
2303			run_all(unsubscribers);
2304			cleanup();
2305			// We need to set this to false because callbacks can still happen despite having unsubscribed:
2306			// Callbacks might already be placed in the queue which doesn't know it should no longer
2307			// invoke this derived store.
2308			started = false;
2309		};
2310	});
2311}
2312
2313/**
2314 * Get the current value from a store by subscribing and immediately unsubscribing.
2315 *
2316 * @template T
2317 * @param {Readable<T>} store
2318 * @returns {T}
2319 */
2320function get(store) {
2321	let value;
2322	subscribe_to_store(store, (_) => (value = _))();
2323	// @ts-expect-error
2324	return value;
2325}
2326
2327/** @import { StoreReferencesContainer } from '#client' */
2328/** @import { Store } from '#shared' */
2329
2330/**
2331 * Whether or not the prop currently being read is a store binding, as in
2332 * `<Child bind:x={$y} />`. If it is, we treat the prop as mutable even in
2333 * runes mode, and skip `binding_property_non_reactive` validation
2334 */
2335let is_store_binding = false;
2336
2337let IS_UNMOUNTED = Symbol();
2338
2339/**
2340 * Gets the current value of a store. If the store isn't subscribed to yet, it will create a proxy
2341 * signal that will be updated when the store is. The store references container is needed to
2342 * track reassignments to stores and to track the correct component context.
2343 * @template V
2344 * @param {Store<V> | null | undefined} store
2345 * @param {string} store_name
2346 * @param {StoreReferencesContainer} stores
2347 * @returns {V}
2348 */
2349function store_get(store, store_name, stores) {
2350	const entry = (stores[store_name] ??= {
2351		store: null,
2352		source: mutable_source(undefined),
2353		unsubscribe: noop
2354	});
2355
2356	if (DEV) {
2357		entry.source.label = store_name;
2358	}
2359
2360	// if the component that setup this is already unmounted we don't want to register a subscription
2361	if (entry.store !== store && !(IS_UNMOUNTED in stores)) {
2362		entry.unsubscribe();
2363		entry.store = store ?? null;
2364
2365		if (store == null) {
2366			entry.source.v = undefined; // see synchronous callback comment below
2367			entry.unsubscribe = noop;
2368		} else {
2369			var is_synchronous_callback = true;
2370
2371			entry.unsubscribe = subscribe_to_store(store, (v) => {
2372				if (is_synchronous_callback) {
2373					// If the first updates to the store value (possibly multiple of them) are synchronously
2374					// inside a derived, we will hit the `state_unsafe_mutation` error if we `set` the value
2375					entry.source.v = v;
2376				} else {
2377					set$1(entry.source, v);
2378				}
2379			});
2380
2381			is_synchronous_callback = false;
2382		}
2383	}
2384
2385	// if the component that setup this stores is already unmounted the source will be out of sync
2386	// so we just use the `get` for the stores, less performant but it avoids to create a memory leak
2387	// and it will keep the value consistent
2388	if (store && IS_UNMOUNTED in stores) {
2389		return get(store);
2390	}
2391
2392	return get$1(entry.source);
2393}
2394
2395/**
2396 * Sets the new value of a store and returns that value.
2397 * @template V
2398 * @param {Store<V>} store
2399 * @param {V} value
2400 * @returns {V}
2401 */
2402function store_set(store, value) {
2403	store.set(value);
2404	return value;
2405}
2406
2407/**
2408 * Unsubscribes from all auto-subscribed stores on destroy
2409 * @returns {[StoreReferencesContainer, ()=>void]}
2410 */
2411function setup_stores() {
2412	/** @type {StoreReferencesContainer} */
2413	const stores = {};
2414
2415	function cleanup() {
2416		teardown(() => {
2417			for (var store_name in stores) {
2418				const ref = stores[store_name];
2419				ref.unsubscribe();
2420			}
2421			define_property(stores, IS_UNMOUNTED, {
2422				enumerable: false,
2423				value: true
2424			});
2425		});
2426	}
2427
2428	return [stores, cleanup];
2429}
2430
2431/**
2432 * Returns a tuple that indicates whether `fn()` reads a prop that is a store binding.
2433 * Used to prevent `binding_property_non_reactive` validation false positives and
2434 * ensure that these props are treated as mutable even in runes mode
2435 * @template T
2436 * @param {() => T} fn
2437 * @returns {[T, boolean]}
2438 */
2439function capture_store_binding(fn) {
2440	var previous_is_store_binding = is_store_binding;
2441
2442	try {
2443		is_store_binding = false;
2444		return [fn(), is_store_binding];
2445	} finally {
2446		is_store_binding = previous_is_store_binding;
2447	}
2448}
2449
2450/** @import { Effect, Source } from './types.js' */
2451
2452/**
2453 * @param {((value?: number) => number)} fn
2454 * @param {1 | -1} [d]
2455 * @returns {number}
2456 */
2457function update_prop(fn, d = 1) {
2458	const value = fn();
2459	fn(value + d);
2460	return value;
2461}
2462
2463/**
2464 * The proxy handler for rest props (i.e. `const { x, ...rest } = $props()`).
2465 * Is passed the full `$$props` object and excludes the named props.
2466 * @type {ProxyHandler<{ props: Record<string | symbol, unknown>, exclude: Array<string | symbol>, name?: string }>}}
2467 */
2468const rest_props_handler = {
2469	get(target, key) {
2470		if (target.exclude.includes(key)) return;
2471		return target.props[key];
2472	},
2473	set(target, key) {
2474		if (DEV) {
2475			// TODO should this happen in prod too?
2476			props_rest_readonly(`${target.name}.${String(key)}`);
2477		}
2478
2479		return false;
2480	},
2481	getOwnPropertyDescriptor(target, key) {
2482		if (target.exclude.includes(key)) return;
2483		if (key in target.props) {
2484			return {
2485				enumerable: true,
2486				configurable: true,
2487				value: target.props[key]
2488			};
2489		}
2490	},
2491	has(target, key) {
2492		if (target.exclude.includes(key)) return false;
2493		return key in target.props;
2494	},
2495	ownKeys(target) {
2496		return Reflect.ownKeys(target.props).filter((key) => !target.exclude.includes(key));
2497	}
2498};
2499
2500/**
2501 * @param {Record<string, unknown>} props
2502 * @param {string[]} exclude
2503 * @param {string} [name]
2504 * @returns {Record<string, unknown>}
2505 */
2506/*#__NO_SIDE_EFFECTS__*/
2507function rest_props(props, exclude, name) {
2508	return new Proxy(
2509		DEV ? { props, exclude, name, other: {}, to_proxy: [] } : { props, exclude },
2510		rest_props_handler
2511	);
2512}
2513
2514/**
2515 * The proxy handler for legacy $$restProps and $$props
2516 * @type {ProxyHandler<{ props: Record<string | symbol, unknown>, exclude: Array<string | symbol>, special: Record<string | symbol, (v?: unknown) => unknown>, version: Source<number>, parent_effect: Effect }>}}
2517 */
2518const legacy_rest_props_handler = {
2519	get(target, key) {
2520		if (target.exclude.includes(key)) return;
2521		get$1(target.version);
2522		return key in target.special ? target.special[key]() : target.props[key];
2523	},
2524	set(target, key, value) {
2525		if (!(key in target.special)) {
2526			var previous_effect = active_effect;
2527
2528			try {
2529				set_active_effect(target.parent_effect);
2530
2531				// Handle props that can temporarily get out of sync with the parent
2532				/** @type {Record<string, (v?: unknown) => unknown>} */
2533				target.special[key] = prop(
2534					{
2535						get [key]() {
2536							return target.props[key];
2537						}
2538					},
2539					/** @type {string} */ (key),
2540					PROPS_IS_UPDATED
2541				);
2542			} finally {
2543				set_active_effect(previous_effect);
2544			}
2545		}
2546
2547		target.special[key](value);
2548		update(target.version); // $$props is coarse-grained: when $$props.x is updated, usages of $$props.y etc are also rerun
2549		return true;
2550	},
2551	getOwnPropertyDescriptor(target, key) {
2552		if (target.exclude.includes(key)) return;
2553		if (key in target.props) {
2554			return {
2555				enumerable: true,
2556				configurable: true,
2557				value: target.props[key]
2558			};
2559		}
2560	},
2561	deleteProperty(target, key) {
2562		// Svelte 4 allowed for deletions on $$restProps
2563		if (target.exclude.includes(key)) return true;
2564		target.exclude.push(key);
2565		update(target.version);
2566		return true;
2567	},
2568	has(target, key) {
2569		if (target.exclude.includes(key)) return false;
2570		return key in target.props;
2571	},
2572	ownKeys(target) {
2573		return Reflect.ownKeys(target.props).filter((key) => !target.exclude.includes(key));
2574	}
2575};
2576
2577/**
2578 * @param {Record<string, unknown>} props
2579 * @param {string[]} exclude
2580 * @returns {Record<string, unknown>}
2581 */
2582function legacy_rest_props(props, exclude) {
2583	return new Proxy(
2584		{
2585			props,
2586			exclude,
2587			special: {},
2588			version: source(0),
2589			// TODO this is only necessary because we need to track component
2590			// destruction inside `prop`, because of `bind:this`, but it
2591			// seems likely that we can simplify `bind:this` instead
2592			parent_effect: /** @type {Effect} */ (active_effect)
2593		},
2594		legacy_rest_props_handler
2595	);
2596}
2597
2598/**
2599 * The proxy handler for spread props. Handles the incoming array of props
2600 * that looks like `() => { dynamic: props }, { static: prop }, ..` and wraps
2601 * them so that the whole thing is passed to the component as the `$$props` argument.
2602 * @type {ProxyHandler<{ props: Array<Record<string | symbol, unknown> | (() => Record<string | symbol, unknown>)> }>}}
2603 */
2604const spread_props_handler = {
2605	get(target, key) {
2606		let i = target.props.length;
2607		while (i--) {
2608			let p = target.props[i];
2609			if (is_function(p)) p = p();
2610			if (typeof p === 'object' && p !== null && key in p) return p[
2610key];
2611		}
2612	},
2613	set(target, key, value) {
2614		let i = target.props.length;
2615		while (i--) {
2616			let p = target.props[i];
2617			if (is_function(p)) p = p();
2618			const desc = get_descriptor(p, key);
2619			if (desc && desc.set) {
2620				desc.set(value);
2621				return true;
2622			}
2623		}
2624		return false;
2625	},
2626	getOwnPropertyDescriptor(target, key) {
2627		let i = target.props.length;
2628		while (i--) {
2629			let p = target.props[i];
2630			if (is_function(p)) p = p();
2631			if (typeof p === 'object' && p !== null && key in p) {
2632				const descriptor = get_descriptor(p, key);
2633				if (descriptor && !descriptor.configurable) {
2634					// Prevent a "Non-configurability Report Error": The target is an array, it does
2635					// not actually contain this property. If it is now described as non-configurable,
2636					// the proxy throws a validation error. Setting it to true avoids that.
2637					descriptor.configurable = true;
2638				}
2639				return descriptor;
2640			}
2641		}
2642	},
2643	has(target, key) {
2644		// To prevent a false positive `is_entry_props` in the `prop` function
2645		if (key === STATE_SYMBOL || key === LEGACY_PROPS) return false;
2646
2647		for (let p of target.props) {
2648			if (is_function(p)) p = p();
2649			if (p != null && key in p) return true;
2650		}
2651
2652		return false;
2653	},
2654	ownKeys(target) {
2655		/** @type {Array<string | symbol>} */
2656		const keys = [];
2657
2658		for (let p of target.props) {
2659			if (is_function(p)) p = p();
2660			if (!p) continue;
2661
2662			for (const key in p) {
2663				if (!keys.includes(key)) keys.push(key);
2664			}
2665
2666			for (const key of Object.getOwnPropertySymbols(p)) {
2667				if (!keys.includes(key)) keys.push(key);
2668			}
2669		}
2670
2671		return keys;
2672	}
2673};
2674
2675/**
2676 * @param {Array<Record<string, unknown> | (() => Record<string, unknown>)>} props
2677 * @returns {any}
2678 */
2679function spread_props(...props) {
2680	return new Proxy({ props }, spread_props_handler);
2681}
2682
2683/**
2684 * This function is responsible for synchronizing a possibly bound prop with the inner component state.
2685 * It is used whenever the compiler sees that the component writes to the prop, or when it has a default prop_value.
2686 * @template V
2687 * @param {Record<string, unknown>} props
2688 * @param {string} key
2689 * @param {number} flags
2690 * @param {V | (() => V)} [fallback]
2691 * @returns {(() => V | ((arg: V) => V) | ((arg: V, mutation: boolean) => V))}
2692 */
2693function prop(props, key, flags, fallback) {
2694	var runes = !legacy_mode_flag || (flags & PROPS_IS_RUNES) !== 0;
2695	var bindable = (flags & PROPS_IS_BINDABLE) !== 0;
2696	var lazy = (flags & PROPS_IS_LAZY_INITIAL) !== 0;
2697
2698	var fallback_value = /** @type {V} */ (fallback);
2699	var fallback_dirty = true;
2700
2701	var get_fallback = () => {
2702		if (fallback_dirty) {
2703			fallback_dirty = false;
2704
2705			fallback_value = lazy
2706				? untrack(/** @type {() => V} */ (fallback))
2707				: /** @type {V} */ (fallback);
2708		}
2709
2710		return fallback_value;
2711	};
2712
2713	/** @type {((v: V) => void) | undefined} */
2714	var setter;
2715
2716	if (bindable) {
2717		// Can be the case when someone does `mount(Component, props)` with `let props = $state({...})`
2718		// or `createClassComponent(Component, props)`
2719		var is_entry_props = STATE_SYMBOL in props || LEGACY_PROPS in props;
2720
2721		setter =
2722			get_descriptor(props, key)?.set ??
2723			(is_entry_props && key in props ? (v) => (props[key] = v) : undefined);
2724	}
2725
2726	var initial_value;
2727	var is_store_sub = false;
2728
2729	if (bindable) {
2730		[initial_value, is_store_sub] = capture_store_binding(() => /** @type {V} */ (props[key]));
2731	} else {
2732		initial_value = /** @type {V} */ (props[key]);
2733	}
2734
2735	if (initial_value === undefined && fallback !== undefined) {
2736		initial_value = get_fallback();
2737
2738		if (setter) {
2739			if (runes) props_invalid_value(key);
2740			setter(initial_value);
2741		}
2742	}
2743
2744	/** @type {() => V} */
2745	var getter;
2746
2747	if (runes) {
2748		getter = () => {
2749			var value = /** @type {V} */ (props[key]);
2750			if (value === undefined) return get_fallback();
2751			fallback_dirty = true;
2752			return value;
2753		};
2754	} else {
2755		getter = () => {
2756			var value = /** @type {V} */ (props[key]);
2757
2758			if (value !== undefined) {
2759				// in legacy mode, we don't revert to the fallback value
2760				// if the prop goes from defined to undefined. The easiest
2761				// way to model this is to make the fallback undefined
2762				// as soon as the prop has a value
2763				fallback_value = /** @type {V} */ (undefined);
2764			}
2765
2766			return value === undefined ? fallback_value : value;
2767		};
2768	}
2769
2770	// prop is never written to — we only need a getter
2771	if (runes && (flags & PROPS_IS_UPDATED) === 0) {
2772		return getter;
2773	}
2774
2775	// prop is written to, but the parent component had `bind:foo` which
2776	// means we can just call `$$props.foo = value` directly
2777	if (setter) {
2778		var legacy_parent = props.$$legacy;
2779		return /** @type {() => V} */ (
2780			function (/** @type {V} */ value, /** @type {boolean} */ mutation) {
2781				if (arguments.length > 0) {
2782					// We don't want to notify if the value was mutated and the parent is in runes mode.
2783					// In that case the state proxy (if it exists) should take care of the notification.
2784					// If the parent is not in runes mode, we need to notify on mutation, too, that the prop
2785					// has changed because the parent will not be able to detect the change otherwise.
2786					if (!runes || !mutation || legacy_parent || is_store_sub) {
2787						/** @type {Function} */ (setter)(mutation ? getter() : value);
2788					}
2789
2790					return value;
2791				}
2792
2793				return getter();
2794			}
2795		);
2796	}
2797
2798	// Either prop is written to, but there's no binding, which means we
2799	// create a derived that we can write to locally.
2800	// Or we are in legacy mode where we always create a derived to replicate that
2801	// Svelte 4 did not trigger updates when a primitive value was updated to the same value.
2802	var overridden = false;
2803
2804	var d = ((flags & PROPS_IS_IMMUTABLE) !== 0 ? derived$1 : derived_safe_equal)(() => {
2805		overridden = false;
2806		return getter();
2807	});
2808
2809	if (DEV) {
2810		d.label = key;
2811	}
2812
2813	// Capture the initial value if it's bindable
2814	if (bindable) get$1(d);
2815
2816	var parent_effect = /** @type {Effect} */ (active_effect);
2817
2818	return /** @type {() => V} */ (
2819		function (/** @type {any} */ value, /** @type {boolean} */ mutation) {
2820			if (arguments.length > 0) {
2821				const new_value = mutation ? get$1(d) : runes && bindable ? proxy(value) : value;
2822
2823				set$1(d, new_value);
2824				overridden = true;
2825
2826				if (fallback_value !== undefined) {
2827					fallback_value = new_value;
2828				}
2829
2830				return value;
2831			}
2832
2833			// special case — avoid recalculating the derived if we're in a
2834			// teardown function and the prop was overridden locally, or the
2835			// component was already destroyed (this latter part is necessary
2836			// because `bind:this` can read props after the component has
2837			// been destroyed. TODO simplify `bind:this`
2838			if ((is_destroying_effect && overridden) || (parent_effect.f & DESTROYED) !== 0) {
2839				return d.v;
2840			}
2841
2842			return get$1(d);
2843		}
2844	);
2845}
2846
2847enable_legacy_mode_flag();
2848
2849enable_async_mode_flag();
2850
2851const space_logo = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='10'%20height='10'%20fill='none'%3e%3cpath%20fill='%23FF3270'%20d='M1.93%206.03v2.04h2.04V6.03H1.93Z'/%3e%3cpath%20fill='%23861FFF'%20d='M6.03%206.03v2.04h2.04V6.03H6.03Z'/%3e%3cpath%20fill='%23097EFF'%20d='M1.93%201.93v2.04h2.04V1.93H1.93Z'/%3e%3cpath%20fill='%23000'%20fill-rule='evenodd'%20d='M.5%201.4c0-.5.4-.9.9-.9h3.1a.9.9%200%200%201%20.87.67A2.44%202.44%200%200%201%209.5%202.95c0%20.65-.25%201.24-.67%201.68.39.1.67.46.67.88v3.08c0%20.5-.4.91-.9.91H1.4a.9.9%200%200%201-.9-.9V1.4Zm1.43.53v2.04h2.04V1.93H1.93Zm0%206.14V6.03h2.04v2.04H1.93Zm4.1%200V6.03h2.04v2.04H6.03Zm0-5.12a1.02%201.02%200%201%201%202.04%200%201.02%201.02%200%200%201-2.04%200Z'%20clip-rule='evenodd'/%3e%3cpath%20fill='%23FFD702'%20d='M7.05%201.93a1.02%201.02%200%201%200%200%202.04%201.02%201.02%200%200%200%200-2.04Z'/%3e%3c/svg%3e";
2852
2853var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2854
2855function getDefaultExportFromCjs (x) {
2856	return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2857}
2858
2859function getAugmentedNamespace(n) {
2860  if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n;
2861  var f = n.default;
2862	if (typeof f == "function") {
2863		var a = function a () {
2864			var isInstance = false;
2865      try {
2866        isInstance = this instanceof a;
2867      } catch {}
2868			if (isInstance) {
2869        return Reflect.construct(f, arguments, this.constructor);
2870			}
2871			return f.apply(this, arguments);
2872		};
2873		a.prototype = f.prototype;
2874  } else a = {};
2875  Object.defineProperty(a, '__esModule', {value: true});
2876	Object.keys(n).forEach(function (k) {
2877		var d = Object.getOwnPropertyDescriptor(n, k);
2878		Object.defineProperty(a, k, d.get ? d : {
2879			enumerable: true,
2880			get: function () {
2881				return n[k];
2882			}
2883		});
2884	});
2885	return a;
2886}
2887
2888var cjs;
2889var hasRequiredCjs;
2890
2891function requireCjs () {
2892	if (hasRequiredCjs) return cjs;
2893	hasRequiredCjs = 1;
2894
2895	var isMergeableObject = function isMergeableObject(value) {
2896		return isNonNullObject(value)
2897			&& !isSpecial(value)
2898	};
2899
2900	function isNonNullObject(value) {
2901		return !!value && typeof value === 'object'
2902	}
2903
2904	function isSpecial(value) {
2905		var stringValue = Object.prototype.toString.call(value);
2906
2907		return stringValue === '[object RegExp]'
2908			|| stringValue === '[object Date]'
2909			|| isReactElement(value)
2910	}
2911
2912	// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
2913	var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
2914	var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
2915
2916	function isReactElement(value) {
2917		return value.$$typeof === REACT_ELEMENT_TYPE
2918	}
2919
2920	function emptyTarget(val) {
2921		return Array.isArray(val) ? [] : {}
2922	}
2923
2924	function cloneUnlessOtherwiseSpecified(value, options) {
2925		return (options.clone !== false && options.isMergeableObject(value))
2926			? deepmerge(emptyTarget(value), value, options)
2927			: value
2928	}
2929
2930	function defaultArrayMerge(target, source, options) {
2931		return target.concat(source).map(function(element) {
2932			return cloneUnlessOtherwiseSpecified(element, options)
2933		})
2934	}
2935
2936	function getMergeFunction(key, options) {
2937		if (!options.customMerge) {
2938			return deepmerge
2939		}
2940		var customMerge = options.customMerge(key);
2941		return typeof customMerge === 'function' ? customMerge : deepmerge
2942	}
2943
2944	function getEnumerableOwnPropertySymbols(target) {
2945		return Object.getOwnPropertySymbols
2946			? Object.getOwnPropertySymbols(target).filter(function(symbol) {
2947				return Object.propertyIsEnumerable.call(target, symbol)
2948			})
2949			: []
2950	}
2951
2952	function getKeys(target) {
2953		return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
2954	}
2955
2956	function propertyIsOnObject(object, property) {
2957		try {
2958			return property in object
2959		} catch(_) {
2960			return false
2961		}
2962	}
2963
2964	// Protects from prototype poisoning and unexpected merging up the prototype chain.
vendor: 5,067 bytes, lines 2965-3098
2965	function propertyIsUnsafe(target, key) {
2966		return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
2967			&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
2968				&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
2969	}
2970
2971	function mergeObject(target, source, options) {
2972		var destination = {};
2973		if (options.isMergeableObject(target)) {
2974			getKeys(target).forEach(function(key) {
2975				destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
2976			});
2977		}
2978		getKeys(source).forEach(function(key) {
2979			if (propertyIsUnsafe(target, key)) {
2980				return
2981			}
2982
2983			if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
2984				destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
2985			} else {
2986				destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
2987			}
2988		});
2989		return destination
2990	}
2991
2992	function deepmerge(target, source, options) {
2993		options = options || {};
2994		options.arrayMerge = options.arrayMerge || defaultArrayMerge;
2995		options.isMergeableObject = options.isMergeableObject || isMergeableObject;
2996		// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
2997		// implementations can use it. The caller may not replace it.
2998		options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
2999
3000		var sourceIsArray = Array.isArray(source);
3001		var targetIsArray = Array.isArray(target);
3002		var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
3003
3004		if (!sourceAndTargetTypesMatch) {
3005			return cloneUnlessOtherwiseSpecified(source, options)
3006		} else if (sourceIsArray) {
3007			return options.arrayMerge(target, source, options)
3008		} else {
3009			return mergeObject(target, source, options)
3010		}
3011	}
3012
3013	deepmerge.all = function deepmergeAll(array, options) {
3014		if (!Array.isArray(array)) {
3015			throw new Error('first argument should be an array')
3016		}
3017
3018		return array.reduce(function(prev, next) {
3019			return deepmerge(prev, next, options)
3020		}, {})
3021	};
3022
3023	var deepmerge_1 = deepmerge;
3024
3025	cjs = deepmerge_1;
3026	return cjs;
3027}
3028
3029var cjsExports = requireCjs();
3030const deepmerge = /*@__PURE__*/getDefaultExportFromCjs(cjsExports);
3031
3032/******************************************************************************
3033Copyright (c) Microsoft Corporation.
3034
3035Permission to use, copy, modify, and/or distribute this software for any
3036purpose with or without fee is hereby granted.
3037
3038THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3039REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3040AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3041INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3042LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3043OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3044PERFORMANCE OF THIS SOFTWARE.
3045***************************************************************************** */
3046/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
3047
3048var extendStatics = function(d, b) {
3049  extendStatics = Object.setPrototypeOf ||
3050      ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
3051      function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
3052  return extendStatics(d, b);
3053};
3054
3055function __extends(d, b) {
3056  if (typeof b !== "function" && b !== null)
3057      throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
3058  extendStatics(d, b);
3059  function __() { this.constructor = d; }
3060  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3061}
3062
3063var __assign = function() {
3064  __assign = Object.assign || function __assign(t) {
3065      for (var s, i = 1, n = arguments.length; i < n; i++) {
3066          s = arguments[i];
3067          for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
3068      }
3069      return t;
3070  };
3071  return __assign.apply(this, arguments);
3072};
3073
3074function __rest(s, e) {
3075  var t = {};
3076  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
3077      t[p] = s[p];
3078  if (s != null && typeof Object.getOwnPropertySymbols === "function")
3079      for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
3080          if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
3081              t[p[i]] = s[p[i]];
3082      }
3083  return t;
3084}
3085
3086function __spreadArray(to, from, pack) {
3087  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3088      if (ar || !(i in from)) {
3089          if (!ar) ar = Array.prototype.slice.call(from, 0, i);
3090          ar[i] = from[i];
3091      }
3092  }
3093  return to.concat(ar || Array.prototype.slice.call(from));
3094}
3095
3096typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
3097  var e = new Error(message);
3098  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
vendor: 14,280 bytes, lines 3098-3459
3098
3099};
3100
3101//
3102// Main
3103//
3104function memoize(fn, options) {
3105    var cache = options && options.cache ? options.cache : cacheDefault;
3106    var serializer = options && options.serializer ? options.serializer : serializerDefault;
3107    var strategy = options && options.strategy ? options.strategy : strategyDefault;
3108    return strategy(fn, {
3109        cache: cache,
3110        serializer: serializer,
3111    });
3112}
3113//
3114// Strategy
3115//
3116function isPrimitive(value) {
3117    return (value == null || typeof value === 'number' || typeof value === 'boolean'); // || typeof value === "string" 'unsafe' primitive for our needs
3118}
3119function monadic(fn, cache, serializer, arg) {
3120    var cacheKey = isPrimitive(arg) ? arg : serializer(arg);
3121    var computedValue = cache.get(cacheKey);
3122    if (typeof computedValue === 'undefined') {
3123        computedValue = fn.call(this, arg);
3124        cache.set(cacheKey, computedValue);
3125    }
3126    return computedValue;
3127}
3128function variadic(fn, cache, serializer) {
3129    var args = Array.prototype.slice.call(arguments, 3);
3130    var cacheKey = serializer(args);
3131    var computedValue = cache.get(cacheKey);
3132    if (typeof computedValue === 'undefined') {
3133        computedValue = fn.apply(this, args);
3134        cache.set(cacheKey, computedValue);
3135    }
3136    return computedValue;
3137}
3138function assemble(fn, context, strategy, cache, serialize) {
3139    return strategy.bind(context, fn, cache, serialize);
3140}
3141function strategyDefault(fn, options) {
3142    var strategy = fn.length === 1 ? monadic : variadic;
3143    return assemble(fn, this, strategy, options.cache.create(), options.serializer);
3144}
3145function strategyVariadic(fn, options) {
3146    return assemble(fn, this, variadic, options.cache.create(), options.serializer);
3147}
3148//
3149// Serializer
3150//
3151var serializerDefault = function () {
3152    return JSON.stringify(arguments);
3153};
3154//
3155// Cache
3156//
3157var ObjectWithoutPrototypeCache = /** @class */ (function () {
3158    function ObjectWithoutPrototypeCache() {
3159        this.cache = Object.create(null);
3160    }
3161    ObjectWithoutPrototypeCache.prototype.get = function (key) {
3162        return this.cache[key];
3163    };
3164    ObjectWithoutPrototypeCache.prototype.set = function (key, value) {
3165        this.cache[key] = value;
3166    };
3167    return ObjectWithoutPrototypeCache;
3168}());
3169var cacheDefault = {
3170    create: function create() {
3171        return new ObjectWithoutPrototypeCache();
3172    },
3173};
3174var strategies = {
3175    variadic: strategyVariadic};
3176
3177var ErrorKind;
3178(function (ErrorKind) {
3179    /** Argument is unclosed (e.g. `{0`) */
3180    ErrorKind[ErrorKind["EXPECT_ARGUMENT_CLOSING_BRACE"] = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE";
3181    /** Argument is empty (e.g. `{}`). */
3182    ErrorKind[ErrorKind["EMPTY_ARGUMENT"] = 2] = "EMPTY_ARGUMENT";
3183    /** Argument is malformed (e.g. `{foo!}``) */
3184    ErrorKind[ErrorKind["MALFORMED_ARGUMENT"] = 3] = "MALFORMED_ARGUMENT";
3185    /** Expect an argument type (e.g. `{foo,}`) */
3186    ErrorKind[ErrorKind["EXPECT_ARGUMENT_TYPE"] = 4] = "EXPECT_ARGUMENT_TYPE";
3187    /** Unsupported argument type (e.g. `{foo,foo}`) */
3188    ErrorKind[ErrorKind["INVALID_ARGUMENT_TYPE"] = 5] = "INVALID_ARGUMENT_TYPE";
3189    /** Expect an argument style (e.g. `{foo, number, }`) */
3190    ErrorKind[ErrorKind["EXPECT_ARGUMENT_STYLE"] = 6] = "EXPECT_ARGUMENT_STYLE";
3191    /** The number skeleton is invalid. */
3192    ErrorKind[ErrorKind["INVALID_NUMBER_SKELETON"] = 7] = "INVALID_NUMBER_SKELETON";
3193    /** The date time skeleton is invalid. */
3194    ErrorKind[ErrorKind["INVALID_DATE_TIME_SKELETON"] = 8] = "INVALID_DATE_TIME_SKELETON";
3195    /** Exepct a number skeleton following the `::` (e.g. `{foo, number, ::}`) */
3196    ErrorKind[ErrorKind["EXPECT_NUMBER_SKELETON"] = 9] = "EXPECT_NUMBER_SKELETON";
3197    /** Exepct a date time skeleton following the `::` (e.g. `{foo, date, ::}`) */
3198    ErrorKind[ErrorKind["EXPECT_DATE_TIME_SKELETON"] = 10] = "EXPECT_DATE_TIME_SKELETON";
3199    /** Unmatched apostrophes in the argument style (e.g. `{foo, number, 'test`) */
3200    ErrorKind[ErrorKind["UNCLOSED_QUOTE_IN_ARGUMENT_STYLE"] = 11] = "UNCLOSED_QUOTE_IN_ARGUMENT_STYLE";
3201    /** Missing select argument options (e.g. `{foo, select}`) */
3202    ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_OPTIONS"] = 12] = "EXPECT_SELECT_ARGUMENT_OPTIONS";
3203    /** Expecting an offset value in `plural` or `selectordinal` argument (e.g `{foo, plural, offset}`) */
3204    ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE"] = 13] = "EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE";
3205    /** Offset value in `plural` or `selectordinal` is invalid (e.g. `{foo, plural, offset: x}`) */
3206    ErrorKind[ErrorKind["INVALID_PLURAL_ARGUMENT_OFFSET_VALUE"] = 14] = "INVALID_PLURAL_ARGUMENT_OFFSET_VALUE";
3207    /** Expecting a selector in `select` argument (e.g `{foo, select}`) */
3208    ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_SELECTOR"] = 15] = "EXPECT_SELECT_ARGUMENT_SELECTOR";
3209    /** Expecting a selector in `plural` or `selectordinal` argument (e.g `{foo, plural}`) */
3210    ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_SELECTOR"] = 16] = "EXPECT_PLURAL_ARGUMENT_SELECTOR";
3211    /** Expecting a message fragment after the `select` selector (e.g. `{foo, select, apple}`) */
3212    ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT"] = 17] = "EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT";
3213    /**
3214     * Expecting a message fragment after the `plural` or `selectordinal` selector
3215     * (e.g. `{foo, plural, one}`)
3216     */
3217    ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT"] = 18] = "EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT";
3218    /** Selector in `plural` or `selectordinal` is malformed (e.g. `{foo, plural, =x {#}}`) */
3219    ErrorKind[ErrorKind["INVALID_PLURAL_ARGUMENT_SELECTOR"] = 19] = "INVALID_PLURAL_ARGUMENT_SELECTOR";
3220    /**
3221     * Duplicate selectors in `plural` or `selectordinal` argument.
3222     * (e.g. {foo, plural, one {#} one {#}})
3223     */
3224    ErrorKind[ErrorKind["DUPLICATE_PLURAL_ARGUMENT_SELECTOR"] = 20] = "DUPLICATE_PLURAL_ARGUMENT_SELECTOR";
3225    /** Duplicate selectors in `select` argument.
3226     * (e.g. {foo, select, apple {apple} apple {apple}})
3227     */
3228    ErrorKind[ErrorKind["DUPLICATE_SELECT_ARGUMENT_SELECTOR"] = 21] = "DUPLICATE_SELECT_ARGUMENT_SELECTOR";
3229    /** Plural or select argument option must have `other` clause. */
3230    ErrorKind[ErrorKind["MISSING_OTHER_CLAUSE"] = 22] = "MISSING_OTHER_CLAUSE";
3231    /** The tag is malformed. (e.g. `<bold!>foo</bold!>) */
3232    ErrorKind[ErrorKind["INVALID_TAG"] = 23] = "INVALID_TAG";
3233    /** The tag name is invalid. (e.g. `<123>foo</123>`) */
3234    ErrorKind[ErrorKind["INVALID_TAG_NAME"] = 25] = "INVALID_TAG_NAME";
3235    /** The closing tag does not match the opening tag. (e.g. `<bold>foo</italic>`) */
3236    ErrorKind[ErrorKind["UNMATCHED_CLOSING_TAG"] = 26] = "UNMATCHED_CLOSING_TAG";
3237    /** The opening tag has unmatched closing tag. (e.g. `<bold>foo`) */
3238    ErrorKind[ErrorKind["UNCLOSED_TAG"] = 27] = "UNCLOSED_TAG";
3239})(ErrorKind || (ErrorKind = {}));
3240
3241var TYPE;
3242(function (TYPE) {
3243    /**
3244     * Raw text
3245     */
3246    TYPE[TYPE["literal"] = 0] = "literal";
3247    /**
3248     * Variable w/o any format, e.g `var` in `this is a {var}`
3249     */
3250    TYPE[TYPE["argument"] = 1] = "argument";
3251    /**
3252     * Variable w/ number format
3253     */
3254    TYPE[TYPE["number"] = 2] = "number";
3255    /**
3256     * Variable w/ date format
3257     */
3258    TYPE[TYPE["date"] = 3] = "date";
3259    /**
3260     * Variable w/ time format
3261     */
3262    TYPE[TYPE["time"] = 4] = "time";
3263    /**
3264     * Variable w/ select format
3265     */
3266    TYPE[TYPE["select"] = 5] = "select";
3267    /**
3268     * Variable w/ plural format
3269     */
3270    TYPE[TYPE["plural"] = 6] = "plural";
3271    /**
3272     * Only possible within plural argument.
3273     * This is the `#` symbol that will be substituted with the count.
3274     */
3275    TYPE[TYPE["pound"] = 7] = "pound";
3276    /**
3277     * XML-like tag
3278     */
3279    TYPE[TYPE["tag"] = 8] = "tag";
3280})(TYPE || (TYPE = {}));
3281var SKELETON_TYPE;
3282(function (SKELETON_TYPE) {
3283    SKELETON_TYPE[SKELETON_TYPE["number"] = 0] = "number";
3284    SKELETON_TYPE[SKELETON_TYPE["dateTime"] = 1] = "dateTime";
3285})(SKELETON_TYPE || (SKELETON_TYPE = {}));
3286/**
3287 * Type Guards
3288 */
3289function isLiteralElement(el) {
3290    return el.type === TYPE.literal;
3291}
3292function isArgumentElement(el) {
3293    return el.type === TYPE.argument;
3294}
3295function isNumberElement(el) {
3296    return el.type === TYPE.number;
3297}
3298function isDateElement(el) {
3299    return el.type === TYPE.date;
3300}
3301function isTimeElement(el) {
3302    return el.type === TYPE.time;
3303}
3304function isSelectElement(el) {
3305    return el.type === TYPE.select;
3306}
3307function isPluralElement(el) {
3308    return el.type === TYPE.plural;
3309}
3310function isPoundElement(el) {
3311    return el.type === TYPE.pound;
3312}
3313function isTagElement(el) {
3314    return el.type === TYPE.tag;
3315}
3316function isNumberSkeleton(el) {
3317    return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.number);
3318}
3319function isDateTimeSkeleton(el) {
3320    return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.dateTime);
3321}
3322
3323// @generated from regex-gen.ts
3324var SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/;
3325
3326/**
3327 * https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
3328 * Credit: https://github.com/caridy/intl-datetimeformat-pattern/blob/master/index.js
3329 * with some tweaks
3330 */
3331var DATE_TIME_REGEX = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;
3332/**
3333 * Parse Date time skeleton into Intl.DateTimeFormatOptions
3334 * Ref: https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
3335 * @public
3336 * @param skeleton skeleton string
3337 */
3338function parseDateTimeSkeleton(skeleton) {
3339    var result = {};
3340    skeleton.replace(DATE_TIME_REGEX, function (match) {
3341        var len = match.length;
3342        switch (match[0]) {
3343            // Era
3344            case 'G':
3345                result.era = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short';
3346                break;
3347            // Year
3348            case 'y':
3349                result.year = len === 2 ? '2-digit' : 'numeric';
3350                break;
3351            case 'Y':
3352            case 'u':
3353            case 'U':
3354            case 'r':
3355                throw new RangeError('`Y/u/U/r` (year) patterns are not supported, use `y` instead');
3356            // Quarter
3357            case 'q':
3358            case 'Q':
3359                throw new RangeError('`q/Q` (quarter) patterns are not supported');
3360            // Month
3361            case 'M':
3362            case 'L':
3363                result.month = ['numeric', '2-digit', 'short', 'long', 'narrow'][len - 1];
3364                break;
3365            // Week
3366            case 'w':
3367            case 'W':
3368                throw new RangeError('`w/W` (week) patterns are not supported');
3369            case 'd':
3370                result.day = ['numeric', '2-digit'][len - 1];
3371                break;
3372            case 'D':
3373            case 'F':
3374            case 'g':
3375                throw new RangeError('`D/F/g` (day) patterns are not supported, use `d` instead');
3376            // Weekday
3377            case 'E':
3378                result.weekday = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short';
3379                break;
3380            case 'e':
3381                if (len < 4) {
3382                    throw new RangeError('`e..eee` (weekday) patterns are not supported');
3383                }
3384                result.weekday = ['short', 'long', 'narrow', 'short'][len - 4];
3385                break;
3386            case 'c':
3387                if (len < 4) {
3388                    throw new RangeError('`c..ccc` (weekday) patterns are not supported');
3389                }
3390                result.weekday = ['short', 'long', 'narrow', 'short'][len - 4];
3391                break;
3392            // Period
3393            case 'a': // AM, PM
3394                result.hour12 = true;
3395                break;
3396            case 'b': // am, pm, noon, midnight
3397            case 'B': // flexible day periods
3398                throw new RangeError('`b/B` (period) patterns are not supported, use `a` instead');
3399            // Hour
3400            case 'h':
3401                result.hourCycle = 'h12';
3402                result.hour = ['numeric', '2-digit'][len - 1];
3403                break;
3404            case 'H':
3405                result.hourCycle = 'h23';
3406                result.hour = ['numeric', '2-digit'][len - 1];
3407                break;
3408            case 'K':
3409                result.hourCycle = 'h11';
3410                result.hour = ['numeric', '2-digit'][len - 1];
3411                break;
3412            case 'k':
3413                result.hourCycle = 'h24';
3414                result.hour = ['numeric', '2-digit'][len - 1];
3415                break;
3416            case 'j':
3417            case 'J':
3418            case 'C':
3419                throw new RangeError('`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead');
3420            // Minute
3421            case 'm':
3422                result.minute = ['numeric', '2-digit'][len - 1];
3423                break;
3424            // Second
3425            case 's':
3426                result.second = ['numeric', '2-digit'][len - 1];
3427                break;
3428            case 'S':
3429            case 'A':
3430                throw new RangeError('`S/A` (second) patterns are not supported, use `s` instead');
3431            // Zone
3432            case 'z': // 1..3, 4: specific non-location format
3433                result.timeZoneName = len < 4 ? 'short' : 'long';
3434                break;
3435            case 'Z': // 1..3, 4, 5: The ISO8601 varios formats
3436            case 'O': // 1, 4: milliseconds in day short, long
3437            case 'v': // 1, 4: generic non-location format
3438            case 'V': // 1, 2, 3, 4: time zone ID or city
3439            case 'X': // 1, 2, 3, 4: The ISO8601 varios formats
3440            case 'x': // 1, 2, 3, 4: The ISO8601 varios formats
3441                throw new RangeError('`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead');
3442        }
3443        return '';
3444    });
3445    return result;
3446}
3447
3448// @generated from regex-gen.ts
3449var WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i;
3450
3451function parseNumberSkeletonFromString(skeleton) {
3452    if (skeleton.length === 0) {
3453        throw new Error('Number skeleton cannot be empty');
3454    }
3455    // Parse the skeleton
3456    var stringTokens = skeleton
3457        .split(WHITE_SPACE_REGEX)
3458        .filter(function (x) { return x.length > 0; });
3459    var tokens = [];
vendor: 4,933 bytes, lines 3460-3618
3460    for (var _i = 0, stringTokens_1 = stringTokens; _i < stringTokens_1.length; _i++) {
3461        var stringToken = stringTokens_1[_i];
3462        var stemAndOptions = stringToken.split('/');
3463        if (stemAndOptions.length === 0) {
3464            throw new Error('Invalid number skeleton');
3465        }
3466        var stem = stemAndOptions[0], options = stemAndOptions.slice(1);
3467        for (var _a = 0, options_1 = options; _a < options_1.length; _a++) {
3468            var option = options_1[_a];
3469            if (option.length === 0) {
3470                throw new Error('Invalid number skeleton');
3471            }
3472        }
3473        tokens.push({ stem: stem, options: options });
3474    }
3475    return tokens;
3476}
3477function icuUnitToEcma(unit) {
3478    return unit.replace(/^(.*?)-/, '');
3479}
3480var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g;
3481var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?[rs]?$/g;
3482var INTEGER_WIDTH_REGEX = /(\*)(0+)|(#+)(0+)|(0+)/g;
3483var CONCISE_INTEGER_WIDTH_REGEX = /^(0+)$/;
3484function parseSignificantPrecision(str) {
3485    var result = {};
3486    if (str[str.length - 1] === 'r') {
3487        result.roundingPriority = 'morePrecision';
3488    }
3489    else if (str[str.length - 1] === 's') {
3490        result.roundingPriority = 'lessPrecision';
3491    }
3492    str.replace(SIGNIFICANT_PRECISION_REGEX, function (_, g1, g2) {
3493        // @@@ case
3494        if (typeof g2 !== 'string') {
3495            result.minimumSignificantDigits = g1.length;
3496            result.maximumSignificantDigits = g1.length;
3497        }
3498        // @@@+ case
3499        else if (g2 === '+') {
3500            result.minimumSignificantDigits = g1.length;
3501        }
3502        // .### case
3503        else if (g1[0] === '#') {
3504            result.maximumSignificantDigits = g1.length;
3505        }
3506        // .@@## or .@@@ case
3507        else {
3508            result.minimumSignificantDigits = g1.length;
3509            result.maximumSignificantDigits =
3510                g1.length + (typeof g2 === 'string' ? g2.length : 0);
3511        }
3512        return '';
3513    });
3514    return result;
3515}
3516function parseSign(str) {
3517    switch (str) {
3518        case 'sign-auto':
3519            return {
3520                signDisplay: 'auto',
3521            };
3522        case 'sign-accounting':
3523        case '()':
3524            return {
3525                currencySign: 'accounting',
3526            };
3527        case 'sign-always':
3528        case '+!':
3529            return {
3530                signDisplay: 'always',
3531            };
3532        case 'sign-accounting-always':
3533        case '()!':
3534            return {
3535                signDisplay: 'always',
3536                currencySign: 'accounting',
3537            };
3538        case 'sign-except-zero':
3539        case '+?':
3540            return {
3541                signDisplay: 'exceptZero',
3542            };
3543        case 'sign-accounting-except-zero':
3544        case '()?':
3545            return {
3546                signDisplay: 'exceptZero',
3547                currencySign: 'accounting',
3548            };
3549        case 'sign-never':
3550        case '+_':
3551            return {
3552                signDisplay: 'never',
3553            };
3554    }
3555}
3556function parseConciseScientificAndEngineeringStem(stem) {
3557    // Engineering
3558    var result;
3559    if (stem[0] === 'E' && stem[1] === 'E') {
3560        result = {
3561            notation: 'engineering',
3562        };
3563        stem = stem.slice(2);
3564    }
3565    else if (stem[0] === 'E') {
3566        result = {
3567            notation: 'scientific',
3568        };
3569        stem = stem.slice(1);
3570    }
3571    if (result) {
3572        var signDisplay = stem.slice(0, 2);
3573        if (signDisplay === '+!') {
3574            result.signDisplay = 'always';
3575            stem = stem.slice(2);
3576        }
3577        else if (signDisplay === '+?') {
3578            result.signDisplay = 'exceptZero';
3579            stem = stem.slice(2);
3580        }
3581        if (!CONCISE_INTEGER_WIDTH_REGEX.test(stem)) {
3582            throw new Error('Malformed concise eng/scientific notation');
3583        }
3584        result.minimumIntegerDigits = stem.length;
3585    }
3586    return result;
3587}
3588function parseNotationOptions(opt) {
3589    var result = {};
3590    var signOpts = parseSign(opt);
3591    if (signOpts) {
3592        return signOpts;
3593    }
3594    return result;
3595}
3596/**
3597 * https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#skeleton-stems-and-options
3598 */
3599function parseNumberSkeleton(tokens) {
3600    var result = {};
3601    for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
3602        var token = tokens_1[_i];
3603        switch (token.stem) {
3604            case 'percent':
3605            case '%':
3606                result.style = 'percent';
3607                continue;
3608            case '%x100':
3609                result.style = 'percent';
3610                result.scale = 100;
3611                continue;
3612            case 'currency':
3613                result.style = 'currency';
3614                result.currency = token.options[0];
3615                continue;
3616            case 'group-off':
3617            case ',_':
3618                result.useGrouping = false;
vendor: 12,268 bytes, lines 3619-4247
3619                continue;
3620            case 'precision-integer':
3621            case '.':
3622                result.maximumFractionDigits = 0;
3623                continue;
3624            case 'measure-unit':
3625            case 'unit':
3626                result.style = 'unit';
3627                result.unit = icuUnitToEcma(token.options[0]);
3628                continue;
3629            case 'compact-short':
3630            case 'K':
3631                result.notation = 'compact';
3632                result.compactDisplay = 'short';
3633                continue;
3634            case 'compact-long':
3635            case 'KK':
3636                result.notation = 'compact';
3637                result.compactDisplay = 'long';
3638                continue;
3639            case 'scientific':
3640                result = __assign(__assign(__assign({}, result), { notation: 'scientific' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));
3641                continue;
3642            case 'engineering':
3643                result = __assign(__assign(__assign({}, result), { notation: 'engineering' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {}));
3644                continue;
3645            case 'notation-simple':
3646                result.notation = 'standard';
3647                continue;
3648            // https://github.com/unicode-org/icu/blob/master/icu4c/source/i18n/unicode/unumberformatter.h
3649            case 'unit-width-narrow':
3650                result.currencyDisplay = 'narrowSymbol';
3651                result.unitDisplay = 'narrow';
3652                continue;
3653            case 'unit-width-short':
3654                result.currencyDisplay = 'code';
3655                result.unitDisplay = 'short';
3656                continue;
3657            case 'unit-width-full-name':
3658                result.currencyDisplay = 'name';
3659                result.unitDisplay = 'long';
3660                continue;
3661            case 'unit-width-iso-code':
3662                result.currencyDisplay = 'symbol';
3663                continue;
3664            case 'scale':
3665                result.scale = parseFloat(token.options[0]);
3666                continue;
3667            case 'rounding-mode-floor':
3668                result.roundingMode = 'floor';
3669                continue;
3670            case 'rounding-mode-ceiling':
3671                result.roundingMode = 'ceil';
3672                continue;
3673            case 'rounding-mode-down':
3674                result.roundingMode = 'trunc';
3675                continue;
3676            case 'rounding-mode-up':
3677                result.roundingMode = 'expand';
3678                continue;
3679            case 'rounding-mode-half-even':
3680                result.roundingMode = 'halfEven';
3681                continue;
3682            case 'rounding-mode-half-down':
3683                result.roundingMode = 'halfTrunc';
3684                continue;
3685            case 'rounding-mode-half-up':
3686                result.roundingMode = 'halfExpand';
3687                continue;
3688            // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width
3689            case 'integer-width':
3690                if (token.options.length > 1) {
3691                    throw new RangeError('integer-width stems only accept a single optional option');
3692                }
3693                token.options[0].replace(INTEGER_WIDTH_REGEX, function (_, g1, g2, g3, g4, g5) {
3694                    if (g1) {
3695                        result.minimumIntegerDigits = g2.length;
3696                    }
3697                    else if (g3 && g4) {
3698                        throw new Error('We currently do not support maximum integer digits');
3699                    }
3700                    else if (g5) {
3701                        throw new Error('We currently do not support exact integer digits');
3702                    }
3703                    return '';
3704                });
3705                continue;
3706        }
3707        // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width
3708        if (CONCISE_INTEGER_WIDTH_REGEX.test(token.stem)) {
3709            result.minimumIntegerDigits = token.stem.length;
3710            continue;
3711        }
3712        if (FRACTION_PRECISION_REGEX.test(token.stem)) {
3713            // Precision
3714            // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#fraction-precision
3715            // precision-integer case
3716            if (token.options.length > 1) {
3717                throw new RangeError('Fraction-precision stems only accept a single optional option');
3718            }
3719            token.stem.replace(FRACTION_PRECISION_REGEX, function (_, g1, g2, g3, g4, g5) {
3720                // .000* case (before ICU67 it was .000+)
3721                if (g2 === '*') {
3722                    result.minimumFractionDigits = g1.length;
3723                }
3724                // .### case
3725                else if (g3 && g3[0] === '#') {
3726                    result.maximumFractionDigits = g3.length;
3727                }
3728                // .00## case
3729                else if (g4 && g5) {
3730                    result.minimumFractionDigits = g4.length;
3731                    result.maximumFractionDigits = g4.length + g5.length;
3732                }
3733                else {
3734                    result.minimumFractionDigits = g1.length;
3735                    result.maximumFractionDigits = g1.length;
3736                }
3737                return '';
3738            });
3739            var opt = token.options[0];
3740            // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#trailing-zero-display
3741            if (opt === 'w') {
3742                result = __assign(__assign({}, result), { trailingZeroDisplay: 'stripIfInteger' });
3743            }
3744            else if (opt) {
3745                result = __assign(__assign({}, result), parseSignificantPrecision(opt));
3746            }
3747            continue;
3748        }
3749        // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#significant-digits-precision
3750        if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) {
3751            result = __assign(__assign({}, result), parseSignificantPrecision(token.stem));
3752            continue;
3753        }
3754        var signOpts = parseSign(token.stem);
3755        if (signOpts) {
3756            result = __assign(__assign({}, result), signOpts);
3757        }
3758        var conciseScientificAndEngineeringOpts = parseConciseScientificAndEngineeringStem(token.stem);
3759        if (conciseScientificAndEngineeringOpts) {
3760            result = __assign(__assign({}, result), conciseScientificAndEngineeringOpts);
3761        }
3762    }
3763    return result;
3764}
3765
3766// @generated from time-data-gen.ts
3767// prettier-ignore  
3768var timeData = {
3769    "001": [
3770        "H",
3771        "h"
3772    ],
3773    "419": [
3774        "h",
3775        "H",
3776        "hB",
3777        "hb"
3778    ],
3779    "AC": [
3780        "H",
3781        "h",
3782        "hb",
3783        "hB"
3784    ],
3785    "AD": [
3786        "H",
3787        "hB"
3788    ],
3789    "AE": [
3790        "h",
3791        "hB",
3792        "hb",
3793        "H"
3794    ],
3795    "AF": [
3796        "H",
3797        "hb",
3798        "hB",
3799        "h"
3800    ],
3801    "AG": [
3802        "h",
3803        "hb",
3804        "H",
3805        "hB"
3806    ],
3807    "AI": [
3808        "H",
3809        "h",
3810        "hb",
3811        "hB"
3812    ],
3813    "AL": [
3814        "h",
3815        "H",
3816        "hB"
3817    ],
3818    "AM": [
3819        "H",
3820        "hB"
3821    ],
3822    "AO": [
3823        "H",
3824        "hB"
3825    ],
3826    "AR": [
3827        "h",
3828        "H",
3829        "hB",
3830        "hb"
3831    ],
3832    "AS": [
3833        "h",
3834        "H"
3835    ],
3836    "AT": [
3837        "H",
3838        "hB"
3839    ],
3840    "AU": [
3841        "h",
3842        "hb",
3843        "H",
3844        "hB"
3845    ],
3846    "AW": [
3847        "H",
3848        "hB"
3849    ],
3850    "AX": [
3851        "H"
3852    ],
3853    "AZ": [
3854        "H",
3855        "hB",
3856        "h"
3857    ],
3858    "BA": [
3859        "H",
3860        "hB",
3861        "h"
3862    ],
3863    "BB": [
3864        "h",
3865        "hb",
3866        "H",
3867        "hB"
3868    ],
3869    "BD": [
3870        "h",
3871        "hB",
3872        "H"
3873    ],
3874    "BE": [
3875        "H",
3876        "hB"
3877    ],
3878    "BF": [
3879        "H",
3880        "hB"
3881    ],
3882    "BG": [
3883        "H",
3884        "hB",
3885        "h"
3886    ],
3887    "BH": [
3888        "h",
3889        "hB",
3890        "hb",
3891        "H"
3892    ],
3893    "BI": [
3894        "H",
3895        "h"
3896    ],
3897    "BJ": [
3898        "H",
3899        "hB"
3900    ],
3901    "BL": [
3902        "H",
3903        "hB"
3904    ],
3905    "BM": [
3906        "h",
3907        "hb",
3908        "H",
3909        "hB"
3910    ],
3911    "BN": [
3912        "hb",
3913        "hB",
3914        "h",
3915        "H"
3916    ],
3917    "BO": [
3918        "h",
3919        "H",
3920        "hB",
3921        "hb"
3922    ],
3923    "BQ": [
3924        "H"
3925    ],
3926    "BR": [
3927        "H",
3928        "hB"
3929    ],
3930    "BS": [
3931        "h",
3932        "hb",
3933        "H",
3934        "hB"
3935    ],
3936    "BT": [
3937        "h",
3938        "H"
3939    ],
3940    "BW": [
3941        "H",
3942        "h",
3943        "hb",
3944        "hB"
3945    ],
3946    "BY": [
3947        "H",
3948        "h"
3949    ],
3950    "BZ": [
3951        "H",
3952        "h",
3953        "hb",
3954        "hB"
3955    ],
3956    "CA": [
3957        "h",
3958        "hb",
3959        "H",
3960        "hB"
3961    ],
3962    "CC": [
3963        "H",
3964        "h",
3965        "hb",
3966        "hB"
3967    ],
3968    "CD": [
3969        "hB",
3970        "H"
3971    ],
3972    "CF": [
3973        "H",
3974        "h",
3975        "hB"
3976    ],
3977    "CG": [
3978        "H",
3979        "hB"
3980    ],
3981    "CH": [
3982        "H",
3983        "hB",
3984        "h"
3985    ],
3986    "CI": [
3987        "H",
3988        "hB"
3989    ],
3990    "CK": [
3991        "H",
3992        "h",
3993        "hb",
3994        "hB"
3995    ],
3996    "CL": [
3997        "h",
3998        "H",
3999        "hB",
4000        "hb"
4001    ],
4002    "CM": [
4003        "H",
4004        "h",
4005        "hB"
4006    ],
4007    "CN": [
4008        "H",
4009        "hB",
4010        "hb",
4011        "h"
4012    ],
4013    "CO": [
4014        "h",
4015        "H",
4016        "hB",
4017        "hb"
4018    ],
4019    "CP": [
4020        "H"
4021    ],
4022    "CR": [
4023        "h",
4024        "H",
4025        "hB",
4026        "hb"
4027    ],
4028    "CU": [
4029        "h",
4030        "H",
4031        "hB",
4032        "hb"
4033    ],
4034    "CV": [
4035        "H",
4036        "hB"
4037    ],
4038    "CW": [
4039        "H",
4040        "hB"
4041    ],
4042    "CX": [
4043        "H",
4044        "h",
4045        "hb",
4046        "hB"
4047    ],
4048    "CY": [
4049        "h",
4050        "H",
4051        "hb",
4052        "hB"
4053    ],
4054    "CZ": [
4055        "H"
4056    ],
4057    "DE": [
4058        "H",
4059        "hB"
4060    ],
4061    "DG": [
4062        "H",
4063        "h",
4064        "hb",
4065        "hB"
4066    ],
4067    "DJ": [
4068        "h",
4069        "H"
4070    ],
4071    "DK": [
4072        "H"
4073    ],
4074    "DM": [
4075        "h",
4076        "hb",
4077        "H",
4078        "hB"
4079    ],
4080    "DO": [
4081        "h",
4082        "H",
4083        "hB",
4084        "hb"
4085    ],
4086    "DZ": [
4087        "h",
4088        "hB",
4089        "hb",
4090        "H"
4091    ],
4092    "EA": [
4093        "H",
4094        "h",
4095        "hB",
4096        "hb"
4097    ],
4098    "EC": [
4099        "h",
4100        "H",
4101        "hB",
4102        "hb"
4103    ],
4104    "EE": [
4105        "H",
4106        "hB"
4107    ],
4108    "EG": [
4109        "h",
4110        "hB",
4111        "hb",
4112        "H"
4113    ],
4114    "EH": [
4115        "h",
4116        "hB",
4117        "hb",
4118        "H"
4119    ],
4120    "ER": [
4121        "h",
4122        "H"
4123    ],
4124    "ES": [
4125        "H",
4126        "hB",
4127        "h",
4128        "hb"
4129    ],
4130    "ET": [
4131        "hB",
4132        "hb",
4133        "h",
4134        "H"
4135    ],
4136    "FI": [
4137        "H"
4138    ],
4139    "FJ": [
4140        "h",
4141        "hb",
4142        "H",
4143        "hB"
4144    ],
4145    "FK": [
4146        "H",
4147        "h",
4148        "hb",
4149        "hB"
4150    ],
4151    "FM": [
4152        "h",
4153        "hb",
4154        "H",
4155        "hB"
4156    ],
4157    "FO": [
4158        "H",
4159        "h"
4160    ],
4161    "FR": [
4162        "H",
4163        "hB"
4164    ],
4165    "GA": [
4166        "H",
4167        "hB"
4168    ],
4169    "GB": [
4170        "H",
4171        "h",
4172        "hb",
4173        "hB"
4174    ],
4175    "GD": [
4176        "h",
4177        "hb",
4178        "H",
4179        "hB"
4180    ],
4181    "GE": [
4182        "H",
4183        "hB",
4184        "h"
4185    ],
4186    "GF": [
4187        "H",
4188        "hB"
4189    ],
4190    "GG": [
4191        "H",
4192        "h",
4193        "hb",
4194        "hB"
4195    ],
4196    "GH": [
4197        "h",
4198        "H"
4199    ],
4200    "GI": [
4201        "H",
4202        "h",
4203        "hb",
4204        "hB"
4205    ],
4206    "GL": [
4207        "H",
4208        "h"
4209    ],
4210    "GM": [
4211        "h",
4212        "hb",
4213        "H",
4214        "hB"
4215    ],
4216    "GN": [
4217        "H",
4218        "hB"
4219    ],
4220    "GP": [
4221        "H",
4222        "hB"
4223    ],
4224    "GQ": [
4225        "H",
4226        "hB",
4227        "h",
4228        "hb"
4229    ],
4230    "GR": [
4231        "h",
4232        "H",
4233        "hb",
4234        "hB"
4235    ],
4236    "GT": [
4237        "h",
4238        "H",
4239        "hB",
4240        "hb"
4241    ],
4242    "GU": [
4243        "h",
4244        "hb",
4245        "H",
4246        "hB"
4247    ],
vendor: 27,756 bytes, lines 4248-5623
4248    "GW": [
4249        "H",
4250        "hB"
4251    ],
4252    "GY": [
4253        "h",
4254        "hb",
4255        "H",
4256        "hB"
4257    ],
4258    "HK": [
4259        "h",
4260        "hB",
4261        "hb",
4262        "H"
4263    ],
4264    "HN": [
4265        "h",
4266        "H",
4267        "hB",
4268        "hb"
4269    ],
4270    "HR": [
4271        "H",
4272        "hB"
4273    ],
4274    "HU": [
4275        "H",
4276        "h"
4277    ],
4278    "IC": [
4279        "H",
4280        "h",
4281        "hB",
4282        "hb"
4283    ],
4284    "ID": [
4285        "H"
4286    ],
4287    "IE": [
4288        "H",
4289        "h",
4290        "hb",
4291        "hB"
4292    ],
4293    "IL": [
4294        "H",
4295        "hB"
4296    ],
4297    "IM": [
4298        "H",
4299        "h",
4300        "hb",
4301        "hB"
4302    ],
4303    "IN": [
4304        "h",
4305        "H"
4306    ],
4307    "IO": [
4308        "H",
4309        "h",
4310        "hb",
4311        "hB"
4312    ],
4313    "IQ": [
4314        "h",
4315        "hB",
4316        "hb",
4317        "H"
4318    ],
4319    "IR": [
4320        "hB",
4321        "H"
4322    ],
4323    "IS": [
4324        "H"
4325    ],
4326    "IT": [
4327        "H",
4328        "hB"
4329    ],
4330    "JE": [
4331        "H",
4332        "h",
4333        "hb",
4334        "hB"
4335    ],
4336    "JM": [
4337        "h",
4338        "hb",
4339        "H",
4340        "hB"
4341    ],
4342    "JO": [
4343        "h",
4344        "hB",
4345        "hb",
4346        "H"
4347    ],
4348    "JP": [
4349        "H",
4350        "K",
4351        "h"
4352    ],
4353    "KE": [
4354        "hB",
4355        "hb",
4356        "H",
4357        "h"
4358    ],
4359    "KG": [
4360        "H",
4361        "h",
4362        "hB",
4363        "hb"
4364    ],
4365    "KH": [
4366        "hB",
4367        "h",
4368        "H",
4369        "hb"
4370    ],
4371    "KI": [
4372        "h",
4373        "hb",
4374        "H",
4375        "hB"
4376    ],
4377    "KM": [
4378        "H",
4379        "h",
4380        "hB",
4381        "hb"
4382    ],
4383    "KN": [
4384        "h",
4385        "hb",
4386        "H",
4387        "hB"
4388    ],
4389    "KP": [
4390        "h",
4391        "H",
4392        "hB",
4393        "hb"
4394    ],
4395    "KR": [
4396        "h",
4397        "H",
4398        "hB",
4399        "hb"
4400    ],
4401    "KW": [
4402        "h",
4403        "hB",
4404        "hb",
4405        "H"
4406    ],
4407    "KY": [
4408        "h",
4409        "hb",
4410        "H",
4411        "hB"
4412    ],
4413    "KZ": [
4414        "H",
4415        "hB"
4416    ],
4417    "LA": [
4418        "H",
4419        "hb",
4420        "hB",
4421        "h"
4422    ],
4423    "LB": [
4424        "h",
4425        "hB",
4426        "hb",
4427        "H"
4428    ],
4429    "LC": [
4430        "h",
4431        "hb",
4432        "H",
4433        "hB"
4434    ],
4435    "LI": [
4436        "H",
4437        "hB",
4438        "h"
4439    ],
4440    "LK": [
4441        "H",
4442        "h",
4443        "hB",
4444        "hb"
4445    ],
4446    "LR": [
4447        "h",
4448        "hb",
4449        "H",
4450        "hB"
4451    ],
4452    "LS": [
4453        "h",
4454        "H"
4455    ],
4456    "LT": [
4457        "H",
4458        "h",
4459        "hb",
4460        "hB"
4461    ],
4462    "LU": [
4463        "H",
4464        "h",
4465        "hB"
4466    ],
4467    "LV": [
4468        "H",
4469        "hB",
4470        "hb",
4471        "h"
4472    ],
4473    "LY": [
4474        "h",
4475        "hB",
4476        "hb",
4477        "H"
4478    ],
4479    "MA": [
4480        "H",
4481        "h",
4482        "hB",
4483        "hb"
4484    ],
4485    "MC": [
4486        "H",
4487        "hB"
4488    ],
4489    "MD": [
4490        "H",
4491        "hB"
4492    ],
4493    "ME": [
4494        "H",
4495        "hB",
4496        "h"
4497    ],
4498    "MF": [
4499        "H",
4500        "hB"
4501    ],
4502    "MG": [
4503        "H",
4504        "h"
4505    ],
4506    "MH": [
4507        "h",
4508        "hb",
4509        "H",
4510        "hB"
4511    ],
4512    "MK": [
4513        "H",
4514        "h",
4515        "hb",
4516        "hB"
4517    ],
4518    "ML": [
4519        "H"
4520    ],
4521    "MM": [
4522        "hB",
4523        "hb",
4524        "H",
4525        "h"
4526    ],
4527    "MN": [
4528        "H",
4529        "h",
4530        "hb",
4531        "hB"
4532    ],
4533    "MO": [
4534        "h",
4535        "hB",
4536        "hb",
4537        "H"
4538    ],
4539    "MP": [
4540        "h",
4541        "hb",
4542        "H",
4543        "hB"
4544    ],
4545    "MQ": [
4546        "H",
4547        "hB"
4548    ],
4549    "MR": [
4550        "h",
4551        "hB",
4552        "hb",
4553        "H"
4554    ],
4555    "MS": [
4556        "H",
4557        "h",
4558        "hb",
4559        "hB"
4560    ],
4561    "MT": [
4562        "H",
4563        "h"
4564    ],
4565    "MU": [
4566        "H",
4567        "h"
4568    ],
4569    "MV": [
4570        "H",
4571        "h"
4572    ],
4573    "MW": [
4574        "h",
4575        "hb",
4576        "H",
4577        "hB"
4578    ],
4579    "MX": [
4580        "h",
4581        "H",
4582        "hB",
4583        "hb"
4584    ],
4585    "MY": [
4586        "hb",
4587        "hB",
4588        "h",
4589        "H"
4590    ],
4591    "MZ": [
4592        "H",
4593        "hB"
4594    ],
4595    "NA": [
4596        "h",
4597        "H",
4598        "hB",
4599        "hb"
4600    ],
4601    "NC": [
4602        "H",
4603        "hB"
4604    ],
4605    "NE": [
4606        "H"
4607    ],
4608    "NF": [
4609        "H",
4610        "h",
4611        "hb",
4612        "hB"
4613    ],
4614    "NG": [
4615        "H",
4616        "h",
4617        "hb",
4618        "hB"
4619    ],
4620    "NI": [
4621        "h",
4622        "H",
4623        "hB",
4624        "hb"
4625    ],
4626    "NL": [
4627        "H",
4628        "hB"
4629    ],
4630    "NO": [
4631        "H",
4632        "h"
4633    ],
4634    "NP": [
4635        "H",
4636        "h",
4637        "hB"
4638    ],
4639    "NR": [
4640        "H",
4641        "h",
4642        "hb",
4643        "hB"
4644    ],
4645    "NU": [
4646        "H",
4647        "h",
4648        "hb",
4649        "hB"
4650    ],
4651    "NZ": [
4652        "h",
4653        "hb",
4654        "H",
4655        "hB"
4656    ],
4657    "OM": [
4658        "h",
4659        "hB",
4660        "hb",
4661        "H"
4662    ],
4663    "PA": [
4664        "h",
4665        "H",
4666        "hB",
4667        "hb"
4668    ],
4669    "PE": [
4670        "h",
4671        "H",
4672        "hB",
4673        "hb"
4674    ],
4675    "PF": [
4676        "H",
4677        "h",
4678        "hB"
4679    ],
4680    "PG": [
4681        "h",
4682        "H"
4683    ],
4684    "PH": [
4685        "h",
4686        "hB",
4687        "hb",
4688        "H"
4689    ],
4690    "PK": [
4691        "h",
4692        "hB",
4693        "H"
4694    ],
4695    "PL": [
4696        "H",
4697        "h"
4698    ],
4699    "PM": [
4700        "H",
4701        "hB"
4702    ],
4703    "PN": [
4704        "H",
4705        "h",
4706        "hb",
4707        "hB"
4708    ],
4709    "PR": [
4710        "h",
4711        "H",
4712        "hB",
4713        "hb"
4714    ],
4715    "PS": [
4716        "h",
4717        "hB",
4718        "hb",
4719        "H"
4720    ],
4721    "PT": [
4722        "H",
4723        "hB"
4724    ],
4725    "PW": [
4726        "h",
4727        "H"
4728    ],
4729    "PY": [
4730        "h",
4731        "H",
4732        "hB",
4733        "hb"
4734    ],
4735    "QA": [
4736        "h",
4737        "hB",
4738        "hb",
4739        "H"
4740    ],
4741    "RE": [
4742        "H",
4743        "hB"
4744    ],
4745    "RO": [
4746        "H",
4747        "hB"
4748    ],
4749    "RS": [
4750        "H",
4751        "hB",
4752        "h"
4753    ],
4754    "RU": [
4755        "H"
4756    ],
4757    "RW": [
4758        "H",
4759        "h"
4760    ],
4761    "SA": [
4762        "h",
4763        "hB",
4764        "hb",
4765        "H"
4766    ],
4767    "SB": [
4768        "h",
4769        "hb",
4770        "H",
4771        "hB"
4772    ],
4773    "SC": [
4774        "H",
4775        "h",
4776        "hB"
4777    ],
4778    "SD": [
4779        "h",
4780        "hB",
4781        "hb",
4782        "H"
4783    ],
4784    "SE": [
4785        "H"
4786    ],
4787    "SG": [
4788        "h",
4789        "hb",
4790        "H",
4791        "hB"
4792    ],
4793    "SH": [
4794        "H",
4795        "h",
4796        "hb",
4797        "hB"
4798    ],
4799    "SI": [
4800        "H",
4801        "hB"
4802    ],
4803    "SJ": [
4804        "H"
4805    ],
4806    "SK": [
4807        "H"
4808    ],
4809    "SL": [
4810        "h",
4811        "hb",
4812        "H",
4813        "hB"
4814    ],
4815    "SM": [
4816        "H",
4817        "h",
4818        "hB"
4819    ],
4820    "SN": [
4821        "H",
4822        "h",
4823        "hB"
4824    ],
4825    "SO": [
4826        "h",
4827        "H"
4828    ],
4829    "SR": [
4830        "H",
4831        "hB"
4832    ],
4833    "SS": [
4834        "h",
4835        "hb",
4836        "H",
4837        "hB"
4838    ],
4839    "ST": [
4840        "H",
4841        "hB"
4842    ],
4843    "SV": [
4844        "h",
4845        "H",
4846        "hB",
4847        "hb"
4848    ],
4849    "SX": [
4850        "H",
4851        "h",
4852        "hb",
4853        "hB"
4854    ],
4855    "SY": [
4856        "h",
4857        "hB",
4858        "hb",
4859        "H"
4860    ],
4861    "SZ": [
4862        "h",
4863        "hb",
4864        "H",
4865        "hB"
4866    ],
4867    "TA": [
4868        "H",
4869        "h",
4870        "hb",
4871        "hB"
4872    ],
4873    "TC": [
4874        "h",
4875        "hb",
4876        "H",
4877        "hB"
4878    ],
4879    "TD": [
4880        "h",
4881        "H",
4882        "hB"
4883    ],
4884    "TF": [
4885        "H",
4886        "h",
4887        "hB"
4888    ],
4889    "TG": [
4890        "H",
4891        "hB"
4892    ],
4893    "TH": [
4894        "H",
4895        "h"
4896    ],
4897    "TJ": [
4898        "H",
4899        "h"
4900    ],
4901    "TL": [
4902        "H",
4903        "hB",
4904        "hb",
4905        "h"
4906    ],
4907    "TM": [
4908        "H",
4909        "h"
4910    ],
4911    "TN": [
4912        "h",
4913        "hB",
4914        "hb",
4915        "H"
4916    ],
4917    "TO": [
4918        "h",
4919        "H"
4920    ],
4921    "TR": [
4922        "H",
4923        "hB"
4924    ],
4925    "TT": [
4926        "h",
4927        "hb",
4928        "H",
4929        "hB"
4930    ],
4931    "TW": [
4932        "hB",
4933        "hb",
4934        "h",
4935        "H"
4936    ],
4937    "TZ": [
4938        "hB",
4939        "hb",
4940        "H",
4941        "h"
4942    ],
4943    "UA": [
4944        "H",
4945        "hB",
4946        "h"
4947    ],
4948    "UG": [
4949        "hB",
4950        "hb",
4951        "H",
4952        "h"
4953    ],
4954    "UM": [
4955        "h",
4956        "hb",
4957        "H",
4958        "hB"
4959    ],
4960    "US": [
4961        "h",
4962        "hb",
4963        "H",
4964        "hB"
4965    ],
4966    "UY": [
4967        "h",
4968        "H",
4969        "hB",
4970        "hb"
4971    ],
4972    "UZ": [
4973        "H",
4974        "hB",
4975        "h"
4976    ],
4977    "VA": [
4978        "H",
4979        "h",
4980        "hB"
4981    ],
4982    "VC": [
4983        "h",
4984        "hb",
4985        "H",
4986        "hB"
4987    ],
4988    "VE": [
4989        "h",
4990        "H",
4991        "hB",
4992        "hb"
4993    ],
4994    "VG": [
4995        "h",
4996        "hb",
4997        "H",
4998        "hB"
4999    ],
5000    "VI": [
5001        "h",
5002        "hb",
5003        "H",
5004        "hB"
5005    ],
5006    "VN": [
5007        "H",
5008        "h"
5009    ],
5010    "VU": [
5011        "h",
5012        "H"
5013    ],
5014    "WF": [
5015        "H",
5016        "hB"
5017    ],
5018    "WS": [
5019        "h",
5020        "H"
5021    ],
5022    "XK": [
5023        "H",
5024        "hB",
5025        "h"
5026    ],
5027    "YE": [
5028        "h",
5029        "hB",
5030        "hb",
5031        "H"
5032    ],
5033    "YT": [
5034        "H",
5035        "hB"
5036    ],
5037    "ZA": [
5038        "H",
5039        "h",
5040        "hb",
5041        "hB"
5042    ],
5043    "ZM": [
5044        "h",
5045        "hb",
5046        "H",
5047        "hB"
5048    ],
5049    "ZW": [
5050        "H",
5051        "h"
5052    ],
5053    "af-ZA": [
5054        "H",
5055        "h",
5056        "hB",
5057        "hb"
5058    ],
5059    "ar-001": [
5060        "h",
5061        "hB",
5062        "hb",
5063        "H"
5064    ],
5065    "ca-ES": [
5066        "H",
5067        "h",
5068        "hB"
5069    ],
5070    "en-001": [
5071        "h",
5072        "hb",
5073        "H",
5074        "hB"
5075    ],
5076    "en-HK": [
5077        "h",
5078        "hb",
5079        "H",
5080        "hB"
5081    ],
5082    "en-IL": [
5083        "H",
5084        "h",
5085        "hb",
5086        "hB"
5087    ],
5088    "en-MY": [
5089        "h",
5090        "hb",
5091        "H",
5092        "hB"
5093    ],
5094    "es-BR": [
5095        "H",
5096        "h",
5097        "hB",
5098        "hb"
5099    ],
5100    "es-ES": [
5101        "H",
5102        "h",
5103        "hB",
5104        "hb"
5105    ],
5106    "es-GQ": [
5107        "H",
5108        "h",
5109        "hB",
5110        "hb"
5111    ],
5112    "fr-CA": [
5113        "H",
5114        "h",
5115        "hB"
5116    ],
5117    "gl-ES": [
5118        "H",
5119        "h",
5120        "hB"
5121    ],
5122    "gu-IN": [
5123        "hB",
5124        "hb",
5125        "h",
5126        "H"
5127    ],
5128    "hi-IN": [
5129        "hB",
5130        "h",
5131        "H"
5132    ],
5133    "it-CH": [
5134        "H",
5135        "h",
5136        "hB"
5137    ],
5138    "it-IT": [
5139        "H",
5140        "h",
5141        "hB"
5142    ],
5143    "kn-IN": [
5144        "hB",
5145        "h",
5146        "H"
5147    ],
5148    "ml-IN": [
5149        "hB",
5150        "h",
5151        "H"
5152    ],
5153    "mr-IN": [
5154        "hB",
5155        "hb",
5156        "h",
5157        "H"
5158    ],
5159    "pa-IN": [
5160        "hB",
5161        "hb",
5162        "h",
5163        "H"
5164    ],
5165    "ta-IN": [
5166        "hB",
5167        "h",
5168        "hb",
5169        "H"
5170    ],
5171    "te-IN": [
5172        "hB",
5173        "h",
5174        "H"
5175    ],
5176    "zu-ZA": [
5177        "H",
5178        "hB",
5179        "hb",
5180        "h"
5181    ]
5182};
5183
5184/**
5185 * Returns the best matching date time pattern if a date time skeleton
5186 * pattern is provided with a locale. Follows the Unicode specification:
5187 * https://www.unicode.org/reports/tr35/tr35-dates.html#table-mapping-requested-time-skeletons-to-patterns
5188 * @param skeleton date time skeleton pattern that possibly includes j, J or C
5189 * @param locale
5190 */
5191function getBestPattern(skeleton, locale) {
5192    var skeletonCopy = '';
5193    for (var patternPos = 0; patternPos < skeleton.length; patternPos++) {
5194        var patternChar = skeleton.charAt(patternPos);
5195        if (patternChar === 'j') {
5196            var extraLength = 0;
5197            while (patternPos + 1 < skeleton.length &&
5198                skeleton.charAt(patternPos + 1) === patternChar) {
5199                extraLength++;
5200                patternPos++;
5201            }
5202            var hourLen = 1 + (extraLength & 1);
5203            var dayPeriodLen = extraLength < 2 ? 1 : 3 + (extraLength >> 1);
5204            var dayPeriodChar = 'a';
5205            var hourChar = getDefaultHourSymbolFromLocale(locale);
5206            if (hourChar == 'H' || hourChar == 'k') {
5207                dayPeriodLen = 0;
5208            }
5209            while (dayPeriodLen-- > 0) {
5210                skeletonCopy += dayPeriodChar;
5211            }
5212            while (hourLen-- > 0) {
5213                skeletonCopy = hourChar + skeletonCopy;
5214            }
5215        }
5216        else if (patternChar === 'J') {
5217            skeletonCopy += 'H';
5218        }
5219        else {
5220            skeletonCopy += patternChar;
5221        }
5222    }
5223    return skeletonCopy;
5224}
5225/**
5226 * Maps the [hour cycle type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle)
5227 * of the given `locale` to the corresponding time pattern.
5228 * @param locale
5229 */
5230function getDefaultHourSymbolFromLocale(locale) {
5231    var hourCycle = locale.hourCycle;
5232    if (hourCycle === undefined &&
5233        // @ts-ignore hourCycle(s) is not identified yet
5234        locale.hourCycles &&
5235        // @ts-ignore
5236        locale.hourCycles.length) {
5237        // @ts-ignore
5238        hourCycle = locale.hourCycles[0];
5239    }
5240    if (hourCycle) {
5241        switch (hourCycle) {
5242            case 'h24':
5243                return 'k';
5244            case 'h23':
5245                return 'H';
5246            case 'h12':
5247                return 'h';
5248            case 'h11':
5249                return 'K';
5250            default:
5251                throw new Error('Invalid hourCycle');
5252        }
5253    }
5254    // TODO: Once hourCycle is fully supported remove the following with data generation
5255    var languageTag = locale.language;
5256    var regionTag;
5257    if (languageTag !== 'root') {
5258        regionTag = locale.maximize().region;
5259    }
5260    var hourCycles = timeData[regionTag || ''] ||
5261        timeData[languageTag || ''] ||
5262        timeData["".concat(languageTag, "-001")] ||
5263        timeData['001'];
5264    return hourCycles[0];
5265}
5266
5267var _a;
5268var SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(SPACE_SEPARATOR_REGEX.source, "*"));
5269var SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(SPACE_SEPARATOR_REGEX.source, "*$"));
5270function createLocation(start, end) {
5271    return { start: start, end: end };
5272}
5273// #region Ponyfills
5274// Consolidate these variables up top for easier toggling during debugging
5275var hasNativeStartsWith = !!String.prototype.startsWith && '_a'.startsWith('a', 1);
5276var hasNativeFromCodePoint = !!String.fromCodePoint;
5277var hasNativeFromEntries = !!Object.fromEntries;
5278var hasNativeCodePointAt = !!String.prototype.codePointAt;
5279var hasTrimStart = !!String.prototype.trimStart;
5280var hasTrimEnd = !!String.prototype.trimEnd;
5281var hasNativeIsSafeInteger = !!Number.isSafeInteger;
5282var isSafeInteger = hasNativeIsSafeInteger
5283    ? Number.isSafeInteger
5284    : function (n) {
5285        return (typeof n === 'number' &&
5286            isFinite(n) &&
5287            Math.floor(n) === n &&
5288            Math.abs(n) <= 0x1fffffffffffff);
5289    };
5290// IE11 does not support y and u.
5291var REGEX_SUPPORTS_U_AND_Y = true;
5292try {
5293    var re = RE('([^\\p{White_Space}\\p{Pattern_Syntax}]*)', 'yu');
5294    /**
5295     * legacy Edge or Xbox One browser
5296     * Unicode flag support: supported
5297     * Pattern_Syntax support: not supported
5298     * See https://github.com/formatjs/formatjs/issues/2822
5299     */
5300    REGEX_SUPPORTS_U_AND_Y = ((_a = re.exec('a')) === null || _a === void 0 ? void 0 : _a[0]) === 'a';
5301}
5302catch (_) {
5303    REGEX_SUPPORTS_U_AND_Y = false;
5304}
5305var startsWith = hasNativeStartsWith
5306    ? // Native
5307        function startsWith(s, search, position) {
5308            return s.startsWith(search, position);
5309        }
5310    : // For IE11
5311        function startsWith(s, search, position) {
5312            return s.slice(position, position + search.length) === search;
5313        };
5314var fromCodePoint = hasNativeFromCodePoint
5315    ? String.fromCodePoint
5316    : // IE11
5317        function fromCodePoint() {
5318            var codePoints = [];
5319            for (var _i = 0; _i < arguments.length; _i++) {
5320                codePoints[_i] = arguments[_i];
5321            }
5322            var elements = '';
5323            var length = codePoints.length;
5324            var i = 0;
5325            var code;
5326            while (length > i) {
5327                code = codePoints[i++];
5328                if (code > 0x10ffff)
5329                    throw RangeError(code + ' is not a valid code point');
5330                elements +=
5331                    code < 0x10000
5332                        ? String.fromCharCode(code)
5333                        : String.fromCharCode(((code -= 0x10000) >> 10) + 0xd800, (code % 0x400) + 0xdc00);
5334            }
5335            return elements;
5336        };
5337var fromEntries = 
5338// native
5339hasNativeFromEntries
5340    ? Object.fromEntries
5341    : // Ponyfill
5342        function fromEntries(entries) {
5343            var obj = {};
5344            for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
5345                var _a = entries_1[_i], k = _a[0], v = _a[1];
5346                obj[k] = v;
5347            }
5348            return obj;
5349        };
5350var codePointAt = hasNativeCodePointAt
5351    ? // Native
5352        function codePointAt(s, index) {
5353            return s.codePointAt(index);
5354        }
5355    : // IE 11
5356        function codePointAt(s, index) {
5357            var size = s.length;
5358            if (index < 0 || index >= size) {
5359                return undefined;
5360            }
5361            var first = s.charCodeAt(index);
5362            var second;
5363            return first < 0xd800 ||
5364                first > 0xdbff ||
5365                index + 1 === size ||
5366                (second = s.charCodeAt(index + 1)) < 0xdc00 ||
5367                second > 0xdfff
5368                ? first
5369                : ((first - 0xd800) << 10) + (second - 0xdc00) + 0x10000;
5370        };
5371var trimStart = hasTrimStart
5372    ? // Native
5373        function trimStart(s) {
5374            return s.trimStart();
5375        }
5376    : // Ponyfill
5377        function trimStart(s) {
5378            return s.replace(SPACE_SEPARATOR_START_REGEX, '');
5379        };
5380var trimEnd = hasTrimEnd
5381    ? // Native
5382        function trimEnd(s) {
5383            return s.trimEnd();
5384        }
5385    : // Ponyfill
5386        function trimEnd(s) {
5387            return s.replace(SPACE_SEPARATOR_END_REGEX, '');
5388        };
5389// Prevent minifier to translate new RegExp to literal form that might cause syntax error on IE11.
5390function RE(s, flag) {
5391    return new RegExp(s, flag);
5392}
5393// #endregion
5394var matchIdentifierAtIndex;
5395if (REGEX_SUPPORTS_U_AND_Y) {
5396    // Native
5397    var IDENTIFIER_PREFIX_RE_1 = RE('([^\\p{White_Space}\\p{Pattern_Syntax}]*)', 'yu');
5398    matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) {
5399        var _a;
5400        IDENTIFIER_PREFIX_RE_1.lastIndex = index;
5401        var match = IDENTIFIER_PREFIX_RE_1.exec(s);
5402        return (_a = match[1]) !== null && _a !== void 0 ? _a : '';
5403    };
5404}
5405else {
5406    // IE11
5407    matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) {
5408        var match = [];
5409        while (true) {
5410            var c = codePointAt(s, index);
5411            if (c === undefined || _isWhiteSpace(c) || _isPatternSyntax(c)) {
5412                break;
5413            }
5414            match.push(c);
5415            index += c >= 0x10000 ? 2 : 1;
5416        }
5417        return fromCodePoint.apply(void 0, match);
5418    };
5419}
5420var Parser = /** @class */ (function () {
5421    function Parser(message, options) {
5422        if (options === void 0) { options = {}; }
5423        this.message = message;
5424        this.position = { offset: 0, line: 1, column: 1 };
5425        this.ignoreTag = !!options.ignoreTag;
5426        this.locale = options.locale;
5427        this.requiresOtherClause = !!options.requiresOtherClause;
5428        this.shouldParseSkeletons = !!options.shouldParseSkeletons;
5429    }
5430    Parser.prototype.parse = function () {
5431        if (this.offset() !== 0) {
5432            throw Error('parser can only be used once');
5433        }
5434        return this.parseMessage(0, '', false);
5435    };
5436    Parser.prototype.parseMessage = function (nestingLevel, parentArgType, expectingCloseTag) {
5437        var elements = [];
5438        while (!this.isEOF()) {
5439            var char = this.char();
5440            if (char === 123 /* `{` */) {
5441                var result = this.parseArgument(nestingLevel, expectingCloseTag);
5442                if (result.err) {
5443                    return result;
5444                }
5445                elements.push(result.val);
5446            }
5447            else if (char === 125 /* `}` */ && nestingLevel > 0) {
5448                break;
5449            }
5450            else if (char === 35 /* `#` */ &&
5451                (parentArgType === 'plural' || parentArgType === 'selectordinal')) {
5452                var position = this.clonePosition();
5453                this.bump();
5454                elements.push({
5455                    type: TYPE.pound,
5456                    location: createLocation(position, this.clonePosition()),
5457                });
5458            }
5459            else if (char === 60 /* `<` */ &&
5460                !this.ignoreTag &&
5461                this.peek() === 47 // char code for '/'
5462            ) {
5463                if (expectingCloseTag) {
5464                    break;
5465                }
5466                else {
5467                    return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition()));
5468                }
5469            }
5470            else if (char === 60 /* `<` */ &&
5471                !this.ignoreTag &&
5472                _isAlpha(this.peek() || 0)) {
5473                var result = this.parseTag(nestingLevel, parentArgType);
5474                if (result.err) {
5475                    return result;
5476                }
5477                elements.push(result.val);
5478            }
5479            else {
5480                var result = this.parseLiteral(nestingLevel, parentArgType);
5481                if (result.err) {
5482                    return result;
5483                }
5484                elements.push(result.val);
5485            }
5486        }
5487        return { val: elements, err: null };
5488    };
5489    /**
5490     * A tag name must start with an ASCII lower/upper case letter. The grammar is based on the
5491     * [custom element name][] except that a dash is NOT always mandatory and uppercase letters
5492     * are accepted:
5493     *
5494     * ```
5495     * tag ::= "<" tagName (whitespace)* "/>" | "<" tagName (whitespace)* ">" message "</" tagName (whitespace)* ">"
5496     * tagName ::= [a-z] (PENChar)*
5497     * PENChar ::=
5498     *     "-" | "." | [0-9] | "_" | [a-z] | [A-Z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] |
5499     *     [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
5500     *     [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
5501     * ```
5502     *
5503     * [custom element name]: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
5504     * NOTE: We're a bit more lax here since HTML technically does not allow uppercase HTML element but we do
5505     * since other tag-based engines like React allow it
5506     */
5507    Parser.prototype.parseTag = function (nestingLevel, parentArgType) {
5508        var startPosition = this.clonePosition();
5509        this.bump(); // `<`
5510        var tagName = this.parseTagName();
5511        this.bumpSpace();
5512        if (this.bumpIf('/>')) {
5513            // Self closing tag
5514            return {
5515                val: {
5516                    type: TYPE.literal,
5517                    value: "<".concat(tagName, "/>"),
5518                    location: createLocation(startPosition, this.clonePosition()),
5519                },
5520                err: null,
5521            };
5522        }
5523        else if (this.bumpIf('>')) {
5524            var childrenResult = this.parseMessage(nestingLevel + 1, parentArgType, true);
5525            if (childrenResult.err) {
5526                return childrenResult;
5527            }
5528            var children = childrenResult.val;
5529            // Expecting a close tag
5530            var endTagStartPosition = this.clonePosition();
5531            if (this.bumpIf('</')) {
5532                if (this.isEOF() || !_isAlpha(this.char())) {
5533                    return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
5534                }
5535                var closingTagNameStartPosition = this.clonePosition();
5536                var closingTagName = this.parseTagName();
5537                if (tagName !== closingTagName) {
5538                    return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(closingTagNameStartPosition, this.clonePosition()));
5539                }
5540                this.bumpSpace();
5541                if (!this.bumpIf('>')) {
5542                    return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition()));
5543                }
5544                return {
5545                    val: {
5546                        type: TYPE.tag,
5547                        value: tagName,
5548                        children: children,
5549                        location: createLocation(startPosition, this.clonePosition()),
5550                    },
5551                    err: null,
5552                };
5553            }
5554            else {
5555                return this.error(ErrorKind.UNCLOSED_TAG, createLocation(startPosition, this.clonePosition()));
5556            }
5557        }
5558        else {
5559            return this.error(ErrorKind.INVALID_TAG, createLocation(startPosition, this.clonePosition()));
5560        }
5561    };
5562    /**
5563     * This method assumes that the caller has peeked ahead for the first tag character.
5564     */
5565    Parser.prototype.parseTagName = function () {
5566        var startOffset = this.offset();
5567        this.bump(); // the first tag name character
5568        while (!this.isEOF() && _isPotentialElementNameChar(this.char())) {
5569            this.bump();
5570        }
5571        return this.message.slice(startOffset, this.offset());
5572    };
5573    Parser.prototype.parseLiteral = function (nestingLevel, parentArgType) {
5574        var start = this.clonePosition();
5575        var value = '';
5576        while (true) {
5577            var parseQuoteResult = this.tryParseQuote(parentArgType);
5578            if (parseQuoteResult) {
5579                value += parseQuoteResult;
5580                continue;
5581            }
5582            var parseUnquotedResult = this.tryParseUnquoted(nestingLevel, parentArgType);
5583            if (parseUnquotedResult) {
5584                value += parseUnquotedResult;
5585                continue;
5586            }
5587            var parseLeftAngleResult = this.tryParseLeftAngleBracket();
5588            if (parseLeftAngleResult) {
5589                value += parseLeftAngleResult;
5590                continue;
5591            }
5592            break;
5593        }
5594        var location = createLocation(start, this.clonePosition());
5595        return {
5596            val: { type: TYPE.literal, value: value, location: location },
5597            err: null,
5598        };
5599    };
5600    Parser.prototype.tryParseLeftAngleBracket = function () {
5601        if (!this.isEOF() &&
5602            this.char() === 60 /* `<` */ &&
5603            (this.ignoreTag ||
5604                // If at the opening tag or closing tag position, bail.
5605                !_isAlphaOrSlash(this.peek() || 0))) {
5606            this.bump(); // `<`
5607            return '<';
5608        }
5609        return null;
5610    };
5611    /**
5612     * Starting with ICU 4.8, an ASCII apostrophe only starts quoted text if it immediately precedes
5613     * a character that requires quoting (that is, "only where needed"), and works the same in
5614     * nested messages as on the top level of the pattern. The new behavior is otherwise compatible.
5615     */
5616    Parser.prototype.tryParseQuote = function (parentArgType) {
5617        if (this.isEOF() || this.char() !== 39 /* `'` */) {
5618            return null;
5619        }
5620        // Parse escaped char following the apostrophe, or early return if there is no escaped char.
5621        // Check if is valid escaped character
5622        switch (this.peek()) {
5623            case 39 /* `'` */:
vendor: 4,213 bytes, lines 5624-5732
5624                // double quote, should return as a single quote.
5625                this.bump();
5626                this.bump();
5627                return "'";
5628            // '{', '<', '>', '}'
5629            case 123:
5630            case 60:
5631            case 62:
5632            case 125:
5633                break;
5634            case 35: // '#'
5635                if (parentArgType === 'plural' || parentArgType === 'selectordinal') {
5636                    break;
5637                }
5638                return null;
5639            default:
5640                return null;
5641        }
5642        this.bump(); // apostrophe
5643        var codePoints = [this.char()]; // escaped char
5644        this.bump();
5645        // read chars until the optional closing apostrophe is found
5646        while (!this.isEOF()) {
5647            var ch = this.char();
5648            if (ch === 39 /* `'` */) {
5649                if (this.peek() === 39 /* `'` */) {
5650                    codePoints.push(39);
5651                    // Bump one more time because we need to skip 2 characters.
5652                    this.bump();
5653                }
5654                else {
5655                    // Optional closing apostrophe.
5656                    this.bump();
5657                    break;
5658                }
5659            }
5660            else {
5661                codePoints.push(ch);
5662            }
5663            this.bump();
5664        }
5665        return fromCodePoint.apply(void 0, codePoints);
5666    };
5667    Parser.prototype.tryParseUnquoted = function (nestingLevel, parentArgType) {
5668        if (this.isEOF()) {
5669            return null;
5670        }
5671        var ch = this.char();
5672        if (ch === 60 /* `<` */ ||
5673            ch === 123 /* `{` */ ||
5674            (ch === 35 /* `#` */ &&
5675                (parentArgType === 'plural' || parentArgType === 'selectordinal')) ||
5676            (ch === 125 /* `}` */ && nestingLevel > 0)) {
5677            return null;
5678        }
5679        else {
5680            this.bump();
5681            return fromCodePoint(ch);
5682        }
5683    };
5684    Parser.prototype.parseArgument = function (nestingLevel, expectingCloseTag) {
5685        var openingBracePosition = this.clonePosition();
5686        this.bump(); // `{`
5687        this.bumpSpace();
5688        if (this.isEOF()) {
5689            return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
5690        }
5691        if (this.char() === 125 /* `}` */) {
5692            this.bump();
5693            return this.error(ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
5694        }
5695        // argument name
5696        var value = this.parseIdentifierIfPossible().value;
5697        if (!value) {
5698            return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
5699        }
5700        this.bumpSpace();
5701        if (this.isEOF()) {
5702            return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
5703        }
5704        switch (this.char()) {
5705            // Simple argument: `{name}`
5706            case 125 /* `}` */: {
5707                this.bump(); // `}`
5708                return {
5709                    val: {
5710                        type: TYPE.argument,
5711                        // value does not include the opening and closing braces.
5712                        value: value,
5713                        location: createLocation(openingBracePosition, this.clonePosition()),
5714                    },
5715                    err: null,
5716                };
5717            }
5718            // Argument with options: `{name, format, ...}`
5719            case 44 /* `,` */: {
5720                this.bump(); // `,`
5721                this.bumpSpace();
5722                if (this.isEOF()) {
5723                    return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
5724                }
5725                return this.parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition);
5726            }
5727            default:
5728                return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition()));
5729        }
5730    };
5731    /**
5732     * Advance the parser until the end of the identifier, if it is currently on
vendor: 11,335 bytes, lines 5733-5974
5733     * an identifier character. Return an empty string otherwise.
5734     */
5735    Parser.prototype.parseIdentifierIfPossible = function () {
5736        var startingPosition = this.clonePosition();
5737        var startOffset = this.offset();
5738        var value = matchIdentifierAtIndex(this.message, startOffset);
5739        var endOffset = startOffset + value.length;
5740        this.bumpTo(endOffset);
5741        var endPosition = this.clonePosition();
5742        var location = createLocation(startingPosition, endPosition);
5743        return { value: value, location: location };
5744    };
5745    Parser.prototype.parseArgumentOptions = function (nestingLevel, expectingCloseTag, value, openingBracePosition) {
5746        var _a;
5747        // Parse this range:
5748        // {name, type, style}
5749        //        ^---^
5750        var typeStartPosition = this.clonePosition();
5751        var argType = this.parseIdentifierIfPossible().value;
5752        var typeEndPosition = this.clonePosition();
5753        switch (argType) {
5754            case '':
5755                // Expecting a style string number, date, time, plural, selectordinal, or select.
5756                return this.error(ErrorKind.EXPECT_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
5757            case 'number':
5758            case 'date':
5759            case 'time': {
5760                // Parse this range:
5761                // {name, number, style}
5762                //              ^-------^
5763                this.bumpSpace();
5764                var styleAndLocation = null;
5765                if (this.bumpIf(',')) {
5766                    this.bumpSpace();
5767                    var styleStartPosition = this.clonePosition();
5768                    var result = this.parseSimpleArgStyleIfPossible();
5769                    if (result.err) {
5770                        return result;
5771                    }
5772                    var style = trimEnd(result.val);
5773                    if (style.length === 0) {
5774                        return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition()));
5775                    }
5776                    var styleLocation = createLocation(styleStartPosition, this.clonePosition());
5777                    styleAndLocation = { style: style, styleLocation: styleLocation };
5778                }
5779                var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
5780                if (argCloseResult.err) {
5781                    return argCloseResult;
5782                }
5783                var location_1 = createLocation(openingBracePosition, this.clonePosition());
5784                // Extract style or skeleton
5785                if (styleAndLocation && startsWith(styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style, '::', 0)) {
5786                    // Skeleton starts with `::`.
5787                    var skeleton = trimStart(styleAndLocation.style.slice(2));
5788                    if (argType === 'number') {
5789                        var result = this.parseNumberSkeletonFromString(skeleton, styleAndLocation.styleLocation);
5790                        if (result.err) {
5791                            return result;
5792                        }
5793                        return {
5794                            val: { type: TYPE.number, value: value, location: location_1, style: result.val },
5795                            err: null,
5796                        };
5797                    }
5798                    else {
5799                        if (skeleton.length === 0) {
5800                            return this.error(ErrorKind.EXPECT_DATE_TIME_SKELETON, location_1);
5801                        }
5802                        var dateTimePattern = skeleton;
5803                        // Get "best match" pattern only if locale is passed, if not, let it
5804                        // pass as-is where `parseDateTimeSkeleton()` will throw an error
5805                        // for unsupported patterns.
5806                        if (this.locale) {
5807                            dateTimePattern = getBestPattern(skeleton, this.locale);
5808                        }
5809                        var style = {
5810                            type: SKELETON_TYPE.dateTime,
5811                            pattern: dateTimePattern,
5812                            location: styleAndLocation.styleLocation,
5813                            parsedOptions: this.shouldParseSkeletons
5814                                ? parseDateTimeSkeleton(dateTimePattern)
5815                                : {},
5816                        };
5817                        var type = argType === 'date' ? TYPE.date : TYPE.time;
5818                        return {
5819                            val: { type: type, value: value, location: location_1, style: style },
5820                            err: null,
5821                        };
5822                    }
5823                }
5824                // Regular style or no style.
5825                return {
5826                    val: {
5827                        type: argType === 'number'
5828                            ? TYPE.number
5829                            : argType === 'date'
5830                                ? TYPE.date
5831                                : TYPE.time,
5832                        value: value,
5833                        location: location_1,
5834                        style: (_a = styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style) !== null && _a !== void 0 ? _a : null,
5835                    },
5836                    err: null,
5837                };
5838            }
5839            case 'plural':
5840            case 'selectordinal':
5841            case 'select': {
5842                // Parse this range:
5843                // {name, plural, options}
5844                //              ^---------^
5845                var typeEndPosition_1 = this.clonePosition();
5846                this.bumpSpace();
5847                if (!this.bumpIf(',')) {
5848                    return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition_1, __assign({}, typeEndPosition_1)));
5849                }
5850                this.bumpSpace();
5851                // Parse offset:
5852                // {name, plural, offset:1, options}
5853                //                ^-----^
5854                //
5855                // or the first option:
5856                //
5857                // {name, plural, one {...} other {...}}
5858                //                ^--^
5859                var identifierAndLocation = this.parseIdentifierIfPossible();
5860                var pluralOffset = 0;
5861                if (argType !== 'select' && identifierAndLocation.value === 'offset') {
5862                    if (!this.bumpIf(':')) {
5863                        return this.error(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, createLocation(this.clonePosition(), this.clonePosition()));
5864                    }
5865                    this.bumpSpace();
5866                    var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
5867                    if (result.err) {
5868                        return result;
5869                    }
5870                    // Parse another identifier for option parsing
5871                    this.bumpSpace();
5872                    identifierAndLocation = this.parseIdentifierIfPossible();
5873                    pluralOffset = result.val;
5874                }
5875                var optionsResult = this.tryParsePluralOrSelectOptions(nestingLevel, argType, expectingCloseTag, identifierAndLocation);
5876                if (optionsResult.err) {
5877                    return optionsResult;
5878                }
5879                var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
5880                if (argCloseResult.err) {
5881                    return argCloseResult;
5882                }
5883                var location_2 = createLocation(openingBracePosition, this.clonePosition());
5884                if (argType === 'select') {
5885                    return {
5886                        val: {
5887                            type: TYPE.select,
5888                            value: value,
5889                            options: fromEntries(optionsResult.val),
5890                            location: location_2,
5891                        },
5892                        err: null,
5893                    };
5894                }
5895                else {
5896                    return {
5897                        val: {
5898                            type: TYPE.plural,
5899                            value: value,
5900                            options: fromEntries(optionsResult.val),
5901                            offset: pluralOffset,
5902                            pluralType: argType === 'plural' ? 'cardinal' : 'ordinal',
5903                            location: location_2,
5904                        },
5905                        err: null,
5906                    };
5907                }
5908            }
5909            default:
5910                return this.error(ErrorKind.INVALID_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition));
5911        }
5912    };
5913    Parser.prototype.tryParseArgumentClose = function (openingBracePosition) {
5914        // Parse: {value, number, ::currency/GBP }
5915        //
5916        if (this.isEOF() || this.char() !== 125 /* `}` */) {
5917            return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition()));
5918        }
5919        this.bump(); // `}`
5920        return { val: true, err: null };
5921    };
5922    /**
5923     * See: https://github.com/unicode-org/icu/blob/af7ed1f6d2298013dc303628438ec4abe1f16479/icu4c/source/common/messagepattern.cpp#L659
5924     */
5925    Parser.prototype.parseSimpleArgStyleIfPossible = function () {
5926        var nestedBraces = 0;
5927        var startPosition = this.clonePosition();
5928        while (!this.isEOF()) {
5929            var ch = this.char();
5930            switch (ch) {
5931                case 39 /* `'` */: {
5932                    // Treat apostrophe as quoting but include it in the style part.
5933                    // Find the end of the quoted literal text.
5934                    this.bump();
5935                    var apostrophePosition = this.clonePosition();
5936                    if (!this.bumpUntil("'")) {
5937                        return this.error(ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, createLocation(apostrophePosition, this.clonePosition()));
5938                    }
5939                    this.bump();
5940                    break;
5941                }
5942                case 123 /* `{` */: {
5943                    nestedBraces += 1;
5944                    this.bump();
5945                    break;
5946                }
5947                case 125 /* `}` */: {
5948                    if (nestedBraces > 0) {
5949                        nestedBraces -= 1;
5950                    }
5951                    else {
5952                        return {
5953                            val: this.message.slice(startPosition.offset, this.offset()),
5954                            err: null,
5955                        };
5956                    }
5957                    break;
5958                }
5959                default:
5960                    this.bump();
5961                    break;
5962            }
5963        }
5964        return {
5965            val: this.message.slice(startPosition.offset, this.offset()),
5966            err: null,
5967        };
5968    };
5969    Parser.prototype.parseNumberSkeletonFromString = function (skeleton, location) {
5970        var tokens = [];
5971        try {
5972            tokens = parseNumberSkeletonFromString(skeleton);
5973        }
5974        catch (e) {
vendor: 4,672 bytes, lines 5975-6074
5975            return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location);
5976        }
5977        return {
5978            val: {
5979                type: SKELETON_TYPE.number,
5980                tokens: tokens,
5981                location: location,
5982                parsedOptions: this.shouldParseSkeletons
5983                    ? parseNumberSkeleton(tokens)
5984                    : {},
5985            },
5986            err: null,
5987        };
5988    };
5989    /**
5990     * @param nesting_level The current nesting level of messages.
5991     *     This can be positive when parsing message fragment in select or plural argument options.
5992     * @param parent_arg_type The parent argument's type.
5993     * @param parsed_first_identifier If provided, this is the first identifier-like selector of
5994     *     the argument. It is a by-product of a previous parsing attempt.
5995     * @param expecting_close_tag If true, this message is directly or indirectly nested inside
5996     *     between a pair of opening and closing tags. The nested message will not parse beyond
5997     *     the closing tag boundary.
5998     */
5999    Parser.prototype.tryParsePluralOrSelectOptions = function (nestingLevel, parentArgType, expectCloseTag, parsedFirstIdentifier) {
6000        var _a;
6001        var hasOtherClause = false;
6002        var options = [];
6003        var parsedSelectors = new Set();
6004        var selector = parsedFirstIdentifier.value, selectorLocation = parsedFirstIdentifier.location;
6005        // Parse:
6006        // one {one apple}
6007        // ^--^
6008        while (true) {
6009            if (selector.length === 0) {
6010                var startPosition = this.clonePosition();
6011                if (parentArgType !== 'select' && this.bumpIf('=')) {
6012                    // Try parse `={number}` selector
6013                    var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR);
6014                    if (result.err) {
6015                        return result;
6016                    }
6017                    selectorLocation = createLocation(startPosition, this.clonePosition());
6018                    selector = this.message.slice(startPosition.offset, this.offset());
6019                }
6020                else {
6021                    break;
6022                }
6023            }
6024            // Duplicate selector clauses
6025            if (parsedSelectors.has(selector)) {
6026                return this.error(parentArgType === 'select'
6027                    ? ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR
6028                    : ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, selectorLocation);
6029            }
6030            if (selector === 'other') {
6031                hasOtherClause = true;
6032            }
6033            // Parse:
6034            // one {one apple}
6035            //     ^----------^
6036            this.bumpSpace();
6037            var openingBracePosition = this.clonePosition();
6038            if (!this.bumpIf('{')) {
6039                return this.error(parentArgType === 'select'
6040                    ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT
6041                    : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, createLocation(this.clonePosition(), this.clonePosition()));
6042            }
6043            var fragmentResult = this.parseMessage(nestingLevel + 1, parentArgType, expectCloseTag);
6044            if (fragmentResult.err) {
6045                return fragmentResult;
6046            }
6047            var argCloseResult = this.tryParseArgumentClose(openingBracePosition);
6048            if (argCloseResult.err) {
6049                return argCloseResult;
6050            }
6051            options.push([
6052                selector,
6053                {
6054                    value: fragmentResult.val,
6055                    location: createLocation(openingBracePosition, this.clonePosition()),
6056                },
6057            ]);
6058            // Keep track of the existing selectors
6059            parsedSelectors.add(selector);
6060            // Prep next selector clause.
6061            this.bumpSpace();
6062            (_a = this.parseIdentifierIfPossible(), selector = _a.value, selectorLocation = _a.location);
6063        }
6064        if (options.length === 0) {
6065            return this.error(parentArgType === 'select'
6066                ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR
6067                : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, createLocation(this.clonePosition(), this.clonePosition()));
6068        }
6069        if (this.requiresOtherClause && !hasOtherClause) {
6070            return this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition()));
6071        }
6072        return { val: options, err: null };
6073    };
6074    Parser.prototype.tryParseDecimalInteger = function (expectNumberError, invalidNumber
vendor: 8,108 bytes, lines 6074-6323
6074Error) {
6075        var sign = 1;
6076        var startingPosition = this.clonePosition();
6077        if (this.bumpIf('+')) ;
6078        else if (this.bumpIf('-')) {
6079            sign = -1;
6080        }
6081        var hasDigits = false;
6082        var decimal = 0;
6083        while (!this.isEOF()) {
6084            var ch = this.char();
6085            if (ch >= 48 /* `0` */ && ch <= 57 /* `9` */) {
6086                hasDigits = true;
6087                decimal = decimal * 10 + (ch - 48);
6088                this.bump();
6089            }
6090            else {
6091                break;
6092            }
6093        }
6094        var location = createLocation(startingPosition, this.clonePosition());
6095        if (!hasDigits) {
6096            return this.error(expectNumberError, location);
6097        }
6098        decimal *= sign;
6099        if (!isSafeInteger(decimal)) {
6100            return this.error(invalidNumberError, location);
6101        }
6102        return { val: decimal, err: null };
6103    };
6104    Parser.prototype.offset = function () {
6105        return this.position.offset;
6106    };
6107    Parser.prototype.isEOF = function () {
6108        return this.offset() === this.message.length;
6109    };
6110    Parser.prototype.clonePosition = function () {
6111        // This is much faster than `Object.assign` or spread.
6112        return {
6113            offset: this.position.offset,
6114            line: this.position.line,
6115            column: this.position.column,
6116        };
6117    };
6118    /**
6119     * Return the code point at the current position of the parser.
6120     * Throws if the index is out of bound.
6121     */
6122    Parser.prototype.char = function () {
6123        var offset = this.position.offset;
6124        if (offset >= this.message.length) {
6125            throw Error('out of bound');
6126        }
6127        var code = codePointAt(this.message, offset);
6128        if (code === undefined) {
6129            throw Error("Offset ".concat(offset, " is at invalid UTF-16 code unit boundary"));
6130        }
6131        return code;
6132    };
6133    Parser.prototype.error = function (kind, location) {
6134        return {
6135            val: null,
6136            err: {
6137                kind: kind,
6138                message: this.message,
6139                location: location,
6140            },
6141        };
6142    };
6143    /** Bump the parser to the next UTF-16 code unit. */
6144    Parser.prototype.bump = function () {
6145        if (this.isEOF()) {
6146            return;
6147        }
6148        var code = this.char();
6149        if (code === 10 /* '\n' */) {
6150            this.position.line += 1;
6151            this.position.column = 1;
6152            this.position.offset += 1;
6153        }
6154        else {
6155            this.position.column += 1;
6156            // 0 ~ 0x10000 -> unicode BMP, otherwise skip the surrogate pair.
6157            this.position.offset += code < 0x10000 ? 1 : 2;
6158        }
6159    };
6160    /**
6161     * If the substring starting at the current position of the parser has
6162     * the given prefix, then bump the parser to the character immediately
6163     * following the prefix and return true. Otherwise, don't bump the parser
6164     * and return false.
6165     */
6166    Parser.prototype.bumpIf = function (prefix) {
6167        if (startsWith(this.message, prefix, this.offset())) {
6168            for (var i = 0; i < prefix.length; i++) {
6169                this.bump();
6170            }
6171            return true;
6172        }
6173        return false;
6174    };
6175    /**
6176     * Bump the parser until the pattern character is found and return `true`.
6177     * Otherwise bump to the end of the file and return `false`.
6178     */
6179    Parser.prototype.bumpUntil = function (pattern) {
6180        var currentOffset = this.offset();
6181        var index = this.message.indexOf(pattern, currentOffset);
6182        if (index >= 0) {
6183            this.bumpTo(index);
6184            return true;
6185        }
6186        else {
6187            this.bumpTo(this.message.length);
6188            return false;
6189        }
6190    };
6191    /**
6192     * Bump the parser to the target offset.
6193     * If target offset is beyond the end of the input, bump the parser to the end of the input.
6194     */
6195    Parser.prototype.bumpTo = function (targetOffset) {
6196        if (this.offset() > targetOffset) {
6197            throw Error("targetOffset ".concat(targetOffset, " must be greater than or equal to the current offset ").concat(this.offset()));
6198        }
6199        targetOffset = Math.min(targetOffset, this.message.length);
6200        while (true) {
6201            var offset = this.offset();
6202            if (offset === targetOffset) {
6203                break;
6204            }
6205            if (offset > targetOffset) {
6206                throw Error("targetOffset ".concat(targetOffset, " is at invalid UTF-16 code unit boundary"));
6207            }
6208            this.bump();
6209            if (this.isEOF()) {
6210                break;
6211            }
6212        }
6213    };
6214    /** advance the parser through all whitespace to the next non-whitespace code unit. */
6215    Parser.prototype.bumpSpace = function () {
6216        while (!this.isEOF() && _isWhiteSpace(this.char())) {
6217            this.bump();
6218        }
6219    };
6220    /**
6221     * Peek at the *next* Unicode codepoint in the input without advancing the parser.
6222     * If the input has been exhausted, then this returns null.
6223     */
6224    Parser.prototype.peek = function () {
6225        if (this.isEOF()) {
6226            return null;
6227        }
6228        var code = this.char();
6229        var offset = this.offset();
6230        var nextCode = this.message.charCodeAt(offset + (code >= 0x10000 ? 2 : 1));
6231        return nextCode !== null && nextCode !== void 0 ? nextCode : null;
6232    };
6233    return Parser;
6234}());
6235/**
6236 * This check if codepoint is alphabet (lower & uppercase)
6237 * @param codepoint
6238 * @returns
6239 */
6240function _isAlpha(codepoint) {
6241    return ((codepoint >= 97 && codepoint <= 122) ||
6242        (codepoint >= 65 && codepoint <= 90));
6243}
6244function _isAlphaOrSlash(codepoint) {
6245    return _isAlpha(codepoint) || codepoint === 47; /* '/' */
6246}
6247/** See `parseTag` function docs. */
6248function _isPotentialElementNameChar(c) {
6249    return (c === 45 /* '-' */ ||
6250        c === 46 /* '.' */ ||
6251        (c >= 48 && c <= 57) /* 0..9 */ ||
6252        c === 95 /* '_' */ ||
6253        (c >= 97 && c <= 122) /** a..z */ ||
6254        (c >= 65 && c <= 90) /* A..Z */ ||
6255        c == 0xb7 ||
6256        (c >= 0xc0 && c <= 0xd6) ||
6257        (c >= 0xd8 && c <= 0xf6) ||
6258        (c >= 0xf8 && c <= 0x37d) ||
6259        (c >= 0x37f && c <= 0x1fff) ||
6260        (c >= 0x200c && c <= 0x200d) ||
6261        (c >= 0x203f && c <= 0x2040) ||
6262        (c >= 0x2070 && c <= 0x218f) ||
6263        (c >= 0x2c00 && c <= 0x2fef) ||
6264        (c >= 0x3001 && c <= 0xd7ff) ||
6265        (c >= 0xf900 && c <= 0xfdcf) ||
6266        (c >= 0xfdf0 && c <= 0xfffd) ||
6267        (c >= 0x10000 && c <= 0xeffff));
6268}
6269/**
6270 * Code point equivalent of regex `\p{White_Space}`.
6271 * From: https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
6272 */
6273function _isWhiteSpace(c) {
6274    return ((c >= 0x0009 && c <= 0x000d) ||
6275        c === 0x0020 ||
6276        c === 0x0085 ||
6277        (c >= 0x200e && c <= 0x200f) ||
6278        c === 0x2028 ||
6279        c === 0x2029);
6280}
6281/**
6282 * Code point equivalent of regex `\p{Pattern_Syntax}`.
6283 * See https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt
6284 */
6285function _isPatternSyntax(c) {
6286    return ((c >= 0x0021 && c <= 0x0023) ||
6287        c === 0x0024 ||
6288        (c >= 0x0025 && c <= 0x0027) ||
6289        c === 0x0028 ||
6290        c === 0x0029 ||
6291        c === 0x002a ||
6292        c === 0x002b ||
6293        c === 0x002c ||
6294        c === 0x002d ||
6295        (c >= 0x002e && c <= 0x002f) ||
6296        (c >= 0x003a && c <= 0x003b) ||
6297        (c >= 0x003c && c <= 0x003e) ||
6298        (c >= 0x003f && c <= 0x0040) ||
6299        c === 0x005b ||
6300        c === 0x005c ||
6301        c === 0x005d ||
6302        c === 0x005e ||
6303        c === 0x0060 ||
6304        c === 0x007b ||
6305        c === 0x007c ||
6306        c === 0x007d ||
6307        c === 0x007e ||
6308        c === 0x00a1 ||
6309        (c >= 0x00a2 && c <= 0x00a5) ||
6310        c === 0x00a6 ||
6311        c === 0x00a7 ||
6312        c === 0x00a9 ||
6313        c === 0x00ab ||
6314        c === 0x00ac ||
6315        c === 0x00ae ||
6316        c === 0x00b0 ||
6317        c === 0x00b1 ||
6318        c === 0x00b6 ||
6319        c === 0x00bb ||
6320        c === 0x00bf ||
6321        c === 0x00d7 ||
6322        c === 0x00f7 ||
6323        (c >
vendor: 6,252 bytes, lines 6323-6536
6323= 0x2010 && c <= 0x2015) ||
6324        (c >= 0x2016 && c <= 0x2017) ||
6325        c === 0x2018 ||
6326        c === 0x2019 ||
6327        c === 0x201a ||
6328        (c >= 0x201b && c <= 0x201c) ||
6329        c === 0x201d ||
6330        c === 0x201e ||
6331        c === 0x201f ||
6332        (c >= 0x2020 && c <= 0x2027) ||
6333        (c >= 0x2030 && c <= 0x2038) ||
6334        c === 0x2039 ||
6335        c === 0x203a ||
6336        (c >= 0x203b && c <= 0x203e) ||
6337        (c >= 0x2041 && c <= 0x2043) ||
6338        c === 0x2044 ||
6339        c === 0x2045 ||
6340        c === 0x2046 ||
6341        (c >= 0x2047 && c <= 0x2051) ||
6342        c === 0x2052 ||
6343        c === 0x2053 ||
6344        (c >= 0x2055 && c <= 0x205e) ||
6345        (c >= 0x2190 && c <= 0x2194) ||
6346        (c >= 0x2195 && c <= 0x2199) ||
6347        (c >= 0x219a && c <= 0x219b) ||
6348        (c >= 0x219c && c <= 0x219f) ||
6349        c === 0x21a0 ||
6350        (c >= 0x21a1 && c <= 0x21a2) ||
6351        c === 0x21a3 ||
6352        (c >= 0x21a4 && c <= 0x21a5) ||
6353        c === 0x21a6 ||
6354        (c >= 0x21a7 && c <= 0x21ad) ||
6355        c === 0x21ae ||
6356        (c >= 0x21af && c <= 0x21cd) ||
6357        (c >= 0x21ce && c <= 0x21cf) ||
6358        (c >= 0x21d0 && c <= 0x21d1) ||
6359        c === 0x21d2 ||
6360        c === 0x21d3 ||
6361        c === 0x21d4 ||
6362        (c >= 0x21d5 && c <= 0x21f3) ||
6363        (c >= 0x21f4 && c <= 0x22ff) ||
6364        (c >= 0x2300 && c <= 0x2307) ||
6365        c === 0x2308 ||
6366        c === 0x2309 ||
6367        c === 0x230a ||
6368        c === 0x230b ||
6369        (c >= 0x230c && c <= 0x231f) ||
6370        (c >= 0x2320 && c <= 0x2321) ||
6371        (c >= 0x2322 && c <= 0x2328) ||
6372        c === 0x2329 ||
6373        c === 0x232a ||
6374        (c >= 0x232b && c <= 0x237b) ||
6375        c === 0x237c ||
6376        (c >= 0x237d && c <= 0x239a) ||
6377        (c >= 0x239b && c <= 0x23b3) ||
6378        (c >= 0x23b4 && c <= 0x23db) ||
6379        (c >= 0x23dc && c <= 0x23e1) ||
6380        (c >= 0x23e2 && c <= 0x2426) ||
6381        (c >= 0x2427 && c <= 0x243f) ||
6382        (c >= 0x2440 && c <= 0x244a) ||
6383        (c >= 0x244b && c <= 0x245f) ||
6384        (c >= 0x2500 && c <= 0x25b6) ||
6385        c === 0x25b7 ||
6386        (c >= 0x25b8 && c <= 0x25c0) ||
6387        c === 0x25c1 ||
6388        (c >= 0x25c2 && c <= 0x25f7) ||
6389        (c >= 0x25f8 && c <= 0x25ff) ||
6390        (c >= 0x2600 && c <= 0x266e) ||
6391        c === 0x266f ||
6392        (c >= 0x2670 && c <= 0x2767) ||
6393        c === 0x2768 ||
6394        c === 0x2769 ||
6395        c === 0x276a ||
6396        c === 0x276b ||
6397        c === 0x276c ||
6398        c === 0x276d ||
6399        c === 0x276e ||
6400        c === 0x276f ||
6401        c === 0x2770 ||
6402        c === 0x2771 ||
6403        c === 0x2772 ||
6404        c === 0x2773 ||
6405        c === 0x2774 ||
6406        c === 0x2775 ||
6407        (c >= 0x2794 && c <= 0x27bf) ||
6408        (c >= 0x27c0 && c <= 0x27c4) ||
6409        c === 0x27c5 ||
6410        c === 0x27c6 ||
6411        (c >= 0x27c7 && c <= 0x27e5) ||
6412        c === 0x27e6 ||
6413        c === 0x27e7 ||
6414        c === 0x27e8 ||
6415        c === 0x27e9 ||
6416        c === 0x27ea ||
6417        c === 0x27eb ||
6418        c === 0x27ec ||
6419        c === 0x27ed ||
6420        c === 0x27ee ||
6421        c === 0x27ef ||
6422        (c >= 0x27f0 && c <= 0x27ff) ||
6423        (c >= 0x2800 && c <= 0x28ff) ||
6424        (c >= 0x2900 && c <= 0x2982) ||
6425        c === 0x2983 ||
6426        c === 0x2984 ||
6427        c === 0x2985 ||
6428        c === 0x2986 ||
6429        c === 0x2987 ||
6430        c === 0x2988 ||
6431        c === 0x2989 ||
6432        c === 0x298a ||
6433        c === 0x298b ||
6434        c === 0x298c ||
6435        c === 0x298d ||
6436        c === 0x298e ||
6437        c === 0x298f ||
6438        c === 0x2990 ||
6439        c === 0x2991 ||
6440        c === 0x2992 ||
6441        c === 0x2993 ||
6442        c === 0x2994 ||
6443        c === 0x2995 ||
6444        c === 0x2996 ||
6445        c === 0x2997 ||
6446        c === 0x2998 ||
6447        (c >= 0x2999 && c <= 0x29d7) ||
6448        c === 0x29d8 ||
6449        c === 0x29d9 ||
6450        c === 0x29da ||
6451        c === 0x29db ||
6452        (c >= 0x29dc && c <= 0x29fb) ||
6453        c === 0x29fc ||
6454        c === 0x29fd ||
6455        (c >= 0x29fe && c <= 0x2aff) ||
6456        (c >= 0x2b00 && c <= 0x2b2f) ||
6457        (c >= 0x2b30 && c <= 0x2b44) ||
6458        (c >= 0x2b45 && c <= 0x2b46) ||
6459        (c >= 0x2b47 && c <= 0x2b4c) ||
6460        (c >= 0x2b4d && c <= 0x2b73) ||
6461        (c >= 0x2b74 && c <= 0x2b75) ||
6462        (c >= 0x2b76 && c <= 0x2b95) ||
6463        c === 0x2b96 ||
6464        (c >= 0x2b97 && c <= 0x2bff) ||
6465        (c >= 0x2e00 && c <= 0x2e01) ||
6466        c === 0x2e02 ||
6467        c === 0x2e03 ||
6468        c === 0x2e04 ||
6469        c === 0x2e05 ||
6470        (c >= 0x2e06 && c <= 0x2e08) ||
6471        c === 0x2e09 ||
6472        c === 0x2e0a ||
6473        c === 0x2e0b ||
6474        c === 0x2e0c ||
6475        c === 0x2e0d ||
6476        (c >= 0x2e0e && c <= 0x2e16) ||
6477        c === 0x2e17 ||
6478        (c >= 0x2e18 && c <= 0x2e19) ||
6479        c === 0x2e1a ||
6480        c === 0x2e1b ||
6481        c === 0x2e1c ||
6482        c === 0x2e1d ||
6483        (c >= 0x2e1e && c <= 0x2e1f) ||
6484        c === 0x2e20 ||
6485        c === 0x2e21 ||
6486        c === 0x2e22 ||
6487        c === 0x2e23 ||
6488        c === 0x2e24 ||
6489        c === 0x2e25 ||
6490        c === 0x2e26 ||
6491        c === 0x2e27 ||
6492        c === 0x2e28 ||
6493        c === 0x2e29 ||
6494        (c >= 0x2e2a && c <= 0x2e2e) ||
6495        c === 0x2e2f ||
6496        (c >= 0x2e30 && c <= 0x2e39) ||
6497        (c >= 0x2e3a && c <= 0x2e3b) ||
6498        (c >= 0x2e3c && c <= 0x2e3f) ||
6499        c === 0x2e40 ||
6500        c === 0x2e41 ||
6501        c === 0x2e42 ||
6502        (c >= 0x2e43 && c <= 0x2e4f) ||
6503        (c >= 0x2e50 && c <= 0x2e51) ||
6504        c === 0x2e52 ||
6505        (c >= 0x2e53 && c <= 0x2e7f) ||
6506        (c >= 0x3001 && c <= 0x3003) ||
6507        c === 0x3008 ||
6508        c === 0x3009 ||
6509        c === 0x300a ||
6510        c === 0x300b ||
6511        c === 0x300c ||
6512        c === 0x300d ||
6513        c === 0x300e ||
6514        c === 0x300f ||
6515        c === 0x3010 ||
6516        c === 0x3011 ||
6517        (c >= 0x3012 && c <= 0x3013) ||
6518        c === 0x3014 ||
6519        c === 0x3015 ||
6520        c === 0x3016 ||
6521        c === 0x3017 ||
6522        c === 0x3018 ||
6523        c === 0x3019 ||
6524        c === 0x301a ||
6525        c === 0x301b ||
6526        c === 0x301c ||
6527        c === 0x301d ||
6528        (c >= 0x301e && c <= 0x301f) ||
6529        c === 0x3020 ||
6530        c === 0x3030 ||
6531        c === 0xfd3e ||
6532        c === 0xfd3f ||
6533        (c >= 0xfe45 && c <= 0xfe46));
6534}
6535
6536function pruneLocation(els) {
vendor: 4,134 bytes, lines 6537-6643
6537    els.forEach(function (el) {
6538        delete el.location;
6539        if (isSelectElement(el) || isPluralElement(el)) {
6540            for (var k in el.options) {
6541                delete el.options[k].location;
6542                pruneLocation(el.options[k].value);
6543            }
6544        }
6545        else if (isNumberElement(el) && isNumberSkeleton(el.style)) {
6546            delete el.style.location;
6547        }
6548        else if ((isDateElement(el) || isTimeElement(el)) &&
6549            isDateTimeSkeleton(el.style)) {
6550            delete el.style.location;
6551        }
6552        else if (isTagElement(el)) {
6553            pruneLocation(el.children);
6554        }
6555    });
6556}
6557function parse(message, opts) {
6558    if (opts === void 0) { opts = {}; }
6559    opts = __assign({ shouldParseSkeletons: true, requiresOtherClause: true }, opts);
6560    var result = new Parser(message, opts).parse();
6561    if (result.err) {
6562        var error = SyntaxError(ErrorKind[result.err.kind]);
6563        // @ts-expect-error Assign to error object
6564        error.location = result.err.location;
6565        // @ts-expect-error Assign to error object
6566        error.originalMessage = result.err.message;
6567        throw error;
6568    }
6569    if (!(opts === null || opts === void 0 ? void 0 : opts.captureLocation)) {
6570        pruneLocation(result.val);
6571    }
6572    return result.val;
6573}
6574
6575var ErrorCode;
6576(function (ErrorCode) {
6577    // When we have a placeholder but no value to format
6578    ErrorCode["MISSING_VALUE"] = "MISSING_VALUE";
6579    // When value supplied is invalid
6580    ErrorCode["INVALID_VALUE"] = "INVALID_VALUE";
6581    // When we need specific Intl API but it's not available
6582    ErrorCode["MISSING_INTL_API"] = "MISSING_INTL_API";
6583})(ErrorCode || (ErrorCode = {}));
6584var FormatError = /** @class */ (function (_super) {
6585    __extends(FormatError, _super);
6586    function FormatError(msg, code, originalMessage) {
6587        var _this = _super.call(this, msg) || this;
6588        _this.code = code;
6589        _this.originalMessage = originalMessage;
6590        return _this;
6591    }
6592    FormatError.prototype.toString = function () {
6593        return "[formatjs Error: ".concat(this.code, "] ").concat(this.message);
6594    };
6595    return FormatError;
6596}(Error));
6597var InvalidValueError = /** @class */ (function (_super) {
6598    __extends(InvalidValueError, _super);
6599    function InvalidValueError(variableId, value, options, originalMessage) {
6600        return _super.call(this, "Invalid values for \"".concat(variableId, "\": \"").concat(value, "\". Options are \"").concat(Object.keys(options).join('", "'), "\""), ErrorCode.INVALID_VALUE, originalMessage) || this;
6601    }
6602    return InvalidValueError;
6603}(FormatError));
6604var InvalidValueTypeError = /** @class */ (function (_super) {
6605    __extends(InvalidValueTypeError, _super);
6606    function InvalidValueTypeError(value, type, originalMessage) {
6607        return _super.call(this, "Value for \"".concat(value, "\" must be of type ").concat(type), ErrorCode.INVALID_VALUE, originalMessage) || this;
6608    }
6609    return InvalidValueTypeError;
6610}(FormatError));
6611var MissingValueError = /** @class */ (function (_super) {
6612    __extends(MissingValueError, _super);
6613    function MissingValueError(variableId, originalMessage) {
6614        return _super.call(this, "The intl string context variable \"".concat(variableId, "\" was not provided to the string \"").concat(originalMessage, "\""), ErrorCode.MISSING_VALUE, originalMessage) || this;
6615    }
6616    return MissingValueError;
6617}(FormatError));
6618
6619var PART_TYPE;
6620(function (PART_TYPE) {
6621    PART_TYPE[PART_TYPE["literal"] = 0] = "literal";
6622    PART_TYPE[PART_TYPE["object"] = 1] = "object";
6623})(PART_TYPE || (PART_TYPE = {}));
6624function mergeLiteral(parts) {
6625    if (parts.length < 2) {
6626        return parts;
6627    }
6628    return parts.reduce(function (all, part) {
6629        var lastPart = all[all.length - 1];
6630        if (!lastPart ||
6631            lastPart.type !== PART_TYPE.literal ||
6632            part.type !== PART_TYPE.literal) {
6633            all.push(part);
6634        }
6635        else {
6636            lastPart.value += part.value;
6637        }
6638        return all;
6639    }, []);
6640}
6641function isFormatXMLElementFn(el) {
6642    return typeof el === 'function';
6643}
vendor: 6,277 bytes, lines 6644-6805
6644// TODO(skeleton): add skeleton support
6645function formatToParts(els, locales, formatters, formats, values, currentPluralValue, 
6646// For debugging
6647originalMessage) {
6648    // Hot path for straight simple msg translations
6649    if (els.length === 1 && isLiteralElement(els[0])) {
6650        return [
6651            {
6652                type: PART_TYPE.literal,
6653                value: els[0].value,
6654            },
6655        ];
6656    }
6657    var result = [];
6658    for (var _i = 0, els_1 = els; _i < els_1.length; _i++) {
6659        var el = els_1[_i];
6660        // Exit early for string parts.
6661        if (isLiteralElement(el)) {
6662            result.push({
6663                type: PART_TYPE.literal,
6664                value: el.value,
6665            });
6666            continue;
6667        }
6668        // TODO: should this part be literal type?
6669        // Replace `#` in plural rules with the actual numeric value.
6670        if (isPoundElement(el)) {
6671            if (typeof currentPluralValue === 'number') {
6672                result.push({
6673                    type: PART_TYPE.literal,
6674                    value: formatters.getNumberFormat(locales).format(currentPluralValue),
6675                });
6676            }
6677            continue;
6678        }
6679        var varName = el.value;
6680        // Enforce that all required values are provided by the caller.
6681        if (!(values && varName in values)) {
6682            throw new MissingValueError(varName, originalMessage);
6683        }
6684        var value = values[varName];
6685        if (isArgumentElement(el)) {
6686            if (!value || typeof value === 'string' || typeof value === 'number') {
6687                value =
6688                    typeof value === 'string' || typeof value === 'number'
6689                        ? String(value)
6690                        : '';
6691            }
6692            result.push({
6693                type: typeof value === 'string' ? PART_TYPE.literal : PART_TYPE.object,
6694                value: value,
6695            });
6696            continue;
6697        }
6698        // Recursively format plural and select parts' option — which can be a
6699        // nested pattern structure. The choosing of the option to use is
6700        // abstracted-by and delegated-to the part helper object.
6701        if (isDateElement(el)) {
6702            var style = typeof el.style === 'string'
6703                ? formats.date[el.style]
6704                : isDateTimeSkeleton(el.style)
6705                    ? el.style.parsedOptions
6706                    : undefined;
6707            result.push({
6708                type: PART_TYPE.literal,
6709                value: formatters
6710                    .getDateTimeFormat(locales, style)
6711                    .format(value),
6712            });
6713            continue;
6714        }
6715        if (isTimeElement(el)) {
6716            var style = typeof el.style === 'string'
6717                ? formats.time[el.style]
6718                : isDateTimeSkeleton(el.style)
6719                    ? el.style.parsedOptions
6720                    : formats.time.medium;
6721            result.push({
6722                type: PART_TYPE.literal,
6723                value: formatters
6724                    .getDateTimeFormat(locales, style)
6725                    .format(value),
6726            });
6727            continue;
6728        }
6729        if (isNumberElement(el)) {
6730            var style = typeof el.style === 'string'
6731                ? formats.number[el.style]
6732                : isNumberSkeleton(el.style)
6733                    ? el.style.parsedOptions
6734                    : undefined;
6735            if (style && style.scale) {
6736                value =
6737                    value *
6738                        (style.scale || 1);
6739            }
6740            result.push({
6741                type: PART_TYPE.literal,
6742                value: formatters
6743                    .getNumberFormat(locales, style)
6744                    .format(value),
6745            });
6746            continue;
6747        }
6748        if (isTagElement(el)) {
6749            var children = el.children, value_1 = el.value;
6750            var formatFn = values[value_1];
6751            if (!isFormatXMLElementFn(formatFn)) {
6752                throw new InvalidValueTypeError(value_1, 'function', originalMessage);
6753            }
6754            var parts = formatToParts(children, locales, formatters, formats, values, currentPluralValue);
6755            var chunks = formatFn(parts.map(function (p) { return p.value; }));
6756            if (!Array.isArray(chunks)) {
6757                chunks = [chunks];
6758            }
6759            result.push.apply(result, chunks.map(function (c) {
6760                return {
6761                    type: typeof c === 'string' ? PART_TYPE.literal : PART_TYPE.object,
6762                    value: c,
6763                };
6764            }));
6765        }
6766        if (isSelectElement(el)) {
6767            var opt = el.options[value] || el.options.other;
6768            if (!opt) {
6769                throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
6770            }
6771            result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values));
6772            continue;
6773        }
6774        if (isPluralElement(el)) {
6775            var opt = el.options["=".concat(value)];
6776            if (!opt) {
6777                if (!Intl.PluralRules) {
6778                    throw new FormatError("Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n", ErrorCode.MISSING_INTL_API, originalMessage);
6779                }
6780                var rule = formatters
6781                    .getPluralRules(locales, { type: el.pluralType })
6782                    .select(value - (el.offset || 0));
6783                opt = el.options[rule] || el.options.other;
6784            }
6785            if (!opt) {
6786                throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage);
6787            }
6788            result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values, value - (el.offset || 0)));
6789            continue;
6790        }
6791    }
6792    return mergeLiteral(result);
6793}
6794
6795/*
6796Copyright (c) 2014, Yahoo! Inc. All rights reserved.
6797Copyrights licensed under the New BSD License.
6798See the accompanying LICENSE file for terms.
6799*/
6800// -- MessageFormat --------------------------------------------------------
6801function mergeConfig(c1, c2) {
6802    if (!c2) {
6803        return c1;
6804    }
6805    return __assign
6805(__assign(__assign({}, (c1 || {})), (c2 || {})), Object.keys(c1).reduce(function (all, k) {
6806        all[k] = __assign(__assign({}, c1[k]), (c2[k] || {}));
6807        return all;
6808    }, {}));
6809}
6810function mergeConfigs(defaultConfig, configs) {
6811    if (!configs) {
6812        return defaultConfig;
6813    }
6814    return Object.keys(defaultConfig).reduce(function (all, k) {
6815        all[k] = mergeConfig(defaultConfig[k], configs[k]);
6816        return all;
6817    }, __assign({}, defaultConfig));
6818}
6819function createFastMemoizeCache(store) {
6820    return {
6821        create: function () {
6822            return {
6823                get: function (key) {
6824                    return store[key];
6825                },
6826                set: function (key, value) {
6827                    store[key] = value;
6828                },
6829            };
6830        },
6831    };
6832}
6833function createDefaultFormatters(cache) {
6834    if (cache === void 0) { cache = {
6835        number: {},
6836        dateTime: {},
6837        pluralRules: {},
6838    }; }
6839    return {
6840        getNumberFormat: memoize(function () {
6841            var _a;
6842            var args = [];
6843            for (var _i = 0; _i < arguments.length; _i++) {
6844                args[_i] = arguments[_i];
6845            }
6846            return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
6847        }, {
6848            cache: createFastMemoizeCache(cache.number),
6849            strategy: strategies.variadic,
6850        }),
6851        getDateTimeFormat: memoize(function () {
6852            var _a;
6853            var args = [];
6854            for (var _i = 0; _i < arguments.length; _i++) {
6855                args[_i] = arguments[_i];
6856            }
6857            return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
6858        }, {
6859            cache: createFastMemoizeCache(cache.dateTime),
6860            strategy: strategies.variadic,
6861        }),
6862        getPluralRules: memoize(function () {
6863            var _a;
6864            var args = [];
6865            for (var _i = 0; _i < arguments.length; _i++) {
6866                args[_i] = arguments[_i];
6867            }
6868            return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArray([void 0], args, false)))();
6869        }, {
6870            cache: createFastMemoizeCache(cache.pluralRules),
6871            strategy: strategies.variadic,
6872        }),
6873    };
6874}
6875var IntlMessageFormat = /** @class */ (function () {
6876    function IntlMessageFormat(message, locales, overrideFormats, opts) {
6877        if (locales === void 0) { locales = IntlMessageFormat.defaultLocale; }
6878        var _this = this;
6879        this.formatterCache = {
6880            number: {},
6881            dateTime: {},
6882            pluralRules: {},
6883        };
6884        this.format = function (values) {
6885            var parts = _this.formatToParts(values);
6886            // Hot path for straight simple msg translations
6887            if (parts.length === 1) {
6888                return parts[0].value;
6889            }
6890            var result = parts.reduce(function (all, part) {
6891                if (!all.length ||
6892                    part.type !== PART_TYPE.literal ||
6893                    typeof all[all.length - 1] !== 'string') {
6894                    all.push(part.value);
6895                }
6896                else {
6897                    all[all.length - 1] += part.value;
6898                }
6899                return all;
6900            }, []);
6901            if (result.length <= 1) {
6902                return result[0] || '';
6903            }
6904            return result;
6905        };
6906        this.formatToParts = function (values) {
6907            return formatToParts(_this.ast, _this.locales, _this.formatters, _this.formats, values, undefined, _this.message);
6908        };
6909        this.resolvedOptions = function () {
6910            var _a;
6911            return ({
6912                locale: ((_a = _this.resolvedLocale) === null || _a === void 0 ? void 0 : _a.toString()) ||
6913                    Intl.NumberFormat.supportedLocalesOf(_this.locales)[0],
6914            });
6915        };
6916        this.getAst = function () { return _this.ast; };
6917        // Defined first because it's used to build the format pattern.
6918        this.locales = locales;
6919        this.resolvedLocale = IntlMessageFormat.resolveLocale(locales);
6920        if (typeof message === 'string') {
6921            this.message = message;
6922            if (!IntlMessageFormat.__parse) {
6923                throw new TypeError('IntlMessageFormat.__parse must be set to process `message` of type `string`');
6924            }
6925            var _a = opts || {}; _a.formatters; var parseOpts = __rest(_a, ["formatters"]);
6926            // Parse string messages into an AST.
6927            this.ast = IntlMessageFormat.__parse(message, __assign(__assign({}, parseOpts), { locale: this.resolvedLocale }));
6928        }
6929        else {
6930            this.ast = message;
6931        }
6932        if (!Array.isArray(this.ast)) {
6933            throw new TypeError('A message must be provided as a String or AST.');
6934        }
6935        // Creates a new object with the specified `formats` merged with the default
6936        // formats.
6937        this.formats = mergeConfigs(IntlMessageFormat.formats, overrideFormats);
6938        this.formatters =
6939            (opts && opts.formatters) || createDefaultFormatters(this.formatterCache);
6940    }
6941    Object.defineProperty(IntlMessageFormat, "defaultLocale", {
6942        get: function () {
6943            if (!IntlMessageFormat.memoizedDefaultLocale) {
6944                IntlMessageFormat.memoizedDefaultLocale =
6945                    new Intl.NumberFormat().resolvedOptions().locale;
6946            }
6947            return IntlMessageFormat.memoizedDefaultLocale;
6948        },
6949        enumerable: false,
6950        configurable: true
6951    });
6952    IntlMessageFormat.memoizedDefaultLocale = null;
6953    IntlMessageFormat.resolveLocale = function (locales) {
6954        if (typeof Intl.Locale === 'undefined') {
6955            return;
6956        }
6957        var supportedLocales = Intl.NumberFormat.supportedLocalesOf(locales);
6958        if (supportedLocales.length > 0) {
6959            return new Intl.Locale(supportedLocales[0]);
6960        }
6961        return new Intl.Locale(typeof locales === 'string' ? locales : locales[0]);
6962    };
6963    IntlMessageFormat.__parse = parse;
6964    // Default format options used as the prototype of the `formats` provided to the
6965    // constructor. These are used when constructing the internal Intl.NumberFormat
6966    // and Intl.DateTimeFormat instances.
6967    IntlMessageFormat.formats = {
6968        number: {
6969            integer: {
6970                maximumFractionDigits: 0,
6971            },
6972            currency: {
6973                style: 'currency',
6974            },
6975            percent: {
6976                style: 'percent',
6977            },
6978        },
6979        date: {
6980            short: {
6981                month: 'numeric',
6982                day: 'numeric',
6983                year: '2-digit',
6984            },
6985            medium: {
6986                month: 'short',
6987                day: 'numeric',
6988                year: 'numeric',
6989            },
6990            long: {
6991                month: 'long',
6992                day: 'numeric',
6993                year: 'numeric',
6994            },
6995            full: {
6996                weekday: 'long',
6997                month: 'long',
6998                day: 'numeric',
6999                year: 'numeric',
7000            },
7001        },
7002        time: {
7003            short: {
7004                hour: 'numeric',
7005                minute: 'numeric',
7006            },
7007            medium: {
7008                hour: 'numeric',
7009                minute: 'numeric',
7010                second: 'numeric',
7011            },
7012            long: {
7013                hour: 'numeric',
7014                minute: 'numeric',
7015                second: 'numeric',
7016                timeZoneName: 'short',
7017            },
7018            full: {
7019                hour: 'numeric',
7020                minute: 'numeric',
7021                second: 'numeric',
7022                timeZoneName: 'short',
7023            },
7024        },
7025    };
7026    return IntlMessageFormat;
7027}());
7028
7029function delve(obj, fullKey) {
7030  if (fullKey == null)
7031    return void 0;
7032  if (fullKey in obj) {
7033    return obj[fullKey];
7034  }
7035  const keys = fullKey.split(".");
7036  let result = obj;
7037  for (let p = 0; p < keys.length; p++) {
7038    if (typeof result === "object") {
7039      if (p > 0) {
7040        const partialKey = keys.slice(p, keys.length).join(".");
7041        if (partialKey in result) {
7042          result = result[partialKey];
7043          break;
7044        }
7045      }
7046      result = result[keys[p]];
7047    } else {
7048      result = void 0;
7049    }
7050  }
7051  return result;
7052}
7053
7054const lookupCache = {};
7055const addToCache = (path, locale, message) => {
7056  if (!message)
7057    return message;
7058  if (!(locale in lookupCache))
7059    lookupCache[locale] = {};
7060  if (!(path in lookupCache[locale]))
7061    lookupCache[locale][path] = message;
7062  return message;
7063};
7064const lookup = (path, refLocale) => {
7065  if (refLocale == null)
7066    return void 0;
7067  if (refLocale in lookupCache && path in lookupCache[refLocale]) {
7068    return lookupCache[refLocale][path];
7069  }
7070  const locales = getPossibleLocales(refLocale);
7071  for (let i = 0; i < locales.length; i++) {
7072    const locale = locales[i];
7073    const message = getMessageFromDictionary(locale, path);
7074    if (message) {
7075      return addToCache(path, refLocale, message);
7076    }
7077  }
7078  return void 0;
7079};
7080
7081let dictionary;
7082const $dictionary = writable({});
7083function getLocaleDictionary(locale) {
7084  return dictionary[locale] || null;
7085}
7086function hasLocaleDictionary(locale) {
7087  return locale in dictionary;
7088}
7089function getMessageFromDictionary(locale, id) {
7090  if (!hasLocaleDictionary(locale)) {
7091    return null;
7092  }
7093  const localeDictionary = getLocaleDictionary(locale);
7094  const match = delve(localeDictionary, id);
7095  return match;
7096}
7097function getClosestAvailableLocale(refLocale) {
7098  if (refLocale == null)
7099    return void 0;
7100  const relatedLocales = getPossibleLocales(refLocale);
7101  for (let i = 0; i < relatedLocales.length; i++) {
7102    const locale = relatedLocales[i];
7103    if (hasLocaleDictionary(locale)) {
7104      return locale;
7105    }
7106  }
7107  return void 0;
7108}
7109function addMessages(locale, ...partials) {
7110  delete lookupCache[locale];
7111  $dictionary.update((d) => {
7112    d[locale] = deepmerge.all([d[locale] || {}, ...partials]);
7113    return d;
7114  });
7115}
7116derived(
7117  [$dictionary],
7118  ([dictionary2]) => Object.keys(dictionary2)
7119);
7120$dictionary.subscribe((newDictionary) => dictionary = newDictionary);
7121
7122const queue = {};
7123function createLocaleQueue(locale) {
7124  queue[locale] = /* @__PURE__ */ new Set();
7125}
7126function removeLoaderFromQueue(locale, loader) {
7127  queue[locale].delete(loader);
7128  if (queue[locale].size === 0) {
7129    delete queue[locale];
7130  }
7131}
7132function getLocaleQueue(locale) {
7133  return queue[locale];
7134}
7135function getLocalesQueues(locale) {
7136  return getPossibleLocales(locale).map((localeItem) => {
7137    const localeQueue = getLocaleQueue(localeItem);
7138    return [localeItem, localeQueue ? [...localeQueue] : []];
7139  }).filter(([, localeQueue]) => localeQueue.length > 0);
7140}
7141function hasLocaleQueue(locale) {
7142  if (locale == null)
7143    return false;
7144  return getPossibleLocales(locale).some(
7145    (localeQueue) => {
7146      var _a;
7147      return (_a = getLocaleQueue(localeQueue)) == null ? void 0 : _a.size;
7148    }
7149  );
7150}
7151function loadLocaleQueue(locale, localeQueue) {
7152  const allLoadersPromise = Promise.all(
7153    localeQueue.map((loader) => {
7154      removeLoaderFromQueue(locale, loader);
7155      return loader().then((partial) => partial.default || partial);
7156    })
7157  );
7158  return allLoadersPromise.then((partials) => addMessages(locale, ...partials));
7159}
7160const activeFlushes = {};
7161function flush(locale) {
7162  if (!hasLocaleQueue(locale)) {
7163    if (locale in activeFlushes) {
7164      return activeFlushes[locale];
7165    }
7166    return Promise.resolve();
7167  }
7168  const queues = getLocalesQueues(locale);
7169  activeFlushes[locale] = Promise.all(
7170    queues.map(
7171      ([localeName, localeQueue]) => loadLocaleQueue(localeName, localeQueue)
7172    )
7173  ).then(() => {
7174    if (hasLocaleQueue(locale)) {
7175      return flush(locale);
7176    }
7177    delete activeFlushes[locale];
7178  });
7179  return activeFlushes[locale];
7180}
7181function registerLocaleLoader(locale, loader) {
7182  if (!getLocaleQueue(locale))
7183    createLocaleQueue(locale);
7184  const localeQueue = getLocaleQueue(locale);
7185  if (getLocaleQueue(locale).has(loader))
7186    return;
7187  if (!hasLocaleDictionary(locale)) {
7188    $dictionary.update((d) => {
7189      d[locale] = {};
7190      return d;
7191    });
7192  }
7193  localeQueue.add(loader);
7194}
7195
7196var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
7197var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
7198var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
7199var __objRest$1 = (source, exclude) => {
7200  var target = {};
7201  for (var prop in source)
7202    if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
7203      target[prop] = source[prop];
7204  if (source != null && __getOwnPropSymbols$2)
7205    for (var prop of __getOwnPropSymbols$2(source)) {
7206      if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
7207        target[prop] = source[prop];
7208    }
7209  return target;
7210};
7211const defaultFormats = {
7212  number: {
7213    scientific: { notation: "scientific" },
7214    engineering: { notation: "engineering" },
7215    compactLong: { notation: "compact", compactDisplay: "long" },
7216    compactShort: { notation: "compact", compactDisplay: "short" }
7217  },
7218  date: {
7219    short: { month: "numeric", day: "numeric", year: "2-digit" },
7220    medium: { month: "short", day: "numeric", year: "numeric" },
7221    long: { month: "long", day: "numeric", year: "numeric" },
7222    full: { weekday: "long", month: "long", day: "numeric", year: "numeric" }
7223  },
7224  time: {
7225    short: { hour: "numeric", minute: "numeric" },
7226    medium: { hour: "numeric", minute: "numeric", second: "numeric" },
7227    long: {
7228      hour: "numeric",
7229      minute: "numeric",
7230      second: "numeric",
7231      timeZoneName: "short"
7232    },
7233    full: {
7234      hour: "numeric",
7235      minute: "numeric",
7236      second: "numeric",
7237      timeZoneName: "short"
7238    }
7239  }
7240};
7241function defaultMissingKeyHandler({ locale, id }) {
7242  console.warn(
7243    `[svelte-i18n] The message "${id}" was not found in "${getPossibleLocales(
7244      locale
7245    ).join('", "')}".${hasLocaleQueue(getCurrentLocale()) ? `
7246
7247Note: there are at least one loader still registered to this locale that wasn't executed.` : ""}`
7248  );
7249}
7250const defaultOptions = {
7251  fallbackLocale: null,
7252  loadingDelay: 200,
7253  formats: defaultFormats,
7254  warnOnMissingMessages: true,
7255  handleMissingMessage: void 0,
7256  ignoreTag: true
7257};
7258const options = defaultOptions;
7259function getOptions() {
7260  return options;
7261}
7262function init(opts) {
7263  const _a = opts, { formats } = _a, rest = __objRest$1(_a, ["formats"]);
7264  let initialLocale = opts.fallbackLocale;
7265  if (opts.initialLocale) {
7266    try {
7267      if (IntlMessageFormat.resolveLocale(opts.initialLocale)) {
7268        initialLocale = opts.initialLocale;
7269      }
7270    } catch (e) {
7271      console.warn(
7272        `[svelte-i18n] The initial locale "${opts.initialLocale}" is not a valid locale.`
7273      );
7274    }
7275  }
7276  if (rest.warnOnMissingMessages) {
7277    delete rest.warnOnMissingMessages;
7278    if (rest.handleMissingMessage == null) {
7279      rest.handleMissingMessage = defaultMissingKeyHandler;
7280    } else {
7281      console.warn(
7282        '[svelte-i18n] The "warnOnMissingMessages" option is deprecated. Please use the "handleMissingMessage" option instead.'
7283      );
7284    }
7285  }
7286  Object.assign(options, rest, { initialLocale });
7287  if (formats) {
7288    if ("number" in formats) {
7289      Object.assign(options.formats.number, formats.number);
7290    }
7291    if ("date" in formats) {
7292      Object.assign(options.formats.date, formats.date);
7293    }
7294    if ("time" in formats) {
7295      Object.assign(options.formats.time, formats.time);
7296    }
7297  }
7298  return $locale.set(initialLocale);
7299}
7300
7301const $isLoading = writable(false);
7302
7303var __defProp$1 = Object.defineProperty;
7304var __defProps = Object.defineProperties;
7305var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7306var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
7307var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
7308var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
7309var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7310var __spreadValues$1 = (a, b) => {
7311  for (var prop in b || (b = {}))
7312    if (__hasOwnProp$1.call(b, prop))
7313      __defNormalProp$1(a, prop, b[prop]);
7314  if (__getOwnPropSymbols$1)
7315    for (var prop of __getOwnPropSymbols$1(b)) {
7316      if (__propIsEnum$1.call(b, prop))
7317        __defNormalProp$1(a, prop, b[prop]);
7318    }
7319  return a;
7320};
7321var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7322let current;
7323const internalLocale = writable(null);
7324function getSubLocales(refLocale) {
7325  return refLocale.split("-").map((_, i, arr) => arr.slice(0, i + 1).join("-")).reverse();
7326}
7327function getPossibleLocales(refLocale, fallbackLocale = getOptions().fallbackLocale) {
7328  const locales = getSubLocales(refLocale);
7329  if (fallbackLocale) {
7330    return [.../* @__PURE__ */ new Set([...locales, ...getSubLocales(fallbackLocale)])];
7331  }
7332  return locales;
7333}
7334function getCurrentLocale() {
7335  return current != null ? current : void 0;
7336}
7337internalLocale.subscribe((newLocale) => {
7338  current = newLocale != null ? newLocale : void 0;
7339  if (typeof window !== "undefined" && newLocale != null) {
7340    document.documentElement.setAttribute("lang", newLocale);
7341  }
7342});
7343const set = (newLocale) => {
7344  if (newLocale && getClosestAvailableLocale(newLocale) && hasLocaleQueue(newLocale)) {
7345    const { loadingDelay } = getOptions();
7346    let loadingTimer;
7347    if (typeof window !== "undefined" && getCurrentLocale() != null && loadingDelay) {
7348      loadingTimer = window.setTimeout(
7349        () => $isLoading.set(true),
7350        loadingDelay
7351      );
7352    } else {
7353      $isLoading.set(true);
7354    }
7355    return flush(newLocale).then(() => {
7356      internalLocale.set(newLocale);
7357    }).finally(() => {
7358      clearTimeout(loadingTimer);
7359      $isLoading.set(false);
7360    });
7361  }
7362  return internalLocale.set(newLocale);
7363};
7364const $locale = __spreadProps(__spreadValues$1({}, internalLocale), {
7365  set
7366});
7367const getLocaleFromNavigator = () => {
7368  if (typeof window === "undefined")
7369    return null;
7370  return window.navigator.language || window.navigator.languages[0];
7371};
7372
7373const monadicMemoize = (fn) => {
7374  const cache = /* @__PURE__ */ Object.create(null);
7375  const memoizedFn = (arg) => {
7376    const cacheKey = JSON.stringify(arg);
7377    if (cacheKey in cache) {
7378      return cache[cacheKey];
7379    }
7380    return cache[cacheKey] = fn(arg);
7381  };
7382  return memoizedFn;
7383};
7384
7385var __defProp = Object.defineProperty;
7386var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7387var __hasOwnProp = Object.prototype.hasOwnProperty;
7388var __propIsEnum = Object.prototype.propertyIsEnumerable;
7389var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7390var __spreadValues = (a, b) => {
7391  for (var prop in b || (b = {}))
7392    if (__hasOwnProp.call(b, prop))
7393      __defNormalProp(a, prop, b[prop]);
7394  if (__getOwnPropSymbols)
7395    for (var prop of __getOwnPropSymbols(b)) {
7396      if (__propIsEnum.call(b, prop))
7397        __defNormalProp(a, prop, b[prop]);
7398    }
7399  return a;
7400};
7401var __objRest = (source, exclude) => {
7402  var target = {};
7403  for (var prop in source)
7404    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
7405      target[prop] = source[prop];
7406  if (source != null && __getOwnPropSymbols)
7407    for (var prop of __getOwnPropSymbols(source)) {
7408      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
7409        target[prop] = source[prop];
7410    }
7411  return target;
7412};
7413const getIntlFormatterOptions = (type, name) => {
7414  const { formats } = getOptions();
7415  if (type in formats && name in formats[type]) {
7416    return formats[type][name];
7417  }
7418  throw new Error(`[svelte-i18n] Unknown "${name}" ${type} format.`);
7419};
7420const createNumberFormatter = monadicMemoize(
7421  (_a) => {
7422    var _b = _a, { locale, format } = _b, options = __objRest(_b, ["locale", "format"]);
7423    if (locale == null) {
7424      throw new Error('[svelte-i18n] A "locale" must be set to format numbers');
7425    }
7426    if (format) {
7427      options = getIntlFormatterOptions("number", format);
7428    }
7429    return new Intl.NumberFormat(locale, options);
7430  }
7431);
7432const createDateFormatter = monadicMemoize(
7433  (_c) => {
7434    var _d = _c, { locale, format } = _d, options = __objRest(_d, ["locale", "format"]);
7435    if (locale == null) {
7436      throw new Error('[svelte-i18n] A "locale" must be set to format dates');
7437    }
7438    if (format) {
7439      options = getIntlFormatterOptions("date", format);
7440    } else if (Object.keys(options).length === 0) {
7441      options = getIntlFormatterOptions("date", "short");
7442    }
7443    return new Intl.DateTimeFormat(locale, options);
7444  }
7445);
7446const createTimeFormatter = monadicMemoize(
7447  (_e) => {
7448    var _f = _e, { locale, format } = _f, options = __objRest(_f, ["locale", "format"]);
7449    if (locale == null) {
7450      throw new Error(
7451        '[svelte-i18n] A "locale" must be set to format time values'
7452      );
7453    }
7454    if (format) {
7455      options = getIntlFormatterOptions("time", format);
7456    } else if (Object.keys(options).length === 0) {
7457      options = getIntlFormatterOptions("time", "short");
7458    }
7459    return new Intl.DateTimeFormat(locale, options);
7460  }
7461);
7462const getNumberFormatter = (_g = {}) => {
7463  var _h = _g, {
7464    locale = getCurrentLocale()
7465  } = _h, args = __objRest(_h, [
7466    "locale"
7467  ]);
7468  return createNumberFormatter(__spreadValues({ locale }, args));
7469};
7470const getDateFormatter = (_i = {}) => {
7471  var _j = _i, {
7472    locale = getCurrentLocale()
7473  } = _j, args = __objRest(_j, [
7474    "locale"
7475  ]);
7476  return createDateFormatter(__spreadValues({ locale }, args));
7477};
7478const getTimeFormatter = (_k = {}) => {
7479  var _l = _k, {
7480    locale = getCurrentLocale()
7481  } = _l, args = __objRest(_l, [
7482    "locale"
7483  ]);
7484  return createTimeFormatter(__spreadValues({ locale }, args));
7485};
7486const getMessageFormatter = monadicMemoize(
7487  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
7488  (message, locale = getCurrentLocale()) => new IntlMessageFormat(message, locale, getOptions().formats, {
7489    ignoreTag: getOptions().ignoreTag
7490  })
7491);
7492
7493const formatMessage = (id, options = {}) => {
7494  var _a, _b, _c, _d;
7495  let messageObj = options;
7496  if (typeof id === "object") {
7497    messageObj = id;
7498    id = messageObj.id;
7499  }
7500  const {
7501    values,
7502    locale = getCurrentLocale(),
7503    default: defaultValue
7504  } = messageObj;
7505  if (locale == null) {
7506    throw new Error(
7507      "[svelte-i18n] Cannot format a message without first setting the initial locale."
7508    );
7509  }
7510  let message = lookup(id, locale);
7511  if (!message) {
7512    message = (_d = (_c = (_b = (_a = getOptions()).handleMissingMessage) == null ? void 0 : _b.call(_a, { locale, id, defaultValue })) != null ? _c : defaultValue) != null ? _d : id;
7513  } else if (typeof message !== "string") {
7514    console.warn(
7515      `[svelte-i18n] Message with id "${id}" must be of type "string", found: "${typeof message}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`
7516    );
7517    return message;
7518  }
7519  if (!values) {
7520    return message;
7521  }
7522  let result = message;
7523  try {
7524    result = getMessageFormatter(message, locale).format(values);
7525  } catch (e) {
7526    if (e instanceof Error) {
7527      console.warn(
7528        `[svelte-i18n] Message "${id}" has syntax error:`,
7529        e.message
7530      );
7531    }
7532  }
7533  return result;
7534};
7535const formatTime = (t, options) => {
7536  return getTimeFormatter(options).format(t);
7537};
7538const formatDate = (d, options) => {
7539  return getDateFormatter(options).format(d);
7540};
7541const formatNumber = (n, options) => {
7542  return getNumberFormatter(options).format(n);
7543};
7544const getJSON = (id, locale = getCurrentLocale()) => {
7545  return lookup(id, locale);
7546};
7547const $format = derived([$locale, $dictionary], () => formatMessage);
7548derived([$locale], () => formatTime);
7549derived([$locale], () => formatDate);
7550derived([$locale], () => formatNumber);
7551derived([$locale, $dictionary], () => getJSON);
7552
7553const navbar_config = writable(null);
7554
7555var root_3 = from_html(`<a data-sveltekit-reload=""> </a>`);
7556var root_2 = from_html(`<div class="nav-holder svelte-99kmwu"><nav></nav></div>`);
7557var root_4 = from_html(`<div class="info svelte-99kmwu"><span class="svelte-99kmwu"><a class="title svelte-99kmwu"> </a></span> <span class="svelte-99kmwu"> <a class="gradio svelte-99kmwu" href="https://gradio.app">Gradio</a>.</span> <span class="svelte-99kmwu"> <a class="hf svelte-99kmwu" href="https://huggingface.co/spaces"><span class="space-logo svelte-99kmwu"><img alt="Hugging Face Space" class="svelte-99kmwu"/></span> Spaces</a></span></div>`);
7558var root_1 = from_html(`<div data-iframe-height=""><!> <div><!> <div><!></div></div></div>`);
7559
7560function Embed($$anchor, $$props) {
7561	push($$props, false);
7562
7563	const $navbar_config = () => store_get(navbar_config, '$navbar_config', $$stores);
7564	const $_ = () => store_get($format, '$_', $$stores);
7565	const [$$stores, $$cleanup] = setup_stores();
7566	const show_navbar = mutable_source();
7567	const effective_pages = mutable_source();
7568	let wrapper = prop($$props, 'wrapper', 12);
7569	let version = prop($$props, 'version', 12);
7570	let initial_height = prop($$props, 'initial_height', 12);
7571	let fill_width = prop($$props, 'fill_width', 12);
7572	let is_embed = prop($$props, 'is_embed', 12);
7573	let space = prop($$props, 'space', 12);
7574	let display = prop($$props, 'display', 12);
7575	let info = prop($$props, 'info', 12);
7576	let loaded = prop($$props, 'loaded', 12);
7577	let pages = prop($$props, 'pages', 28, () => []);
7578	let current_page = prop($$props, 'current_page', 12, "");
7579	let root = prop($$props, 'root', 12);
7580	let components = prop($$props, 'components', 28, () => []);
7581	let navbar_component = components().find((c) => c.type === "navbar");
7582
7583	let navbar = mutable_source(navbar_component
7584		? {
7585			visible: navbar_component.props.visible,
7586			main_page_name: navbar_component.props.main_page_name,
7587			value: navbar_component.props.value
7588		}
7589		: null);
7590
7591	if (get$1(navbar)) {
7592		navbar_config.set(get$1(navbar));
7593	}
7594
7595	function normalize_path(path) {
7596		// Remove query parameters, hash fragments, and leading/trailing slashes from the path
7597		let normalized = path.split("?")[0].split("#")[0];
7598
7599		normalized = normalized.replace(/^\/+|\/+$/g, "");
7600
7601		return normalized;
7602	}
7603
7604	function is_active_route(route, current) {
7605		if (route.startsWith("http://") || route.startsWith("https://")) {
7606			return false;
7607		}
7608
7609		return normalize_path(route) === normalize_path(current);
7610	}
7611
7612	legacy_pre_effect(() => ($navbar_config()), () => {
7613		if ($navbar_config()) {
7614			set$1(navbar, {
7615				visible: $navbar_config().visible ?? true,
7616				main_page_name: $navbar_config().main_page_name ?? "Home",
7617				value: $navbar_config().value ?? null
7618			});
7619		}
7620	});
7621
7622	legacy_pre_effect(() => (deep_read_state(pages()), get$1(navbar)), () => {
7623		set$1(show_navbar, pages().length > 1 && (get$1(navbar) === null || get$1(navbar).visible !== false));
7624	});
7625
7626	legacy_pre_effect(() => (deep_read_state(pages()), get$1(navbar)), () => {
7627		set$1(effective_pages, (() => {
7628			let visible_pages = pages().filter(([route, label, show], index) => {
7629				if (index === 0 && route === "") {
7630					return get$1(navbar)?.main_page_name !== false;
7631				}
7632
7633				return show !== false;
7634			});
7635
7636			let base_pages = get$1(navbar) && get$1(navbar).main_page_name !== false && get$1(navbar).main_page_name !== "Home"
7637				? visible_pages.map(([route, label, show], index) => index === 0 && route === "" && label === "Home"
7638					? [route, get$1(navbar).main_page_name]
7639					: [route, label])
7640				: visible_pages.map(([route, label]) => [route, label]);
7641
7642			if (get$1(navbar)?.value && get$1(navbar).value.length > 0) {
7643				const existing_routes = new Set(base_pages.map(([route]) => route));
7644				const additional_pages = get$1(navbar).value.map(([page_name, page_path]) => [page_path, page_name]).filter(([route]) => !existing_routes.has(route));
7645
7646				return [...base_pages, ...additional_pages];
7647			}
7648
7649			return base_pages;
7650		})());
7651	});
7652
7653	legacy_pre_effect_reset();
7654
7655	var $$exports = {
7656		get wrapper() {
7657			return wrapper();
7658		},
7659
7660		set wrapper($$value) {
7661			wrapper($$value);
7662			flushSync();
7663		},
7664
7665		get version() {
7666			return version();
7667		},
7668
7669		set version($$value) {
7670			version($$value);
7671			flushSync();
7672		},
7673
7674		get initial_height() {
7675			return initial_height();
7676		},
7677
7678		set initial_height($$value) {
7679			initial_height($$value);
7680			flushSync();
7681		},
7682
7683		get fill_width() {
7684			return fill_width();
7685		},
7686
7687		set fill_width($$value) {
7688			fill_width($$value);
7689			flushSync();
7690		},
7691
7692		get is_embed() {
7693			return is_embed();
7694		},
7695
7696		set is_embed($$value) {
7697			is_embed($$value);
7698			flushSync();
7699		},
7700
7701		get space() {
7702			return space();
7703		},
7704
7705		set space($$value) {
7706			space($$value);
7707			flushSync();
7708		},
7709
7710		get display() {
7711			return display();
7712		},
7713
7714		set display($$value) {
7715			display($$value);
7716			flushSync();
7717		},
7718
7719		get info() {
7720			return info();
7721		},
7722
7723		set info($$value) {
7724			info($$value);
7725			flushSync();
7726		},
7727
7728		get loaded() {
7729			return loaded();
7730		},
7731
7732		set loaded($$value) {
7733			loaded($$value);
7734			flushSync();
7735		},
7736
7737		get pages() {
7738			return pages();
7739		},
7740
7741		set pages($$value) {
7742			pages($$value);
7743			flushSync();
7744		},
7745
7746		get current_page() {
7747			return current_page();
7748		},
7749
7750		set current_page($$value) {
7751			current_page($$value);
7752			flushSync();
7753		},
7754
7755		get root() {
7756			return root();
7757		},
7758
7759		set root($$value) {
7760			root($$value);
7761			flushSync();
7762		},
7763
7764		get components() {
7765			return components();
7766		},
7767
7768		set components($$value) {
7769			components($$value);
7770			flushSync();
7771		}
7772	};
7773
7774	init$1();
7775
7776	var div = root_1();
7777	let classes;
7778	let styles;
7779	var node = child(div);
7780
7781	{
7782		var consequent = ($$anchor) => {
7783			var div_1 = root_2();
7784			var nav = child(div_1);
7785			let classes_1;
7786
7787			each(nav, 5, () => get$1(effective_pages), index, ($$anchor, $$item) => {
7788				var $$array = user_derived(() => to_array(get$1($$item), 2));
7789				let route = () => get$1($$array)[0];
7790				let label = () => get$1($$array)[1];
7791				var a = root_3();
7792				let classes_2;
7793				var text = child(a, true);
7794
7795				reset(a);
7796
7797				template_effect(
7798					($0, $1, $2, $3) => {
7799						set_attribute(a, 'href', $0);
7800						set_attribute(a, 'target', $1);
7801						set_attribute(a, 'rel', $2);
7802						classes_2 = set_class(a, 1, 'svelte-99kmwu', null, classes_2, $3);
7803						set_text(text, label());
7804					},
7805					[
7806						() => (
7807							route(),
7808							deep_read_state(root()),
7809							untrack(() => route().startsWith("http://") || route().startsWith("https://") ? route() : `${root()}/${route()}`)
7810						),
7811
7812						() => (
7813							route(),
7814							untrack(() => route().startsWith("http://") || route().startsWith("https://") ? "_blank" : "_self")
7815						),
7816
7817						() => (
7818							route(),
7819							untrack(() => route().startsWith("http://") || route().startsWith("https://") ? "noopener noreferrer" : "")
7820						),
7821						() => ({ active: is_active_route(route(), current_page()) })
7822					]
7823				);
7824
7825				append($$anchor, a);
7826			});
7827
7828			reset(nav);
7829			reset(div_1);
7830			template_effect(() => classes_1 = set_class(nav, 1, 'fillable svelte-99kmwu', null, classes_1, { fill_width: fill_width() }));
7831			append($$anchor, div_1);
7832		};
7833
7834		if_block(node, ($$render) => {
7835			if (get$1(show_navbar)) $$render(consequent);
7836		});
7837	}
7838
7839	var div_2 = sibling(node, 2);
7840	let classes_3;
7841	var node_1 = child(div_2);
7842
7843	slot(node_1, $$props, 'default', {});
7844
7845	var div_3 = sibling(node_1, 2);
7846	var node_2 = child(div_3);
7847
7848	{
7849		var consequent_1 = ($$anchor) => {
7850			var div_4 = root_4();
7851			var span = child(div_4);
7852			var a_1 = child(span);
7853			var text_1 = child(a_1, true);
7854
7855			reset(a_1);
7856			reset(span);
7857
7858			var span_1 = sibling(span, 2);
7859			var text_2 = child(span_1);
7860
7861			next(2);
7862			reset(span_1);
7863
7864			var span_2 = sibling(span_1, 2);
7865			var text_3 = child(span_2);
7866			var a_2 = sibling(text_3);
7867			var span_3 = child(a_2);
7868			var img = child(span_3);
7869
7870			reset(span_3);
7871			next();
7872			reset(a_2);
7873			reset(span_2);
7874			reset(div_4);
7875
7876			template_effect(
7877				($0, $1) => {
7878					set_attribute(a_1, 'href', `https://huggingface.co/spaces/${space() ?? ''}`);
7879					set_text(text_1, space());
7880					set_text(text_2, `${$0 ?? ''} `);
7881					set_text(text_3, `${$1 ?? ''} `);
7882					set_attribute(img, 'src', space_logo);
7883				},
7884				[
7885					() => ($_(), untrack(() => $_()("common.built_with"))),
7886					() => ($_(), untrack(() => $_()("common.hosted_on")))
7887				]
7888			);
7889
7890			append($$anchor, div_4);
7891		};
7892
7893		if_block(node_2, ($$render) => {
7894			if (display() && space() && info()) $$render(consequent_1);
7895		});
7896	}
7897
7898	reset(div_3);
7899	reset(div_2);
7900	reset(div);
7901	bind_this(div, ($$value) => wrapper($$value), () => wrapper());
7902
7903	template_effect(() => {
7904		classes = set_class(div, 1, `gradio-container gradio-container-${version() ?? ''}`, 'svelte-99kmwu', classes, {
7905			fill_width: fill_width(),
7906			'embed-container': display(),
7907			'with-info': info()
7908		});
7909
7910		styles = set_style(div, '', styles, {
7911			'min-height': loaded() ? "initial" : initial_height(),
7912			'flex-grow': !display() ? "1" : "auto"
7913		});
7914
7915		classes_3 = set_class(div_2, 1, 'main fillable svelte-99kmwu', null, classes_3, { fill_width: fill_width(), app: !display() && !is_embed() });
7916	});
7917
7918	append($$anchor, div);
7919
7920	var $$pop = pop($$exports);
7921
7922	$$cleanup();
7923
7924	return $$pop;
7925}
7926
7927let supports_adopted_stylesheets = false;
7928if (typeof window !== "undefined" && "attachShadow" in Element.prototype && "adoptedStyleSheets" in Document.prototype) {
7929  const shadow_root_test = document.createElement("div").attachShadow({ mode: "open" });
7930  supports_adopted_stylesheets = "adoptedStyleSheets" in shadow_root_test;
7931}
7932function mount_css(url, target) {
7933  const base = new URL(import.meta.url).origin;
7934  var _url = url;
7935  if (window.location.origin !== base) {
7936    _url = new URL(url, base).href;
7937  }
7938  const existing_link = document.querySelector(`link[href='${_url}']`);
7939  if (existing_link) return Promise.resolve();
7940  const link = document.createElement("link");
7941  link.rel = "stylesheet";
7942  link.href = _url;
7943  return new Promise((res, rej) => {
7944    link.addEventListener("load", () => res());
7945    link.addEventListener("error", () => {
7946      console.error(`Unable to preload CSS for ${_url}`);
7947      res();
7948    });
7949    target.appendChild(link);
7950  });
7951}
7952function prefix_css(string, version, style_element) {
7953  if (!supports_adopted_stylesheets) return string;
7954  if (!style_element) {
7955    style_element = document.createElement("style");
7956  }
7957  style_element.remove();
7958  const stylesheet = new CSSStyleSheet();
7959  stylesheet.replaceSync(string);
7960  let importString = "";
7961  string = string.replace(/@import\s+url\((.*?)\);\s*/g, (match, url) => {
7962    importString += `@import url(${url});
7963`;
7964    return "";
7965  });
7966  const rules = stylesheet.cssRules;
7967  let css_string = "";
7968  let gradio_css_infix = `.gradio-container.gradio-container-${version} .contain `;
7969  for (let i = 0; i < rules.length; i++) {
7970    const rule = rules[i];
7971    let is_dark_rule = rule.cssText.includes(".dark");
7972    if (rule instanceof CSSStyleRule) {
7973      const selector = rule.selectorText;
7974      if (selector) {
7975        const new_selector = selector.replace(".dark", "").split(",").map(
7976          (s) => `${is_dark_rule ? ".dark" : ""} ${gradio_css_infix} ${s.trim()} `
7977        ).join(",");
7978        css_string += rule.cssText;
7979        css_string += rule.cssText.replace(selector, new_selector);
7980      }
7981    } else if (rule instanceof CSSMediaRule) {
7982      let mediaCssString = `@media ${rule.media.mediaText} {`;
7983      for (let j = 0; j < rule.cssRules.length; j++) {
7984        const innerRule = rule.cssRules[j];
7985        if (innerRule instanceof CSSStyleRule) {
7986          let is_dark_rule2 = innerRule.cssText.includes(".dark ");
7987          const selector = innerRule.selectorText;
7988          const new_selector = selector.replace(".dark", "").split(",").map(
7989            (s) => `${is_dark_rule2 ? ".dark" : ""} ${gradio_css_infix} ${s.trim()} `
7990          ).join(",");
7991          mediaCssString += innerRule.cssText.replace(selector, new_selector);
7992        }
7993      }
7994      mediaCssString += "}";
7995      css_string += mediaCssString;
7996    } else if (rule instanceof CSSKeyframesRule) {
7997      css_string += `@keyframes ${rule.name} {`;
7998      for (let j = 0; j < rule.cssRules.length; j++) {
7999        const innerRule = rule.cssRules[j];
8000        if (innerRule instanceof CSSKeyframeRule) {
8001          css_string += `${innerRule.keyText} { ${innerRule.style.cssText} }`;
8002        }
8003      }
8004      css_string += "}";
8005    } else if (rule instanceof CSSFontFaceRule) {
8006      css_string += `@font-face { ${rule.style.cssText} }`;
8007    }
8008  }
8009  return importString + css_string;
8010}
8011
8012const component_map = {
8013			"accordion": {
8014			
8015			
8016			component: () => __vitePreload(() => import('./Index-B6k2WpQm.js'),true              ?__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]):void 0,import.meta.url)
8017			},
8018"annotatedimage": {
8019			
8020			
8021			component: () => __vitePreload(() => import('./Index-DWC_ST0U.js'),true              ?__vite__mapDeps([18,1,2,3,4,5,6,19,20,21,7,8,22,23,24,9,10,11,12,13,14,25]):void 0,import.meta.url)
8022			},
8023"audio": {
8024			base: () => __vitePreload(() => import('./StaticAudio-DGaZb-fW.js').then(n => n.a),true              ?__vite__mapDeps([26,1,2,7,8,4,5,6,19,27,20,28,29,30,22,31,32,33,34,35,36]):void 0,import.meta.url),
8025
8026			example: () => __vitePreload(() => import('./Example-hTHSlRG1.js'),true              ?__vite__mapDeps([37,1,2,38]):void 0,import.meta.url),
8027
8028			component: () => __vitePreload(() => import('./index-D65tv47j.js'),true              ?__vite__mapDeps([39,1,2,7,8,9,10,11,4,5,6,12,13,14,26,19,27,20,28,29,30,22,31,32,33,34,35,36,40,41,42,43,44,45,46,47,3,48,37,38,49]):void 0,import.meta.url)
8029			},
8030"box": {
8031			
8032			
8033			component: () => __vitePreload(() => import('./Index-m58JVqMG.js'),true              ?__vite__mapDeps([50,1,2,3,4,5,6]):void 0,import.meta.url)
8034			},
8035"browserstate": {
8036			
8037			
8038			component: () => __vitePreload(() => import('./Index-CI0xDggI.js'),true              ?__vite__mapDeps([51,1,2,52,7,8]):void 0,import.meta.url)
8039			},
8040"button": {
8041			
8042			
8043			component: () => __vitePreload(() => import('./Index-DIRpB5DY.js'),true              ?__vite__mapDeps([53,1,2,7,8,54,5,55,56,57,4,6,58,59]):void 0,import.meta.url)
8044			},
8045"chatbot": {
8046			
8047			
8048			component: () => __vitePreload(() => import('./Index-DuFh5Mes.js'),true              ?__vite__mapDeps([60,1,2,41,7,8,61,55,56,57,4,5,6,62,63,14,29,44,35,27,28,22,64,65,11,66,12,67,10,13,68,69,30,3,19,9,70,59]):void 0,import.meta.url)
8049			},
8050"checkbox": {
8051			
8052			example: () => __vitePreload(() => import('./Example-KB5oRY7o.js'),true              ?__vite__mapDeps([71,1,2,72]):void 0,import.meta.url),
8053
8054			component: () => __vitePreload(() => import('./Index-BHwo3edq.js'),true              ?__vite__mapDeps([73,1,2,7,8,3,4,5,6,74,11,22,9,10,12,13,14,75,61,76]):void 0,import.meta.url)
8055			},
8056"checkboxgroup": {
8057			
8058			example: () => __vitePreload(() => import('./Example-ugztAPLa.js'),true              ?__vite__mapDeps([77,1,2,78]):void 0,import.meta.url),
8059
8060			component: () => __vitePreload(() => import('./Index-CcMpJndr.js'),true              ?__vite__mapDeps([79,1,2,8,7,3,4,5,6,80,74,11,22,9,10,12,13,14,81,82]):void 0,import.meta.url)
8061			},
8062"code": {
8063			
8064			example: () => __vitePreload(() => import('./Example-obvXP67p.js'),true              ?__vite__mapDeps([83,1,2,84]):void 0,import.meta.url),
8065
8066			component: () => __vitePreload(() => import('./Index-BuAoQXgO.js'),true              ?__vite__mapDeps([85,1,2,7,8,9,10,11,4,5,6,12,13,14,86,87,62,63,29,27,22,3,19,20,88,83,84]):void 0,import.meta.url)
8067			},
8068"colorpicker": {
8069			
8070			example: () => __vitePreload(() => import('./Example-CCEyD4GV.js'),true              ?__vite__mapDeps([89,1,2,90]):void 0,import.meta.url),
8071
8072			component: () => __vitePreload(() => import('./Index-Dt4t8F3U.js'),true              ?__vite__mapDeps([91,1,2,7,8,41,61,92,4,5,6,80,74,11,3,9,10,12,13,14,89,90,93]):void 0,import.meta.url)
8073			},
8074"column": {
8075			
8076			
8077			component: () => __vitePreload(() => import('./Index-BsVOYSj7.js'),true              ?__vite__mapDeps([94,1,2,7,8,15,9,10,11,4,5,6,12,13,14,16
8077]):void 0,import.meta.url)
8078			},
8079"core": {
8080			
8081			
8082			component: () => __vitePreload(() => import('./index-BJk8VOjP.js'),true              ?__vite__mapDeps([95,1,2,81,7,8]):void 0,import.meta.url)
8083			},
8084"dataframe": {
8085			
8086			example: () => __vitePreload(() => import('./Example-DL_4juBu.js'),true              ?__vite__mapDeps([96,1,2,97]):void 0,import.meta.url),
8087
8088			component: () => __vitePreload(() => import('./Index-CxOOE7R5.js'),true              ?__vite__mapDeps([98,1,2,11,41,40,5,42,4,6,61,65,66,12,67,10,13,75,8,76,62,99,63,23,24,100,9,14,3,7,96,97,101]):void 0,import.meta.url)
8089			},
8090"dataset": {
8091			
8092			
8093			component: () => __vitePreload(() => import('./Index-N-hoPZP9.js'),true              ?__vite__mapDeps([102,1,2,3,4,5,6,7,8,103,104,41,61,80,74,11,62,63,105,106,22,107,10,12,13,108,109,110,111]):void 0,import.meta.url)
8094			},
8095"datetime": {
8096			
8097			example: () => __vitePreload(() => import('./Example-BA64u5Sp.js'),true              ?__vite__mapDeps([112,1,2]):void 0,import.meta.url),
8098
8099			component: () => __vitePreload(() => import('./Index-6_Y9ygNz.js'),true              ?__vite__mapDeps([113,1,2,61,3,4,5,6,80,74,11,7,8,22,112,114]):void 0,import.meta.url)
8100			},
8101"dialogue": {
8102			
8103			example: () => __vitePreload(() => import('./Example-BIlLUrfo.js'),true              ?__vite__mapDeps([115,1,2,116]):void 0,import.meta.url),
8104
8105			component: () => __vitePreload(() => import('./Index-BAJ5KXXp.js'),true              ?__vite__mapDeps([117,1,2,7,8,10,11,4,5,6,12,13,61,80,74,62,63,118,105,69,22,119,120,99,121,3,9,14,115,116,122,123]):void 0,import.meta.url)
8106			},
8107"downloadbutton": {
8108			
8109			
8110			component: () => __vitePreload(() => import('./Index-CBNBXH2C.js'),true              ?__vite__mapDeps([124,1,2,7,8,5,54,55,56,57,4,6,58,59,125]):void 0,import.meta.url)
8111			},
8112"draggable": {
8113			
8114			
8115			component: () => __vitePreload(() => import('./Index-CKqdXlH-.js'),true              ?__vite__mapDeps([126,1,2,7,8,9,10,11,4,5,6,12,13,14,127]):void 0,import.meta.url)
8116			},
8117"dropdown": {
8118			
8119			example: () => __vitePreload(() => import('./Example-t0cB3HBf.js'),true              ?__vite__mapDeps([128,1,2,123]):void 0,import.meta.url),
8120
8121			component: () => __vitePreload(() => import('./Index-CnMXw2NO.js'),true              ?__vite__mapDeps([129,1,2,7,8,61,68,4,5,6,80,74,11,99,22,119,10,12,13,120,121,3,9,14,128,123]):void 0,import.meta.url)
8122			},
8123"file": {
8124			
8125			example: () => __vitePreload(() => import('./Example-CI1jJDZu.js'),true              ?__vite__mapDeps([130,1,2,131]):void 0,import.meta.url),
8126
8127			component: () => __vitePreload(() => import('./Index-Tozf4a30.js'),true              ?__vite__mapDeps([132,1,2,8,7,4,5,6,19,20,64,22,133,40,41,42,14,11,27,134,3,48,9,10,12,13,130,131]):void 0,import.meta.url)
8128			},
8129"fileexplorer": {
8130			
8131			example: () => __vitePreload(() => import('./Example-BCn1Ltli.js'),true              ?__vite__mapDeps([135,1,2,136]):void 0,import.meta.url),
8132
8133			component: () => __vitePreload(() => import('./Index-DZsFFtsx.js'),true              ?__vite__mapDeps([137,1,2,103,7,8,4,5,6,64,3,19,22,61,9,10,11,12,13,14,138]):void 0,import.meta.url)
8134			},
8135"form": {
8136			
8137			
8138			component: () => __vitePreload(() => import('./Index-Dvxi9axQ.js'),true              ?__vite__mapDeps([139,1,2,7,8,140,141]):void 0,import.meta.url)
8139			},
8140"gallery": {
8141			base: () => __vitePreload(() => import('./Gallery-DaBd1NXs.js').then(n => n.a),true              ?__vite__mapDeps([142,1,2,120,68,4,5,6,19,20,28,7,8,14,29,21,34,22,23,24,40,41,42,43,27,44,35,55,56,57,143,144,81,145,59]):void 0,import.meta.url),
8142
8143			example: () => __vitePreload(() => import('./Example-BgRaJ5Hk.js'),true              ?__vite__mapDeps([146,1,2,147]):void 0,import.meta.url),
8144
8145			component: () => __vitePreload(() => import('./Index-CGOALv4G.js'),true              ?__vite__mapDeps([148,1,2,56,3,4,5,6,7,8,48,142,120,68,19,20,28,14,29,21,34,22,23,24,40,41,42,43,27,44,35,55,57,143,144,81,145,59,9,10,11,12,13,133,64,134,149,99,106,47,45,150,146,147,151,131,152]):void 0,import.meta.url)
8146			},
8147"group": {
8148			
8149			
8150			component: () => __vitePreload(() => import('./Index-QSoBFEc3.js'),true              ?__vite__mapDeps([153,1,2,7,8,154]):void 0,import.meta.url)
8151			},
8152"highlightedtext": {
8153			
8154			
8155			component: () => __vitePreload(() => import('./Index-DS7IaHHH.js'),true              ?__vite__mapDeps([155,1,2,156,14,4,5,6,3,19,20,7,8,22,9,10,11,12,13,157]):void 0,import.meta.url)
8156			},
8157"html": {
8158			base: () => __vitePreload(() => import('./HTML-Cns4Rn3B.js'),true              ?__vite__mapDeps([158,1,2,8,5,159]):void 0,import.meta.url),
8159
8160			example: () => __vitePreload(() => import('./Example-BEiY6GLN.js'),true              ?__vite__mapDeps([160,1,2,11,161]):void 0,import.meta.url),
8161
8162			component: () => __vitePreload(() => import('./Index-DKemNWiC.js'),true              ?__vite__mapDeps([162,1,2,7,8,158,5,159,9,10,11,4,6,12,13,14,3,19,88,22,160,161,163]):void 0,import.meta.url)
8163			},
8164"image": {
8165			base: () => __vitePreload(() => import('./ImagePreview-CCH9abCE.js').then(n => n.a),true              ?__vite__mapDeps([164,1,2,56,7,8,4,5,6,19,27,20,28,29,21,22,23,24,55,57,59]):void 0,import.meta.url),
8166
8167			example: () => __vitePreload(() => import('./Example-C7SZxPdR.js'),true              ?__vite__mapDeps([165,1,2,55,56,57,152]):void 0,import.meta.url),
8168
8169			component: () => __vitePreload(() => import('./Index-ClljYZ7y.js'),true              ?__vite__mapDeps([166,1,2,7,8,164,56,4,5,6,19,27,20,28,29,21,22,23,24,55,57,59,14,149,10,11,12,13,41,99,106,47,45,150,40,42,3,48,9,165,152]):void 0,import.meta.url)
8170			},
8171"imageeditor": {
8172			
8173			example: () => __vitePreload(() => import('./Example-C5ywtI19.js'),true              ?__vite__mapDeps([167,1,2,4,5,6,55,56,57,10,11,12,13,40,41,42,168,59,150,152]):void 0,import.meta.url),
8174
8175			component: () => __vitePreload(() => import('./Index-8FtW5e5c.js').then(n => n.au),true              ?__vite__mapDeps([169,1,2,56,7,8,164,4,5,6,19,27,20,28,29,21,22,23,24,55,57,59,3,9,10,11,12,13,14,40,41,42,149,99,106,47,45,150,120,92,118,61,62,68,170,69,35,171,152]):void 0,import.meta.url)
8176			},
8177"imageslider": {
8178			
8179			example: () => __vitePreload(() => import('./Example-CwgO_twd.js'),true              ?__vite__mapDeps([172,1,2,173]):void 0,import.meta.url),
8180
8181			component: () => __vitePreload(() => import('./Index-9ldVfY2_.js'),true              ?__vite__mapDeps([174,1,2,7,8,109,56,175,176,4,5,6,19,27,20,14,29,21,35,22,23,24,10,11,12,13,9,40,41,42,3,48,177]):void 0,import.meta.url)
8182			},
8183"json": {
8184			
8185			example: () => __vitePreload(() => import('./Example-igKOU0iw.js'),true              ?__vite__mapDeps([178,1,2,179,62,63,4,5,6,20,22,180,181]):void 0,import.meta.url),
8186
8187			component: () => __vitePreload(() => import('./Index-AvMR-Z-Q.js'),true              ?__vite__mapDeps([182,1,2,109,7,8,179,62,63,4,5,6,20,22,180,3,19,9,10,11,12,13,14]):void 0,import.meta.url)
8188			},
8189"label": {
8190			
8191			
8192			component: () => __vitePreload(() => import('./Index-DMFg_noi.js'),true              ?__vite__mapDeps([183,1,2,7,8,4,5,6,184,3,19,20,22,9,10,11,12,13,14,185]):void 0,import.meta.url)
8193			},
8194"markdown": {
8195			
8196			example: () => __vitePreload(() => import('./Example-YwgBtWi1.js'),true              ?__vite__mapDeps([186,1,2,65,11,66,12,67,187]):void 0,import.meta.url),
8197
8198			component: () => __vitePreload(() => import('./Index-TKDXb_h_.js'),true              ?__vite__mapDeps([188,1,2,7,8,189,41,62,63,4,5,6,22,65,11,66,12,67,190,9,10,13,14,3,191,186,187]):void 0,import.meta.url)
8199			},
8200"model3d": {
8201			base: () => __vitePreload(() => import('./Model3D-CWtA1JFE.js'),true              ?__vite__mapDeps([192,1,2,4,5,6,19,29,64,35,22,81,193]):void 0,import.meta.url),
8202
8203			example: () => __vitePreload(() => import('./Example-qy-BJ3UM.js'),true              ?__vite__mapDeps([194,1,2,195]):void 0,import.meta.url),
8204
8205			component: () => __vitePreload(() => import('./Index-VR1jY_B8.js'),true              ?__vite__mapDeps([196,1,2,7,8,192,4,5,6,19,29,64,35,22,81,193,40,41,42,43,27,14,44,3,20,48,9,10,11,12,13,194,195,197]):void 0,import.meta.url)
8206			},
8207"multimodaltextbox": {
8208			
8209			example: () => __vitePreload(() => import('./Example-BqGmQLY6.js'),true              ?__vite__mapDeps([198,1,2,109,55,56,57,4,5,6,143,41,144,199,59]):void 0,import.meta.url),
8210
8211			component: () => __vitePreload(() => import('./Index-DiVjWtzo.js'),true              ?__vite__mapDeps([200,1,2,7,8,41,61,4,5,6,80,74,11,170,62,14,64,30,106,191,40,42,55,56,57,31,32,46,3,9,10,12,13,198,109,143,144,199,59,201]):void 0,import.meta.url)
8212			},
8213"nativeplot": {
8214			
8215			example: () => __vitePreload(() => import('./Example-CjtGxran.js'),true              ?__vite__mapDeps([202,1,2]):void 0,import.meta.url),
8216
8217			component: () => __vitePreload(() => import('./Index-DgDgGRDA.js'),true              ?__vite__mapDeps([203,1,2,7,8,3,4,5,6,80,74,11,20,29,184,22,23,24,9,10,12,13,14,204]):void 0,import.meta.url)
8218			},
8219"navbar": {
8220			base: () => __vitePreload(() => import('./Index-My9wgKRU.js'),true              ?__vite__mapDeps([205,1,2,7,8]):void 0,import.meta.url),
8221
8222			example: () => __vitePreload(() => import('./Example-7kC6V8Ah.js'),true              ?__vite__mapDeps([206,1,2]):void 0,import.meta.url),
8223
8224			component: () => __vitePreload(() => import('./Index-My9wgKRU.js'),true              ?__vite__mapDeps([205,1,2,7,8]):void 0,import.meta.url)
8225			},
8226"number": {
8227			
8228			example: () => __vitePreload(() => import('./Example-C-YjHQke.js'),true              ?__vite__mapDeps([207,1,2,208]):void 0,import.meta.url),
8229
8230			component: () => __vitePreload(() => import('./Index-BVPgEV5I.js'),true              ?__vite__mapDeps([209,1,2,61,7,8,3,4,5,6,80,74,11,22,9,10,12,13,14,210]):void 0,import.meta.url)
8231			},
8232"paramviewer": {
8233			
8234			example: () => __vitePreload(() => import('./Example-jxpEXkTh.js'),true              ?__vite__mapDeps([211,1,2,212]):void 0,import.meta.url),
8235
8236			component: () => __vitePreload(() => import('./Index-Dtsvb4cq.js'),true              ?__vite__mapDeps([213,1,2,7,8,11,66,214]):void 0,import.meta.url)
8237			},
8238"plot": {
8239			base: () => __vitePreload(() => import('./Plot-B28lJT0D.js').then(n => n.b),true              ?__vite__mapDeps([215,1,2,103,4,5,6,56,20]):void 0,import.meta.url),
8240
8241			
8242			component: () => __vitePreload(() => import('./Index-9LSEPVH5.js'),true              ?__vite__mapDeps([216,1,2,7,8,215,103,4,5,6,56,20,3,19,22,23,24,9,10,11,12,13,14]):void 0,import.meta.url)
8243			},
8244"radio": {
8245			
8246			example: () => __vitePreload(() => import('./Example-GBtWCYGT.js'),true              ?__vite__mapDeps([217,1,2,218]):void 0,import.meta.url),
8247
8248			component: () => __vitePreload(() => import('./Index-CKPl_BKA.js'),true              ?__vite__mapDeps([219,1,2,7,8,3,4,5,6,80,74,11,22,9,10,12,13,14,61,217,218,220]):void 0,import.meta.url)
8249			},
8250"row": {
8251			
8252			
8253			component: () => __vitePreload(() => import('./Index-DbuJYMQk.js'),true              ?__vite__mapDeps([221,1,2,9,10,11,4,5,6,12,13,14,7,8,222]):void 0,import.meta.url)
8254			},
8255"sidebar": {
8256			
8257			
8258			component: () => __vitePreload(() => import('./Index-DL_2b7d7.js'),true              ?__vite__mapDeps([223,1,2,7,8,9,10,11,4,5,6,12,13,14,15,16,224]):void 0,import.meta.url)
8259			},
8260"slider": {
8261			
8262			example: () => __vitePreload(() => import('./Example-Bzun0EwA.js'),true              ?__vite__mapDeps([225,1,2,226]):void 0,import.meta.url),
8263
8264			component: () => __vitePreload(() => import('./Index-D3Ps12Zs.js'),true              ?__vite__mapDeps([227,1,2,61,7,8,3,4,5,6,80,74,11,9,10,12,13,14,228]):void 0,import.meta.url)
8265			},
8266"state": {
8267			
8268			
8269			component: () => __vitePreload(() => import('./Index-D_ICCRmo.js'),true              ?__vite__mapDeps([229,1,2,7,8]):void 0,import.meta.url)
8270			},
8271"statustracker": {
8272			
8273			
8274			component: () => __vitePreload(() => import('./index-Bzj-ruDk.js'),true              ?__vite__mapDeps([230,9,1,2,10,11,4,5,6,12,13,14,231,45]):void 0,import.meta.url)
8275			},
8276"tabitem": {
8277			
8278			
8279			component: () => __vitePreload(() => import('./Index-CHpEZTbG.js'),true              ?__vite__mapDeps([232,1,2,7,8,233,68,234,15,9,10,11,4,5,6,12,13,14,16,235]):void 0,import.meta.url)
8280			},
8281"tabs": {
8282			
8283			
8284			component: () => __vitePreload(() => import('./Index-DjI-Ei2E.js'),true              ?__vite__mapDeps([236,1,2,7,8,233,68,234]):void 0,import.meta.url)
8285			},
8286"textbox": {
8287			
8288			example: () => __vitePreload(() => import('./Example-a64hbcxE.js'),true              ?__vite__mapDeps([108,1,2,109,110]):void 0,import.meta.url),
8289
8290			component: () => __vitePreload(() => import('./Index-m_Bbn_W3.js'),true              ?__vite__mapDeps([237,1,2,8,104,41,61,4,5,6,80,74,11,62,63,105,106,22,107,9,10,12,13,14,3,7,108,109,110]):void 0,import.meta.url)
8291			},
8292"timer": {
8293			
8294			
8295			component: () => __vitePreload(() => import('./Index-B51SJCw-.js'),true              ?__vite__mapDeps([238,1,2,7,8]):void 0,import.meta.url)
8296			},
8297"uploadbutton": {
8298			
8299			
8300			component: () => __vitePreload(() => import('./Index-C_TyKbH0.js'),true              ?__vite__mapDeps([239,1,2,7,8,5,54,55,56,57,4,6,58,59,240]):void 0,import.meta.url)
8301			},
8302"vibeeditor": {
8303			
8304			
8305			component: () => __vitePreload(() => import('./Index-DrpT8pjh.js'),true              ?__vite__mapDeps([241,1,2,61,10,11,4,5,6,12,13,86,87,189,41,7,8,62,63,22,65,66,67,190,242,84,187]):void 0,import.meta.url)
8306			},
8307"video": {
8308			base: () => __vitePreload(() => import('./VideoPreview-B9h4wUga.js').then(n => n.a),true              ?__vite__mapDeps([243,1,2,103,4,5,6,19,27,20,28,7,8,29,22,24,33,34,35,143,41,144,40,42,43,14,44,244]):void 0,import.meta.url),
8309
8310			example: () => __vitePreload(() => import('./Example-CTYifxHH.js'),true              ?__vite__mapDeps([245,1,2,143,5,41,144,246]):void 0,import.meta.url),
8311
8312			component: () => __vitePreload(() => import('./index-DZgoAkOA.js'),true              ?__vite__mapDeps([247,1,2,103,5,40,41,42,4,6,19,149,10,11,12,13,99,106,47,45,150,143,144,243,27,20,28,7,8,29,22,24,33,34,35,43,14,44,244,245,246,3,48,9,248,57,59,152]):void 0,import.meta.url)
8313			},
8314"walkthrough": {
8315			
8316			
8317			component: () => __vitePreload(() => import('./Index-DjI-Ei2E.js'),true              ?__vite__mapDeps([236,1,2,7,8,233,68,234]):void 0,import.meta.url)
8318			},
8319"walkthroughstep": {
8320			
8321			
8322			component: () => __vitePreload(() => import('./Index-CHpEZTbG.js'),true              ?__vite__mapDeps([232,1,2,7,8,233,68,234,15,9,10,11,4,5,6,12,13,14,16,235]):void 0,import.meta.url)
8323			},
8324
8325		};
8326		
8327
8328// @ts-nocheck
8329
8330const request_map = {};
8331const runtime_map = {};
8332
8333const is_browser = typeof window !== "undefined";
8334
8335function load_component({ api_url, name, id, variant }) {
8336	const comps = is_browser && window.__GRADIO__CC__;
8337
8338	const _component_map = {
8339		// eslint-disable-next-line no-undef
8340		...component_map,
8341		...(!comps ? {} : comps)
8342	};
8343
8344	let _id = id || name;
8345
8346	if (request_map[`${_id}-${variant}`]) {
8347		return {
8348			component: request_map[`${_id}-${variant}`],
8349			name,
8350			runtime: runtime_map[`${_id}-${variant}`]
8351		};
8352	}
8353	try {
8354		if (!_component_map?.[_id]?.[variant] && !_component_map?.[name]?.[variant])
8355			throw new Error();
8356
8357		request_map[`${_id}-${variant}`] = (
8358			_component_map?.[_id]?.[variant] || // for dev mode custom components
8359			_component_map?.[name]?.[variant]
8360		)();
8361
8362		runtime_map[`${_id}-${variant}`] =
8363			(is_browser && window.__GRADIO__CC__RUNTIMES__?.[id]) || // for dev mode custom components
8364			false;
8365
8366		return {
8367			name,
8368			component: request_map[`${_id}-${variant}`],
8369			runtime: runtime_map[`${_id}-${variant}`]
8370		};
8371	} catch (e) {
8372		if (!_id) throw new Error(`Component not found: ${name}`);
8373		try {
8374			const cc = get_component_with_css(api_url, _id, variant);
8375			const [component_module, svelte_runtime_module] = cc;
8376
8377			request_map[`${_id}-${variant}`] = component_module;
8378
8379			runtime_map[`${_id}-${variant}`] = svelte_runtime_module;
8380
8381			return {
8382				name,
8383				component: request_map[`${_id}-${variant}`],
8384				runtime: runtime_map[`${_id}-${variant}`]
8385			};
8386		} catch (e) {
8387			if (variant === "example") {
8388				request_map[`${_id}-${variant}`] = __vitePreload(() => import('./Example-LogrIR8y.js'),true              ?__vite__mapDeps([249,1,2,250]):void 0,import.meta.url);
8389
8390				return {
8391					name,
8392					component: request_map[`${_id}-${variant}`],
8393					runtime: runtime_map[`${_id}-${variant}`]
8394				};
8395			}
8396			console.error(`failed to load: ${name}`);
8397			console.error(e);
8398			throw e;
8399		}
8400	}
8401}
8402
8403function load_css(url) {
8404	if (!is_browser) {
8405		return Promise.resolve();
8406	}
8407	return new Promise((resolve, reject) => {
8408		const link = document.createElement("link");
8409		link.rel = "stylesheet";
8410		link.href = url;
8411		document.head.appendChild(link);
8412		link.onload = () => resolve();
8413		link.onerror = () => reject();
8414	});
8415}
8416
8417function get_component_with_css(api_url, id, variant) {
8418	const environment = is_browser ? "client" : "server";
8419
8420	if (environment === "server") {
8421		// Node.js cannot dynamically import HTTP URLs.
8422		// Fall back to @gradio/fallback during SSR; the real component
8423		// will be loaded client-side.
8424		return [__vitePreload(() => import('./Index-AgZJDK0R.js'),true              ?__vite__mapDeps([251,1,2,7,8,3,4,5,6,9,10,11,12,13,14,252]):void 0,import.meta.url), Promise.resolve(false)];
8425	}
8426
8427	const path = `${api_url}/custom_component/${id}/${environment}/${variant}/index.js`;
8428
8429	return [
8430		Promise.all([
8431			load_css(
8432				`${api_url}/custom_component/${id}/${environment}/${variant}/style.css`
8433			),
8434			import(
8435				/* @vite-ignore */
8436				path
8437			)
8438		]).then(([_, component_module]) => {
8439			return component_module;
8440		}),
8441		__vitePreload(() => import(
8442			/* @vite-ignore */
8443			`${api_url}/custom_component/${id}/${environment}/${variant}/svelte_runtime_entry.js`
8444		),true              ?[]:void 0,import.meta.url)
8445	];
8446}
8447
8448function get_component(type, class_id, root, variant = "component") {
8449  if (type === "api") type = "state";
8450  return load_component({
8451    api_url: root,
8452    name: type,
8453    id: class_id,
8454    variant
8455  });
8456}
8457function get_inputs_outputs(dependencies) {
8458  const inputs = /* @__PURE__ */ new Set();
8459  const outputs = /* @__PURE__ */ new Set();
8460  for (const dep of dependencies) {
8461    dep.inputs.forEach((input) => inputs.add(input));
8462    dep.outputs.forEach((output) => outputs.add(output));
8463  }
8464  return [inputs, outputs];
8465}
8466function determine_interactivity(id, interactive_prop, value, dependencies) {
8467  const [inputs, outputs] = dependencies;
8468  if (interactive_prop === false) {
8469    return false;
8470  } else if (interactive_prop === true) {
8471    return true;
8472  } else if (inputs.has(id) || !outputs.has(id) && has_no_default_value(value)) {
8473    return true;
8474  }
8475  return false;
8476}
8477function has_no_default_value(value) {
8478  return Array.isArray(value) && value.length === 0 || value === "" || value === 0 || !value;
8479}
8480const AsyncFunction = Object.getPrototypeOf(
8481  async function() {
8482  }
8483).constructor;
8484
8485const ordered_colors = [
8486  "red",
8487  "green",
8488  "blue",
8489  "yellow",
8490  "purple",
8491  "teal",
8492  "orange",
8493  "cyan",
8494  "lime",
8495  "pink"
8496];
8497const color_values = [
8498  { color: "red", primary: 600, secondary: 100 },
8499  { color: "green", primary: 600, secondary: 100 },
8500  { color: "blue", primary: 600, secondary: 100 },
8501  { color: "yellow", primary: 500, secondary: 100 },
8502  { color: "purple", primary: 600, secondary: 100 },
8503  { color: "teal", primary: 600, secondary: 100 },
8504  { color: "orange", primary: 600, secondary: 100 },
8505  { color: "cyan", primary: 600, secondary: 100 },
8506  { color: "lime", primary: 500, secondary: 100 },
8507  { color: "pink", primary: 600, secondary: 100 }
8508];
8509const tw_colors = {
8510  inherit: "inherit",
8511  current: "currentColor",
8512  transparent: "transparent",
8513  black: "#000",
8514  white: "#fff",
8515  slate: {
8516    50: "#f8fafc",
8517    100: "#f1f5f9",
8518    200: "#e2e8f0",
8519    300: "#cbd5e1",
8520    400: "#94a3b8",
8521    500: "#64748b",
8522    600: "#475569",
8523    700: "#334155",
8524    800: "#1e293b",
8525    900: "#0f172a",
8526    950: "#020617"
8527  },
8528  gray: {
8529    50: "#f9fafb",
8530    100: "#f3f4f6",
8531    200: "#e5e7eb",
8532    300: "#d1d5db",
8533    400: "#9ca3af",
8534    500: "#6b7280",
8535    600: "#4b5563",
8536    700: "#374151",
8537    800: "#1f2937",
8538    900: "#111827",
8539    950: "#030712"
8540  },
8541  zinc: {
8542    50: "#fafafa",
8543    100: "#f4f4f5",
8544    200: "#e4e4e7",
8545    300: "#d4d4d8",
8546    400: "#a1a1aa",
8547    500: "#71717a",
8548    600: "#52525b",
8549    700: "#3f3f46",
8550    800: "#27272a",
8551    900: "#18181b",
8552    950: "#09090b"
8553  },
8554  neutral: {
8555    50: "#fafafa",
8556    100: "#f5f5f5",
8557    200: "#e5e5e5",
8558    300: "#d4d4d4",
8559    400: "#a3a3a3",
8560    500: "#737373",
8561    600: "#525252",
8562    700: "#404040",
8563    800: "#262626",
8564    900: "#171717",
8565    950: "#0a0a0a"
8566  },
8567  stone: {
8568    50: "#fafaf9",
8569    100: "#f5f5f4",
8570    200: "#e7e5e4",
8571    300: "#d6d3d1",
8572    400: "#a8a29e",
8573    500: "#78716c",
8574    600: "#57534e",
8575    700: "#44403c",
8576    800: "#292524",
8577    900: "#1c1917",
8578    950: "#0c0a09"
8579  },
8580  red: {
8581    50: "#fef2f2",
8582    100: "#fee2e2",
8583    200: "#fecaca",
8584    300: "#fca5a5",
8585    400: "#f87171",
8586    500: "#ef4444",
8587    600: "#dc2626",
8588    700: "#b91c1c",
8589    800: "#991b1b",
8590    900: "#7f1d1d",
8591    950: "#450a0a"
8592  },
8593  orange: {
8594    50: "#fff7ed",
8595    100: "#ffedd5",
8596    200: "#fed7aa",
8597    300: "#fdba74",
8598    400: "#fb923c",
8599    500: "#f97316",
8600    600: "#ea580c",
8601    700: "#c2410c",
8602    800: "#9a3412",
8603    900: "#7c2d12",
8604    950: "#431407"
8605  },
8606  amber: {
8607    50: "#fffbeb",
8608    100: "#fef3c7",
8609    200: "#fde68a",
8610    300: "#fcd34d",
8611    400: "#fbbf24",
8612    500: "#f59e0b",
8613    600: "#d97706",
8614    700: "#b45309",
8615    800: "#92400e",
8616    900: "#78350f",
8617    950: "#451a03"
8618  },
8619  yellow: {
8620    50: "#fefce8",
8621    100: "#fef9c3",
8622    200: "#fef08a",
8623    300: "#fde047",
8624    400: "#facc15",
8625    500: "#eab308",
8626    600: "#ca8a04",
8627    700: "#a16207",
8628    800: "#854d0e",
8629    900: "#713f12",
8630    950: "#422006"
8631  },
8632  lime: {
8633    50: "#f7fee7",
8634    100: "#ecfccb",
8635    200: "#d9f99d",
8636    300: "#bef264",
8637    400: "#a3e635",
8638    500: "#84cc16",
8639    600: "#65a30d",
8640    700: "#4d7c0f",
8641    800: "#3f6212",
8642    900: "#365314",
8643    950: "#1a2e05"
8644  },
8645  green: {
8646    50: "#f0fdf4",
8647    100: "#dcfce7",
8648    200: "#bbf7d0",
8649    300: "#86efac",
8650    400: "#4ade80",
8651    500: "#22c55e",
8652    600: "#16a34a",
8653    700: "#15803d",
8654    800: "#166534",
8655    900: "#14532d",
8656    950: "#052e16"
8657  },
8658  emerald: {
8659    50: "#ecfdf5",
8660    100: "#d1fae5",
8661    200: "#a7f3d0",
8662    300: "#6ee7b7",
8663    400: "#34d399",
8664    500: "#10b981",
8665    600: "#059669",
8666    700: "#047857",
8667    800: "#065f46",
8668    900: "#064e3b",
8669    950: "#022c22"
8670  },
8671  teal: {
8672    50: "#f0fdfa",
8673    100: "#ccfbf1",
8674    200: "#99f6e4",
8675    300: "#5eead4",
8676    400: "#2dd4bf",
8677    500: "#14b8a6",
8678    600: "#0d9488",
8679    700: "#0f766e",
8680    800: "#115e59",
8681    900: "#134e4a",
8682    950: "#042f2e"
8683  },
8684  cyan: {
8685    50: "#ecfeff",
8686    100: "#cffafe",
8687    200: "#a5f3fc",
8688    300: "#67e8f9",
8689    400: "#22d3ee",
8690    500: "#06b6d4",
8691    600: "#0891b2",
8692    700: "#0e7490",
8693    800: "#155e75",
8694    900: "#164e63",
8695    950: "#083344"
8696  },
8697  sky: {
8698    50: "#f0f9ff",
8699    100: "#e0f2fe",
8700    200: "#bae6fd",
8701    300: "#7dd3fc",
8702    400: "#38bdf8",
8703    500: "#0ea5e9",
8704    600: "#0284c7",
8705    700: "#0369a1",
8706    800: "#075985",
8707    900: "#0c4a6e",
8708    950: "#082f49"
8709  },
8710  blue: {
8711    50: "#eff6ff",
8712    100: "#dbeafe",
8713    200: "#bfdbfe",
8714    300: "#93c5fd",
8715    400: "#60a5fa",
8716    500: "#3b82f6",
8717    600: "#2563eb",
8718    700: "#1d4ed8",
8719    800: "#1e40af",
8720    900: "#1e3a8a",
8721    950: "#172554"
8722  },
8723  indigo: {
8724    50: "#eef2ff",
8725    100: "#e0e7ff",
8726    200: "#c7d2fe",
8727    300: "#a5b4fc",
8728    400: "#818cf8",
8729    500: "#6366f1",
8730    600: "#4f46e5",
8731    700: "#4338ca",
8732    800: "#3730a3",
8733    900: "#312e81",
8734    950: "#1e1b4b"
8735  },
8736  violet: {
8737    50: "#f5f3ff",
8738    100: "#ede9fe",
8739    200: "#ddd6fe",
8740    300: "#c4b5fd",
8741    400: "#a78bfa",
8742    500: "#8b5cf6",
8743    600: "#7c3aed",
8744    700: "#6d28d9",
8745    800: "#5b21b6",
8746    900: "#4c1d95",
8747    950: "#2e1065"
8748  },
8749  purple: {
8750    50: "#faf5ff",
8751    100: "#f3e8ff",
8752    200: "#e9d5ff",
8753    300: "#d8b4fe",
8754    400: "#c084fc",
8755    500: "#a855f7",
8756    600: "#9333ea",
8757    700: "#7e22ce",
8758    800: "#6b21a8",
8759    900: "#581c87",
8760    950: "#3b0764"
8761  },
8762  fuchsia: {
8763    50: "#fdf4ff",
8764    100: "#fae8ff",
8765    200: "#f5d0fe",
8766    300: "#f0abfc",
8767    400: "#e879f9",
8768    500: "#d946ef",
8769    600: "#c026d3",
8770    700: "#a21caf",
8771    800: "#86198f",
8772    900: "#701a75",
8773    950: "#4a044e"
8774  },
8775  pink: {
8776    50: "#fdf2f8",
8777    100: "#fce7f3",
8778    200: "#fbcfe8",
8779    300: "#f9a8d4",
8780    400: "#f472b6",
8781    500: "#ec4899",
8782    600: "#db2777",
8783    700: "#be185d",
8784    800: "#9d174d",
8785    900: "#831843",
8786    950: "#500724"
8787  },
8788  rose: {
8789    50: "#fff1f2",
8790    100: "#ffe4e6",
8791    200: "#fecdd3",
8792    300: "#fda4af",
8793    400: "#fb7185",
8794    500: "#f43f5e",
8795    600: "#e11d48",
8796    700: "#be123c",
8797    800: "#9f1239",
8798    900: "#881337",
8799    950: "#4c0519"
8800  }
8801};
8802const colors = color_values.reduce(
8803  (acc, { color, primary, secondary }) => ({
8804    ...acc,
8805    [color]: {
8806      primary: tw_colors[color][primary],
8807      secondary: tw_colors[color][secondary]
8808    }
8809  }),
8810  {}
8811);
8812
8813const loading = {
8814  ar: "جاري التحميل",
8815  ca: "S'està carregant",
8816  ckb: "بارکردن",
8817  de: "Laden",
8818  en: "Loading",
8819  es: "Cargando",
8820  eu: "Kargatzen",
8821  fa: "در حال بارگذاری",
8822  fi: "Ladataan",
8823  fr: "Chargement",
8824  he: "טוען",
8825  hi: "लोड हो रहा है",
8826  ja: "読み込み中",
8827  ko: "로딩 중",
8828  lt: "Kraunama",
8829  nb: "Laster",
8830  nl: "Laden",
8831  pl: "Ładowanie",
8832  "pt-BR": "Carregando",
8833  pt: "A carregar",
8834  ro: "Se încarcă",
8835  ru: "Загрузка",
8836  sv: "Laddar",
8837  ta: "ஏற்றுகிறது",
8838  th: "กำลังโหลด",
8839  tr: "Yükleniyor",
8840  uk: "Завантаження",
8841  ur: "لوڈ ہو رہا ہے",
8842  uz: "Yuklanmoqda",
8843  "zh-CN": "加载中",
8844  "zh-TW": "載入中"
8845};
8846
8847const _name = "English";
8848const annotated_image = {"annotated_image":"Annotated Image"};
8849const audio = {"allow_recording_access":"Please allow access to the microphone for recording.","audio":"Audio","drop_to_upload":"Drop an audio file here to upload","record_from_microphone":"Record from microphone","stop_recording":"Stop recording","no_device_support":"Media devices could not be accessed. Check that you are running on a secure origin (https) or localhost (or you have passed a valid SSL certificate to ssl_verify), and you have allowed browser access to your device.","stop":"Stop","resume":"Resume","record":"Record","no_microphone":"No microphone found","pause":"Pause","play":"Play","waiting":"Waiting"};
8850const blocks = {"connection_can_break":"On mobile, the connection can break if this tab is unfocused or the device sleeps, losing your position in queue.","long_requests_queue":"There is a long queue of requests pending. Duplicate this Space to skip.","lost_connection":"Lost connection due to leaving page. Rejoining queue...","waiting_for_inputs":"Waiting for file(s) to finish uploading, please retry."};
8851const chatbot = {"edit":"Edit","retry":"Retry","undo":"Undo","submit":"Submit","cancel":"Cancel","like":"Like","dislike":"Dislike","clear":"Clear","copy_message":"Copy message","copied_message":"Copied message"};
8852const chat_interface = {"new_chat":"New chat","message_placeholder":"Type a message...","additional_inputs":"Additional inputs","chatbot":"Chatbot","conversation":"Conversation"};
8853const checkbox = {"checkbox":"Checkbox","checkbox_group":"Checkbox Group"};
8854const code = {"code":"Code"};
8855const color_picker = {"color_picker":"Color Picker"};
8856const common = {"built_with":"built with","built_with_gradio":"Built with Gradio","clear":"Clear","download":"Download","edit":"Edit","empty":"Empty","error":"Error","hosted_on":"Hosted on","loading":"Loading","logo":"logo","or":"or","remove":"Remove","settings":"Settings","share":"Share","submit":"Submit","undo":"Undo","no_devices":"No devices found","language":"Language","display_theme":"Display Theme","pwa":"Progressive Web App","record":"Record","stop_recording":"Stop Recording","screen_studio":"Screen Studio","share_gradio_tab":"[Sharing] Gradio Tab","run":"Run"};
8857const dataframe = {"incorrect_format":"Incorrect format, only CSV and TSV files are supported","new_column":"Add column","new_row":"New row","add_row_above":"Add row above","add_row_below":"Add row below","delete_row":"Delete row","delete_column":"Delete column","add_column_left":"Add column to the left","add_column_right":"Add column to the right","sort_column":"Sort column","sort_ascending":"Sort ascending","sort_descending":"Sort descending","drop_to_upload":"Drop CSV or TSV files here to import data into dataframe","clear_sort":"Clear sort","filter":"Filter","clear_filter":"Clear filters"};
8858const dropdown = {"dropdown":"Dropdown"};
8859const errors = {"build_error":"there is a build error","config_error":"there is a config error","contact_page_author":"Please contact the author of the page to let them know.","no_app_file":"there is no app file","runtime_error":"there is a runtime error","space_not_working":"\"Space isn't working because\" {0}","space_paused":"the space is paused","use_via_api":"Use via API","use_via_api_or_mcp":"Use via API or MCP"};
8860const file = {"uploading":"Uploading..."};
8861const highlighted_text = {"highlighted_text":"Highlighted Text"};
8862const image = {"allow_webcam_access":"Please allow access to the webcam for recording.","brush_color":"Brush color","brush_radius":"Brush radius","image":"Image","remove_image":"Remove Image","select_brush_color":"Select brush color","start_drawing":"Start drawing","use_brush":"Use brush","drop_to_upload":"Drop an image file here to upload"};
8863const label = {"label":"Label"};
8864const login = {"enable_cookies":"If you are visiting a HuggingFace Space in Incognito mode, you must enable third party cookies.","incorrect_credentials":"Incorrect Credentials","username":"username","password":"password","login":"Login"};
8865const number = {"number":"Number"};
8866const plot = {"plot":"Plot"};
8867const radio = {"radio":"Radio"};
8868const slider = {"slider":"Slider"};
8869const upload_text = {"click_to_upload":"Click to Upload","drop_audio":"Drop Audio Here","drop_csv":"Drop CSV Here","drop_file":"Drop File Here","drop_image":"Drop Image Here","drop_video":"Drop Video Here","drop_gallery":"Drop Media Here","paste_clipboard":"Paste from Clipboard"};
8870const video = {"drop_to_upload":"Drop a video file here to upload"};
8871const en = {
8872  _name,
8873  "3D_model": {"3d_model":"3D Model","drop_to_upload":"Drop a 3D model (.obj, .glb, .stl, .gltf, .splat, or .ply) file here to upload"},
8874  annotated_image,
8875  audio,
8876  blocks,
8877  chatbot,
8878  chat_interface,
8879  checkbox,
8880  code,
8881  color_picker,
8882  common,
8883  dataframe,
8884  dropdown,
8885  errors,
8886  file,
8887  highlighted_text,
8888  image,
8889  label,
8890  login,
8891  number,
8892  plot,
8893  radio,
8894  slider,
8895  upload_text,
8896  video,
8897};
8898
8899const en$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
8900	__proto__: null,
8901	_name,
8902	annotated_image,
8903	audio,
8904	blocks,
8905	chat_interface,
8906	chatbot,
8907	checkbox,
8908	code,
8909	color_picker,
8910	common,
8911	dataframe,
8912	default: en,
8913	dropdown,
8914	errors,
8915	file,
8916	highlighted_text,
8917	image,
8918	label,
8919	login,
8920	number,
8921	plot,
8922	radio,
8923	slider,
8924	upload_text,
8925	video
8926}, Symbol.toStringTag, { value: 'Module' }));
8927
8928const lang_map = {
8929  ar: "العربية",
8930  ca: "Català",
8931  ckb: "کوردی",
8932  de: "Deutsch",
8933  en: "English",
8934  es: "Español",
8935  eu: "Euskara",
8936  fa: "فارسی",
8937  fi: "Suomi",
8938  fr: "Français",
8939  he: "עברית",
8940  hi: "हिंदी",
8941  ja: "日本語",
8942  ko: "한국어",
8943  lt: "Lietuvių",
8944  nb: "Norsk bokmål",
8945  nl: "Nederlands",
8946  pl: "Polski",
8947  "pt-BR": "Português do Brasil",
8948  pt: "Português",
8949  ro: "Română",
8950  ru: "Русский",
8951  sv: "Svenska",
8952  ta: "தமிழ்",
8953  th: "ภาษาไทย",
8954  tr: "Türkçe",
8955  uk: "Українська",
8956  ur: "اردو",
8957  uz: "O'zbek",
8958  "zh-CN": "简体中文",
8959  "zh-TW": "繁體中文"
8960};
8961const langs = /* #__PURE__ */ Object.assign({
8961"./lang/ar.json": () => __vitePreload(() => import('./ar-Bnr8rik1.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/ca.json": () => __vitePreload(() => import('./ca-ZVB5Zcgj.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/ckb.json": () => __vitePreload(() => import('./ckb-B5osF7U3.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/de.json": () => __vitePreload(() => import('./de-BqO16QIZ.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/en.json": () => __vitePreload(() => Promise.resolve().then(() => en$1),true              ?void 0:void 0,import.meta.url),
8961"./lang/es.json": () => __vitePreload(() => import('./es-BECHJ7T0.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/eu.json": () => __vitePreload(() => import('./eu-CdvSJ_NN.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/fa.json": () => __vitePreload(() => import('./fa-n05ND1i-.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/fi.json": () => __vitePreload(() => import('./fi-f63CrSuU.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/fr.json": () => __vitePreload(() => import('./fr-Xtgf04nj.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/he.json": () => __vitePreload(() => import('./he-DzhX_ol8.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/hi.json": () => __vitePreload(() => import('./hi-CGq3rrRL.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/id.json": () => __vitePreload(() => import('./id-DTBwfi3A.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/ja.json": () => __vitePreload(() => import('./ja-Ckff7MTr.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/ko.json": () => __vitePreload(() => import('./ko-C2zECW0e.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/lt.json": () => __vitePreload(() => import('./lt-CE6Ln202.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/nb.json": () => __vitePreload(() => import('./nb-CNxglIEs.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/nl.json": () => __vitePreload(() => import('./nl-DO2suw4j.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/pl.json": () => __vitePreload(() => import('./pl-BlSku3we.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/pt-BR.json": () => __vitePreload(() => import('./pt-BR-87jk7nQ9.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/pt.json": () => __vitePreload(() => import('./pt-BVfKCBHm.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/ro.json": () => __vitePreload(() => import('./ro-B-y0swIh.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/ru.json": () => __vitePreload(() => import('./ru-DGhkoewM.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/sv.json": () => __vitePreload(() => import('./sv-CC6VQTaJ.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/ta.json": () => __vitePreload(() => import('./ta-BTn6NxAt.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/th.json": () => __vitePreload(() => import('./th-Bq4LzcN7.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/tr.json": () => __vitePreload(() => import('./tr-DPCQxv16.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/uk.json": () => __vitePreload(() => import('./uk-BHClIR2f.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/ur.json": () => __vitePreload(() => import('./ur-D3imbk6t.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/uz.json": () => __vitePreload(() => import('./uz-Dw46OF3I.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/zh-CN.json": () => __vitePreload(() => import('./zh-CN-XOyJonQP.js'),true              ?[]:void 0,import.meta.url),
8961"./lang/zh-TW.json": () => __vitePreload(() => import('./zh-TW-BlEWhqmM.js'),true              ?[]:void 0,import.meta.url)
8961});
8962function is_translation_metadata(obj) {
8963  const result = obj && typeof obj === "object" && obj.__type__ === "translation_metadata" && typeof obj.key === "string";
8964  return result;
8965}
8966function process_langs() {
8967  const lazy_langs = Object.fromEntries(
8968    Object.entries(langs).map(([path, mod]) => [
8969      path.split("/").pop().split(".")[0],
8970      { type: "lazy", data: mod }
8971    ])
8972  );
8973  return {
8974    ...lazy_langs,
8975    en: { type: "static", data: en }
8976  };
8977}
8978const processed_langs = process_langs();
8979const available_locales = Object.keys(processed_langs);
8980const language_choices = Object.entries(
8981  processed_langs
8982).map(([code]) => [lang_map[code] || code, code]);
8983let i18n_initialized = false;
8984let previous_translations;
8985function get_lang_from_preferred_locale(header) {
8986  const options = header.split(",").map(
8987    (value) => value.includes(";") ? value.split(";").slice(0, 2) : [value, 1]
8988  );
8989  options.sort(
8990    (a, b) => parseFloat(b[1]) - parseFloat(a[1])
8991  );
8992  for (const [lang, _] of options) {
8993    if (available_locales.includes(lang)) {
8994      return lang;
8995    }
8996  }
8997  return null;
8998}
8999async function setupi18n(custom_translations, preferred_locale) {
9000  const should_reinitialize = i18n_initialized && custom_translations !== previous_translations;
9001  if (i18n_initialized && !should_reinitialize) {
9002    return;
9003  }
9004  const translations_to_use = custom_translations ?? previous_translations ?? {};
9005  if (custom_translations !== void 0) {
9006    previous_translations = custom_translations;
9007  }
9008  load_translations({
9009    processed_langs,
9010    custom_translations: translations_to_use
9011  });
9012  let initial_locale = null;
9013  const browser_locale = getLocaleFromNavigator();
9014  if (preferred_locale) {
9015    initial_locale = get_lang_from_preferred_locale(preferred_locale);
9016  } else {
9017    initial_locale = browser_locale && available_locales.includes(browser_locale) ? browser_locale : null;
9018  }
9019  if (!initial_locale) {
9020    const normalized_locale = browser_locale?.split("-")[0];
9021    initial_locale = normalized_locale && available_locales.includes(normalized_locale) ? normalized_locale : "en";
9022  }
9023  await init({
9024    fallbackLocale: "en",
9025    initialLocale: initial_locale
9026  });
9027  i18n_initialized = true;
9028}
9029function changeLocale(new_locale) {
9030  $locale.set(new_locale);
9031}
9032function get_initial_locale(browser_locale, available_locales2, fallback_locale = "en") {
9033  if (!browser_locale) return fallback_locale;
9034  if (available_locales2.includes(browser_locale)) {
9035    return browser_locale;
9036  }
9037  return fallback_locale;
9038}
9039function load_translations(translations) {
9040  if (!translations) {
9041    return;
9042  }
9043  try {
9044    for (const lang in translations.custom_translations) {
9045      addMessages(lang, translations.custom_translations[lang]);
9046    }
9047    for (const lang in translations.processed_langs) {
9048      if (lang === "en" && translations.processed_langs[lang].type === "static") {
9049        addMessages(lang, en);
9050      } else if (translations.processed_langs[lang].type === "lazy") {
9051        registerLocaleLoader(lang, translations.processed_langs[lang].data);
9052      }
9053    }
9054  } catch (e) {
9055    console.error("Error loading translations:", e);
9056  }
9057  for (const lang in loading) {
9058    addMessages(lang, {
9059      common: { loading: loading[lang] }
9060    });
9061  }
9062}
9063
9064export { $locale as $, prefix_css as A, BranchManager as B, CLASS as C, mount_css as D, Embed as E, set_value as F, getDefaultExportFromCjs as G, language_choices as H, changeLocale as I, commonjsGlobal as J, update_prop as K, set_selected as L, colors as M, bind_select_value as N, derived as O, AsyncFunction as P, getAugmentedNamespace as Q, get_inputs_outputs as R, STYLE as S, get_component as T, determine_interactivity as U, get_initial_locale as V, is_translation_metadata as W, load_translations as X, process_langs as Y, set_attribute as a, set_class as b, attribute_effect as c, bind_this as d, init$1 as e, set_style as f, spread_props as g, clsx as h, if_block as i, get as j, each as k, legacy_rest_props as l, setup_stores as m, navbar_config as n, ordered_colors as o, prop as p, store_get as q, rest_props as r, slot as s, remove_input_defaults as t, index as u, set_checked as v, writable as w, store_set as x, setupi18n as y, $format as z };
9065//# sourceMappingURL=i18n-CMo5lpzy.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.