UNPKG

@schukai/monster

Version:

Monster is a simple library for creating fast, robust and lightweight websites.

1,357 lines (1,340 loc) 7.72 MB
try { (() => { var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a2, b) => (typeof require !== "undefined" ? require : a2)[b] }) : x)(function(x) { if (typeof require !== "undefined") return require.apply(this, arguments); throw Error('Dynamic require of "' + x + '" is not supported'); }); var __esm = (fn2, res) => function __init() { return fn2 && (res = (0, fn2[__getOwnPropNames(fn2)[0]])(fn2 = 0)), res; }; var __commonJS = (cb, mod) => function __require2() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); // source/constants.mjs var internalSymbol, internalStateSymbol, instanceSymbol, proxyInstanceMarker; var init_constants = __esm({ "source/constants.mjs"() { internalSymbol = Symbol.for("@schukai/monster/internal"); internalStateSymbol = Symbol.for("@schukai/monster/state"); instanceSymbol = Symbol.for("@schukai/monster/instance"); proxyInstanceMarker = Symbol.for( "@schukai/monster/proxy-instance-marker" ); } }); // source/types/is.mjs function isProxy(value) { return value?.[proxyInstanceMarker] === proxyInstanceMarker; } function isIterable(value) { if (value === void 0) return false; if (value === null) return false; return typeof value?.[Symbol.iterator] === "function"; } function isPrimitive(value) { var type3; if (value === void 0 || value === null) { return true; } type3 = typeof value; if (type3 === "string" || type3 === "number" || type3 === "boolean" || type3 === "symbol") { return true; } return false; } function isSymbol(value) { return "symbol" === typeof value ? true : false; } function isBoolean(value) { if (value === true || value === false) { return true; } return false; } function isString(value) { if (value === void 0 || typeof value !== "string") { return false; } return true; } function isObject(value) { if (isArray(value)) return false; if (isPrimitive(value)) return false; if (typeof value === "object") { return true; } return false; } function isInstance(value, instance) { if (!isObject(value)) return false; if (!isFunction(instance)) return false; if (!instance.hasOwnProperty("prototype")) return false; if (value instanceof instance) return true; let proto = Object.getPrototypeOf(value); while (proto != null) { if (proto === instance.prototype) return true; proto = Object.getPrototypeOf(proto); } return false; } function isArray(value) { return Array.isArray(value); } function isFunction(value) { if (isArray(value)) return false; if (isPrimitive(value)) return false; if (typeof value === "function") { return true; } return false; } function isInteger(value) { return Number.isInteger(value); } var init_is = __esm({ "source/types/is.mjs"() { init_constants(); } }); // source/types/validate.mjs function validateIterable(value) { if (!isIterable(value)) { throw new TypeError("value is not iterable"); } return value; } function validatePrimitive(value) { if (!isPrimitive(value)) { throw new TypeError("value is not a primitive"); } return value; } function validateBoolean(value) { if (!isBoolean(value)) { throw new TypeError("value is not a boolean"); } return value; } function validateString(value) { if (!isString(value)) { throw new TypeError("value is not a string"); } return value; } function validateObject(value) { if (!isObject(value)) { throw new TypeError("value is not a object"); } return value; } function validateInstance(value, instance) { if (!isInstance(value, instance)) { let n = ""; if (isObject(instance) || isFunction(instance)) { n = instance?.["name"]; } if (n) { n = ` ${n}`; } throw new TypeError(`value is not an instance of${n}`); } return value; } function validateArray(value) { if (!isArray(value)) { throw new TypeError("value is not an array"); } return value; } function validateSymbol(value) { if (!isSymbol(value)) { throw new TypeError("value is not an symbol"); } return value; } function validateFunction(value) { if (!isFunction(value)) { throw new TypeError("value is not a function"); } return value; } function validateInteger(value) { if (!isInteger(value)) { throw new TypeError("value is not an integer"); } return value; } var init_validate = __esm({ "source/types/validate.mjs"() { init_is(); } }); // source/types/global.mjs function getGlobal() { return globalReference; } function getGlobalObject(name) { validateString(name); const o = globalReference?.[name]; if (typeof o === "undefined") throw new Error(`the object ${name} is not defined`); validateObject(o); return o; } function getGlobalFunction(name) { validateString(name); const f = globalReference?.[name]; if (typeof f === "undefined") { throw new Error(`the function ${name} is not defined`); } validateFunction(f); return f; } var globalReference; var init_global = __esm({ "source/types/global.mjs"() { init_validate(); (function() { if (typeof globalThis === "object") { globalReference = globalThis; return; } if (typeof self !== "undefined") { globalReference = self; return; } else if (typeof window !== "undefined") { globalReference = window; return; } Object.defineProperty(Object.prototype, "__monster__", { get: function() { return this; }, configurable: true }); if (typeof __monster__ === "object") { __monster__.globalThis = __monster__; delete Object.prototype.__monster__; globalReference = globalThis; return; } try { globalReference = Function("return this")(); } catch (e) { } throw new Error("unsupported environment."); })(); } }); // source/types/typeof.mjs function typeOf(value) { let type3 = {}.toString.call(value).match(/\s([a-zA-Z]+)/)[1]; if ("Object" === type3) { const name = value.constructor.name; if (name) { return name.toLowerCase(); } const results = /^(class|function)\s+(\w+)/.exec( value.constructor.toString() ); type3 = results && results.length > 2 ? results[2] : ""; } return type3.toLowerCase(); } var init_typeof = __esm({ "source/types/typeof.mjs"() { } }); // source/data/extend.mjs function extend(...args) { let o; let i; if (typeof args !== "object" || args[0] === null) { throw new Error(`unsupported argument ${JSON.stringify(args[0])}`); } for (i = 0; i < args.length; i++) { const a2 = args[i]; if (!(isObject(a2) || isArray(a2))) { throw new Error(`unsupported argument ${JSON.stringify(a2)}`); } if (o === void 0) { o = a2; continue; } for (const k in a2) { const v = a2?.[k]; if (k in o && v === o?.[k]) { continue; } if (isObject(v) && typeOf(v) === "object" || isArray(v)) { if (o[k] === void 0) { if (isArray(v)) { o[k] = []; } else { o[k] = {}; } } else { if (typeOf(o[k]) !== typeOf(v)) { throw new Error( `type mismatch: ${JSON.stringify(o[k])}(${typeOf( o[k] )}) != ${JSON.stringify(v)}(${typeOf(v)})` ); } } if (isArray(o[k])) { o[k] = []; o[k].push(...v); continue; } o[k] = extend(o[k], v); } else { if (isArray(o)) { o.push(v); continue; } o[k] = v; } } } return o; } var init_extend = __esm({ "source/data/extend.mjs"() { init_is(); init_typeof(); } }); // node_modules/dom-storage/lib/index.js var require_lib = __commonJS({ "node_modules/dom-storage/lib/index.js"(exports, module) { (function() { "use strict"; var fs = __require("fs"); function Storage2(path, opts) { opts = opts || {}; var db; Object.defineProperty(this, "___priv_bk___", { value: { path }, writable: false, enumerable: false }); Object.defineProperty(this, "___priv_strict___", { value: !!opts.strict, writable: false, enumerable: false }); Object.defineProperty(this, "___priv_ws___", { value: opts.ws || " ", writable: false, enumerable: false }); try { db = JSON.parse(fs.readFileSync(path)); } catch (e) { db = {}; } Object.keys(db).forEach(function(key) { this[key] = db[key]; }, this); } Storage2.prototype.getItem = function(key) { if (this.hasOwnProperty(key)) { if (this.___priv_strict___) { return String(this[key]); } else { return this[key]; } } return null; }; Storage2.prototype.setItem = function(key, val) { if (val === void 0) { this[key] = null; } else if (this.___priv_strict___) { this[key] = String(val); } else { this[key] = val; } this.___save___(); }; Storage2.prototype.removeItem = function(key) { delete this[key]; this.___save___(); }; Storage2.prototype.clear = function() { var self2 = this; Object.keys(self2).forEach(function(key) { self2[key] = void 0; delete self2[key]; }); }; Storage2.prototype.key = function(i) { i = i || 0; return Object.keys(this)[i]; }; Object.defineProperty(Storage2.prototype, "length", { get: function() { return Object.keys(this).length; } }); Storage2.prototype.___save___ = function() { var self2 = this; if (!this.___priv_bk___.path) { return; } if (this.___priv_bk___.lock) { this.___priv_bk___.wait = true; return; } this.___priv_bk___.lock = true; fs.writeFile( this.___priv_bk___.path, JSON.stringify(this, null, this.___priv_ws___), "utf8", function(e) { self2.___priv_bk___.lock = false; if (e) { console.error("Could not write to database", self2.___priv_bk___.path); console.error(e); return; } if (self2.___priv_bk___.wait) { self2.___priv_bk___.wait = false; self2.___save___(); } } ); }; Object.defineProperty(Storage2, "create", { value: function(path, opts) { return new Storage2(path, opts); }, writable: false, enumerable: false }); module.exports = Storage2; })(); } }); // node_modules/element-internals-polyfill/dist/maps.js var refMap, validityMap, hiddenInputMap, internalsMap, validationMessageMap, formsMap, shadowHostsMap, formElementsMap, refValueMap, upgradeMap, shadowRootMap, validationAnchorMap, documentFragmentMap, connectedCallbackMap, validityUpgradeMap; var init_maps = __esm({ "node_modules/element-internals-polyfill/dist/maps.js"() { refMap = /* @__PURE__ */ new WeakMap(); validityMap = /* @__PURE__ */ new WeakMap(); hiddenInputMap = /* @__PURE__ */ new WeakMap(); internalsMap = /* @__PURE__ */ new WeakMap(); validationMessageMap = /* @__PURE__ */ new WeakMap(); formsMap = /* @__PURE__ */ new WeakMap(); shadowHostsMap = /* @__PURE__ */ new WeakMap(); formElementsMap = /* @__PURE__ */ new WeakMap(); refValueMap = /* @__PURE__ */ new WeakMap(); upgradeMap = /* @__PURE__ */ new WeakMap(); shadowRootMap = /* @__PURE__ */ new WeakMap(); validationAnchorMap = /* @__PURE__ */ new WeakMap(); documentFragmentMap = /* @__PURE__ */ new WeakMap(); connectedCallbackMap = /* @__PURE__ */ new WeakMap(); validityUpgradeMap = /* @__PURE__ */ new WeakMap(); } }); // node_modules/element-internals-polyfill/dist/utils.js function mutationObserverExists() { return typeof MutationObserver !== "undefined"; } var setAttribute, setDisabled, removeHiddenInputs, createHiddenInput, initLabels, setFormValidity, formInputCallback, formChangeCallback, wireSubmitLogic, formResetCallback, initForm, findParentForm, throwIfNotFormAssociated, overrideFormMethod, upgradeInternals; var init_utils = __esm({ "node_modules/element-internals-polyfill/dist/utils.js"() { init_maps(); setAttribute = (ref, name, value) => { if (ref.getAttribute(name) === value) { return; } ref.setAttribute(name, value); }; setDisabled = (ref, disabled) => { ref.toggleAttribute("internals-disabled", disabled); if (disabled) { setAttribute(ref, "aria-disabled", "true"); } else { ref.removeAttribute("aria-disabled"); } if (ref.formDisabledCallback) { ref.formDisabledCallback.apply(ref, [disabled]); } }; removeHiddenInputs = (internals) => { const hiddenInputs = hiddenInputMap.get(internals); hiddenInputs.forEach((hiddenInput) => { hiddenInput.remove(); }); hiddenInputMap.set(internals, []); }; createHiddenInput = (ref, internals) => { const input = document.createElement("input"); input.type = "hidden"; input.name = ref.getAttribute("name"); ref.after(input); hiddenInputMap.get(internals).push(input); return input; }; initLabels = (ref, labels) => { if (labels.length) { const labelList = Array.from(labels); labelList.forEach((label) => label.addEventListener("click", ref.click.bind(ref))); const [firstLabel] = labelList; let firstLabelId = firstLabel.id; if (!firstLabel.id) { firstLabelId = `${firstLabel.htmlFor}_Label`; firstLabel.id = firstLabelId; } setAttribute(ref, "aria-labelledby", firstLabelId); } }; setFormValidity = (form) => { const nativeControlValidity = Array.from(form.elements).filter((element) => !element.tagName.includes("-") && element.validity).map((element) => element.validity.valid); const polyfilledElements = formElementsMap.get(form) || []; const polyfilledValidity = Array.from(polyfilledElements).filter((control) => control.isConnected).map((control) => internalsMap.get(control).validity.valid); const hasInvalid = [...nativeControlValidity, ...polyfilledValidity].includes(false); form.toggleAttribute("internals-invalid", hasInvalid); form.toggleAttribute("internals-valid", !hasInvalid); }; formInputCallback = (event) => { setFormValidity(findParentForm(event.target)); }; formChangeCallback = (event) => { setFormValidity(findParentForm(event.target)); }; wireSubmitLogic = (form) => { const submitButtonSelector = [ "button[type=submit]", "input[type=submit]", "button:not([type])" ].map((sel) => `${sel}:not([disabled])`).map((sel) => `${sel}:not([form])${form.id ? `,${sel}[form='${form.id}']` : ""}`).join(","); form.addEventListener("click", (event) => { const target = event.target; if (target.closest(submitButtonSelector)) { const elements = formElementsMap.get(form); if (form.noValidate) { return; } if (elements.size) { const nodes = Array.from(elements); const validityList = nodes.reverse().map((node) => { const internals = internalsMap.get(node); return internals.reportValidity(); }); if (validityList.includes(false)) { event.preventDefault(); } } } }); }; formResetCallback = (event) => { const elements = formElementsMap.get(event.target); if (elements && elements.size) { elements.forEach((element) => { if (element.constructor.formAssociated && element.formResetCallback) { element.formResetCallback.apply(element); } }); } }; initForm = (ref, form, internals) => { if (form) { const formElements = formElementsMap.get(form); if (formElements) { formElements.add(ref); } else { const initSet = /* @__PURE__ */ new Set(); initSet.add(ref); formElementsMap.set(form, initSet); wireSubmitLogic(form); form.addEventListener("reset", formResetCallback); form.addEventListener("input", formInputCallback); form.addEventListener("change", formChangeCallback); } formsMap.set(form, { ref, internals }); if (ref.constructor["formAssociated"] && ref.formAssociatedCallback) { setTimeout(() => { ref.formAssociatedCallback.apply(ref, [form]); }, 0); } setFormValidity(form); } }; findParentForm = (elem) => { let parent = elem.parentNode; if (parent && parent.tagName !== "FORM") { parent = findParentForm(parent); } return parent; }; throwIfNotFormAssociated = (ref, message, ErrorType = DOMException) => { if (!ref.constructor["formAssociated"]) { throw new ErrorType(message); } }; overrideFormMethod = (form, returnValue, method) => { const elements = formElementsMap.get(form); if (elements && elements.size) { elements.forEach((element) => { const internals = internalsMap.get(element); const valid = internals[method](); if (!valid) { returnValue = false; } }); } return returnValue; }; upgradeInternals = (ref) => { let attached = false; if (ref.constructor["formAssociated"]) { let internals = internalsMap.get(ref); if (internals === void 0) { ref.attachInternals(); internals = internalsMap.get(ref); attached = true; } const { labels, form } = internals; initLabels(ref, labels); initForm(ref, form, internals); } return attached; }; } }); // node_modules/element-internals-polyfill/dist/types.js var init_types = __esm({ "node_modules/element-internals-polyfill/dist/types.js"() { } }); // node_modules/element-internals-polyfill/dist/aom.js var aom, initAom; var init_aom = __esm({ "node_modules/element-internals-polyfill/dist/aom.js"() { init_maps(); init_utils(); init_types(); aom = { ariaAtomic: "aria-atomic", ariaAutoComplete: "aria-autocomplete", ariaBrailleLabel: "aria-braillelabel", ariaBrailleRoleDescription: "aria-brailleroledescription", ariaBusy: "aria-busy", ariaChecked: "aria-checked", ariaColCount: "aria-colcount", ariaColIndex: "aria-colindex", ariaColIndexText: "aria-colindextext", ariaColSpan: "aria-colspan", ariaCurrent: "aria-current", ariaDescription: "aria-description", ariaDisabled: "aria-disabled", ariaExpanded: "aria-expanded", ariaHasPopup: "aria-haspopup", ariaHidden: "aria-hidden", ariaInvalid: "aria-invalid", ariaKeyShortcuts: "aria-keyshortcuts", ariaLabel: "aria-label", ariaLevel: "aria-level", ariaLive: "aria-live", ariaModal: "aria-modal", ariaMultiLine: "aria-multiline", ariaMultiSelectable: "aria-multiselectable", ariaOrientation: "aria-orientation", ariaPlaceholder: "aria-placeholder", ariaPosInSet: "aria-posinset", ariaPressed: "aria-pressed", ariaReadOnly: "aria-readonly", ariaRelevant: "aria-relevant", ariaRequired: "aria-required", ariaRoleDescription: "aria-roledescription", ariaRowCount: "aria-rowcount", ariaRowIndex: "aria-rowindex", ariaRowIndexText: "aria-rowindextext", ariaRowSpan: "aria-rowspan", ariaSelected: "aria-selected", ariaSetSize: "aria-setsize", ariaSort: "aria-sort", ariaValueMax: "aria-valuemax", ariaValueMin: "aria-valuemin", ariaValueNow: "aria-valuenow", ariaValueText: "aria-valuetext", role: "role" }; initAom = (ref, internals) => { for (let key in aom) { internals[key] = null; let closureValue = null; const attributeName = aom[key]; Object.defineProperty(internals, key, { get() { return closureValue; }, set(value) { closureValue = value; if (ref.isConnected) { setAttribute(ref, attributeName, value); } else { upgradeMap.set(ref, internals); } } }); } }; } }); // node_modules/element-internals-polyfill/dist/mutation-observers.js function initNode(node) { const internals = internalsMap.get(node); const { form } = internals; initForm(node, form, internals); initLabels(node, internals.labels); } function observerCallback(mutationList) { mutationList.forEach((mutationRecord) => { const { addedNodes: addedNodes2, removedNodes } = mutationRecord; const added = Array.from(addedNodes2); const removed = Array.from(removedNodes); added.forEach((node) => { if (internalsMap.has(node) && node.constructor["formAssociated"]) { initNode(node); } if (upgradeMap.has(node)) { const internals = upgradeMap.get(node); const aomKeys = Object.keys(aom); aomKeys.filter((key) => internals[key] !== null).forEach((key) => { setAttribute(node, aom[key], internals[key]); }); upgradeMap.delete(node); } if (validityUpgradeMap.has(node)) { const internals = validityUpgradeMap.get(node); setAttribute(node, "internals-valid", internals.validity.valid.toString()); setAttribute(node, "internals-invalid", (!internals.validity.valid).toString()); setAttribute(node, "aria-invalid", (!internals.validity.valid).toString()); validityUpgradeMap.delete(node); } if (node.localName === "form") { const formElements = formElementsMap.get(node); const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, { acceptNode(node2) { return internalsMap.has(node2) && node2.constructor["formAssociated"] && !(formElements && formElements.has(node2)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP; } }); let current = walker.nextNode(); while (current) { initNode(current); current = walker.nextNode(); } } if (node.localName === "fieldset") { disabledOrNameObserver.observe?.(node, disabledOrNameObserverConfig); walkFieldset(node, true); } }); removed.forEach((node) => { const internals = internalsMap.get(node); if (internals && hiddenInputMap.get(internals)) { removeHiddenInputs(internals); } if (shadowHostsMap.has(node)) { const observer2 = shadowHostsMap.get(node); observer2.disconnect(); } }); }); } function fragmentObserverCallback(mutationList) { mutationList.forEach((mutation) => { const { removedNodes } = mutation; removedNodes.forEach((node) => { const observer2 = documentFragmentMap.get(mutation.target); if (internalsMap.has(node)) { upgradeInternals(node); } observer2.disconnect(); }); }); } var initRef, walkFieldset, disabledOrNameObserverConfig, disabledOrNameObserver, deferUpgrade, observer, observerConfig; var init_mutation_observers = __esm({ "node_modules/element-internals-polyfill/dist/mutation-observers.js"() { init_maps(); init_aom(); init_utils(); initRef = (ref, internals) => { hiddenInputMap.set(internals, []); disabledOrNameObserver.observe?.(ref, disabledOrNameObserverConfig); }; walkFieldset = (node, firstRender = false) => { const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT, { acceptNode(node2) { return internalsMap.has(node2) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP; } }); let current = walker.nextNode(); const isCallNecessary = !firstRender || node.disabled; while (current) { if (current.formDisabledCallback && isCallNecessary) { setDisabled(current, node.disabled); } current = walker.nextNode(); } }; disabledOrNameObserverConfig = { attributes: true, attributeFilter: ["disabled", "name"] }; disabledOrNameObserver = mutationObserverExists() ? new MutationObserver((mutationsList) => { for (const mutation of mutationsList) { const target = mutation.target; if (mutation.attributeName === "disabled") { if (target.constructor["formAssociated"]) { setDisabled(target, target.hasAttribute("disabled")); } else if (target.localName === "fieldset") { walkFieldset(target); } } if (mutation.attributeName === "name") { if (target.constructor["formAssociated"]) { const internals = internalsMap.get(target); const value = refValueMap.get(target); internals.setFormValue(value); } } } }) : {}; deferUpgrade = (fragment) => { const observer2 = new MutationObserver(fragmentObserverCallback); if (window?.ShadyDOM?.inUse && fragment.mode && fragment.host) { fragment = fragment.host; } observer2.observe?.(fragment, { childList: true }); documentFragmentMap.set(fragment, observer2); }; observer = mutationObserverExists() ? new MutationObserver(observerCallback) : {}; observerConfig = { childList: true, subtree: true }; } }); // node_modules/element-internals-polyfill/dist/ValidityState.js var ValidityState, setValid, reconcileValidity, isValid; var init_ValidityState = __esm({ "node_modules/element-internals-polyfill/dist/ValidityState.js"() { init_utils(); ValidityState = class { constructor() { this.badInput = false; this.customError = false; this.patternMismatch = false; this.rangeOverflow = false; this.rangeUnderflow = false; this.stepMismatch = false; this.tooLong = false; this.tooShort = false; this.typeMismatch = false; this.valid = true; this.valueMissing = false; Object.seal(this); } }; setValid = (validityObject) => { validityObject.badInput = false; validityObject.customError = false; validityObject.patternMismatch = false; validityObject.rangeOverflow = false; validityObject.rangeUnderflow = false; validityObject.stepMismatch = false; validityObject.tooLong = false; validityObject.tooShort = false; validityObject.typeMismatch = false; validityObject.valid = true; validityObject.valueMissing = false; return validityObject; }; reconcileValidity = (validityObject, newState, form) => { validityObject.valid = isValid(newState); Object.keys(newState).forEach((key) => validityObject[key] = newState[key]); if (form) { setFormValidity(form); } return validityObject; }; isValid = (validityState) => { let valid = true; for (let key in validityState) { if (key !== "valid" && validityState[key] !== false) { valid = false; } } return valid; }; } }); // node_modules/element-internals-polyfill/dist/CustomStateSet.js function addState(ref, stateName) { ref.toggleAttribute(stateName, true); if (ref.part) { ref.part.add(stateName); } } var customStateMap, CustomStateSet; var init_CustomStateSet = __esm({ "node_modules/element-internals-polyfill/dist/CustomStateSet.js"() { customStateMap = /* @__PURE__ */ new WeakMap(); CustomStateSet = class extends Set { static get isPolyfilled() { return true; } constructor(ref) { super(); if (!ref || !ref.tagName || ref.tagName.indexOf("-") === -1) { throw new TypeError("Illegal constructor"); } customStateMap.set(this, ref); } add(state) { if (!/^--/.test(state) || typeof state !== "string") { throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${state} must start with '--'.`); } const result = super.add(state); const ref = customStateMap.get(this); const stateName = `state${state}`; if (ref.isConnected) { addState(ref, stateName); } else { setTimeout(() => { addState(ref, stateName); }); } return result; } clear() { for (let [entry] of this.entries()) { this.delete(entry); } super.clear(); } delete(state) { const result = super.delete(state); const ref = customStateMap.get(this); if (ref.isConnected) { ref.toggleAttribute(`state${state}`, false); if (ref.part) { ref.part.remove(`state${state}`); } } else { setTimeout(() => { ref.toggleAttribute(`state${state}`, false); if (ref.part) { ref.part.remove(`state${state}`); } }); } return result; } }; } }); // node_modules/element-internals-polyfill/dist/HTMLFormControlsCollection.js var __classPrivateFieldSet, __classPrivateFieldGet, _HTMLFormControlsCollection_elements, HTMLFormControlsCollection; var init_HTMLFormControlsCollection = __esm({ "node_modules/element-internals-polyfill/dist/HTMLFormControlsCollection.js"() { __classPrivateFieldSet = function(receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; }; __classPrivateFieldGet = function(receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; HTMLFormControlsCollection = class { constructor(elements) { _HTMLFormControlsCollection_elements.set(this, void 0); __classPrivateFieldSet(this, _HTMLFormControlsCollection_elements, elements, "f"); for (let i = 0; i < elements.length; i++) { let element = elements[i]; this[i] = element; if (element.hasAttribute("name")) { this[element.getAttribute("name")] = element; } } Object.freeze(this); } get length() { return __classPrivateFieldGet(this, _HTMLFormControlsCollection_elements, "f").length; } [(_HTMLFormControlsCollection_elements = /* @__PURE__ */ new WeakMap(), Symbol.iterator)]() { return __classPrivateFieldGet(this, _HTMLFormControlsCollection_elements, "f")[Symbol.iterator](); } item(i) { return this[i] == null ? null : this[i]; } namedItem(name) { return this[name] == null ? null : this[name]; } }; } }); // node_modules/element-internals-polyfill/dist/patch-form-prototype.js function patchFormPrototype() { const checkValidity = HTMLFormElement.prototype.checkValidity; HTMLFormElement.prototype.checkValidity = checkValidityOverride; const reportValidity = HTMLFormElement.prototype.reportValidity; HTMLFormElement.prototype.reportValidity = reportValidityOverride; function checkValidityOverride(...args) { let returnValue = checkValidity.apply(this, args); return overrideFormMethod(this, returnValue, "checkValidity"); } function reportValidityOverride(...args) { let returnValue = reportValidity.apply(this, args); return overrideFormMethod(this, returnValue, "reportValidity"); } const { get: get2 } = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, "elements"); Object.defineProperty(HTMLFormElement.prototype, "elements", { get(...args) { const elements = get2.call(this, ...args); const polyfilledElements = Array.from(formElementsMap.get(this) || []); if (polyfilledElements.length === 0) { return elements; } const orderedElements = Array.from(elements).concat(polyfilledElements).sort((a2, b) => { if (a2.compareDocumentPosition) { return a2.compareDocumentPosition(b) & 2 ? 1 : -1; } return 0; }); return new HTMLFormControlsCollection(orderedElements); } }); } var init_patch_form_prototype = __esm({ "node_modules/element-internals-polyfill/dist/patch-form-prototype.js"() { init_HTMLFormControlsCollection(); init_maps(); init_utils(); } }); // node_modules/element-internals-polyfill/dist/element-internals.js function isElementInternalsSupported() { if (typeof window === "undefined" || !window.ElementInternals || !HTMLElement.prototype.attachInternals) { return false; } class ElementInternalsFeatureDetection extends HTMLElement { constructor() { super(); this.internals = this.attachInternals(); } } const randomName = `element-internals-feature-detection-${Math.random().toString(36).replace(/[^a-z]+/g, "")}`; customElements.define(randomName, ElementInternalsFeatureDetection); const featureDetectionElement = new ElementInternalsFeatureDetection(); return [ "shadowRoot", "form", "willValidate", "validity", "validationMessage", "labels", "setFormValue", "setValidity", "checkValidity", "reportValidity" ].every((prop) => prop in featureDetectionElement.internals); } function forceCustomStateSetPolyfill(attachInternals) { if (hasCustomStateSetPolyfillBeenApplied) { return; } hasCustomStateSetPolyfillBeenApplied = true; window.CustomStateSet = CustomStateSet; if (attachInternals) { HTMLElement.prototype.attachInternals = function(...args) { const internals = attachInternals.call(this, args); internals.states = new CustomStateSet(this); return internals; }; } } function forceElementInternalsPolyfill(forceCustomStateSet = true) { let attachedFlag = false; if (hasElementInternalsPolyfillBeenApplied) { return; } hasElementInternalsPolyfillBeenApplied = true; if (typeof window !== "undefined") { window.ElementInternals = ElementInternals; } if (typeof CustomElementRegistry !== "undefined") { const define = CustomElementRegistry.prototype.define; CustomElementRegistry.prototype.define = function(name, constructor, options2) { if (constructor.formAssociated) { const connectedCallback = constructor.prototype.connectedCallback; constructor.prototype.connectedCallback = function() { if (!connectedCallbackMap.has(this)) { connectedCallbackMap.set(this, true); if (this.hasAttribute("disabled")) { setDisabled(this, true); } } if (connectedCallback != null) { connectedCallback.apply(this); } attachedFlag = upgradeInternals(this); }; } define.call(this, name, constructor, options2); }; } if (typeof HTMLElement !== "undefined") { HTMLElement.prototype.attachInternals = function() { if (!this.tagName) { return {}; } else if (this.tagName.indexOf("-") === -1) { throw new Error(`Failed to execute 'attachInternals' on 'HTMLElement': Unable to attach ElementInternals to non-custom elements.`); } if (internalsMap.has(this) && !attachedFlag) { throw new DOMException(`DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.`); } return new ElementInternals(this); }; } if (typeof Element !== "undefined") { let attachShadowObserver = function(...args) { const shadowRoot = attachShadow.apply(this, args); shadowRootMap.set(this, shadowRoot); if (mutationObserverExists()) { const observer2 = new MutationObserver(observerCallback); if (window.ShadyDOM) { observer2.observe(this, observerConfig); } else { observer2.observe(shadowRoot, observerConfig); } shadowHostsMap.set(this, observer2); } return shadowRoot; }; const attachShadow = Element.prototype.attachShadow; Element.prototype.attachShadow = attachShadowObserver; } if (mutationObserverExists() && typeof document !== "undefined") { const documentObserver = new MutationObserver(observerCallback); documentObserver.observe(document.documentElement, observerConfig); } if (typeof HTMLFormElement !== "undefined") { patchFormPrototype(); } if (forceCustomStateSet || typeof window !== "undefined" && !window.CustomStateSet) { forceCustomStateSetPolyfill(); } } var ElementInternals, hasElementInternalsPolyfillBeenApplied, hasCustomStateSetPolyfillBeenApplied; var init_element_internals = __esm({ "node_modules/element-internals-polyfill/dist/element-internals.js"() { init_maps(); init_utils(); init_mutation_observers(); init_aom(); init_ValidityState(); init_mutation_observers(); init_CustomStateSet(); init_patch_form_prototype(); ElementInternals = class { static get isPolyfilled() { return true; } constructor(ref) { if (!ref || !ref.tagName || ref.tagName.indexOf("-") === -1) { throw new TypeError("Illegal constructor"); } const rootNode = ref.getRootNode(); const validity = new ValidityState(); this.states = new CustomStateSet(ref); refMap.set(this, ref); validityMap.set(this, validity); internalsMap.set(ref, this); initAom(ref, this); initRef(ref, this); Object.seal(this); if (rootNode instanceof DocumentFragment) { deferUpgrade(rootNode); } } /** * Will return true if the element is in a valid state */ checkValidity() { const ref = refMap.get(this); throwIfNotFormAssociated(ref, `Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element.`); if (!this.willValidate) { return true; } const validity = validityMap.get(this); if (!validity.valid) { const validityEvent = new Event("invalid", { bubbles: false, cancelable: true, composed: false }); ref.dispatchEvent(validityEvent); } return validity.valid; } /** The form element the custom element is associated with */ get form() { const ref = refMap.get(this); throwIfNotFormAssociated(ref, `Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.`); let form; if (ref.constructor["formAssociated"] === true) { form = findParentForm(ref); } return form; } /** A list of all relative form labels for this element */ get labels() { const ref = refMap.get(this); throwIfNotFormAssociated(ref, `Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.`); const id = ref.getAttribute("id"); const hostRoot = ref.getRootNode(); if (hostRoot && id) { return hostRoot.querySelectorAll(`[for="${id}"]`); } return []; } /** Will report the elements validity state */ reportValidity() { const ref = refMap.get(this); throwIfNotFormAssociated(ref, `Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.`); if (!this.willValidate) { return true; } const valid = this.checkValidity(); const anchor = validationAnchorMap.get(this); if (anchor && !ref.constructor["formAssociated"]) { throw new DOMException(`Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.`); } if (!valid && anchor) { ref.focus(); anchor.focus(); } return valid; } /** Sets the element's value within the form */ setFormValue(value) { const ref = refMap.get(this); throwIfNotFormAssociated(ref, `Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element.`); removeHiddenInputs(this); if (value != null && !(value instanceof FormData)) { if (ref.getAttribute("name")) { const hiddenInput = createHiddenInput(ref, this); hiddenInput.value = value; } } else if (value != null && value instanceof FormData) { Array.from(value).reverse().forEach(([formDataKey, formDataValue]) => { if (typeof formDataValue === "string") { const hiddenInput = createHiddenInput(ref, this); hiddenInput.name = formDataKey; hiddenInput.value = formDataValue; } }); } refValueMap.set(ref, value); } /** * Sets the element's validity. The first argument is a partial ValidityState object * reflecting the changes to be made to the element's validity. If the element is invalid, * the second argument sets the element's validation message. * * If the field is valid and a message is specified, the method will throw a TypeError. */ setValidity(validityChanges, validationMessage, anchor) { const ref = refMap.get(this); throwIfNotFormAssociated(ref, `Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element.`); if (!validityChanges) { throw new TypeError("Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present."); } validationAnchorMap.set(this, anchor); const validity = validityMap.get(this); const validityChangesObj = {}; for (const key in validityChanges) { validityChangesObj[key] = validityChanges[key]; } if (Object.keys(validityChangesObj).length === 0) { setValid(validity); } const check = { ...validity, ...validityChangesObj }; delete check.valid; const { valid } = reconcileValidity(validity, check, this.form); if (!valid && !validationMessage) { throw new DOMException(`Failed to execute 'setValidity' on 'ElementInternals': The second argument should not be empty if one or more flags in the first argument are true.`); } validationMessageMap.set(this, valid ? "" : validationMessage); if (ref.isConnected) { ref.toggleAttribute("internals-invalid", !valid); ref.toggleAttribute("internals-valid", valid); setAttribute(ref, "aria-invalid", `${!valid}`); } else { validityUpgradeMap.set(ref, this); } } get shadowRoot() { const ref = refMap.get(this); const shadowRoot = shadowRootMap.get(ref); if (shadowRoot) { return shadowRoot; } return null; } /** The element's validation message set during a call to ElementInternals.setValidity */ get validationMessage() { const ref = refMap.get(this); throwIfNotFormAssociated(ref, `Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element.`); return validationMessageMap.get(this); } /** The current validity state of the object */ get validity() { const ref = refMap.get(this); throwIfNotFormAssociated(ref, `Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element.`); const validity = validityMap.get(this); return validity; } /** If true the element will participate in a form's constraint validation. */ get willValidate() { const ref = refMap.get(this); throwIfNotFormAssociated(ref, `Failed to read the 'willValidate' property from 'ElementInternals': The target element is not a form-associated custom element.`); if (ref.matches(":disabled") || ref["disabled"] || ref.hasAttribute("disabled") ||