1338 lines
42 KiB
JavaScript
1338 lines
42 KiB
JavaScript
import { $n as NAMESPACE_SVG, Ar as is_array, Bn as hydrating, Cr as define_property, G as create_fragment, Gn as set_hydrating, Gt as queue_micro_task, H as clear_text_content, Hn as read_hydration_instruction, I as user_pre_effect, J as get_first_child, Jn as FILENAME, K as create_text, Kn as skip_nodes, Ln as hydrate_next, Mn as lifecycle_outside_component, Nr as noop, O as move_effect, On as svelte_boundary_reset_onerror, Q as merge_text_nodes, Qn as NAMESPACE_MATHML, R as invoke_error_boundary, Rn as hydrate_node, Sn as hydration_failed, U as create_comment, Ut as defer_effect, Vn as next, W as create_element, Wn as set_hydrate_node, Wt as set_signal_status, X as init_operations, Xn as HYDRATION_ERROR, Y as get_next_sibling, Yt as dev_current_component_function, Z as is_firefox, _ as branch, _t as current_batch, a as get, an as set_component_context, b as destroy_effect, br as TEXT_CACHE, c as set_active_effect, cr as EFFECT_TRANSPARENT, ct as internal_set, dt as set, et as set_attribute, ft as source, g as block, gr as MAYBE_DIRTY, gt as Batch, ir as DESTROYING, k as pause_effect, l as set_active_reaction, ln as tag, lt as mutable_source, mr as LEGACY_PROPS, n as active_reaction, nn as pop, pr as IS_XHTML, qt as component_context, rn as push, rr as DESTROYED, sr as EFFECT_PRESERVED, t as active_effect, tn as mark_as_component, v as component_root, xr as array_from, yn as effect_pending_outside_reaction, yt as flushSync } from "./runtime-BOFXI46e.js";
|
||
import "./esm-env-D8Yi5ac9.js";
|
||
import { c as on, s as handle_event_propagation, t as all_registered_events, u as root_event_handles } from "./events-21uQP6Br.js";
|
||
import { d as hydration_mismatch, m as lifecycle_double_unmount, p as legacy_recursive_reactive_block, y as svelte_boundary_reset_noop } from "./warnings-BCxPSjeg.js";
|
||
import { t as createSubscriber } from "./create-subscriber-C6AIq2F7.js";
|
||
import { t as async_mode_flag } from "./flags-qfBdqUK7.js";
|
||
// node_modules/svelte/src/utils.js
|
||
var regex_return_characters = /\r/g;
|
||
/**
|
||
* @param {string} str
|
||
* @returns {string}
|
||
*/
|
||
function hash(str) {
|
||
str = str.replace(regex_return_characters, "");
|
||
let hash = 5381;
|
||
let i = str.length;
|
||
while (i--) hash = (hash << 5) - hash ^ str.charCodeAt(i);
|
||
return (hash >>> 0).toString(36);
|
||
}
|
||
var VOID_ELEMENT_NAMES = [
|
||
"area",
|
||
"base",
|
||
"br",
|
||
"col",
|
||
"command",
|
||
"embed",
|
||
"hr",
|
||
"img",
|
||
"input",
|
||
"keygen",
|
||
"link",
|
||
"meta",
|
||
"param",
|
||
"source",
|
||
"track",
|
||
"wbr"
|
||
];
|
||
/**
|
||
* Returns `true` if `name` is of a void element
|
||
* @param {string} name
|
||
*/
|
||
function is_void(name) {
|
||
return VOID_ELEMENT_NAMES.includes(name) || name.toLowerCase() === "!doctype";
|
||
}
|
||
/**
|
||
* @param {string} name
|
||
*/
|
||
function is_capture_event(name) {
|
||
return name.endsWith("capture") && name !== "gotpointercapture" && name !== "lostpointercapture";
|
||
}
|
||
/** List of Element events that will be delegated */
|
||
var DELEGATED_EVENTS = [
|
||
"beforeinput",
|
||
"click",
|
||
"change",
|
||
"dblclick",
|
||
"contextmenu",
|
||
"focusin",
|
||
"focusout",
|
||
"input",
|
||
"keydown",
|
||
"keyup",
|
||
"mousedown",
|
||
"mousemove",
|
||
"mouseout",
|
||
"mouseover",
|
||
"mouseup",
|
||
"pointerdown",
|
||
"pointermove",
|
||
"pointerout",
|
||
"pointerover",
|
||
"pointerup",
|
||
"touchend",
|
||
"touchmove",
|
||
"touchstart"
|
||
];
|
||
/**
|
||
* Returns `true` if `event_name` is a delegated event
|
||
* @param {string} event_name
|
||
*/
|
||
function can_delegate_event(event_name) {
|
||
return DELEGATED_EVENTS.includes(event_name);
|
||
}
|
||
/**
|
||
* Attributes that are boolean, i.e. they are present or not present.
|
||
*/
|
||
var DOM_BOOLEAN_ATTRIBUTES = [
|
||
"allowfullscreen",
|
||
"async",
|
||
"autofocus",
|
||
"autoplay",
|
||
"checked",
|
||
"controls",
|
||
"default",
|
||
"disabled",
|
||
"formnovalidate",
|
||
"indeterminate",
|
||
"inert",
|
||
"ismap",
|
||
"loop",
|
||
"multiple",
|
||
"muted",
|
||
"nomodule",
|
||
"novalidate",
|
||
"open",
|
||
"playsinline",
|
||
"readonly",
|
||
"required",
|
||
"reversed",
|
||
"seamless",
|
||
"selected",
|
||
"webkitdirectory",
|
||
"defer",
|
||
"disablepictureinpicture",
|
||
"disableremoteplayback"
|
||
];
|
||
/**
|
||
* @type {Record<string, string>}
|
||
* List of attribute names that should be aliased to their property names
|
||
* because they behave differently between setting them as an attribute and
|
||
* setting them as a property.
|
||
*/
|
||
var ATTRIBUTE_ALIASES = {
|
||
formnovalidate: "formNoValidate",
|
||
ismap: "isMap",
|
||
nomodule: "noModule",
|
||
playsinline: "playsInline",
|
||
readonly: "readOnly",
|
||
defaultvalue: "defaultValue",
|
||
defaultchecked: "defaultChecked",
|
||
srcobject: "srcObject",
|
||
novalidate: "noValidate",
|
||
allowfullscreen: "allowFullscreen",
|
||
disablepictureinpicture: "disablePictureInPicture",
|
||
disableremoteplayback: "disableRemotePlayback"
|
||
};
|
||
/**
|
||
* @param {string} name
|
||
*/
|
||
function normalize_attribute(name) {
|
||
name = name.toLowerCase();
|
||
return ATTRIBUTE_ALIASES[name] ?? name;
|
||
}
|
||
[...DOM_BOOLEAN_ATTRIBUTES];
|
||
/**
|
||
* Subset of delegated events which should be passive by default.
|
||
* These two are already passive via browser defaults on window, document and body.
|
||
* But since
|
||
* - we're delegating them
|
||
* - they happen often
|
||
* - they apply to mobile which is generally less performant
|
||
* we're marking them as passive by default for other elements, too.
|
||
*/
|
||
var PASSIVE_EVENTS = ["touchstart", "touchmove"];
|
||
/**
|
||
* Returns `true` if `name` is a passive event
|
||
* @param {string} name
|
||
*/
|
||
function is_passive_event(name) {
|
||
return PASSIVE_EVENTS.includes(name);
|
||
}
|
||
/** List of elements that require raw contents and should not have SSR comments put in them */
|
||
var RAW_TEXT_ELEMENTS = [
|
||
"textarea",
|
||
"script",
|
||
"style",
|
||
"title"
|
||
];
|
||
/** @param {string} name */
|
||
function is_raw_text_element(name) {
|
||
return RAW_TEXT_ELEMENTS.includes(name);
|
||
}
|
||
/**
|
||
* Prevent devtools trying to make `location` a clickable link by inserting a zero-width space
|
||
* @template {string | undefined} T
|
||
* @param {T} location
|
||
* @returns {T};
|
||
*/
|
||
function sanitize_location(location) {
|
||
return location?.replace(/\//g, "/");
|
||
}
|
||
// node_modules/svelte/src/internal/client/dom/reconciler.js
|
||
var policy = globalThis?.window?.trustedTypes && /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy("svelte-trusted-html", {
|
||
/** @param {string} html */
|
||
createHTML: (html) => {
|
||
return html;
|
||
} });
|
||
/** @param {string} html */
|
||
function create_trusted_html(html) {
|
||
return policy?.createHTML(html) ?? html;
|
||
}
|
||
/**
|
||
* @param {string} html
|
||
*/
|
||
function create_fragment_from_html(html) {
|
||
var elem = create_element("template");
|
||
elem.innerHTML = create_trusted_html(html.replaceAll("<!>", "<!---->"));
|
||
return elem.content;
|
||
}
|
||
// node_modules/svelte/src/internal/client/dom/template.js
|
||
/** @import { Effect, EffectNodes, TemplateNode } from '#client' */
|
||
/** @import { TemplateStructure } from './types' */
|
||
var TEMPLATE_TAG = IS_XHTML ? "template" : "TEMPLATE";
|
||
var SCRIPT_TAG = IS_XHTML ? "script" : "SCRIPT";
|
||
/**
|
||
* @param {TemplateNode} start
|
||
* @param {TemplateNode | null} end
|
||
*/
|
||
function assign_nodes(start, end) {
|
||
var effect = active_effect;
|
||
if (effect.nodes === null) effect.nodes = {
|
||
start,
|
||
end,
|
||
a: null,
|
||
t: null
|
||
};
|
||
}
|
||
/**
|
||
* @param {string} content
|
||
* @param {number} flags
|
||
* @returns {() => Node | Node[]}
|
||
*/
|
||
/*#__NO_SIDE_EFFECTS__*/
|
||
function from_html(content, flags) {
|
||
var is_fragment = (flags & 1) !== 0;
|
||
var use_import_node = (flags & 2) !== 0;
|
||
/** @type {Node} */
|
||
var node;
|
||
/**
|
||
* Whether or not the first item is a text/element node. If not, we need to
|
||
* create an additional comment node to act as `effect.nodes.start`
|
||
*/
|
||
var has_start = !content.startsWith("<!>");
|
||
return () => {
|
||
if (hydrating) {
|
||
assign_nodes(hydrate_node, null);
|
||
return hydrate_node;
|
||
}
|
||
if (node === void 0) {
|
||
node = create_fragment_from_html(has_start ? content : "<!>" + content);
|
||
if (!is_fragment) node = /* @__PURE__ */ get_first_child(node);
|
||
}
|
||
var clone = use_import_node || is_firefox ? document.importNode(node, true) : node.cloneNode(true);
|
||
if (is_fragment) {
|
||
var start = /* @__PURE__ */ get_first_child(clone);
|
||
var end = clone.lastChild;
|
||
assign_nodes(start, end);
|
||
} else assign_nodes(clone, clone);
|
||
return clone;
|
||
};
|
||
}
|
||
/**
|
||
* @param {string} content
|
||
* @param {number} flags
|
||
* @param {'svg' | 'math'} ns
|
||
* @returns {() => Node | Node[]}
|
||
*/
|
||
/*#__NO_SIDE_EFFECTS__*/
|
||
function from_namespace(content, flags, ns = "svg") {
|
||
/**
|
||
* Whether or not the first item is a text/element node. If not, we need to
|
||
* create an additional comment node to act as `effect.nodes.start`
|
||
*/
|
||
var has_start = !content.startsWith("<!>");
|
||
var is_fragment = (flags & 1) !== 0;
|
||
var wrapped = `<${ns}>${has_start ? content : "<!>" + content}</${ns}>`;
|
||
/** @type {Element | DocumentFragment} */
|
||
var node;
|
||
return () => {
|
||
if (hydrating) {
|
||
assign_nodes(hydrate_node, null);
|
||
return hydrate_node;
|
||
}
|
||
if (!node) {
|
||
var fragment = create_fragment_from_html(wrapped);
|
||
var root = /* @__PURE__ */ get_first_child(fragment);
|
||
if (is_fragment) {
|
||
node = document.createDocumentFragment();
|
||
while (/* @__PURE__ */ get_first_child(root)) node.appendChild(/* @__PURE__ */ get_first_child(root));
|
||
} else node = /* @__PURE__ */ get_first_child(root);
|
||
}
|
||
var clone = node.cloneNode(true);
|
||
if (is_fragment) {
|
||
var start = /* @__PURE__ */ get_first_child(clone);
|
||
var end = clone.lastChild;
|
||
assign_nodes(start, end);
|
||
} else assign_nodes(clone, clone);
|
||
return clone;
|
||
};
|
||
}
|
||
/**
|
||
* @param {string} content
|
||
* @param {number} flags
|
||
*/
|
||
/*#__NO_SIDE_EFFECTS__*/
|
||
function from_svg(content, flags) {
|
||
return /* @__PURE__ */ from_namespace(content, flags, "svg");
|
||
}
|
||
/**
|
||
* @param {string} content
|
||
* @param {number} flags
|
||
*/
|
||
/*#__NO_SIDE_EFFECTS__*/
|
||
function from_mathml(content, flags) {
|
||
return /* @__PURE__ */ from_namespace(content, flags, "math");
|
||
}
|
||
/**
|
||
* @param {TemplateStructure[]} structure
|
||
* @param {typeof NAMESPACE_SVG | typeof NAMESPACE_MATHML | undefined} [ns]
|
||
*/
|
||
function fragment_from_tree(structure, ns) {
|
||
var fragment = create_fragment();
|
||
for (var item of structure) {
|
||
if (typeof item === "string") {
|
||
fragment.append(create_text(item));
|
||
continue;
|
||
}
|
||
if (item === void 0 || item[0][0] === "/") {
|
||
fragment.append(create_comment(item ? item[0].slice(3) : ""));
|
||
continue;
|
||
}
|
||
const [name, attributes, ...children] = item;
|
||
const namespace = name === "svg" ? NAMESPACE_SVG : name === "math" ? NAMESPACE_MATHML : ns;
|
||
var element = create_element(name, namespace, attributes?.is);
|
||
for (var key in attributes) set_attribute(element, key, attributes[key]);
|
||
if (children.length > 0) (element.nodeName === TEMPLATE_TAG ? element.content : element).append(fragment_from_tree(children, element.nodeName === "foreignObject" ? void 0 : namespace));
|
||
fragment.append(element);
|
||
}
|
||
return fragment;
|
||
}
|
||
/**
|
||
* @param {TemplateStructure[]} structure
|
||
* @param {number} flags
|
||
* @returns {() => Node | Node[]}
|
||
*/
|
||
/*#__NO_SIDE_EFFECTS__*/
|
||
function from_tree(structure, flags) {
|
||
var is_fragment = (flags & 1) !== 0;
|
||
var use_import_node = (flags & 2) !== 0;
|
||
/** @type {Node} */
|
||
var node;
|
||
return () => {
|
||
if (hydrating) {
|
||
assign_nodes(hydrate_node, null);
|
||
return hydrate_node;
|
||
}
|
||
if (node === void 0) {
|
||
node = fragment_from_tree(structure, (flags & 4) !== 0 ? NAMESPACE_SVG : (flags & 8) !== 0 ? NAMESPACE_MATHML : void 0);
|
||
if (!is_fragment) node = /* @__PURE__ */ get_first_child(node);
|
||
}
|
||
var clone = use_import_node || is_firefox ? document.importNode(node, true) : node.cloneNode(true);
|
||
if (is_fragment) {
|
||
var start = /* @__PURE__ */ get_first_child(clone);
|
||
var end = clone.lastChild;
|
||
assign_nodes(start, end);
|
||
} else assign_nodes(clone, clone);
|
||
return clone;
|
||
};
|
||
}
|
||
/**
|
||
* @param {() => Element | DocumentFragment} fn
|
||
*/
|
||
function with_script(fn) {
|
||
return () => run_scripts(fn());
|
||
}
|
||
/**
|
||
* Creating a document fragment from HTML that contains script tags will not execute
|
||
* the scripts. We need to replace the script tags with new ones so that they are executed.
|
||
* @param {Element | DocumentFragment} node
|
||
* @returns {Node | Node[]}
|
||
*/
|
||
function run_scripts(node) {
|
||
if (hydrating) return node;
|
||
const is_fragment = node.nodeType === 11;
|
||
const scripts = node.nodeName === SCRIPT_TAG ? [node] : node.querySelectorAll("script");
|
||
const effect = active_effect;
|
||
for (const script of scripts) {
|
||
const clone = create_element("script");
|
||
for (var attribute of script.attributes) clone.setAttribute(attribute.name, attribute.value);
|
||
clone.textContent = script.textContent;
|
||
if (is_fragment ? node.firstChild === script : node === script) effect.nodes.start = clone;
|
||
if (is_fragment ? node.lastChild === script : node === script) effect.nodes.end = clone;
|
||
script.replaceWith(clone);
|
||
}
|
||
return node;
|
||
}
|
||
/**
|
||
* Don't mark this as side-effect-free, hydration needs to walk all nodes
|
||
* @param {any} value
|
||
*/
|
||
function text(value = "") {
|
||
if (!hydrating) {
|
||
var t = create_text(value + "");
|
||
assign_nodes(t, t);
|
||
return t;
|
||
}
|
||
var node = hydrate_node;
|
||
if (node.nodeType !== 3) {
|
||
node.before(node = create_text());
|
||
set_hydrate_node(node);
|
||
} else merge_text_nodes(node);
|
||
assign_nodes(node, node);
|
||
return node;
|
||
}
|
||
/**
|
||
* @returns {TemplateNode | DocumentFragment}
|
||
*/
|
||
function comment() {
|
||
if (hydrating) {
|
||
assign_nodes(hydrate_node, null);
|
||
return hydrate_node;
|
||
}
|
||
var frag = document.createDocumentFragment();
|
||
var start = document.createComment("");
|
||
var anchor = create_text();
|
||
frag.append(start, anchor);
|
||
assign_nodes(start, anchor);
|
||
return frag;
|
||
}
|
||
/**
|
||
* Assign the created (or in hydration mode, traversed) dom elements to the current block
|
||
* and insert the elements into the dom (in client mode).
|
||
* @param {Text | Comment | Element} anchor
|
||
* @param {DocumentFragment | Element} dom
|
||
*/
|
||
function append(anchor, dom) {
|
||
if (hydrating) {
|
||
var effect = active_effect;
|
||
if ((effect.f & 32768) === 0 || effect.nodes.end === null) effect.nodes.end = hydrate_node;
|
||
hydrate_next();
|
||
return;
|
||
}
|
||
if (anchor === null) return;
|
||
anchor.before(dom);
|
||
}
|
||
/**
|
||
* Create (or hydrate) an unique UID for the component instance.
|
||
*/
|
||
function props_id() {
|
||
if (hydrating && hydrate_node && hydrate_node.nodeType === 8 && hydrate_node.textContent?.startsWith(`$`)) {
|
||
const id = hydrate_node.textContent.substring(1);
|
||
hydrate_next();
|
||
return id;
|
||
}
|
||
(window.__svelte ??= {}).uid ??= 1;
|
||
return `c${window.__svelte.uid++}`;
|
||
}
|
||
// node_modules/svelte/src/internal/client/dom/blocks/boundary.js
|
||
/** @import { Effect, Source, TemplateNode, } from '#client' */
|
||
/**
|
||
* @typedef {{
|
||
* onerror?: ((error: unknown, reset: () => void) => void) | null;
|
||
* failed?: ((anchor: Node, error: () => unknown, reset: () => () => void) => void) | null;
|
||
* pending?: ((anchor: Node) => void) | null;
|
||
* }} BoundaryProps
|
||
*/
|
||
var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
|
||
/**
|
||
* @param {TemplateNode} node
|
||
* @param {BoundaryProps} props
|
||
* @param {((anchor: Node) => void)} children
|
||
* @param {((error: unknown) => unknown) | undefined} [transform_error]
|
||
* @returns {void}
|
||
*/
|
||
function boundary(node, props, children, transform_error) {
|
||
new Boundary(node, props, children, transform_error);
|
||
}
|
||
var Boundary = class {
|
||
/** @type {Boundary | null} */
|
||
parent;
|
||
is_pending = false;
|
||
/**
|
||
* API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
|
||
* Inherited from parent boundary, or defaults to identity.
|
||
* @type {(error: unknown) => unknown}
|
||
*/
|
||
transform_error;
|
||
/** @type {TemplateNode} */
|
||
#anchor;
|
||
/** @type {TemplateNode | null} */
|
||
#hydrate_open = hydrating ? hydrate_node : null;
|
||
/** @type {BoundaryProps} */
|
||
#props;
|
||
/** @type {((anchor: Node) => void)} */
|
||
#children;
|
||
/** @type {Effect} */
|
||
#effect;
|
||
/** @type {Effect | null} */
|
||
#main_effect = null;
|
||
/** @type {Effect | null} */
|
||
#pending_effect = null;
|
||
/** @type {Effect | null} */
|
||
#failed_effect = null;
|
||
/** @type {DocumentFragment | null} */
|
||
#offscreen_fragment = null;
|
||
#local_pending_count = 0;
|
||
#pending_count = 0;
|
||
#pending_count_update_queued = false;
|
||
/** @type {Map<Effect, number>} */
|
||
#dirty_reactions = /* @__PURE__ */ new Map();
|
||
/**
|
||
* A source containing the number of pending async deriveds/expressions.
|
||
* Only created if `$effect.pending()` is used inside the boundary,
|
||
* otherwise updating the source results in needless `Batch.ensure()`
|
||
* calls followed by no-op flushes
|
||
* @type {Source<number> | null}
|
||
*/
|
||
#effect_pending = null;
|
||
#effect_pending_subscriber = createSubscriber(() => {
|
||
this.#effect_pending = source(this.#local_pending_count);
|
||
tag(this.#effect_pending, "$effect.pending()");
|
||
return () => {
|
||
this.#effect_pending = null;
|
||
};
|
||
});
|
||
/**
|
||
* @param {TemplateNode} node
|
||
* @param {BoundaryProps} props
|
||
* @param {((anchor: Node) => void)} children
|
||
* @param {((error: unknown) => unknown) | undefined} [transform_error]
|
||
*/
|
||
constructor(node, props, children, transform_error) {
|
||
this.#anchor = node;
|
||
this.#props = props;
|
||
this.#children = (anchor) => {
|
||
var effect = active_effect;
|
||
effect.b = this;
|
||
effect.f |= 128;
|
||
children(anchor);
|
||
};
|
||
this.parent = active_effect.b;
|
||
this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
|
||
this.#effect = block(() => {
|
||
if (hydrating) {
|
||
const comment_data = read_hydration_instruction(this.#hydrate_open);
|
||
hydrate_next();
|
||
const server_rendered_pending = comment_data === "[!";
|
||
if (comment_data.startsWith("[?")) {
|
||
const serialized_error = JSON.parse(comment_data.slice(2));
|
||
this.#hydrate_failed_content(serialized_error);
|
||
} else if (server_rendered_pending) this.#hydrate_pending_content();
|
||
else this.#hydrate_resolved_content();
|
||
} else this.#render();
|
||
}, flags);
|
||
if (hydrating) this.#anchor = hydrate_node;
|
||
}
|
||
#hydrate_resolved_content() {
|
||
try {
|
||
this.#main_effect = branch(() => this.#children(this.#anchor));
|
||
} catch (error) {
|
||
this.error(error);
|
||
}
|
||
}
|
||
/**
|
||
* @param {unknown} error The deserialized error from the server's hydration comment
|
||
*/
|
||
#hydrate_failed_content(error) {
|
||
const failed = this.#props.failed;
|
||
const { reset, invoke_onerror } = this.#create_reset(error);
|
||
queue_micro_task(invoke_onerror);
|
||
if (!failed) return;
|
||
this.#failed_effect = branch(() => {
|
||
failed(this.#anchor, () => error, () => reset);
|
||
});
|
||
}
|
||
/**
|
||
* Creates the `reset` function for a failed boundary, along with a function
|
||
* that invokes `onerror` with it (if provided)
|
||
* @param {unknown} error
|
||
* @returns {{ reset: () => void, invoke_onerror: () => void }}
|
||
*/
|
||
#create_reset(error) {
|
||
var did_reset = false;
|
||
var calling_on_error = false;
|
||
const reset = () => {
|
||
if (this.#is_destroyed()) return;
|
||
if (did_reset) {
|
||
svelte_boundary_reset_noop();
|
||
return;
|
||
}
|
||
did_reset = true;
|
||
if (calling_on_error) svelte_boundary_reset_onerror();
|
||
if (this.#failed_effect !== null) pause_effect(this.#failed_effect, () => {
|
||
this.#failed_effect = null;
|
||
});
|
||
this.#run(() => {
|
||
this.#render();
|
||
});
|
||
};
|
||
const invoke_onerror = () => {
|
||
if (this.#is_destroyed()) return;
|
||
try {
|
||
calling_on_error = true;
|
||
this.#props.onerror?.(error, reset);
|
||
calling_on_error = false;
|
||
} catch (err) {
|
||
invoke_error_boundary(err, this.#effect && this.#effect.parent);
|
||
}
|
||
};
|
||
return {
|
||
reset,
|
||
invoke_onerror
|
||
};
|
||
}
|
||
#is_destroyed() {
|
||
return (this.#effect.f & (DESTROYED | DESTROYING)) !== 0;
|
||
}
|
||
#hydrate_pending_content() {
|
||
const pending = this.#props.pending;
|
||
if (!pending) return;
|
||
this.is_pending = true;
|
||
this.#pending_effect = branch(() => pending(this.#anchor));
|
||
queue_micro_task(() => {
|
||
if (this.#is_destroyed()) return;
|
||
var fragment = this.#offscreen_fragment = document.createDocumentFragment();
|
||
var anchor = create_text();
|
||
var handled = false;
|
||
fragment.append(anchor);
|
||
this.#main_effect = this.#run(() => {
|
||
try {
|
||
return branch(() => this.#children(anchor));
|
||
} catch (error) {
|
||
try {
|
||
this.error(error);
|
||
handled = true;
|
||
} catch (error) {
|
||
invoke_error_boundary(error, this.#effect.parent);
|
||
}
|
||
return null;
|
||
}
|
||
});
|
||
if (this.#main_effect === null) {
|
||
this.#offscreen_fragment = null;
|
||
if (handled) this.#resolve(current_batch);
|
||
return;
|
||
}
|
||
if (this.#pending_count === 0) {
|
||
this.#anchor.before(fragment);
|
||
this.#offscreen_fragment = null;
|
||
pause_effect(this.#pending_effect, () => {
|
||
this.#pending_effect = null;
|
||
});
|
||
this.#resolve(current_batch);
|
||
}
|
||
});
|
||
}
|
||
#render() {
|
||
try {
|
||
this.is_pending = this.has_pending_snippet();
|
||
this.#pending_count = 0;
|
||
this.#local_pending_count = 0;
|
||
this.#main_effect = branch(() => {
|
||
this.#children(this.#anchor);
|
||
});
|
||
if (this.#pending_count > 0) {
|
||
var fragment = this.#offscreen_fragment = document.createDocumentFragment();
|
||
move_effect(this.#main_effect, fragment);
|
||
const pending = this.#props.pending;
|
||
this.#pending_effect = branch(() => pending(this.#anchor));
|
||
} else this.#resolve(current_batch);
|
||
} catch (error) {
|
||
this.error(error);
|
||
}
|
||
}
|
||
/**
|
||
* @param {Batch} batch
|
||
*/
|
||
#resolve(batch) {
|
||
this.is_pending = false;
|
||
batch.transfer_reactions(this.#dirty_reactions);
|
||
}
|
||
/**
|
||
* Defer an effect inside a pending boundary until the boundary resolves
|
||
* @param {Effect} effect
|
||
*/
|
||
defer_effect(effect) {
|
||
defer_effect(effect, this.#dirty_reactions);
|
||
}
|
||
/**
|
||
* Returns `false` if the effect exists inside a boundary whose pending snippet is shown
|
||
* @returns {boolean}
|
||
*/
|
||
is_rendered() {
|
||
return !this.is_pending && (!this.parent || this.parent.is_rendered());
|
||
}
|
||
has_pending_snippet() {
|
||
return !!this.#props.pending;
|
||
}
|
||
/**
|
||
* @template T
|
||
* @param {() => T} fn
|
||
*/
|
||
#run(fn) {
|
||
var previous_effect = active_effect;
|
||
var previous_reaction = active_reaction;
|
||
var previous_ctx = component_context;
|
||
set_active_effect(this.#effect);
|
||
set_active_reaction(this.#effect);
|
||
set_component_context(this.#effect.ctx);
|
||
try {
|
||
Batch.ensure();
|
||
return fn();
|
||
} finally {
|
||
set_active_effect(previous_effect);
|
||
set_active_reaction(previous_reaction);
|
||
set_component_context(previous_ctx);
|
||
}
|
||
}
|
||
/**
|
||
* Updates the pending count associated with the currently visible pending snippet,
|
||
* if any, such that we can replace the snippet with content once work is done
|
||
* @param {1 | -1} d
|
||
* @param {Batch} batch
|
||
*/
|
||
#update_pending_count(d, batch) {
|
||
if (!this.has_pending_snippet()) {
|
||
if (this.parent) this.parent.#update_pending_count(d, batch);
|
||
return;
|
||
}
|
||
this.#pending_count += d;
|
||
if (this.#pending_count === 0) {
|
||
this.#resolve(batch);
|
||
if (this.#pending_effect) pause_effect(this.#pending_effect, () => {
|
||
this.#pending_effect = null;
|
||
});
|
||
if (this.#offscreen_fragment) {
|
||
this.#anchor.before(this.#offscreen_fragment);
|
||
this.#offscreen_fragment = null;
|
||
}
|
||
}
|
||
}
|
||
/**
|
||
* Update the source that powers `$effect.pending()` inside this boundary,
|
||
* and controls when the current `pending` snippet (if any) is removed.
|
||
* Do not call from inside the class
|
||
* @param {1 | -1} d
|
||
* @param {Batch} batch
|
||
*/
|
||
update_pending_count(d, batch) {
|
||
this.#update_pending_count(d, batch);
|
||
this.#local_pending_count += d;
|
||
if (!this.#effect_pending || this.#pending_count_update_queued) return;
|
||
this.#pending_count_update_queued = true;
|
||
queue_micro_task(() => {
|
||
this.#pending_count_update_queued = false;
|
||
if (this.#effect_pending) internal_set(this.#effect_pending, this.#local_pending_count);
|
||
});
|
||
}
|
||
get_effect_pending() {
|
||
this.#effect_pending_subscriber();
|
||
return get(this.#effect_pending);
|
||
}
|
||
/** @param {unknown} error */
|
||
error(error) {
|
||
if (error === HYDRATION_ERROR) throw error;
|
||
if (!this.#props.onerror && !this.#props.failed) throw error;
|
||
if (current_batch?.is_fork) {
|
||
if (this.#main_effect) current_batch.skip_effect(this.#main_effect);
|
||
if (this.#pending_effect) current_batch.skip_effect(this.#pending_effect);
|
||
if (this.#failed_effect) current_batch.skip_effect(this.#failed_effect);
|
||
current_batch.oncommit(() => {
|
||
if (!this.#is_destroyed()) this.#handle_error(error);
|
||
});
|
||
} else this.#handle_error(error);
|
||
}
|
||
/**
|
||
* @param {unknown} error
|
||
*/
|
||
#handle_error(error) {
|
||
if (this.#main_effect) {
|
||
destroy_effect(this.#main_effect);
|
||
this.#main_effect = null;
|
||
}
|
||
if (this.#pending_effect) {
|
||
destroy_effect(this.#pending_effect);
|
||
this.#pending_effect = null;
|
||
}
|
||
if (this.#failed_effect) {
|
||
destroy_effect(this.#failed_effect);
|
||
this.#failed_effect = null;
|
||
}
|
||
if (hydrating) {
|
||
set_hydrate_node(this.#hydrate_open);
|
||
next();
|
||
set_hydrate_node(skip_nodes());
|
||
}
|
||
let failed = this.#props.failed;
|
||
/** @param {unknown} transformed_error */
|
||
const handle_error_result = (transformed_error) => {
|
||
if (this.#is_destroyed()) return;
|
||
const { reset, invoke_onerror } = this.#create_reset(transformed_error);
|
||
invoke_onerror();
|
||
if (failed && !this.#is_destroyed()) this.#failed_effect = this.#run(() => {
|
||
try {
|
||
return branch(() => {
|
||
var effect = active_effect;
|
||
effect.b = this;
|
||
effect.f |= 128;
|
||
failed(this.#anchor, () => transformed_error, () => reset);
|
||
});
|
||
} catch (error) {
|
||
invoke_error_boundary(error, this.#effect.parent);
|
||
return null;
|
||
}
|
||
});
|
||
};
|
||
queue_micro_task(() => {
|
||
if (this.#is_destroyed()) return;
|
||
/** @type {unknown} */
|
||
var result;
|
||
try {
|
||
result = this.transform_error(error);
|
||
} catch (e) {
|
||
invoke_error_boundary(e, this.#effect && this.#effect.parent);
|
||
return;
|
||
}
|
||
if (result !== null && typeof result === "object" && typeof result.then === "function")
|
||
/** @type {any} */ result.then(
|
||
handle_error_result,
|
||
/** @param {unknown} e */
|
||
(e) => invoke_error_boundary(e, this.#effect && this.#effect.parent)
|
||
);
|
||
else handle_error_result(result);
|
||
});
|
||
}
|
||
};
|
||
function pending() {
|
||
if (active_effect === null) effect_pending_outside_reaction();
|
||
var boundary = active_effect.b;
|
||
if (boundary === null) return 0;
|
||
return boundary.get_effect_pending();
|
||
}
|
||
// node_modules/svelte/src/internal/client/render.js
|
||
/** @import { ComponentContext, Effect, EffectNodes, TemplateNode } from '#client' */
|
||
/** @import { Component, ComponentType, SvelteComponent, MountOptions } from '../../index.js' */
|
||
/**
|
||
* This is normally true — block effects should run their intro transitions —
|
||
* but is false during hydration (unless `options.intro` is `true`) and
|
||
* when creating the children of a `<svelte:element>` that just changed tag
|
||
*/
|
||
var should_intro = true;
|
||
/** @param {boolean} value */
|
||
function set_should_intro(value) {
|
||
should_intro = value;
|
||
}
|
||
/**
|
||
* @param {Element} text
|
||
* @param {string} value
|
||
* @returns {void}
|
||
*/
|
||
function set_text(text, value) {
|
||
var str = value == null ? "" : typeof value === "object" ? `${value}` : value;
|
||
if (str !== (text[TEXT_CACHE] ??= text.nodeValue)) {
|
||
/** @type {any} */ text[TEXT_CACHE] = str;
|
||
text.nodeValue = `${str}`;
|
||
}
|
||
}
|
||
/**
|
||
* Mounts a component to the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component.
|
||
* Transitions will play during the initial render unless the `intro` option is set to `false`.
|
||
*
|
||
* @template {Record<string, any>} Props
|
||
* @template {Record<string, any>} Exports
|
||
* @param {ComponentType<SvelteComponent<Props>> | Component<Props, Exports, any>} component
|
||
* @param {MountOptions<Props>} options
|
||
* @returns {Exports}
|
||
*/
|
||
function mount(component, options) {
|
||
return _mount(component, options);
|
||
}
|
||
/**
|
||
* Hydrates a component on the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component
|
||
*
|
||
* @template {Record<string, any>} Props
|
||
* @template {Record<string, any>} Exports
|
||
* @param {ComponentType<SvelteComponent<Props>> | Component<Props, Exports, any>} component
|
||
* @param {{} extends Props ? {
|
||
* target: Document | Element | ShadowRoot;
|
||
* props?: Props;
|
||
* events?: Record<string, (e: any) => any>;
|
||
* context?: Map<any, any>;
|
||
* intro?: boolean;
|
||
* recover?: boolean;
|
||
* transformError?: (error: unknown) => unknown;
|
||
* } : {
|
||
* target: Document | Element | ShadowRoot;
|
||
* props: Props;
|
||
* events?: Record<string, (e: any) => any>;
|
||
* context?: Map<any, any>;
|
||
* intro?: boolean;
|
||
* recover?: boolean;
|
||
* transformError?: (error: unknown) => unknown;
|
||
* }} options
|
||
* @returns {Exports}
|
||
*/
|
||
function hydrate(component, options) {
|
||
init_operations();
|
||
options.intro = options.intro ?? false;
|
||
const target = options.target;
|
||
const was_hydrating = hydrating;
|
||
const previous_hydrate_node = hydrate_node;
|
||
try {
|
||
var anchor = /* @__PURE__ */ get_first_child(target);
|
||
while (anchor && (anchor.nodeType !== 8 || anchor.data !== "[")) anchor = /* @__PURE__ */ get_next_sibling(anchor);
|
||
if (!anchor) throw HYDRATION_ERROR;
|
||
set_hydrating(true);
|
||
set_hydrate_node(anchor);
|
||
const instance = _mount(component, {
|
||
...options,
|
||
anchor
|
||
});
|
||
set_hydrating(false);
|
||
return instance;
|
||
} catch (error) {
|
||
if (error instanceof Error && error.message.split("\n").some((line) => line.startsWith("https://svelte.dev/e/"))) throw error;
|
||
if (error !== HYDRATION_ERROR) console.warn("Failed to hydrate: ", error);
|
||
if (options.recover === false) hydration_failed();
|
||
init_operations();
|
||
clear_text_content(target);
|
||
set_hydrating(false);
|
||
return mount(component, options);
|
||
} finally {
|
||
set_hydrating(was_hydrating);
|
||
set_hydrate_node(previous_hydrate_node);
|
||
}
|
||
}
|
||
/** @type {Map<EventTarget, Map<string, number>>} */
|
||
var listeners = /* @__PURE__ */ new Map();
|
||
/**
|
||
* @template {Record<string, any>} Exports
|
||
* @param {ComponentType<SvelteComponent<any>> | Component<any>} Component
|
||
* @param {MountOptions} options
|
||
* @returns {Exports}
|
||
*/
|
||
function _mount(Component, { target, anchor, props = {}, events, context, intro = true, transformError }) {
|
||
init_operations();
|
||
/** @type {Exports} */
|
||
var component = void 0;
|
||
var unmount = component_root(() => {
|
||
var anchor_node = anchor ?? target.appendChild(create_text());
|
||
boundary(anchor_node, { pending: () => {} }, (anchor_node) => {
|
||
push({});
|
||
var ctx = component_context;
|
||
if (context) ctx.c = context;
|
||
if (events)
|
||
/** @type {any} */ props.$$events = events;
|
||
if (hydrating) assign_nodes(anchor_node, null);
|
||
should_intro = intro;
|
||
component = Component(anchor_node, props) || mark_as_component();
|
||
should_intro = true;
|
||
if (hydrating) {
|
||
/** @type {Effect & { nodes: EffectNodes }} */ active_effect.nodes.end = hydrate_node;
|
||
if (hydrate_node === null || hydrate_node.nodeType !== 8 || hydrate_node.data !== "]") {
|
||
hydration_mismatch();
|
||
throw HYDRATION_ERROR;
|
||
}
|
||
}
|
||
pop();
|
||
}, transformError);
|
||
/** @type {Set<string>} */
|
||
var registered_events = /* @__PURE__ */ new Set();
|
||
/** @param {Array<string>} events */
|
||
var event_handle = (events) => {
|
||
for (var i = 0; i < events.length; i++) {
|
||
var event_name = events[i];
|
||
if (registered_events.has(event_name)) continue;
|
||
registered_events.add(event_name);
|
||
var passive = is_passive_event(event_name);
|
||
for (const node of [target, document]) {
|
||
var counts = listeners.get(node);
|
||
if (counts === void 0) {
|
||
counts = /* @__PURE__ */ new Map();
|
||
listeners.set(node, counts);
|
||
}
|
||
var count = counts.get(event_name);
|
||
if (count === void 0) {
|
||
node.addEventListener(event_name, handle_event_propagation, { passive });
|
||
counts.set(event_name, 1);
|
||
} else counts.set(event_name, count + 1);
|
||
}
|
||
}
|
||
};
|
||
event_handle(array_from(all_registered_events));
|
||
root_event_handles.add(event_handle);
|
||
return () => {
|
||
for (var event_name of registered_events) for (const node of [target, document]) {
|
||
var counts = listeners.get(node);
|
||
var count = counts.get(event_name);
|
||
if (--count == 0) {
|
||
node.removeEventListener(event_name, handle_event_propagation);
|
||
counts.delete(event_name);
|
||
if (counts.size === 0) listeners.delete(node);
|
||
} else counts.set(event_name, count);
|
||
}
|
||
root_event_handles.delete(event_handle);
|
||
if (anchor_node !== anchor) anchor_node.parentNode?.removeChild(anchor_node);
|
||
};
|
||
});
|
||
mounted_components.set(component, unmount);
|
||
return component;
|
||
}
|
||
/**
|
||
* References of the components that were mounted or hydrated.
|
||
* Uses a `WeakMap` to avoid memory leaks.
|
||
*/
|
||
var mounted_components = /* @__PURE__ */ new WeakMap();
|
||
/**
|
||
* Unmounts a component that was previously mounted using `mount` or `hydrate`.
|
||
*
|
||
* Since 5.13.0, if `options.outro` is `true`, [transitions](https://svelte.dev/docs/svelte/transition) will play before the component is removed from the DOM.
|
||
*
|
||
* Returns a `Promise` that resolves after transitions have completed if `options.outro` is true, or immediately otherwise (prior to 5.13.0, returns `void`).
|
||
*
|
||
* ```js
|
||
* import { mount, unmount } from 'svelte';
|
||
* import App from './App.svelte';
|
||
*
|
||
* const app = mount(App, { target: document.body });
|
||
*
|
||
* // later...
|
||
* unmount(app, { outro: true });
|
||
* ```
|
||
* @param {Record<string, any>} component
|
||
* @param {{ outro?: boolean }} [options]
|
||
* @returns {Promise<void>}
|
||
*/
|
||
function unmount(component, options) {
|
||
const fn = mounted_components.get(component);
|
||
if (fn) {
|
||
mounted_components.delete(component);
|
||
return fn(options);
|
||
}
|
||
lifecycle_double_unmount();
|
||
return Promise.resolve();
|
||
}
|
||
// node_modules/svelte/src/internal/client/dom/legacy/event-modifiers.js
|
||
/**
|
||
* Substitute for the `trusted` event modifier
|
||
* @deprecated
|
||
* @param {(event: Event, ...args: Array<unknown>) => void} fn
|
||
* @returns {(event: Event, ...args: unknown[]) => void}
|
||
*/
|
||
function trusted(fn) {
|
||
return function(...args) {
|
||
if (args[0].isTrusted) fn?.apply(this, args);
|
||
};
|
||
}
|
||
/**
|
||
* Substitute for the `self` event modifier
|
||
* @deprecated
|
||
* @param {(event: Event, ...args: Array<unknown>) => void} fn
|
||
* @returns {(event: Event, ...args: unknown[]) => void}
|
||
*/
|
||
function self(fn) {
|
||
return function(...args) {
|
||
if (args[0].target === this) fn?.apply(this, args);
|
||
};
|
||
}
|
||
/**
|
||
* Substitute for the `stopPropagation` event modifier
|
||
* @deprecated
|
||
* @param {(event: Event, ...args: Array<unknown>) => void} fn
|
||
* @returns {(event: Event, ...args: unknown[]) => void}
|
||
*/
|
||
function stopPropagation(fn) {
|
||
return function(...args) {
|
||
args[0].stopPropagation();
|
||
return fn?.apply(this, args);
|
||
};
|
||
}
|
||
/**
|
||
* Substitute for the `once` event modifier
|
||
* @deprecated
|
||
* @param {(event: Event, ...args: Array<unknown>) => void} fn
|
||
* @returns {(event: Event, ...args: unknown[]) => void}
|
||
*/
|
||
function once(fn) {
|
||
var ran = false;
|
||
return function(...args) {
|
||
if (ran) return;
|
||
ran = true;
|
||
return fn?.apply(this, args);
|
||
};
|
||
}
|
||
/**
|
||
* Substitute for the `stopImmediatePropagation` event modifier
|
||
* @deprecated
|
||
* @param {(event: Event, ...args: Array<unknown>) => void} fn
|
||
* @returns {(event: Event, ...args: unknown[]) => void}
|
||
*/
|
||
function stopImmediatePropagation(fn) {
|
||
return function(...args) {
|
||
args[0].stopImmediatePropagation();
|
||
return fn?.apply(this, args);
|
||
};
|
||
}
|
||
/**
|
||
* Substitute for the `preventDefault` event modifier
|
||
* @deprecated
|
||
* @param {(event: Event, ...args: Array<unknown>) => void} fn
|
||
* @returns {(event: Event, ...args: unknown[]) => void}
|
||
*/
|
||
function preventDefault(fn) {
|
||
return function(...args) {
|
||
args[0].preventDefault();
|
||
return fn?.apply(this, args);
|
||
};
|
||
}
|
||
/**
|
||
* Substitute for the `passive` event modifier, implemented as an action
|
||
* @deprecated
|
||
* @param {HTMLElement} node
|
||
* @param {[event: string, handler: () => EventListener]} options
|
||
*/
|
||
function passive(node, [event, handler]) {
|
||
user_pre_effect(() => {
|
||
return on(node, event, handler() ?? noop, { passive: true });
|
||
});
|
||
}
|
||
/**
|
||
* Substitute for the `nonpassive` event modifier, implemented as an action
|
||
* @deprecated
|
||
* @param {HTMLElement} node
|
||
* @param {[event: string, handler: () => EventListener]} options
|
||
*/
|
||
function nonpassive(node, [event, handler]) {
|
||
user_pre_effect(() => {
|
||
return on(node, event, handler() ?? noop, { passive: false });
|
||
});
|
||
}
|
||
// node_modules/svelte/src/legacy/legacy-client.js
|
||
/** @import { ComponentConstructorOptions, ComponentType, SvelteComponent, Component } from 'svelte' */
|
||
/**
|
||
* Takes the same options as a Svelte 4 component and the component function and returns a Svelte 4 compatible component.
|
||
*
|
||
* @deprecated Use this only as a temporary solution to migrate your imperative component code to Svelte 5.
|
||
*
|
||
* @template {Record<string, any>} Props
|
||
* @template {Record<string, any>} Exports
|
||
* @template {Record<string, any>} Events
|
||
* @template {Record<string, any>} Slots
|
||
*
|
||
* @param {ComponentConstructorOptions<Props> & {
|
||
* component: ComponentType<SvelteComponent<Props, Events, Slots>> | Component<Props>;
|
||
* }} options
|
||
* @returns {SvelteComponent<Props, Events, Slots> & Exports}
|
||
*/
|
||
function createClassComponent(options) {
|
||
return new Svelte4Component(options);
|
||
}
|
||
/**
|
||
* Takes the component function and returns a Svelte 4 compatible component constructor.
|
||
*
|
||
* @deprecated Use this only as a temporary solution to migrate your imperative component code to Svelte 5.
|
||
*
|
||
* @template {Record<string, any>} Props
|
||
* @template {Record<string, any>} Exports
|
||
* @template {Record<string, any>} Events
|
||
* @template {Record<string, any>} Slots
|
||
*
|
||
* @param {SvelteComponent<Props, Events, Slots> | Component<Props>} component
|
||
* @returns {ComponentType<SvelteComponent<Props, Events, Slots> & Exports>}
|
||
*/
|
||
function asClassComponent(component) {
|
||
return class extends Svelte4Component {
|
||
/** @param {any} options */
|
||
constructor(options) {
|
||
super({
|
||
component,
|
||
...options
|
||
});
|
||
}
|
||
};
|
||
}
|
||
/**
|
||
* Support using the component as both a class and function during the transition period
|
||
* @typedef {{new (o: ComponentConstructorOptions): SvelteComponent;(...args: Parameters<Component<Record<string, any>>>): ReturnType<Component<Record<string, any>, Record<string, any>>>;}} LegacyComponentType
|
||
*/
|
||
var Svelte4Component = class {
|
||
/** @type {any} */
|
||
#events;
|
||
/** @type {Record<string, any>} */
|
||
#instance;
|
||
/**
|
||
* @param {ComponentConstructorOptions & {
|
||
* component: any;
|
||
* }} options
|
||
*/
|
||
constructor(options) {
|
||
var sources = /* @__PURE__ */ new Map();
|
||
/**
|
||
* @param {string | symbol} key
|
||
* @param {unknown} value
|
||
*/
|
||
var add_source = (key, value) => {
|
||
var s = /* @__PURE__ */ mutable_source(value, false, false);
|
||
sources.set(key, s);
|
||
return s;
|
||
};
|
||
const props = new Proxy({
|
||
...options.props || {},
|
||
$$events: {}
|
||
}, {
|
||
get(target, prop) {
|
||
return get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
|
||
},
|
||
has(target, prop) {
|
||
if (prop === LEGACY_PROPS) return true;
|
||
get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
|
||
return Reflect.has(target, prop);
|
||
},
|
||
set(target, prop, value) {
|
||
set(sources.get(prop) ?? add_source(prop, value), value);
|
||
return Reflect.set(target, prop, value);
|
||
}
|
||
});
|
||
this.#instance = (options.hydrate ? hydrate : mount)(options.component, {
|
||
target: options.target,
|
||
anchor: options.anchor,
|
||
props,
|
||
context: options.context,
|
||
intro: options.intro ?? false,
|
||
recover: options.recover,
|
||
transformError: options.transformError
|
||
});
|
||
if (!async_mode_flag && (!options?.props?.$$host || options.sync === false)) flushSync();
|
||
this.#events = props.$$events;
|
||
for (const key of Object.keys(this.#instance)) {
|
||
if (key === "$set" || key === "$destroy" || key === "$on") continue;
|
||
define_property(this, key, {
|
||
get() {
|
||
return this.#instance[key];
|
||
},
|
||
/** @param {any} value */
|
||
set(value) {
|
||
this.#instance[key] = value;
|
||
},
|
||
enumerable: true
|
||
});
|
||
}
|
||
this.#instance.$set = (next) => {
|
||
Object.assign(props, next);
|
||
};
|
||
this.#instance.$destroy = () => {
|
||
unmount(this.#instance);
|
||
};
|
||
}
|
||
/** @param {Record<string, any>} props */
|
||
$set(props) {
|
||
this.#instance.$set(props);
|
||
}
|
||
/**
|
||
* @param {string} event
|
||
* @param {(...args: any[]) => any} callback
|
||
* @returns {any}
|
||
*/
|
||
$on(event, callback) {
|
||
this.#events[event] = this.#events[event] || [];
|
||
/** @param {any[]} args */
|
||
const cb = (...args) => callback.call(this, ...args);
|
||
this.#events[event].push(cb);
|
||
return () => {
|
||
this.#events[event] = this.#events[event].filter(
|
||
/** @param {any} fn */
|
||
(fn) => fn !== cb
|
||
);
|
||
};
|
||
}
|
||
$destroy() {
|
||
this.#instance.$destroy();
|
||
}
|
||
};
|
||
/**
|
||
* Runs the given function once immediately on the server, and works like `$effect.pre` on the client.
|
||
*
|
||
* @deprecated Use this only as a temporary solution to migrate your component code to Svelte 5.
|
||
* @param {() => void | (() => void)} fn
|
||
* @returns {void}
|
||
*/
|
||
function run(fn) {
|
||
user_pre_effect(() => {
|
||
fn();
|
||
var effect = active_effect;
|
||
if ((effect.f & 2048) !== 0) {
|
||
let filename = "a file (we can't know which one)";
|
||
filename = dev_current_component_function?.[FILENAME] ?? filename;
|
||
legacy_recursive_reactive_block(filename);
|
||
set_signal_status(effect, MAYBE_DIRTY);
|
||
}
|
||
});
|
||
}
|
||
/**
|
||
* Function to mimic the multiple listeners available in svelte 4
|
||
* @deprecated
|
||
* @param {EventListener[]} handlers
|
||
* @returns {EventListener}
|
||
*/
|
||
function handlers(...handlers) {
|
||
return function(event) {
|
||
const { stopImmediatePropagation } = event;
|
||
let stopped = false;
|
||
event.stopImmediatePropagation = () => {
|
||
stopped = true;
|
||
stopImmediatePropagation.call(event);
|
||
};
|
||
const errors = [];
|
||
for (const handler of handlers) {
|
||
try {
|
||
handler?.call(this, event);
|
||
} catch (e) {
|
||
errors.push(e);
|
||
}
|
||
if (stopped) break;
|
||
}
|
||
for (let error of errors) queueMicrotask(() => {
|
||
throw error;
|
||
});
|
||
};
|
||
}
|
||
/**
|
||
* Function to create a `bubble` function that mimic the behavior of `on:click` without handler available in svelte 4.
|
||
* @deprecated Use this only as a temporary solution to migrate your automatically delegated events in Svelte 5.
|
||
*/
|
||
function createBubbler() {
|
||
const active_component_context = component_context;
|
||
if (active_component_context === null) lifecycle_outside_component("createBubbler");
|
||
return (type) => (event) => {
|
||
const events = active_component_context.s.$$events?.[type];
|
||
if (events) {
|
||
const callbacks = is_array(events) ? events.slice() : [events];
|
||
for (const fn of callbacks) fn.call(active_component_context.x, event);
|
||
return !event.defaultPrevented;
|
||
}
|
||
return true;
|
||
};
|
||
}
|
||
export { text as A, sanitize_location as B, assign_nodes as C, from_svg as D, from_mathml as E, hash as F, is_capture_event as I, is_raw_text_element as L, create_fragment_from_html as M, create_trusted_html as N, from_tree as O, can_delegate_event as P, is_void as R, append as S, from_html as T, set_text as _, run as a, boundary as b, passive as c, stopImmediatePropagation as d, stopPropagation as f, set_should_intro as g, mount as h, handlers as i, with_script as j, props_id as k, preventDefault as l, hydrate as m, createBubbler as n, nonpassive as o, trusted as p, createClassComponent as r, once as s, asClassComponent as t, self as u, should_intro as v, comment as w, pending as x, unmount as y, normalize_attribute as z };
|