UNPKG

@postnord/web-components

Version:
33,156 lines 1.45 MB
/*!
 * Built with Stencil
 * By PostNord.
 */
import { Readable } from 'stream';

const modeResolutionChain = [];

function hydrateFactory($stencilWindow, $stencilHydrateOpts, $stencilHydrateResults, $stencilAfterHydrate, $stencilHydrateResolve) {
  var globalThis = $stencilWindow;
  var self = $stencilWindow;
  var top = $stencilWindow;
  var parent = $stencilWindow;

  var addEventListener = $stencilWindow.addEventListener.bind($stencilWindow);
  var alert = $stencilWindow.alert.bind($stencilWindow);
  var blur = $stencilWindow.blur.bind($stencilWindow);
  var cancelAnimationFrame = $stencilWindow.cancelAnimationFrame.bind($stencilWindow);
  var cancelIdleCallback = $stencilWindow.cancelIdleCallback.bind($stencilWindow);
  var clearInterval = $stencilWindow.clearInterval.bind($stencilWindow);
  var clearTimeout = $stencilWindow.clearTimeout.bind($stencilWindow);
  var close = () => {};
  var confirm = $stencilWindow.confirm.bind($stencilWindow);
  var dispatchEvent = $stencilWindow.dispatchEvent.bind($stencilWindow);
  var focus = $stencilWindow.focus.bind($stencilWindow);
  var getComputedStyle = $stencilWindow.getComputedStyle.bind($stencilWindow);
  var matchMedia = $stencilWindow.matchMedia.bind($stencilWindow);
  var open = $stencilWindow.open.bind($stencilWindow);
  var prompt = $stencilWindow.prompt.bind($stencilWindow);
  var removeEventListener = $stencilWindow.removeEventListener.bind($stencilWindow);
  var requestAnimationFrame = $stencilWindow.requestAnimationFrame.bind($stencilWindow);
  var requestIdleCallback = $stencilWindow.requestIdleCallback.bind($stencilWindow);
  var setInterval = $stencilWindow.setInterval.bind($stencilWindow);
  var setTimeout = $stencilWindow.setTimeout.bind($stencilWindow);

  // Tag transform functions are provided from the outer scope
  // This ensures the factory uses the same instance as the runner
  var setTagTransformer = $stencilTagTransform.setTagTransformer;
  var transformTag = $stencilTagTransform.transformTag;

  var CharacterData = $stencilWindow.CharacterData;
  var CSS = $stencilWindow.CSS;
  var CustomEvent = $stencilWindow.CustomEvent;
  var CSSStyleSheet = $stencilWindow.CSSStyleSheet;
  var Document = $stencilWindow.Document;
  var ShadowRoot = $stencilWindow.ShadowRoot;
  var DocumentFragment = $stencilWindow.DocumentFragment;
  var DocumentType = $stencilWindow.DocumentType;
  var DOMTokenList = $stencilWindow.DOMTokenList;
  var Element = $stencilWindow.Element;
  var Event = $stencilWindow.Event;
  var HTMLAnchorElement = $stencilWindow.HTMLAnchorElement;
  var HTMLBaseElement = $stencilWindow.HTMLBaseElement;
  var HTMLButtonElement = $stencilWindow.HTMLButtonElement;
  var HTMLCanvasElement = $stencilWindow.HTMLCanvasElement;
  var HTMLElement = $stencilWindow.HTMLElement;
  var HTMLFormElement = $stencilWindow.HTMLFormElement;
  var HTMLImageElement = $stencilWindow.HTMLImageElement;
  var HTMLInputElement = $stencilWindow.HTMLInputElement;
  var HTMLLinkElement = $stencilWindow.HTMLLinkElement;
  var HTMLMetaElement = $stencilWindow.HTMLMetaElement;
  var HTMLScriptElement = $stencilWindow.HTMLScriptElement;
  var HTMLStyleElement = $stencilWindow.HTMLStyleElement;
  var HTMLTemplateElement = $stencilWindow.HTMLTemplateElement;
  var HTMLTitleElement = $stencilWindow.HTMLTitleElement;
  var IntersectionObserver = $stencilWindow.IntersectionObserver;
  var ResizeObserver = $stencilWindow.ResizeObserver;
  var KeyboardEvent = $stencilWindow.KeyboardEvent;
  var MouseEvent = $stencilWindow.MouseEvent;
  var Node = $stencilWindow.Node;
  var NodeList = $stencilWindow.NodeList;
  var URL = $stencilWindow.URL;

  var console = $stencilWindow.console;
  var customElements = $stencilWindow.customElements;
  var history = $stencilWindow.history;
  var localStorage = $stencilWindow.localStorage;
  var location = $stencilWindow.location;
  var navigator = $stencilWindow.navigator;
  var performance = $stencilWindow.performance;
  var sessionStorage = $stencilWindow.sessionStorage;

  var devicePixelRatio = $stencilWindow.devicePixelRatio;
  var innerHeight = $stencilWindow.innerHeight;
  var innerWidth = $stencilWindow.innerWidth;
  var origin = $stencilWindow.origin;
  var pageXOffset = $stencilWindow.pageXOffset;
  var pageYOffset = $stencilWindow.pageYOffset;
  var screen = $stencilWindow.screen;
  var screenLeft = $stencilWindow.screenLeft;
  var screenTop = $stencilWindow.screenTop;
  var screenX = $stencilWindow.screenX;
  var screenY = $stencilWindow.screenY;
  var scrollX = $stencilWindow.scrollX;
  var scrollY = $stencilWindow.scrollY;
  var exports = {};

  var fetch, FetchError, Headers, Request, Response;

  if (typeof $stencilWindow.fetch === 'function') {
    fetch = $stencilWindow.fetch;
  } else {
    fetch = $stencilWindow.fetch = function() { throw new Error('fetch() is not implemented'); };
  }

  if (typeof $stencilWindow.FetchError === 'function') {
    FetchError = $stencilWindow.FetchError;
  } else {
    FetchError = $stencilWindow.FetchError = class FetchError { constructor() { throw new Error('FetchError is not implemented'); } };
  }

  if (typeof $stencilWindow.Headers === 'function') {
    Headers = $stencilWindow.Headers;
  } else {
    Headers = $stencilWindow.Headers = class Headers { constructor() { throw new Error('Headers is not implemented'); } };
  }

  if (typeof $stencilWindow.Request === 'function') {
    Request = $stencilWindow.Request;
  } else {
    Request = $stencilWindow.Request = class Request { constructor() { throw new Error('Request is not implemented'); } };
  }

  if (typeof $stencilWindow.Response === 'function') {
    Response = $stencilWindow.Response;
  } else {
    Response = $stencilWindow.Response = class Response { constructor() { throw new Error('Response is not implemented'); } };
  }

  function hydrateAppClosure($stencilWindow) {
    const window = $stencilWindow;
    const document = $stencilWindow.document;
    /*hydrateAppClosure start*/


const NAMESPACE = 'postnord-web-components';
const BUILD = /* postnord-web-components */ { hotModuleReplacement: false, hydratedSelectorName: "hydrated", shadowDom: false, slotRelocation: true, state: true, updatable: true};

/*
 Stencil Hydrate Platform v4.43.2 | MIT Licensed | https://stenciljs.com
 */
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 __typeError = (msg) => {
  throw TypeError(msg);
};
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __commonJS = (cb, mod) => function __require() {
  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.
  __defProp(target, "default", { value: mod, enumerable: true }) ,
  mod
));
var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);

// node_modules/balanced-match/index.js
var require_balanced_match = __commonJS({
  "node_modules/balanced-match/index.js"(exports, module) {
    module.exports = balanced;
    function balanced(a, b, str) {
      if (a instanceof RegExp) a = maybeMatch(a, str);
      if (b instanceof RegExp) b = maybeMatch(b, str);
      var r = range(a, b, str);
      return r && {
        start: r[0],
        end: r[1],
        pre: str.slice(0, r[0]),
        body: str.slice(r[0] + a.length, r[1]),
        post: str.slice(r[1] + b.length)
      };
    }
    function maybeMatch(reg, str) {
      var m = str.match(reg);
      return m ? m[0] : null;
    }
    balanced.range = range;
    function range(a, b, str) {
      var begs, beg, left, right, result;
      var ai = str.indexOf(a);
      var bi = str.indexOf(b, ai + 1);
      var i2 = ai;
      if (ai >= 0 && bi > 0) {
        if (a === b) {
          return [ai, bi];
        }
        begs = [];
        left = str.length;
        while (i2 >= 0 && !result) {
          if (i2 == ai) {
            begs.push(i2);
            ai = str.indexOf(a, i2 + 1);
          } else if (begs.length == 1) {
            result = [begs.pop(), bi];
          } else {
            beg = begs.pop();
            if (beg < left) {
              left = beg;
              right = bi;
            }
            bi = str.indexOf(b, i2 + 1);
          }
          i2 = ai < bi && ai >= 0 ? ai : bi;
        }
        if (begs.length) {
          result = [left, right];
        }
      }
      return result;
    }
  }
});

// node_modules/brace-expansion/index.js
var require_brace_expansion = __commonJS({
  "node_modules/brace-expansion/index.js"(exports, module) {
    var balanced = require_balanced_match();
    module.exports = expandTop;
    var escSlash = "\0SLASH" + Math.random() + "\0";
    var escOpen = "\0OPEN" + Math.random() + "\0";
    var escClose = "\0CLOSE" + Math.random() + "\0";
    var escComma = "\0COMMA" + Math.random() + "\0";
    var escPeriod = "\0PERIOD" + Math.random() + "\0";
    function numeric(str) {
      return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
    }
    function escapeBraces(str) {
      return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
    }
    function unescapeBraces(str) {
      return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
    }
    function parseCommaParts(str) {
      if (!str)
        return [""];
      var parts = [];
      var m = balanced("{", "}", str);
      if (!m)
        return str.split(",");
      var pre = m.pre;
      var body = m.body;
      var post = m.post;
      var p = pre.split(",");
      p[p.length - 1] += "{" + body + "}";
      var postParts = parseCommaParts(post);
      if (post.length) {
        p[p.length - 1] += postParts.shift();
        p.push.apply(p, postParts);
      }
      parts.push.apply(parts, p);
      return parts;
    }
    function expandTop(str) {
      if (!str)
        return [];
      if (str.substr(0, 2) === "{}") {
        str = "\\{\\}" + str.substr(2);
      }
      return expand2(escapeBraces(str), true).map(unescapeBraces);
    }
    function embrace(str) {
      return "{" + str + "}";
    }
    function isPadded(el) {
      return /^-?0\d/.test(el);
    }
    function lte(i2, y) {
      return i2 <= y;
    }
    function gte(i2, y) {
      return i2 >= y;
    }
    function expand2(str, isTop) {
      var expansions = [];
      var m = balanced("{", "}", str);
      if (!m) return [str];
      var pre = m.pre;
      var post = m.post.length ? expand2(m.post, false) : [""];
      if (/\$$/.test(m.pre)) {
        for (var k = 0; k < post.length; k++) {
          var expansion = pre + "{" + m.body + "}" + post[k];
          expansions.push(expansion);
        }
      } else {
        var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
        var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
        var isSequence = isNumericSequence || isAlphaSequence;
        var isOptions = m.body.indexOf(",") >= 0;
        if (!isSequence && !isOptions) {
          if (m.post.match(/,(?!,).*\}/)) {
            str = m.pre + "{" + m.body + escClose + m.post;
            return expand2(str);
          }
          return [str];
        }
        var n;
        if (isSequence) {
          n = m.body.split(/\.\./);
        } else {
          n = parseCommaParts(m.body);
          if (n.length === 1) {
            n = expand2(n[0], false).map(embrace);
            if (n.length === 1) {
              return post.map(function(p) {
                return m.pre + n[0] + p;
              });
            }
          }
        }
        var N;
        if (isSequence) {
          var x = numeric(n[0]);
          var y = numeric(n[1]);
          var width = Math.max(n[0].length, n[1].length);
          var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
          var test = lte;
          var reverse = y < x;
          if (reverse) {
            incr *= -1;
            test = gte;
          }
          var pad = n.some(isPadded);
          N = [];
          for (var i2 = x; test(i2, y); i2 += incr) {
            var c;
            if (isAlphaSequence) {
              c = String.fromCharCode(i2);
              if (c === "\\")
                c = "";
            } else {
              c = String(i2);
              if (pad) {
                var need = width - c.length;
                if (need > 0) {
                  var z = new Array(need + 1).join("0");
                  if (i2 < 0)
                    c = "-" + z + c.slice(1);
                  else
                    c = z + c;
                }
              }
            }
            N.push(c);
          }
        } else {
          N = [];
          for (var j = 0; j < n.length; j++) {
            N.push.apply(N, expand2(n[j], false));
          }
        }
        for (var j = 0; j < N.length; j++) {
          for (var k = 0; k < post.length; k++) {
            var expansion = pre + N[j] + post[k];
            if (!isTop || isSequence || expansion)
              expansions.push(expansion);
          }
        }
      }
      return expansions;
    }
  }
});

// src/utils/constants.ts
var SVG_NS = "http://www.w3.org/2000/svg";
var HTML_NS = "http://www.w3.org/1999/xhtml";
var PrimitiveType = /* @__PURE__ */ ((PrimitiveType2) => {
  PrimitiveType2["Undefined"] = "undefined";
  PrimitiveType2["Null"] = "null";
  PrimitiveType2["String"] = "string";
  PrimitiveType2["Number"] = "number";
  PrimitiveType2["SpecialNumber"] = "number";
  PrimitiveType2["Boolean"] = "boolean";
  PrimitiveType2["BigInt"] = "bigint";
  return PrimitiveType2;
})(PrimitiveType || {});
var NonPrimitiveType = /* @__PURE__ */ ((NonPrimitiveType2) => {
  NonPrimitiveType2["Array"] = "array";
  NonPrimitiveType2["Date"] = "date";
  NonPrimitiveType2["Map"] = "map";
  NonPrimitiveType2["Object"] = "object";
  NonPrimitiveType2["RegularExpression"] = "regexp";
  NonPrimitiveType2["Set"] = "set";
  NonPrimitiveType2["Channel"] = "channel";
  NonPrimitiveType2["Symbol"] = "symbol";
  return NonPrimitiveType2;
})(NonPrimitiveType || {});
var TYPE_CONSTANT = "type";
var VALUE_CONSTANT = "value";
var SERIALIZED_PREFIX = "serialized:";

// src/utils/get-prop-descriptor.ts
function getPropertyDescriptor(obj, memberName, getOnly) {
  const stopAt = typeof HTMLElement !== "undefined" ? HTMLElement.prototype : null;
  while (obj && obj !== stopAt) {
    const desc = Object.getOwnPropertyDescriptor(obj, memberName);
    if (desc && (!getOnly || desc.get)) return desc;
    obj = Object.getPrototypeOf(obj);
  }
  return void 0;
}

// src/utils/es2022-rewire-class-members.ts
var reWireGetterSetter = (instance, hostRef) => {
  var _a;
  const cmpMeta = hostRef.$cmpMeta$;
  const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
  members.map(([memberName, [memberFlags]]) => {
    if ((memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
      const ogValue = instance[memberName];
      const ogDescriptor = getPropertyDescriptor(Object.getPrototypeOf(instance), memberName, true) || Object.getOwnPropertyDescriptor(instance, memberName);
      if (ogDescriptor) {
        Object.defineProperty(instance, memberName, {
          get() {
            return ogDescriptor.get.call(this);
          },
          set(newValue) {
            ogDescriptor.set.call(this, newValue);
          },
          configurable: true,
          enumerable: true
        });
      }
      if (hostRef.$instanceValues$.has(memberName)) {
        instance[memberName] = hostRef.$instanceValues$.get(memberName);
      } else if (ogValue !== void 0) {
        instance[memberName] = ogValue;
      }
    }
  });
};

// src/runtime/runtime-constants.ts
var CONTENT_REF_ID = "r";
var ORG_LOCATION_ID = "o";
var SLOT_NODE_ID = "s";
var TEXT_NODE_ID = "t";
var COMMENT_NODE_ID = "c";
var HYDRATE_ID = "s-id";
var HYDRATED_STYLE_ID = "sty-id";
var HYDRATE_CHILD_ID = "c-id";
var STENCIL_DOC_DATA = "_stencilDocData";
var DEFAULT_DOC_DATA = {
  hostIds: 0,
  rootLevelIds: 0,
  staticComponents: /* @__PURE__ */ new Set()
};
var SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
var XLINK_NS = "http://www.w3.org/1999/xlink";

// src/utils/style.ts
function createStyleSheetIfNeededAndSupported(styles2) {
  return void 0;
}

// src/utils/shadow-root.ts
var globalStyleSheet;
function createShadowRoot(cmpMeta) {
  var _a;
  const opts = { mode: "open" };
  const shadowRoot = this.attachShadow(opts);
  if (globalStyleSheet === void 0) globalStyleSheet = (_a = createStyleSheetIfNeededAndSupported()) != null ? _a : null;
  if (globalStyleSheet) {
    {
      shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, globalStyleSheet];
    }
  }
}
var updateFallbackSlotVisibility = (elm) => {
  const childNodes = internalCall(elm, "childNodes");
  if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") {
    getHostSlotNodes(childNodes, elm.tagName).forEach((slotNode) => {
      if (slotNode.nodeType === 1 /* ElementNode */ && slotNode.tagName === "SLOT-FB") {
        if (getSlotChildSiblings(slotNode, getSlotName(slotNode), false).length) {
          slotNode.hidden = true;
        } else {
          slotNode.hidden = false;
        }
      }
    });
  }
  let i2 = 0;
  for (i2 = 0; i2 < childNodes.length; i2++) {
    const childNode = childNodes[i2];
    if (childNode.nodeType === 1 /* ElementNode */ && internalCall(childNode, "childNodes").length) {
      updateFallbackSlotVisibility(childNode);
    }
  }
};
var getSlottedChildNodes = (childNodes) => {
  const result = [];
  for (let i2 = 0; i2 < childNodes.length; i2++) {
    const slottedNode = childNodes[i2]["s-nr"] || void 0;
    if (slottedNode && slottedNode.isConnected) {
      result.push(slottedNode);
    }
  }
  return result;
};
function getHostSlotNodes(childNodes, hostName, slotName) {
  let i2 = 0;
  let slottedNodes = [];
  let childNode;
  for (; i2 < childNodes.length; i2++) {
    childNode = childNodes[i2];
    if (childNode["s-sr"] && (!hostName || childNode["s-hn"] === hostName) && (slotName === void 0 || getSlotName(childNode) === slotName)) {
      slottedNodes.push(childNode);
      if (typeof slotName !== "undefined") return slottedNodes;
    }
    slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
  }
  return slottedNodes;
}
var getSlotChildSiblings = (slot, slotName, includeSlot = true) => {
  const childNodes = [];
  if (includeSlot && slot["s-sr"] || !slot["s-sr"]) childNodes.push(slot);
  let node = slot;
  while (node = node.nextSibling) {
    if (getSlotName(node) === slotName && (includeSlot || !node["s-sr"])) childNodes.push(node);
  }
  return childNodes;
};
var isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
  if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
    if (nodeToRelocate.getAttribute("slot") === null && slotName === "") {
      return true;
    }
    if (nodeToRelocate.getAttribute("slot") === slotName) {
      return true;
    }
    return false;
  }
  if (nodeToRelocate["s-sn"] === slotName) {
    return true;
  }
  return slotName === "";
};
var addSlotRelocateNode = (newChild, slotNode, prepend, position) => {
  if (newChild["s-ol"] && newChild["s-ol"].isConnected) {
    return;
  }
  const slottedNodeLocation = document.createTextNode("");
  slottedNodeLocation["s-nr"] = newChild;
  if (!slotNode["s-cr"] || !slotNode["s-cr"].parentNode) return;
  const parent = slotNode["s-cr"].parentNode;
  const appendMethod = internalCall(parent, "appendChild");
  if (typeof position !== "undefined") {
    slottedNodeLocation["s-oo"] = position;
    const childNodes = internalCall(parent, "childNodes");
    const slotRelocateNodes = [slottedNodeLocation];
    childNodes.forEach((n) => {
      if (n["s-nr"]) slotRelocateNodes.push(n);
    });
    slotRelocateNodes.sort((a, b) => {
      if (!a["s-oo"] || a["s-oo"] < (b["s-oo"] || 0)) return -1;
      else if (!b["s-oo"] || b["s-oo"] < a["s-oo"]) return 1;
      return 0;
    });
    slotRelocateNodes.forEach((n) => appendMethod.call(parent, n));
  } else {
    appendMethod.call(parent, slottedNodeLocation);
  }
  newChild["s-ol"] = slottedNodeLocation;
  newChild["s-sh"] = slotNode["s-hn"];
};
var getSlotName = (node) => typeof node["s-sn"] === "string" ? node["s-sn"] : node.nodeType === 1 && node.getAttribute("slot") || void 0;
function patchSlotNode(node) {
  if (node.assignedElements || node.assignedNodes || !node["s-sr"]) return;
  const assignedFactory = (elementsOnly) => (function(opts) {
    const toReturn = [];
    const slotName = this["s-sn"];
    if (opts == null ? void 0 : opts.flatten) {
      console.error(`
          Flattening is not supported for Stencil non-shadow slots.
          You can use \`.childNodes\` to nested slot fallback content.
          If you have a particular use case, please open an issue on the Stencil repo.
        `);
    }
    const parent = this["s-cr"].parentElement;
    const slottedNodes = parent.__childNodes ? parent.childNodes : getSlottedChildNodes(parent.childNodes);
    slottedNodes.forEach((n) => {
      if (slotName === getSlotName(n)) {
        toReturn.push(n);
      }
    });
    if (elementsOnly) {
      return toReturn.filter((n) => n.nodeType === 1 /* ElementNode */);
    }
    return toReturn;
  }).bind(node);
  node.assignedElements = assignedFactory(true);
  node.assignedNodes = assignedFactory(false);
}
function dispatchSlotChangeEvent(elm) {
  elm.dispatchEvent(new CustomEvent("slotchange", { bubbles: false, cancelable: false, composed: false }));
}
function findSlotFromSlottedNode(slottedNode, parentHost) {
  var _a;
  parentHost = parentHost || ((_a = slottedNode["s-ol"]) == null ? void 0 : _a.parentElement);
  if (!parentHost) return { slotNode: null, slotName: "" };
  const slotName = slottedNode["s-sn"] = getSlotName(slottedNode) || "";
  const childNodes = internalCall(parentHost, "childNodes");
  const slotNode = getHostSlotNodes(childNodes, parentHost.tagName, slotName)[0];
  return { slotNode, slotName };
}
function internalCall(node, method) {
  if ("__" + method in node) {
    const toReturn = node["__" + method];
    if (typeof toReturn !== "function") return toReturn;
    return toReturn.bind(node);
  } else {
    if (typeof node[method] !== "function") return node[method];
    return node[method].bind(node);
  }
}
var createTime = (fnName, tagName = "") => {
  {
    return () => {
      return;
    };
  }
};
var uniqueTime = (key, measureText) => {
  {
    return () => {
      return;
    };
  }
};

// src/utils/query-nonce-meta-tag-content.ts
function queryNonceMetaTagContent(doc) {
  var _a, _b, _c;
  return (_c = (_b = (_a = doc.head) == null ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) == null ? void 0 : _b.getAttribute("content")) != null ? _c : void 0;
}

// src/runtime/styles.ts
var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
var registerStyle = (scopeId2, cssText, allowCS) => {
  let style = styles.get(scopeId2);
  {
    style = cssText;
  }
  styles.set(scopeId2, style);
};
var addStyle = (styleContainerNode, cmpMeta, mode) => {
  var _a;
  const scopeId2 = getScopeId(cmpMeta);
  const style = styles.get(scopeId2);
  if (!win.document) {
    return scopeId2;
  }
  styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : win.document;
  if (style) {
    if (typeof style === "string") {
      styleContainerNode = styleContainerNode.head || styleContainerNode;
      let appliedStyles = rootAppliedStyles.get(styleContainerNode);
      let styleElm;
      if (!appliedStyles) {
        rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
      }
      const existingStyleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId2}"]`);
      if (existingStyleElm) {
        existingStyleElm.textContent = style;
      } else if (!appliedStyles.has(scopeId2)) {
        styleElm = win.document.createElement("style");
        styleElm.textContent = style;
        const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(win.document);
        if (nonce != null) {
          styleElm.setAttribute("nonce", nonce);
        }
        if ((cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */ || cmpMeta.$flags$ & 128 /* shadowNeedsScopedCss */ || cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
          styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId2);
        }
        if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
          if (styleContainerNode.nodeName === "HEAD") {
            const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
            const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
            styleContainerNode.insertBefore(
              styleElm,
              (referenceNode2 == null ? void 0 : referenceNode2.parentNode) === styleContainerNode ? referenceNode2 : null
            );
          } else if ("host" in styleContainerNode) {
            {
              const existingStyleContainer = styleContainerNode.querySelector("style");
              if (existingStyleContainer && true) {
                existingStyleContainer.textContent = style + existingStyleContainer.textContent;
              } else {
                styleContainerNode.prepend(styleElm);
              }
            }
          } else {
            styleContainerNode.append(styleElm);
          }
        }
        if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
          styleContainerNode.insertBefore(styleElm, null);
        }
        if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
          styleElm.textContent += SLOT_FB_CSS;
        }
        if (appliedStyles) {
          appliedStyles.add(scopeId2);
        }
      }
    }
  }
  return scopeId2;
};
var attachStyles = (hostRef) => {
  const cmpMeta = hostRef.$cmpMeta$;
  const elm = hostRef.$hostElement$;
  const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
  addStyle(
    elm.getRootNode(),
    cmpMeta);
  endAttachStyles();
};
var getScopeId = (cmp, mode) => "sc-" + (cmp.$tagName$);
var isComplexType = (o) => {
  o = typeof o;
  return o === "object" || o === "function";
};

// src/runtime/vdom/h.ts
var h = (nodeName, vnodeData, ...children) => {
  if (typeof nodeName === "string") {
    nodeName = transformTag(nodeName);
  }
  let child = null;
  let key = null;
  let slotName = null;
  let simple = false;
  let lastSimple = false;
  const vNodeChildren = [];
  const walk = (c) => {
    for (let i2 = 0; i2 < c.length; i2++) {
      child = c[i2];
      if (Array.isArray(child)) {
        walk(child);
      } else if (child != null && typeof child !== "boolean") {
        if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
          child = String(child);
        }
        if (simple && lastSimple) {
          vNodeChildren[vNodeChildren.length - 1].$text$ += child;
        } else {
          vNodeChildren.push(simple ? newVNode(null, child) : child);
        }
        lastSimple = simple;
      }
    }
  };
  walk(children);
  if (vnodeData) {
    if (vnodeData.key) {
      key = vnodeData.key;
    }
    if (vnodeData.name) {
      slotName = vnodeData.name;
    }
    {
      const classData = vnodeData.className || vnodeData.class;
      if (classData) {
        vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
      }
    }
  }
  if (typeof nodeName === "function") {
    return nodeName(
      vnodeData === null ? {} : vnodeData,
      vNodeChildren,
      vdomFnUtils
    );
  }
  const vnode = newVNode(nodeName, null);
  vnode.$attrs$ = vnodeData;
  if (vNodeChildren.length > 0) {
    vnode.$children$ = vNodeChildren;
  }
  {
    vnode.$key$ = key;
  }
  {
    vnode.$name$ = slotName;
  }
  return vnode;
};
var newVNode = (tag, text) => {
  const vnode = {
    $flags$: 0,
    $tag$: tag,
    // Normalize undefined to null to prevent rendering "undefined" as text
    $text$: text != null ? text : null,
    $elm$: null,
    $children$: null
  };
  {
    vnode.$attrs$ = null;
  }
  {
    vnode.$key$ = null;
  }
  {
    vnode.$name$ = null;
  }
  return vnode;
};
var Host = {};
var isHost = (node) => node && node.$tag$ === Host;
var vdomFnUtils = {
  forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
  map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate)
};
var convertToPublic = (node) => ({
  vattrs: node.$attrs$,
  vchildren: node.$children$,
  vkey: node.$key$,
  vname: node.$name$,
  vtag: node.$tag$,
  vtext: node.$text$
});
var convertToPrivate = (node) => {
  if (typeof node.vtag === "function") {
    const vnodeData = { ...node.vattrs };
    if (node.vkey) {
      vnodeData.key = node.vkey;
    }
    if (node.vname) {
      vnodeData.name = node.vname;
    }
    return h(node.vtag, vnodeData, ...node.vchildren || []);
  }
  const vnode = newVNode(node.vtag, node.vtext);
  vnode.$attrs$ = node.vattrs;
  vnode.$children$ = node.vchildren;
  vnode.$key$ = node.vkey;
  vnode.$name$ = node.vname;
  return vnode;
};

// src/runtime/client-hydrate.ts
var initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
  var _a, _b, _c, _d;
  const endHydrate = createTime("hydrateClient", tagName);
  const shadowRoot = hostElm.shadowRoot;
  const childRenderNodes = [];
  const slotNodes = [];
  const slottedNodes = [];
  const shadowRootNodes = null;
  const vnode = newVNode(tagName, null);
  vnode.$elm$ = hostElm;
  if (win.document && (!plt.$orgLocNodes$ || !plt.$orgLocNodes$.size)) {
    initializeDocumentHydrate(win.document.body, plt.$orgLocNodes$ = /* @__PURE__ */ new Map());
  }
  hostElm[HYDRATE_ID] = hostId;
  hostElm.removeAttribute(HYDRATE_ID);
  hostRef.$vnode$ = clientHydrate(
    vnode,
    childRenderNodes,
    slotNodes,
    shadowRootNodes,
    hostElm,
    hostElm,
    hostId,
    slottedNodes
  );
  let crIndex = 0;
  const crLength = childRenderNodes.length;
  let childRenderNode;
  for (crIndex; crIndex < crLength; crIndex++) {
    childRenderNode = childRenderNodes[crIndex];
    const orgLocationId = childRenderNode.$hostId$ + "." + childRenderNode.$nodeId$;
    const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
    const node = childRenderNode.$elm$;
    if (!shadowRoot) {
      node["s-hn"] = transformTag(tagName).toUpperCase();
      if (childRenderNode.$tag$ === "slot") {
        node["s-cr"] = hostElm["s-cr"];
      }
    } else if (((_a = childRenderNode.$tag$) == null ? void 0 : _a.toString().includes("-")) && childRenderNode.$tag$ !== "slot-fb" && !childRenderNode.$elm$.shadowRoot) {
      const cmpMeta = getHostRef(childRenderNode.$elm$);
      if (cmpMeta) {
        const scopeId3 = getScopeId(
          cmpMeta.$cmpMeta$);
        const styleSheet = win.document.querySelector(`style[sty-id="${scopeId3}"]`);
        if (styleSheet) {
          shadowRootNodes.unshift(styleSheet.cloneNode(true));
        }
      }
    }
    if (childRenderNode.$tag$ === "slot") {
      childRenderNode.$name$ = childRenderNode.$elm$["s-sn"] || childRenderNode.$elm$["name"] || null;
      if (childRenderNode.$children$) {
        childRenderNode.$flags$ |= 2 /* isSlotFallback */;
        if (!childRenderNode.$elm$.childNodes.length) {
          childRenderNode.$children$.forEach((c) => {
            childRenderNode.$elm$.appendChild(c.$elm$);
          });
        }
      } else {
        childRenderNode.$flags$ |= 1 /* isSlotReference */;
      }
    }
    if (orgLocationNode && orgLocationNode.isConnected) {
      if (orgLocationNode.parentElement.shadowRoot && orgLocationNode["s-en"] === "") {
        orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
      }
      orgLocationNode.parentNode.removeChild(orgLocationNode);
      if (!shadowRoot) {
        node["s-oo"] = parseInt(childRenderNode.$nodeId$);
      }
    }
    if (orgLocationNode && !orgLocationNode["s-id"]) {
      plt.$orgLocNodes$.delete(orgLocationId);
    }
  }
  const hosts = [];
  const snLen = slottedNodes.length;
  let snIndex = 0;
  let slotGroup;
  let snGroupIdx;
  let snGroupLen;
  let slottedItem;
  let currentPos = 0;
  for (snIndex; snIndex < snLen; snIndex++) {
    slotGroup = slottedNodes[snIndex];
    if (!slotGroup || !slotGroup.length) continue;
    snGroupLen = slotGroup.length;
    snGroupIdx = 0;
    for (snGroupIdx; snGroupIdx < snGroupLen; snGroupIdx++) {
      slottedItem = slotGroup[snGroupIdx];
      if (!hosts[slottedItem.hostId]) {
        hosts[slottedItem.hostId] = plt.$orgLocNodes$.get(slottedItem.hostId);
      }
      if (!hosts[slottedItem.hostId]) continue;
      const hostEle = hosts[slottedItem.hostId];
      if (hostEle.shadowRoot && slottedItem.node.parentElement !== hostEle) {
        hostEle.insertBefore(slottedItem.node, (_c = (_b = slotGroup[snGroupIdx - 1]) == null ? void 0 : _b.node) == null ? void 0 : _c.nextSibling);
      }
      if (!hostEle.shadowRoot || !shadowRoot) {
        if (!slottedItem.slot["s-cr"]) {
          slottedItem.slot["s-cr"] = hostEle["s-cr"];
          if (!slottedItem.slot["s-cr"] && hostEle.shadowRoot) {
            slottedItem.slot["s-cr"] = hostEle;
          } else {
            slottedItem.slot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
          }
        }
        addSlotRelocateNode(slottedItem.node, slottedItem.slot, false, slottedItem.node["s-oo"] || currentPos);
        if (((_d = slottedItem.node.parentElement) == null ? void 0 : _d.shadowRoot) && slottedItem.node["getAttribute"] && slottedItem.node.getAttribute("slot")) {
          slottedItem.node.removeAttribute("slot");
        }
      }
      currentPos = (slottedItem.node["s-oo"] || currentPos) + 1;
    }
  }
  hostRef.$hostElement$ = hostElm;
  endHydrate();
};
var clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId, slottedNodes = []) => {
  let childNodeType;
  let childIdSplt;
  let childVNode;
  let i2;
  if (node.nodeType === 1 /* ElementNode */) {
    childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
    if (childNodeType) {
      childIdSplt = childNodeType.split(".");
      if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
        childVNode = createSimpleVNode({
          $flags$: 0,
          $hostId$: childIdSplt[0],
          $nodeId$: childIdSplt[1],
          $depth$: childIdSplt[2],
          $index$: childIdSplt[3],
          $tag$: node.tagName.toLowerCase(),
          $elm$: node,
          // If we don't add the initial classes to the VNode, the first `vdom-render.ts` patch
          // won't try to reconcile them. Classes set on the node will be blown away.
          $attrs$: { class: node.className || "" }
        });
        childRenderNodes.push(childVNode);
        node.removeAttribute(HYDRATE_CHILD_ID);
        if (!parentVNode.$children$) {
          parentVNode.$children$ = [];
        }
        const slotName = childVNode.$elm$.getAttribute("s-sn");
        if (typeof slotName === "string") {
          if (childVNode.$tag$ === "slot-fb") {
            addSlot(
              slotName,
              childIdSplt[2],
              childVNode,
              node,
              parentVNode,
              childRenderNodes,
              slotNodes,
              shadowRootNodes,
              slottedNodes
            );
          }
          childVNode.$elm$["s-sn"] = slotName;
          childVNode.$elm$.removeAttribute("s-sn");
        }
        if (childVNode.$index$ !== void 0) {
          parentVNode.$children$[childVNode.$index$] = childVNode;
        }
        parentVNode = childVNode;
      }
    }
    if (node.shadowRoot) {
      for (i2 = node.shadowRoot.childNodes.length - 1; i2 >= 0; i2--) {
        clientHydrate(
          parentVNode,
          childRenderNodes,
          slotNodes,
          shadowRootNodes,
          hostElm,
          node.shadowRoot.childNodes[i2],
          hostId,
          slottedNodes
        );
      }
    }
    const nonShadowNodes = node.__childNodes || node.childNodes;
    for (i2 = nonShadowNodes.length - 1; i2 >= 0; i2--) {
      clientHydrate(
        parentVNode,
        childRenderNodes,
        slotNodes,
        shadowRootNodes,
        hostElm,
        nonShadowNodes[i2],
        hostId,
        slottedNodes
      );
    }
  } else if (node.nodeType === 8 /* CommentNode */) {
    childIdSplt = node.nodeValue.split(".");
    if (childIdSplt[1] === hostId || childIdSplt[1] === "0") {
      childNodeType = childIdSplt[0];
      childVNode = createSimpleVNode({
        $hostId$: childIdSplt[1],
        $nodeId$: childIdSplt[2],
        $depth$: childIdSplt[3],
        $index$: childIdSplt[4] || "0",
        $elm$: node,
        $attrs$: null,
        $children$: null,
        $key$: null,
        $name$: null,
        $tag$: null,
        $text$: null
      });
      if (childNodeType === TEXT_NODE_ID) {
        childVNode.$elm$ = findCorrespondingNode(node, 3 /* TextNode */);
        if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
          childVNode.$text$ = childVNode.$elm$.textContent;
          childRenderNodes.push(childVNode);
          node.remove();
          if (hostId === childVNode.$hostId$) {
            if (!parentVNode.$children$) {
              parentVNode.$children$ = [];
            }
            parentVNode.$children$[childVNode.$index$] = childVNode;
          }
        }
      } else if (childNodeType === COMMENT_NODE_ID) {
        childVNode.$elm$ = findCorrespondingNode(node, 8 /* CommentNode */);
        if (childVNode.$elm$ && childVNode.$elm$.nodeType === 8 /* CommentNode */) {
          childRenderNodes.push(childVNode);
          node.remove();
        }
      } else if (childVNode.$hostId$ === hostId) {
        if (childNodeType === SLOT_NODE_ID) {
          const slotName = node["s-sn"] = childIdSplt[5] || "";
          addSlot(
            slotName,
            childIdSplt[2],
            childVNode,
            node,
            parentVNode,
            childRenderNodes,
            slotNodes,
            shadowRootNodes,
            slottedNodes
          );
        } else if (childNodeType === CONTENT_REF_ID) {
          {
            hostElm["s-cr"] = node;
            node["s-cn"] = true;
          }
        }
      }
    }
  } else if (parentVNode && parentVNode.$tag$ === "style") {
    const vnode = newVNode(null, node.textContent);
    vnode.$elm$ = node;
    vnode.$index$ = "0";
    parentVNode.$children$ = [vnode];
  }
  return parentVNode;
};
var initializeDocumentHydrate = (node, orgLocNodes) => {
  if (node.nodeType === 1 /* ElementNode */) {
    const componentId = node[HYDRATE_ID] || node.getAttribute(HYDRATE_ID);
    if (componentId) {
      orgLocNodes.set(componentId, node);
    }
    let i2 = 0;
    if (node.shadowRoot) {
      for (; i2 < node.shadowRoot.childNodes.length; i2++) {
        initializeDocumentHydrate(node.shadowRoot.childNodes[i2], orgLocNodes);
      }
    }
    const nonShadowNodes = node.__childNodes || node.childNodes;
    for (i2 = 0; i2 < nonShadowNodes.length; i2++) {
      initializeDocumentHydrate(nonShadowNodes[i2], orgLocNodes);
    }
  } else if (node.nodeType === 8 /* CommentNode */) {
    const childIdSplt = node.nodeValue.split(".");
    if (childIdSplt[0] === ORG_LOCATION_ID) {
      orgLocNodes.set(childIdSplt[1] + "." + childIdSplt[2], node);
      node.nodeValue = "";
      node["s-en"] = childIdSplt[3];
    }
  }
};
var createSimpleVNode = (vnode) => {
  const defaultVNode = {
    $flags$: 0,
    $hostId$: null,
    $nodeId$: null,
    $depth$: null,
    $index$: "0",
    $elm$: null,
    $attrs$: null,
    $children$: null,
    $key$: null,
    $name$: null,
    $tag$: null,
    $text$: null
  };
  return { ...defaultVNode, ...vnode };
};
function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
  node["s-sr"] = true;
  childVNode.$name$ = slotName || null;
  childVNode.$tag$ = "slot";
  const parentNodeId = (parentVNode == null ? void 0 : parentVNode.$elm$) ? parentVNode.$elm$["s-id"] || parentVNode.$elm$.getAttribute("s-id") : "";
  {
    const slot = childVNode.$elm$;
    const shouldMove = parentNodeId && parentNodeId !== childVNode.$hostId$ && parentVNode.$elm$.shadowRoot;
    addSlottedNodes(slottedNodes, slotId, slotName, node, shouldMove ? parentNodeId : childVNode.$hostId$);
    patchSlotNode(node);
    if (shouldMove) {
      parentVNode.$elm$.insertBefore(slot, parentVNode.$elm$.children[0]);
    }
  }
  childRenderNodes.push(childVNode);
  slotNodes.push(childVNode);
  if (!parentVNode.$children$) {
    parentVNode.$children$ = [];
  }
  parentVNode.$children$[childVNode.$index$] = childVNode;
}
var addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) => {
  var _a, _b;
  let slottedNode = slotNode.nextSibling;
  slottedNodes[slotNodeId] = slottedNodes[slotNodeId] || [];
  if (!slottedNode || ((_a = slottedNode.nodeValue) == null ? void 0 : _a.startsWith(SLOT_NODE_ID + "."))) return;
  do {
    if (slottedNode && ((slottedNode["getAttribute"] && slottedNode.getAttribute("slot") || slottedNode["s-sn"]) === slotName || slotName === "" && !slottedNode["s-sn"] && (!slottedNode["getAttribute"] || !slottedNode.getAttribute("slot")) && (slottedNode.nodeType === 8 /* CommentNode */ || slottedNode.nodeType === 3 /* TextNode */))) {
      slottedNode["s-sn"] = slotName;
      slottedNodes[slotNodeId].push({ slot: slotNode, node: slottedNode, hostId });
    }
    slottedNode = slottedNode == null ? void 0 : slottedNode.nextSibling;
  } while (slottedNode && !((_b = slottedNode.nodeValue) == null ? void 0 : _b.startsWith(SLOT_NODE_ID + ".")));
};
var findCorrespondingNode = (node, type) => {
  let sibling = node;
  do {
    sibling = sibling.nextSibling;
  } while (sibling && (sibling.nodeType !== type || !sibling.nodeValue));
  return sibling;
};

// src/utils/remote-value.ts
var RemoteValue = class _RemoteValue {
  /**
   * Deserializes a LocalValue serialized object back to its original JavaScript representation
   *
   * @param serialized The serialized LocalValue object
   * @returns The original JavaScript value/object
   */
  static fromLocalValue(serialized) {
    const type = serialized[TYPE_CONSTANT];
    const value = VALUE_CONSTANT in serialized ? serialized[VALUE_CONSTANT] : void 0;
    switch (type) {
      case "string" /* String */:
        return value;
      case "boolean" /* Boolean */:
        return value;
      case "bigint" /* BigInt */:
        return BigInt(value);
      case "undefined" /* Undefined */:
        return void 0;
      case "null" /* Null */:
        return null;
      case "number" /* Number */:
        if (value === "NaN") return NaN;
        if (value === "-0") return -0;
        if (value === "Infinity") return Infinity;
        if (value === "-Infinity") return -Infinity;
        return value;
      case "array" /* Array */:
        return value.map((item) => _RemoteValue.fromLocalValue(item));
      case "date" /* Date */:
        return new Date(value);
      case "map" /* Map */:
        const map2 = /* @__PURE__ */ new Map();
        for (const [key, val] of value) {
          const deserializedKey = typeof key === "object" && key !== null ? _RemoteValue.fromLocalValue(key) : key;
          const deserializedValue = _RemoteValue.fromLocalValue(val);
          map2.set(deserializedKey, deserializedValue);
        }
        return map2;
      case "object" /* Object */:
        const obj = {};
        for (const [key, val] of value) {
          obj[key] = _RemoteValue.fromLocalValue(val);
        }
        return obj;
      case "regexp" /* RegularExpression */:
        const { pattern, flags } = value;
        return new RegExp(pattern, flags);
      case "set" /* Set */:
        const set = /* @__PURE__ */ new Set();
        for (const item of value) {
          set.add(_RemoteValue.fromLocalValue(item));
        }
        return set;
      case "symbol" /* Symbol */:
        return Symbol(value);
      default:
        throw new Error(`Unsupported type: ${type}`);
    }
  }
  /**
   * Utility method to deserialize multiple LocalValues at once
   *
   * @param serializedValues Array of serialized LocalValue objects
   * @returns Array of deserialized JavaScript values
   */
  static fromLocalValueArray(serializedValues) {
    return serializedValues.map((value) => _RemoteValue.fromLocalValue(value));
  }
  /**
   * Verifies if the given object matches the structure of a serialized LocalValue
   *
   * @param obj Object to verify
   * @returns boolean indicating if the object has LocalValue structure
   */
  static isLocalValueObject(obj) {
    if (typeof obj !== "object" || obj === null) {
      return false;
    }
    if (!obj.hasOwnProperty(TYPE_CONSTANT)) {
      return false;
    }
    const type = obj[TYPE_CONSTANT];
    const hasTypeProperty = Object.values({ ...PrimitiveType, ...NonPrimitiveType }).includes(type);
    if (!hasTypeProperty) {
      return false;
    }
    if (type !== "null" /* Null */ && type !== "undefined" /* Undefined */) {
      return obj.hasOwnProperty(VALUE_CONSTANT);
    }
    return true;
  }
};

// src/utils/serialize.ts
function deserializeProperty(value) {
  if (typeof value !== "string" || !value.startsWith(SERIALIZED_PREFIX)) {
    return value;
  }
  return RemoteValue.fromLocalValue(JSON.parse(atob(value.slice(SERIALIZED_PREFIX.length))));
}

// src/runtime/parse-property-value.ts
var parsePropertyValue = (propValue, propType, isFormAssociated) => {
  if (typeof propValue === "string" && propValue.startsWith(SERIALIZED_PREFIX)) {
    propValue = deserializeProperty(propValue);
    return propValue;
  }
  if (propValue != null && !isComplexType(propValue)) {
    if (propType & 4 /* Boolean */) {
      {
        return propValue === "false" ? false : propValue === "" || !!propValue;
      }
    }
    if (propType & 2 /* Number */) {
      return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
    }
    if (propType & 1 /* String */) {
      return String(propValue);
    }
    return propValue;
  }
  return propValue;
};
var getElement = (ref) => {
  var _a;
  return (_a = getHostRef(ref)) == null ? void 0 : _a.$hostElement$ ;
};

// src/runtime/event-emitter.ts
var createEvent = (ref, name, flags) => {
  const elm = getElement(ref);
  return {
    emit: (detail) => {
      return emitEvent(elm, name, {
        bubbles: !!(flags & 4 /* Bubbles */),
        composed: !!(flags & 2 /* Composed */),
        cancelable: !!(flags & 1 /* Cancellable */),
        detail
      });
    }
  };
};
var emitEvent = (elm, name, opts) => {
  const ev = plt.ce(name, opts);
  elm.dispatchEvent(ev);
  return ev;
};
var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRender) => {
  if (oldValue === newValue) {
    return;
  }
  let isProp = isMemberInElement(elm, memberName);
  let ln = memberName.toLowerCase();
  if (memberName === "class") {
    const classList = elm.classList;
    const oldClasses = parseClassList(oldValue);
    let newClasses = parseClassList(newValue);
    if ((elm["s-si"] || elm["s-sc"]) && initialRender) {
      const scopeId2 = elm["s-sc"] || elm["s-si"];
      newClasses.push(scopeId2);
      oldClasses.forEach((c) => {
        if (c.startsWith(scopeId2)) newClasses.push(c);
      });
      newClasses = [...new Set(newClasses)].filter((c) => c);
      classList.add(...newClasses);
    } else {
      classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
      classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
    }
  } else if (memberName === "style") {
    {
      for (const prop in oldValue) {
        if (!newValue || newValue[prop] == null) {
          {
            elm.style[prop] = "";
          }
        }
      }
    }
    for (const prop in newValue) {
      if (!oldValue || newValue[prop] !== oldValue[prop]) {
        {
          elm.style[prop] = newValue[prop];
        }
      }
    }
  } else if (memberName === "key") ; else if (memberName === "ref") {
    if (newValue) {
      queueRefAttachment(newValue, elm);
    }
  } else if ((!isProp ) && memberName[0] === "o" && memberName[1] === "n") {
    if (memberName[2] === "-") {
      memberName = memberName.slice(3);
    } else if (isMemberInElement(win, ln)) {
      memberName = ln.slice(2);
    } else {
      memberName = ln[2] + memberName.slice(3);
    }
    if (oldValue || newValue) {
      const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
      memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
      if (oldValue) {
        plt.rel(elm, memberName, oldValue, capture);
      }
      if (newValue) {
        plt.ael(elm, memberName, newValue, capture);
      }
    }
  } else if (memberName[0] === "a" && memberName.startsWith("attr:")) {
    const propName = memberName.slice(5);
    let attrName;
    {
      const hostRef = getHostRef(elm);
      if (hostRef && hostRef.$cmpMeta$ && hostRef.$cmpMeta$.$members$) {
        const memberMeta = hostRef.$cmpMeta$.$members$[propName];
        if (memberMeta && memberMeta[1]) {
          attrName = memberMeta[1];
        }
      }
    }
    if (!attrName) {
      attrName = propName.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
    }
    if (newValue == null || newValue === false) {
      if (newValue !== false || elm.getAttribute(attrName) === "") {
        elm.removeAttribute(attrName);
      }
    } else {
      elm.setAttribute(attrName, newValue === true ? "" : newValue);
    }
    return;
  } else if (memberName[0] === "p" && memberName.startsWith("prop:")) {
    const propName = memberName.slice(5);
    try {
      elm[propName] = newValue;
    } catch (e) {
    }
    return;
  } else {
    const isComplex = isComplexType(newValue);
    if ((isProp || isComplex && newValue !== null) && !isSvg) {
      try {
        if (!elm.tagName.includes("-")) {
          const n = newValue == null ? "" : newValue;
          if (memberName === "list") {
            isProp = false;
          } else if (oldValue == null || elm[memberName] !== n) {
            if (typeof elm.__lookupSetter__(memberName) === "function") {
              elm[memberName] = n;
            } else {
              elm.setAttribute(memberName, n);
            }
          }
        } else if (elm[memberName] !== newValue) {
          elm[memberName] = newValue;
        }
      } catch (e) {
      }
    }
    let xlink = false;
    {
      if (ln !== (ln = ln.replace(/^xlink\:?/, ""))) {
        memberName = ln;
        xlink = true;
      }
    }
    if (newValue == null || newValue === false) {
      if (newValue !== false || elm.getAttribute(memberName) === "") {
        if (xlink) {
          elm.removeAttributeNS(XLINK_NS, memberName);
        } else {
          elm.removeAttribute(memberName);
        }
      }
    } else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex && elm.nodeType === 1 /* ElementNode */) {
      newValue = newValue === true ? "" : newValue;
      if (xlink) {
        elm.setAttributeNS(XLINK_NS, memberName, newValue);
      } else {
        elm.setAttribute(memberName, newValue);
      }
    }
  }
};
var parseClassListRegex = /\s/;
var parseClassList = (value) => {
  if (typeof value === "object" && value && "baseVal" in value) {
    value = value.baseVal;
  }
  if (!value || typeof value !== "string") {
    return [];
  }
  return value.split(parseClassListRegex);
};
var CAPTURE_EVENT_SUFFIX = "Capture";
var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");

// src/runtime/vdom/update-element.ts
var updateElement = (oldVnode, newVnode, isSvgMode2, isInitialRender) => {
  const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
  const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
  const newVnodeAttrs = newVnode.$attrs$ || {};
  {
    for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
      if (!(memberName in newVnodeAttrs)) {
        setAccessor(
          elm,
          memberName,
          oldVnodeAttrs[memberName],
          void 0,
          isSvgMode2,
          newVnode.$flags$,
          isInitialRender
        );
      }
    }
  }
  for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
    setAccessor(
      elm,
      memberName,
      oldVnodeAttrs[memberName],
      newVnodeAttrs[memberName],
      isSvgMode2,
      newVnode.$flags$,
      isInitialRender
    );
  }
};
function sortedAttrNames(attrNames) {
  return attrNames.includes("ref") ? (
    // we need to sort these to ensure that `'ref'` is the last attr
    [...attrNames.filter((attr) => attr !== "ref"), "ref"]
  ) : (
    // no need to sort, return the original array
    attrNames
  );
}
var contentRef;
var hostTagName;
var useNativeShadowDom = false;
var checkSlotFallbackVisibility = false;
var checkSlotRelocate = false;
var isSvgMode = false;
var refCallbacksToRemove = [];
var refCallbacksToAttach = [];
var createElm = (oldParentVNode, newParentVNode, childIndex) => {
  var _a;
  const newVNode2 = newParentVNode.$children$[childIndex];
  let i2 = 0;
  let elm;
  let childNode;
  let oldVNode;
  if (!useNativeShadowDom) {
    checkSlotRelocate = true;
    if (newVNode2.$tag$ === "slot") {
      newVNode2.$flags$ |= newVNode2.$children$ ? (
        // slot element has fallback content
        // still create an element that "mocks" the slot element
        2 /* isSlotFallback */
      ) : (
        // slot element does not have fallback content
        // create an html comment we'll use to always reference
        // where actual slot content should sit next to
        1 /* isSlotReference */
      );
    }
  }
  if (newVNode2.$text$ != null) {
    elm = newVNode2.$elm$ = win.document.createTextNode(newVNode2.$text$);
  } else if (newVNode2.$flags$ & 1 /* isSlotReference */) {
    elm = newVNode2.$elm$ = slotReferenceDebugNode(newVNode2) ;
    {
      updateElement(null, newVNode2, isSvgMode);
    }
  } else {
    if (!isSvgMode) {
      isSvgMode = newVNode2.$tag$ === "svg";
    }
    if (!win.document) {
      throw new Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.");
    }
    elm = newVNode2.$elm$ = win.document.createElementNS(
      isSvgMode ? SVG_NS : HTML_NS,
      !useNativeShadowDom && BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
    ) ;
    if (isSvgMode && newVNode2.$tag$ === "foreignObject") {
      isSvgMode = false;
    }
    {
      updateElement(null, newVNode2, isSvgMode);
    }
    if (newVNode2.$children$) {
      const appendTarget = newVNode2.$tag$ === "template" ? elm.content : elm;
      for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
        childNode = createElm(oldParentVNode, newVNode2, i2);
        if (childNode) {
          appendTarget.appendChild(childNode);
        }
      }
    }
    {
      if (newVNode2.$tag$ === "svg") {
        isSvgMode = false;
      } else if (elm.tagName === "foreignObject") {
        isSvgMode = true;
      }
    }
  }
  elm["s-hn"] = hostTagName;
  {
    if (newVNode2.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
      elm["s-sr"] = true;
      elm["s-cr"] = contentRef;
      elm["s-sn"] = newVNode2.$name$ || "";
      elm["s-rf"] = (_a = newVNode2.$attrs$) == null ? void 0 : _a.ref;
      patchSlotNode(elm);
      oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
      if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
        relocateToHostRoot(oldParentVNode.$elm$);
      }
      {
        addRemoveSlotScopedClass(contentRef, elm, newParentVNode.$elm$, oldParentVNode == null ? void 0 : oldParentVNode.$elm$);
      }
    }
  }
  return elm;
};
var relocateToHostRoot = (parentElm) => {
  plt.$flags$ |= 1 /* isTmpDisconnected */;
  const host = parentElm.closest(hostTagName.toLowerCase());
  if (host != null) {
    const contentRefNode = Array.from(host.__childNodes || host.childNodes).find(
      (ref) => ref["s-cr"]
    );
    const childNodeArray = Array.from(
      parentElm.__childNodes || parentElm.childNodes
    );
    for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
      if (childNode["s-sh"] != null) {
        insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
        childNode["s-sh"] = void 0;
        checkSlotRelocate = true;
      }
    }
  }
  plt.$flags$ &= -2 /* isTmpDisconnected */;
};
var putBackInOriginalLocation = (parentElm, recursive) => {
  plt.$flags$ |= 1 /* isTmpDisconnected */;
  const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
  if (parentElm["s-sr"]) {
    let node = parentElm;
    while (node = node.nextSibling) {
      if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
        oldSlotChildNodes.push(node);
      }
    }
  }
  for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
    const childNode = oldSlotChildNodes[i2];
    if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
      insertBefore(referenceNode(childNode).parentNode, childNode, referenceNode(childNode));
      childNode["s-ol"].remove();
      childNode["s-ol"] = void 0;
      childNode["s-sh"] = void 0;
      checkSlotRelocate = true;
    }
    if (recursive) {
      putBackInOriginalLocation(childNode, recursive);
    }
  }
  plt.$flags$ &= -2 /* isTmpDisconnected */;
};
var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
  let containerElm = parentElm["s-cr"] && parentElm["s-cr"].parentNode || parentElm;
  let childNode;
  if (parentVNode.$tag$ === "template") {
    containerElm = containerElm.content;
  }
  for (; startIdx <= endIdx; ++startIdx) {
    if (vnodes[startIdx]) {
      childNode = createElm(null, parentVNode, startIdx);
      if (childNode) {
        vnodes[startIdx].$elm$ = childNode;
        insertBefore(containerElm, childNode, referenceNode(before) );
      }
    }
  }
};
var removeVnodes = (vnodes, startIdx, endIdx) => {
  for (let index = startIdx; index <= endIdx; ++index) {
    const vnode = vnodes[index];
    if (vnode) {
      const elm = vnode.$elm$;
      nullifyVNodeRefs(vnode);
      if (elm) {
        {
          checkSlotFallbackVisibility = true;
          if (elm["s-ol"]) {
            elm["s-ol"].remove();
          } else {
            putBackInOriginalLocation(elm, true);
          }
        }
        elm.remove();
      }
    }
  }
};
var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
  let oldStartIdx = 0;
  let newStartIdx = 0;
  let idxInOld = 0;
  let i2 = 0;
  let oldEndIdx = oldCh.length - 1;
  let oldStartVnode = oldCh[0];
  let oldEndVnode = oldCh[oldEndIdx];
  let newEndIdx = newCh.length - 1;
  let newStartVnode = newCh[0];
  let newEndVnode = newCh[newEndIdx];
  let node;
  let elmToMove;
  const containerElm = newVNode2.$tag$ === "template" ? parentElm.content : parentElm;
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
    if (oldStartVnode == null) {
      oldStartVnode = oldCh[++oldStartIdx];
    } else if (oldEndVnode == null) {
      oldEndVnode = oldCh[--oldEndIdx];
    } else if (newStartVnode == null) {
      newStartVnode = newCh[++newStartIdx];
    } else if (newEndVnode == null) {
      newEndVnode = newCh[--newEndIdx];
    } else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
      patch(oldStartVnode, newStartVnode, isInitialRender);
      oldStartVnode = oldCh[++oldStartIdx];
      newStartVnode = newCh[++newStartIdx];
    } else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
      patch(oldEndVnode, newEndVnode, isInitialRender);
      oldEndVnode = oldCh[--oldEndIdx];
      newEndVnode = newCh[--newEndIdx];
    } else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
      if ((oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
        putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
      }
      patch(oldStartVnode, newEndVnode, isInitialRender);
      insertBefore(containerElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
      oldStartVnode = oldCh[++oldStartIdx];
      newEndVnode = newCh[--newEndIdx];
    } else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
      if ((oldStartVnode.$tag$ === "slot" || newEndVnode.$tag$ === "slot")) {
        putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
      }
      patch(oldEndVnode, newStartVnode, isInitialRender);
      insertBefore(containerElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
      oldEndVnode = oldCh[--oldEndIdx];
      newStartVnode = newCh[++newStartIdx];
    } else {
      idxInOld = -1;
      {
        for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
          if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
            idxInOld = i2;
            break;
          }
        }
      }
      if (idxInOld >= 0) {
        elmToMove = oldCh[idxInOld];
        if (elmToMove.$tag$ !== newStartVnode.$tag$) {
          node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
        } else {
          patch(elmToMove, newStartVnode, isInitialRender);
          oldCh[idxInOld] = void 0;
          node = elmToMove.$elm$;
        }
        newStartVnode = newCh[++newStartIdx];
      } else {
        node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
        newStartVnode = newCh[++newStartIdx];
      }
      if (node) {
        {
          insertBefore(
            referenceNode(oldStartVnode.$elm$).parentNode,
            node,
            referenceNode(oldStartVnode.$elm$)
          );
        }
      }
    }
  }
  if (oldStartIdx > oldEndIdx) {
    addVnodes(
      parentElm,
      newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
      newVNode2,
      newCh,
      newStartIdx,
      newEndIdx
    );
  } else if (newStartIdx > newEndIdx) {
    removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  }
};
var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
  if (leftVNode.$tag$ === rightVNode.$tag$) {
    if (leftVNode.$tag$ === "slot") {
      return leftVNode.$name$ === rightVNode.$name$;
    }
    if (!isInitialRender) {
      return leftVNode.$key$ === rightVNode.$key$;
    }
    if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
      leftVNode.$key$ = rightVNode.$key$;
    }
    return true;
  }
  return false;
};
var referenceNode = (node) => node && node["s-ol"] || node;
var patch = (oldVNode, newVNode2, isInitialRender = false) => {
  const elm = newVNode2.$elm$ = oldVNode.$elm$;
  const oldChildren = oldVNode.$children$;
  const newChildren = newVNode2.$children$;
  const tag = newVNode2.$tag$;
  const text = newVNode2.$text$;
  let defaultHolder;
  if (text == null) {
    {
      isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
    }
    {
      if (tag === "slot" && !useNativeShadowDom) {
        if (oldVNode.$name$ !== newVNode2.$name$) {
          newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
          relocateToHostRoot(newVNode2.$elm$.parentElement);
        }
      }
      updateElement(oldVNode, newVNode2, isSvgMode, isInitialRender);
    }
    if (oldChildren !== null && newChildren !== null) {
      updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
    } else if (newChildren !== null) {
      if (oldVNode.$text$ !== null) {
        elm.textContent = "";
      }
      addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
    } else if (
      // don't do this on initial render as it can cause non-hydrated content to be removed
      !isInitialRender && BUILD.updatable && oldChildren !== null
    ) {
      removeVnodes(oldChildren, 0, oldChildren.length - 1);
    } else if (isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) {
      newVNode2.$children$ = oldChildren;
    }
    if (isSvgMode && tag === "svg") {
      isSvgMode = false;
    }
  } else if ((defaultHolder = elm["s-cr"])) {
    defaultHolder.parentNode.textContent = text;
  } else if (oldVNode.$text$ !== text) {
    elm.data = text;
  }
};
var relocateNodes = [];
var markSlotContentForRelocation = (elm) => {
  let node;
  let hostContentNodes;
  let j;
  const children = elm.__childNodes || elm.childNodes;
  for (const childNode of children) {
    if (childNode["s-sr"] && (node = childNode["s-cr"]) && node.parentNode) {
      hostContentNodes = node.parentNode.__childNodes || node.parentNode.childNodes;
      const slotName = childNode["s-sn"];
      for (j = hostContentNodes.length - 1; j >= 0; j--) {
        node = hostContentNodes[j];
        if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
          if (isNodeLocatedInSlot(node, slotName)) {
            let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
            checkSlotFallbackVisibility = true;
            node["s-sn"] = node["s-sn"] || slotName;
            if (relocateNodeData) {
              relocateNodeData.$nodeToRelocate$["s-sh"] = childNode["s-hn"];
              relocateNodeData.$slotRefNode$ = childNode;
            } else {
              node["s-sh"] = childNode["s-hn"];
              relocateNodes.push({
                $slotRefNode$: childNode,
                $nodeToRelocate$: node
              });
            }
            if (node["s-sr"]) {
              relocateNodes.map((relocateNode) => {
                if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node["s-sn"])) {
                  relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
                  if (relocateNodeData && !relocateNode.$slotRefNode$) {
                    relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
                  }
                }
              });
            }
          } else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
            relocateNodes.push({
              $nodeToRelocate$: node
            });
          }
        }
      }
    }
    if (childNode.nodeType === 1 /* ElementNode */) {
      markSlotContentForRelocation(childNode);
    }
  }
};
var nullifyVNodeRefs = (vNode) => {
  {
    if (vNode.$attrs$ && vNode.$attrs$.ref) {
      refCallbacksToRemove.push(() => vNode.$attrs$.ref(null));
    }
    vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
  }
};
var queueRefAttachment = (refCallback, elm) => {
  {
    refCallbacksToAttach.push(() => refCallback(elm));
  }
};
var flushQueuedRefCallbacks = () => {
  {
    refCallbacksToRemove.forEach((cb) => cb());
    refCallbacksToRemove.length = 0;
    refCallbacksToAttach.forEach((cb) => cb());
    refCallbacksToAttach.length = 0;
  }
};
var insertBefore = (parent, newNode, reference, isInitialLoad) => {
  {
    if (typeof newNode["s-sn"] === "string") {
      parent.insertBefore(newNode, reference);
      const { slotNode } = findSlotFromSlottedNode(newNode);
      if (slotNode && !isInitialLoad) dispatchSlotChangeEvent(slotNode);
      return newNode;
    }
  }
  if (parent.__insertBefore) {
    return parent.__insertBefore(newNode, reference);
  } else {
    return parent == null ? void 0 : parent.insertBefore(newNode, reference);
  }
};
function addRemoveSlotScopedClass(reference, slotNode, newParent, oldParent) {
  var _a, _b;
  let scopeId2;
  if (reference && typeof slotNode["s-sn"] === "string" && !!slotNode["s-sr"] && reference.parentNode && reference.parentNode["s-sc"] && (scopeId2 = slotNode["s-si"] || reference.parentNode["s-sc"])) {
    const scopeName = slotNode["s-sn"];
    const hostName = slotNode["s-hn"];
    (_a = newParent.classList) == null ? void 0 : _a.add(scopeId2 + "-s");
    if (oldParent && ((_b = oldParent.classList) == null ? void 0 : _b.contains(scopeId2 + "-s"))) {
      let child = (oldParent.__childNodes || oldParent.childNodes)[0];
      let found = false;
      while (child) {
        if (child["s-sn"] !== scopeName && child["s-hn"] === hostName && !!child["s-sr"]) {
          found = true;
          break;
        }
        child = child.nextSibling;
      }
      if (!found) oldParent.classList.remove(scopeId2 + "-s");
    }
  }
}
var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
  var _a, _d, _e;
  const hostElm = hostRef.$hostElement$;
  const cmpMeta = hostRef.$cmpMeta$;
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
  const isHostElement = isHost(renderFnResults);
  const rootVnode = isHostElement ? renderFnResults : h(null, null, renderFnResults);
  hostTagName = hostElm.tagName;
  if (cmpMeta.$attrsToReflect$) {
    rootVnode.$attrs$ = rootVnode.$attrs$ || {};
    cmpMeta.$attrsToReflect$.forEach(([propName, attribute]) => {
      {
        rootVnode.$attrs$[attribute] = hostElm[propName];
      }
    });
  }
  if (isInitialLoad && rootVnode.$attrs$) {
    for (const key of Object.keys(rootVnode.$attrs$)) {
      if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
        rootVnode.$attrs$[key] = hostElm[key];
      }
    }
  }
  rootVnode.$tag$ = null;
  rootVnode.$flags$ |= 4 /* isHost */;
  hostRef.$vnode$ = rootVnode;
  rootVnode.$elm$ = oldVNode.$elm$ = hostElm;
  useNativeShadowDom = supportsShadow;
  {
    contentRef = hostElm["s-cr"];
    checkSlotFallbackVisibility = false;
  }
  patch(oldVNode, rootVnode, isInitialLoad);
  {
    plt.$flags$ |= 1 /* isTmpDisconnected */;
    if (checkSlotRelocate) {
      markSlotContentForRelocation(rootVnode.$elm$);
      for (const relocateData of relocateNodes) {
        const nodeToRelocate = relocateData.$nodeToRelocate$;
        if (!nodeToRelocate["s-ol"] && win.document) {
          const orgLocationNode = originalLocationDebugNode(nodeToRelocate) ;
          orgLocationNode["s-nr"] = nodeToRelocate;
          insertBefore(
            nodeToRelocate.parentNode,
            nodeToRelocate["s-ol"] = orgLocationNode,
            nodeToRelocate,
            isInitialLoad
          );
        }
      }
      for (const relocateData of relocateNodes) {
        const nodeToRelocate = relocateData.$nodeToRelocate$;
        const slotRefNode = relocateData.$slotRefNode$;
        if (nodeToRelocate.nodeType === 1 /* ElementNode */ && isInitialLoad) {
          nodeToRelocate["s-ih"] = (_a = nodeToRelocate.hidden) != null ? _a : false;
        }
        if (slotRefNode) {
          const parentNodeRef = slotRefNode.parentNode;
          let insertBeforeNode = slotRefNode.nextSibling;
          const parent = nodeToRelocate.__parentNode || nodeToRelocate.parentNode;
          const nextSibling = nodeToRelocate.__nextSibling || nodeToRelocate.nextSibling;
          if (!insertBeforeNode && parentNodeRef !== parent || nextSibling !== insertBeforeNode) {
            if (nodeToRelocate !== insertBeforeNode) {
              insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode, isInitialLoad);
              if (nodeToRelocate.nodeType === 8 /* CommentNode */ && nodeToRelocate.nodeValue.startsWith("s-nt-")) {
                const textNode = win.document.createTextNode(nodeToRelocate.nodeValue.replace(/^s-nt-/, ""));
                textNode["s-hn"] = nodeToRelocate["s-hn"];
                textNode["s-sn"] = nodeToRelocate["s-sn"];
                textNode["s-sh"] = nodeToRelocate["s-sh"];
                textNode["s-sr"] = nodeToRelocate["s-sr"];
                textNode["s-ol"] = nodeToRelocate["s-ol"];
                textNode["s-ol"]["s-nr"] = textNode;
                insertBefore(nodeToRelocate.parentNode, textNode, nodeToRelocate, isInitialLoad);
                nodeToRelocate.parentNode.removeChild(nodeToRelocate);
              }
              if (nodeToRelocate.nodeType === 1 /* ElementNode */ && nodeToRelocate.tagName !== "SLOT-FB") {
                nodeToRelocate.hidden = (_d = nodeToRelocate["s-ih"]) != null ? _d : false;
              }
            }
          }
          nodeToRelocate && typeof slotRefNode["s-rf"] === "function" && slotRefNode["s-rf"](slotRefNode);
        } else if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
          nodeToRelocate.hidden = true;
        }
      }
    }
    if (checkSlotFallbackVisibility) {
      updateFallbackSlotVisibility(rootVnode.$elm$);
    }
    plt.$flags$ &= -2 /* isTmpDisconnected */;
    relocateNodes.length = 0;
  }
  if (!useNativeShadowDom && !(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) && hostElm["s-cr"]) {
    const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
    for (const childNode of children) {
      if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
        if (isInitialLoad && childNode["s-ih"] == null) {
          childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
        }
        if (childNode.nodeType === 1 /* ElementNode */) {
          childNode.hidden = true;
        } else if (childNode.nodeType === 3 /* TextNode */ && !!childNode.nodeValue.trim()) {
          const textCommentNode = win.document.createComment("s-nt-" + childNode.nodeValue);
          textCommentNode["s-sn"] = childNode["s-sn"];
          insertBefore(childNode.parentNode, textCommentNode, childNode, isInitialLoad);
          childNode.parentNode.removeChild(childNode);
        }
      }
    }
  }
  contentRef = void 0;
  flushQueuedRefCallbacks();
};
var slotReferenceDebugNode = (slotVNode) => {
  var _a;
  return (_a = win.document) == null ? void 0 : _a.createComment(
    `<slot${slotVNode.$name$ ? ' name="' + slotVNode.$name$ + '"' : ""}> (host=${hostTagName.toLowerCase()})`
  );
};
var originalLocationDebugNode = (nodeToRelocate) => {
  var _a;
  return (_a = win.document) == null ? void 0 : _a.createComment(
    `org-location for ` + (nodeToRelocate.localName ? `<${nodeToRelocate.localName}> (host=${nodeToRelocate["s-hn"]})` : `[${nodeToRelocate.textContent}]`)
  );
};

// src/runtime/update-component.ts
var attachToAncestor = (hostRef, ancestorComponent) => {
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
    const index = ancestorComponent["s-p"].push(
      new Promise(
        (r) => hostRef.$onRenderResolve$ = () => {
          ancestorComponent["s-p"].splice(index - 1, 1);
          r();
        }
      )
    );
  }
};
var scheduleUpdate = (hostRef, isInitialLoad) => {
  {
    hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
  }
  if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
    hostRef.$flags$ |= 512 /* needsRerender */;
    return;
  }
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
  if (isInitialLoad) {
    queueMicrotask(() => {
      dispatch();
    });
    return;
  }
  return writeTask(dispatch) ;
};
var dispatchHooks = (hostRef, isInitialLoad) => {
  const elm = hostRef.$hostElement$;
  const endSchedule = createTime("scheduleUpdate", hostRef.$cmpMeta$.$tagName$);
  const instance = hostRef.$lazyInstance$ ;
  if (!instance) {
    throw new Error(
      `Can't render component <${elm.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`
    );
  }
  let maybePromise;
  if (isInitialLoad) {
    {
      if (hostRef.$deferredConnectedCallback$) {
        hostRef.$deferredConnectedCallback$ = false;
        safeCall(instance, "connectedCallback", void 0, elm);
      }
      {
        hostRef.$flags$ |= 256 /* isListenReady */;
        if (hostRef.$queuedListeners$) {
          hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event, elm));
          hostRef.$queuedListeners$ = void 0;
        }
      }
      if (hostRef.$fetchedCbList$.length) {
        hostRef.$fetchedCbList$.forEach((cb) => cb(elm));
      }
    }
    maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
  } else {
    maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
  }
  maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender", void 0, elm));
  endSchedule();
  return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
};
var enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn).catch((err2) => {
  console.error(err2);
  fn();
}) : fn();
var isPromisey = (maybePromise) => maybePromise instanceof Promise || maybePromise && maybePromise.then && typeof maybePromise.then === "function";
var updateComponent = async (hostRef, instance, isInitialLoad) => {
  var _a;
  const elm = hostRef.$hostElement$;
  const endUpdate = createTime("update", hostRef.$cmpMeta$.$tagName$);
  const rc = elm["s-rc"];
  if (isInitialLoad) {
    attachStyles(hostRef);
  }
  const endRender = createTime("render", hostRef.$cmpMeta$.$tagName$);
  {
    await callRender(hostRef, instance, elm, isInitialLoad);
  }
  {
    try {
      serverSideConnected(elm);
      if (isInitialLoad) {
        if (hostRef.$cmpMeta$.$flags$ & 1 /* shadowDomEncapsulation */) {
          elm["s-en"] = "";
        } else if (hostRef.$cmpMeta$.$flags$ & 2 /* scopedCssEncapsulation */) {
          elm["s-en"] = "c";
        }
      }
    } catch (e) {
      consoleError(e, elm);
    }
  }
  if (rc) {
    rc.map((cb) => cb());
    elm["s-rc"] = void 0;
  }
  endRender();
  endUpdate();
  {
    const childrenPromises = (_a = elm["s-p"]) != null ? _a : [];
    const postUpdate = () => postUpdateComponent(hostRef);
    if (childrenPromises.length === 0) {
      postUpdate();
    } else {
      Promise.all(childrenPromises).then(postUpdate).catch(postUpdate);
      hostRef.$flags$ |= 4 /* isWaitingForChildren */;
      childrenPromises.length = 0;
    }
  }
};
var callRender = (hostRef, instance, elm, isInitialLoad) => {
  try {
    instance = instance.render() ;
    {
      hostRef.$flags$ &= -17 /* isQueuedForUpdate */;
    }
    {
      hostRef.$flags$ |= 2 /* hasRendered */;
    }
    {
      {
        {
          return Promise.resolve(instance).then((value) => renderVdom(hostRef, value, isInitialLoad));
        }
      }
    }
  } catch (e) {
    consoleError(e, hostRef.$hostElement$);
  }
  return null;
};
var postUpdateComponent = (hostRef) => {
  const tagName = hostRef.$cmpMeta$.$tagName$;
  const elm = hostRef.$hostElement$;
  const endPostUpdate = createTime("postUpdate", tagName);
  const instance = hostRef.$lazyInstance$ ;
  const ancestorComponent = hostRef.$ancestorComponent$;
  safeCall(instance, "componentDidRender", void 0, elm);
  if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
    hostRef.$flags$ |= 64 /* hasLoadedComponent */;
    {
      addHydratedFlag(elm);
    }
    safeCall(instance, "componentDidLoad", void 0, elm);
    endPostUpdate();
    {
      hostRef.$onReadyResolve$(elm);
      if (!ancestorComponent) {
        appDidLoad();
      }
    }
  } else {
    safeCall(instance, "componentDidUpdate", void 0, elm);
    endPostUpdate();
  }
  {
    hostRef.$onInstanceResolve$(elm);
  }
  {
    if (hostRef.$onRenderResolve$) {
      hostRef.$onRenderResolve$();
      hostRef.$onRenderResolve$ = void 0;
    }
    if (hostRef.$flags$ & 512 /* needsRerender */) {
      nextTick(() => scheduleUpdate(hostRef, false));
    }
    hostRef.$flags$ &= -517;
  }
};
var forceUpdate = (ref) => {
  return false;
};
var appDidLoad = (who) => {
  var _a;
  if (BUILD.asyncQueue) {
    plt.$flags$ |= 2 /* appLoaded */;
  }
  nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
  {
    if ((_a = plt.$orgLocNodes$) == null ? void 0 : _a.size) {
      plt.$orgLocNodes$.clear();
    }
  }
};
var safeCall = (instance, method, arg, elm) => {
  if (instance && instance[method]) {
    try {
      return instance[method](arg);
    } catch (e) {
      consoleError(e, elm);
    }
  }
  return void 0;
};
var addHydratedFlag = (elm) => {
  var _a;
  return elm.classList.add((_a = BUILD.hydratedSelectorName) != null ? _a : "hydrated") ;
};
var serverSideConnected = (elm) => {
  const children = elm.children;
  if (children != null) {
    for (let i2 = 0, ii = children.length; i2 < ii; i2++) {
      const childElm = children[i2];
      if (typeof childElm.connectedCallback === "function") {
        childElm.connectedCallback();
      }
      serverSideConnected(childElm);
    }
  }
};

// src/runtime/set-value.ts
var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
var setValue = (ref, propName, newVal, cmpMeta) => {
  const hostRef = getHostRef(ref);
  if (!hostRef) {
    return;
  }
  if (!hostRef) {
    throw new Error(
      `Couldn't find host element for "${cmpMeta.$tagName$}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/stenciljs/core/issues/5457).`
    );
  }
  const elm = hostRef.$hostElement$ ;
  const oldVal = hostRef.$instanceValues$.get(propName);
  const flags = hostRef.$flags$;
  const instance = hostRef.$lazyInstance$ ;
  newVal = parsePropertyValue(
    newVal,
    cmpMeta.$members$[propName][0]);
  const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
  const didValueChange = newVal !== oldVal && !areBothNaN;
  if ((!(flags & 8 /* isConstructingInstance */) || oldVal === void 0) && didValueChange) {
    hostRef.$instanceValues$.set(propName, newVal);
    if (cmpMeta.$watchers$) {
      const watchMethods = cmpMeta.$watchers$[propName];
      if (watchMethods) {
        watchMethods.map((watcher) => {
          try {
            const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
            if (flags & 128 /* isWatchReady */ || watcherFlags & 1 /* Immediate */) {
              if (!instance) {
                hostRef.$fetchedCbList$.push(() => {
                  hostRef.$lazyInstance$[watchMethodName](newVal, oldVal, propName);
                });
              } else {
                instance[watchMethodName](newVal, oldVal, propName);
              }
            }
          } catch (e) {
            consoleError(e, elm);
          }
        });
      }
    }
    if (flags & 2 /* hasRendered */) {
      if (instance.componentShouldUpdate) {
        const shouldUpdate = instance.componentShouldUpdate(newVal, oldVal, propName);
        if (shouldUpdate === false && !(flags & 16 /* isQueuedForUpdate */)) {
          return;
        }
      }
      if (!(flags & 16 /* isQueuedForUpdate */)) {
        scheduleUpdate(hostRef, false);
      }
    }
  }
};

// src/runtime/proxy-component.ts
var proxyComponent = (Cstr, cmpMeta, flags) => {
  var _a;
  const prototype = Cstr.prototype;
  {
    {
      if (Cstr.watchers && !cmpMeta.$watchers$) {
        cmpMeta.$watchers$ = Cstr.watchers;
      }
      if (Cstr.deserializers && !cmpMeta.$deserializers$) {
        cmpMeta.$deserializers$ = Cstr.deserializers;
      }
      if (Cstr.serializers && !cmpMeta.$serializers$) {
        cmpMeta.$serializers$ = Cstr.serializers;
      }
    }
    const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
    members.map(([memberName, [memberFlags]]) => {
      if ((memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
        const { get: origGetter, set: origSetter } = getPropertyDescriptor(prototype, memberName) || {};
        if (origGetter) cmpMeta.$members$[memberName][0] |= 2048 /* Getter */;
        if (origSetter) cmpMeta.$members$[memberName][0] |= 4096 /* Setter */;
        if (!origGetter) {
          Object.defineProperty(prototype, memberName, {
            get() {
              {
                if ((cmpMeta.$members$[memberName][0] & 2048 /* Getter */) === 0) {
                  return getValue(this, memberName);
                }
                const ref = getHostRef(this);
                const instance = ref ? ref.$lazyInstance$ : prototype;
                if (!instance) return;
                return instance[memberName];
              }
            },
            configurable: true,
            enumerable: true
          });
        }
        Object.defineProperty(prototype, memberName, {
          set(newValue) {
            const ref = getHostRef(this);
            if (!ref) {
              return;
            }
            if (origSetter) {
              const currentValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
              if (typeof currentValue === "undefined" && ref.$instanceValues$.get(memberName)) {
                newValue = ref.$instanceValues$.get(memberName);
              }
              origSetter.apply(this, [
                parsePropertyValue(
                  newValue,
                  memberFlags)
              ]);
              newValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
              setValue(this, memberName, newValue, cmpMeta);
              return;
            }
            {
              {
                setValue(this, memberName, newValue, cmpMeta);
                return;
              }
            }
          }
        });
      }
    });
  }
  return Cstr;
};

// src/runtime/initialize-component.ts
var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
  let Cstr;
  try {
    if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
      hostRef.$flags$ |= 32 /* hasInitializedComponent */;
      const bundleId = cmpMeta.$lazyBundleId$;
      if (bundleId) {
        const CstrImport = loadModule(cmpMeta);
        if (CstrImport && "then" in CstrImport) {
          const endLoad = uniqueTime();
          Cstr = await CstrImport;
          endLoad();
        } else {
          Cstr = CstrImport;
        }
        if (!Cstr) {
          throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
        }
        if (!Cstr.isProxied) {
          {
            cmpMeta.$watchers$ = Cstr.watchers;
            cmpMeta.$serializers$ = Cstr.serializers;
            cmpMeta.$deserializers$ = Cstr.deserializers;
          }
          proxyComponent(Cstr, cmpMeta);
          Cstr.isProxied = true;
        }
        const endNewInstance = createTime("createInstance", cmpMeta.$tagName$);
        {
          hostRef.$flags$ |= 8 /* isConstructingInstance */;
        }
        try {
          new Cstr(hostRef);
        } catch (e) {
          consoleError(e, elm);
        }
        {
          hostRef.$flags$ &= -9 /* isConstructingInstance */;
        }
        {
          hostRef.$flags$ |= 128 /* isWatchReady */;
        }
        endNewInstance();
        const needsDeferredCallback = cmpMeta.$flags$ & 4 /* hasSlotRelocation */;
        if (!needsDeferredCallback) {
          fireConnectedCallback(hostRef.$lazyInstance$, elm);
        } else {
          hostRef.$deferredConnectedCallback$ = true;
        }
      } else {
        Cstr = elm.constructor;
        const cmpTag = elm.localName;
        customElements.whenDefined(cmpTag).then(() => hostRef.$flags$ |= 128 /* isWatchReady */);
      }
      if (Cstr && Cstr.style) {
        let style;
        if (typeof Cstr.style === "string") {
          style = Cstr.style;
        }
        const scopeId2 = getScopeId(cmpMeta);
        if (!styles.has(scopeId2) || BUILD.hotModuleReplacement) {
          const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
          registerStyle(scopeId2, style);
          endRegisterStyles();
        }
      }
    }
    const ancestorComponent = hostRef.$ancestorComponent$;
    const schedule = () => scheduleUpdate(hostRef, true);
    if (ancestorComponent && ancestorComponent["s-rc"]) {
      ancestorComponent["s-rc"].push(schedule);
    } else {
      schedule();
    }
  } catch (e) {
    consoleError(e, elm);
    if (hostRef.$onRenderResolve$) {
      hostRef.$onRenderResolve$();
      hostRef.$onRenderResolve$ = void 0;
    }
    if (hostRef.$onReadyResolve$) {
      hostRef.$onReadyResolve$(elm);
    }
  }
};
var fireConnectedCallback = (instance, elm) => {
  {
    safeCall(instance, "connectedCallback", void 0, elm);
  }
};

// src/runtime/connected-callback.ts
var connectedCallback = (elm) => {
  if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
    const hostRef = getHostRef(elm);
    if (!hostRef) {
      return;
    }
    const cmpMeta = hostRef.$cmpMeta$;
    const endConnected = createTime("connectedCallback", cmpMeta.$tagName$);
    if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
      hostRef.$flags$ |= 1 /* hasConnected */;
      let hostId;
      {
        hostId = elm.getAttribute(HYDRATE_ID);
        if (hostId) {
          initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
        }
      }
      if (!hostId) {
        {
          setContentReference(elm);
        }
      }
      {
        let ancestorComponent = elm;
        while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
          if (ancestorComponent.nodeType === 1 /* ElementNode */ && ancestorComponent.hasAttribute("s-id") && ancestorComponent["s-p"] || ancestorComponent["s-p"]) {
            attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
            break;
          }
        }
      }
      if (BUILD.initializeNextTick) {
        nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
      } else {
        initializeComponent(elm, hostRef, cmpMeta);
      }
    } else {
      addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
      if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
        fireConnectedCallback(hostRef.$lazyInstance$, elm);
      } else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
        hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$, elm));
      }
    }
    endConnected();
  }
};
var setContentReference = (elm) => {
  if (!win.document) {
    return;
  }
  const contentRefElm = elm["s-cr"] = win.document.createComment(
    ""
  );
  contentRefElm["s-cn"] = true;
  insertBefore(elm, contentRefElm, elm.firstChild);
};

// src/runtime/fragment.ts
var Fragment = (_, children) => children;
var addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
  if (listeners && win.document) {
    listeners.map(([flags, name, method]) => {
      const target = getHostListenerTarget(win.document, elm, flags) ;
      const handler = hostListenerProxy(hostRef, method);
      const opts = hostListenerOpts(flags);
      plt.ael(target, name, handler, opts);
      (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
    });
  }
};
var hostListenerProxy = (hostRef, methodName) => (ev) => {
  var _a;
  try {
    {
      if (hostRef.$flags$ & 256 /* isListenReady */) {
        (_a = hostRef.$lazyInstance$) == null ? void 0 : _a[methodName](ev);
      } else {
        (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
      }
    }
  } catch (e) {
    consoleError(e, hostRef.$hostElement$);
  }
};
var getHostListenerTarget = (doc, elm, flags) => {
  if (flags & 8 /* TargetWindow */) {
    return win;
  }
  return elm;
};
var hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
var baseClass = class {
} ;
function Mixin(...mixins) {
  return mixins.reduceRight((acc, mixin) => mixin(acc), baseClass);
}
function transformTag(tag) {
  return tag;
}

// src/runtime/vdom/vdom-annotations.ts
var insertVdomAnnotations = (doc, staticComponents) => {
  if (doc != null) {
    const docData = STENCIL_DOC_DATA in doc ? doc[STENCIL_DOC_DATA] : { ...DEFAULT_DOC_DATA };
    docData.staticComponents = new Set(staticComponents);
    const orgLocationNodes = [];
    parseVNodeAnnotations(doc, doc.body, docData, orgLocationNodes);
    orgLocationNodes.forEach((orgLocationNode) => {
      var _a;
      if (orgLocationNode != null && orgLocationNode["s-nr"]) {
        const nodeRef = orgLocationNode["s-nr"];
        let hostId = nodeRef["s-host-id"];
        let nodeId = nodeRef["s-node-id"];
        let childId = `${hostId}.${nodeId}`;
        if (hostId == null) {
          hostId = 0;
          docData.rootLevelIds++;
          nodeId = docData.rootLevelIds;
          childId = `${hostId}.${nodeId}`;
          if (nodeRef.nodeType === 1 /* ElementNode */) {
            nodeRef.setAttribute(HYDRATE_CHILD_ID, childId);
            if (typeof nodeRef["s-sn"] === "string" && !nodeRef.getAttribute("slot")) {
              nodeRef.setAttribute("s-sn", nodeRef["s-sn"]);
            }
          } else if (nodeRef.nodeType === 3 /* TextNode */) {
            if (hostId === 0) {
              const textContent = (_a = nodeRef.nodeValue) == null ? void 0 : _a.trim();
              if (textContent === "") {
                orgLocationNode.remove();
                return;
              }
            }
            const commentBeforeTextNode = doc.createComment(childId);
            commentBeforeTextNode.nodeValue = `${TEXT_NODE_ID}.${childId}`;
            insertBefore(nodeRef.parentNode, commentBeforeTextNode, nodeRef);
          } else if (nodeRef.nodeType === 8 /* CommentNode */) {
            const commentBeforeTextNode = doc.createComment(childId);
            commentBeforeTextNode.nodeValue = `${COMMENT_NODE_ID}.${childId}`;
            nodeRef.parentNode.insertBefore(commentBeforeTextNode, nodeRef);
          }
        }
        let orgLocationNodeId = `${ORG_LOCATION_ID}.${childId}`;
        const orgLocationParentNode = orgLocationNode.parentElement;
        if (orgLocationParentNode) {
          if (orgLocationParentNode["s-en"] === "") {
            orgLocationNodeId += `.`;
          } else if (orgLocationParentNode["s-en"] === "c") {
            orgLocationNodeId += `.c`;
          }
        }
        orgLocationNode.nodeValue = orgLocationNodeId;
      }
    });
  }
};
var parseVNodeAnnotations = (doc, node, docData, orgLocationNodes) => {
  var _a;
  if (node == null) {
    return;
  }
  if (node["s-nr"] != null) {
    orgLocationNodes.push(node);
  }
  if (node.nodeType === 1 /* ElementNode */) {
    const childNodes = [...Array.from(node.childNodes), ...Array.from(((_a = node.shadowRoot) == null ? void 0 : _a.childNodes) || [])];
    childNodes.forEach((childNode) => {
      const hostRef = getHostRef(childNode);
      if (hostRef != null && !docData.staticComponents.has(childNode.nodeName.toLowerCase())) {
        const cmpData = {
          nodeIds: 0
        };
        insertVNodeAnnotations(doc, childNode, hostRef.$vnode$, docData, cmpData);
      }
      parseVNodeAnnotations(doc, childNode, docData, orgLocationNodes);
    });
  }
};
var insertVNodeAnnotations = (doc, hostElm, vnode, docData, cmpData) => {
  if (vnode != null) {
    const hostId = ++docData.hostIds;
    hostElm.setAttribute(HYDRATE_ID, hostId);
    if (hostElm["s-cr"] != null) {
      hostElm["s-cr"].nodeValue = `${CONTENT_REF_ID}.${hostId}`;
    }
    if (vnode.$children$ != null) {
      const depth = 0;
      vnode.$children$.forEach((vnodeChild, index) => {
        insertChildVNodeAnnotations(doc, vnodeChild, cmpData, hostId, depth, index);
      });
    }
    if (hostElm && vnode && vnode.$elm$ && !hostElm.hasAttribute(HYDRATE_CHILD_ID)) {
      const parent = hostElm.parentElement;
      if (parent && parent.childNodes) {
        const parentChildNodes = Array.from(parent.childNodes);
        const comment = parentChildNodes.find(
          (node) => node.nodeType === 8 /* CommentNode */ && node["s-sr"]
        );
        if (comment) {
          const index = parentChildNodes.indexOf(hostElm) - 1;
          vnode.$elm$.setAttribute(
            HYDRATE_CHILD_ID,
            `${comment["s-host-id"]}.${comment["s-node-id"]}.0.${index}`
          );
        }
      }
    }
  }
};
var insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, index) => {
  const childElm = vnodeChild.$elm$;
  if (childElm == null) {
    return;
  }
  const nodeId = cmpData.nodeIds++;
  const childId = `${hostId}.${nodeId}.${depth}.${index}`;
  childElm["s-host-id"] = hostId;
  childElm["s-node-id"] = nodeId;
  if (childElm.nodeType === 1 /* ElementNode */) {
    childElm.setAttribute(HYDRATE_CHILD_ID, childId);
    if (typeof childElm["s-sn"] === "string" && !childElm.getAttribute("slot")) {
      childElm.setAttribute("s-sn", childElm["s-sn"]);
    }
  } else if (childElm.nodeType === 3 /* TextNode */) {
    const parentNode = childElm.parentNode;
    const nodeName = parentNode == null ? void 0 : parentNode.nodeName;
    if (nodeName !== "STYLE" && nodeName !== "SCRIPT") {
      const textNodeId = `${TEXT_NODE_ID}.${childId}`;
      const commentBeforeTextNode = doc.createComment(textNodeId);
      insertBefore(parentNode, commentBeforeTextNode, childElm);
    }
  } else if (childElm.nodeType === 8 /* CommentNode */) {
    if (childElm["s-sr"]) {
      const slotName = childElm["s-sn"] || "";
      const slotNodeId = `${SLOT_NODE_ID}.${childId}.${slotName}`;
      childElm.nodeValue = slotNodeId;
    }
  }
  if (vnodeChild.$children$ != null) {
    const childDepth = depth + 1;
    vnodeChild.$children$.forEach((vnode, index2) => {
      insertChildVNodeAnnotations(doc, vnode, cmpData, hostId, childDepth, index2);
    });
  }
};

// src/hydrate/platform/h-async.ts
var hAsync = (nodeName, vnodeData, ...children) => {
  if (Array.isArray(children) && children.length > 0) {
    const flatChildren = children.flat(Infinity);
    if (flatChildren.some((child) => child instanceof Promise)) {
      return Promise.all(flatChildren).then((resolvedChildren) => {
        return h(nodeName, vnodeData, ...resolvedChildren);
      }).catch((err2) => {
        return h(nodeName, vnodeData);
      });
    }
    return h(nodeName, vnodeData, ...flatChildren);
  }
  return h(nodeName, vnodeData);
};

// node_modules/minimatch/dist/esm/index.js
var import_brace_expansion = __toESM(require_brace_expansion());

// node_modules/minimatch/dist/esm/assert-valid-pattern.js
var MAX_PATTERN_LENGTH = 1024 * 64;
var assertValidPattern = (pattern) => {
  if (typeof pattern !== "string") {
    throw new TypeError("invalid pattern");
  }
  if (pattern.length > MAX_PATTERN_LENGTH) {
    throw new TypeError("pattern is too long");
  }
};

// node_modules/minimatch/dist/esm/brace-expressions.js
var posixClasses = {
  "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
  "[:alpha:]": ["\\p{L}\\p{Nl}", true],
  "[:ascii:]": ["\\x00-\\x7f", false],
  "[:blank:]": ["\\p{Zs}\\t", true],
  "[:cntrl:]": ["\\p{Cc}", true],
  "[:digit:]": ["\\p{Nd}", true],
  "[:graph:]": ["\\p{Z}\\p{C}", true, true],
  "[:lower:]": ["\\p{Ll}", true],
  "[:print:]": ["\\p{C}", true],
  "[:punct:]": ["\\p{P}", true],
  "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
  "[:upper:]": ["\\p{Lu}", true],
  "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
  "[:xdigit:]": ["A-Fa-f0-9", false]
};
var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
var rangesToString = (ranges) => ranges.join("");
var parseClass = (glob, position) => {
  const pos = position;
  if (glob.charAt(pos) !== "[") {
    throw new Error("not in a brace expression");
  }
  const ranges = [];
  const negs = [];
  let i2 = pos + 1;
  let sawStart = false;
  let uflag = false;
  let escaping = false;
  let negate = false;
  let endPos = pos;
  let rangeStart = "";
  WHILE: while (i2 < glob.length) {
    const c = glob.charAt(i2);
    if ((c === "!" || c === "^") && i2 === pos + 1) {
      negate = true;
      i2++;
      continue;
    }
    if (c === "]" && sawStart && !escaping) {
      endPos = i2 + 1;
      break;
    }
    sawStart = true;
    if (c === "\\") {
      if (!escaping) {
        escaping = true;
        i2++;
        continue;
      }
    }
    if (c === "[" && !escaping) {
      for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
        if (glob.startsWith(cls, i2)) {
          if (rangeStart) {
            return ["$.", false, glob.length - pos, true];
          }
          i2 += cls.length;
          if (neg)
            negs.push(unip);
          else
            ranges.push(unip);
          uflag = uflag || u;
          continue WHILE;
        }
      }
    }
    escaping = false;
    if (rangeStart) {
      if (c > rangeStart) {
        ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
      } else if (c === rangeStart) {
        ranges.push(braceEscape(c));
      }
      rangeStart = "";
      i2++;
      continue;
    }
    if (glob.startsWith("-]", i2 + 1)) {
      ranges.push(braceEscape(c + "-"));
      i2 += 2;
      continue;
    }
    if (glob.startsWith("-", i2 + 1)) {
      rangeStart = c;
      i2 += 2;
      continue;
    }
    ranges.push(braceEscape(c));
    i2++;
  }
  if (endPos < i2) {
    return ["", false, 0, false];
  }
  if (!ranges.length && !negs.length) {
    return ["$.", false, glob.length - pos, true];
  }
  if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
    const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
    return [regexpEscape(r), false, endPos - pos, false];
  }
  const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
  const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
  const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs;
  return [comb, uflag, endPos - pos, true];
};

// node_modules/minimatch/dist/esm/unescape.js
var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
  return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
};

// node_modules/minimatch/dist/esm/ast.js
var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
var isExtglobType = (c) => types.has(c);
var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
var startNoDot = "(?!\\.)";
var addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
var justDots = /* @__PURE__ */ new Set(["..", "."]);
var reSpecials = new Set("().*{}+?[]^$\\!");
var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
var qmark = "[^/]";
var star = qmark + "*?";
var starNoEmpty = qmark + "+?";
var _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, partsToRegExp_fn, parseGlob_fn;
var _AST = class _AST {
  constructor(type, parent, options = {}) {
    __privateAdd(this, _AST_instances);
    __publicField(this, "type");
    __privateAdd(this, _root);
    __privateAdd(this, _hasMagic);
    __privateAdd(this, _uflag, false);
    __privateAdd(this, _parts, []);
    __privateAdd(this, _parent);
    __privateAdd(this, _parentIndex);
    __privateAdd(this, _negs);
    __privateAdd(this, _filledNegs, false);
    __privateAdd(this, _options);
    __privateAdd(this, _toString);
    // set to true if it's an extglob with no children
    // (which really means one child of '')
    __privateAdd(this, _emptyExt, false);
    this.type = type;
    if (type)
      __privateSet(this, _hasMagic, true);
    __privateSet(this, _parent, parent);
    __privateSet(this, _root, __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _root) : this);
    __privateSet(this, _options, __privateGet(this, _root) === this ? options : __privateGet(__privateGet(this, _root), _options));
    __privateSet(this, _negs, __privateGet(this, _root) === this ? [] : __privateGet(__privateGet(this, _root), _negs));
    if (type === "!" && !__privateGet(__privateGet(this, _root), _filledNegs))
      __privateGet(this, _negs).push(this);
    __privateSet(this, _parentIndex, __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _parts).length : 0);
  }
  get hasMagic() {
    if (__privateGet(this, _hasMagic) !== void 0)
      return __privateGet(this, _hasMagic);
    for (const p of __privateGet(this, _parts)) {
      if (typeof p === "string")
        continue;
      if (p.type || p.hasMagic)
        return __privateSet(this, _hasMagic, true);
    }
    return __privateGet(this, _hasMagic);
  }
  // reconstructs the pattern
  toString() {
    if (__privateGet(this, _toString) !== void 0)
      return __privateGet(this, _toString);
    if (!this.type) {
      return __privateSet(this, _toString, __privateGet(this, _parts).map((p) => String(p)).join(""));
    } else {
      return __privateSet(this, _toString, this.type + "(" + __privateGet(this, _parts).map((p) => String(p)).join("|") + ")");
    }
  }
  push(...parts) {
    for (const p of parts) {
      if (p === "")
        continue;
      if (typeof p !== "string" && !(p instanceof _AST && __privateGet(p, _parent) === this)) {
        throw new Error("invalid part: " + p);
      }
      __privateGet(this, _parts).push(p);
    }
  }
  toJSON() {
    var _a;
    const ret = this.type === null ? __privateGet(this, _parts).slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...__privateGet(this, _parts).map((p) => p.toJSON())];
    if (this.isStart() && !this.type)
      ret.unshift([]);
    if (this.isEnd() && (this === __privateGet(this, _root) || __privateGet(__privateGet(this, _root), _filledNegs) && ((_a = __privateGet(this, _parent)) == null ? void 0 : _a.type) === "!")) {
      ret.push({});
    }
    return ret;
  }
  isStart() {
    var _a;
    if (__privateGet(this, _root) === this)
      return true;
    if (!((_a = __privateGet(this, _parent)) == null ? void 0 : _a.isStart()))
      return false;
    if (__privateGet(this, _parentIndex) === 0)
      return true;
    const p = __privateGet(this, _parent);
    for (let i2 = 0; i2 < __privateGet(this, _parentIndex); i2++) {
      const pp = __privateGet(p, _parts)[i2];
      if (!(pp instanceof _AST && pp.type === "!")) {
        return false;
      }
    }
    return true;
  }
  isEnd() {
    var _a, _b, _c;
    if (__privateGet(this, _root) === this)
      return true;
    if (((_a = __privateGet(this, _parent)) == null ? void 0 : _a.type) === "!")
      return true;
    if (!((_b = __privateGet(this, _parent)) == null ? void 0 : _b.isEnd()))
      return false;
    if (!this.type)
      return (_c = __privateGet(this, _parent)) == null ? void 0 : _c.isEnd();
    const pl = __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _parts).length : 0;
    return __privateGet(this, _parentIndex) === pl - 1;
  }
  copyIn(part) {
    if (typeof part === "string")
      this.push(part);
    else
      this.push(part.clone(this));
  }
  clone(parent) {
    const c = new _AST(this.type, parent);
    for (const p of __privateGet(this, _parts)) {
      c.copyIn(p);
    }
    return c;
  }
  static fromGlob(pattern, options = {}) {
    var _a;
    const ast = new _AST(null, void 0, options);
    __privateMethod(_a = _AST, _AST_static, parseAST_fn).call(_a, pattern, ast, 0, options);
    return ast;
  }
  // returns the regular expression if there's magic, or the unescaped
  // string if not.
  toMMPattern() {
    if (this !== __privateGet(this, _root))
      return __privateGet(this, _root).toMMPattern();
    const glob = this.toString();
    const [re, body, hasMagic, uflag] = this.toRegExpSource();
    const anyMagic = hasMagic || __privateGet(this, _hasMagic) || __privateGet(this, _options).nocase && !__privateGet(this, _options).nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase();
    if (!anyMagic) {
      return body;
    }
    const flags = (__privateGet(this, _options).nocase ? "i" : "") + (uflag ? "u" : "");
    return Object.assign(new RegExp(`^${re}$`, flags), {
      _src: re,
      _glob: glob
    });
  }
  get options() {
    return __privateGet(this, _options);
  }
  // returns the string match, the regexp source, whether there's magic
  // in the regexp (so a regular expression is required) and whether or
  // not the uflag is needed for the regular expression (for posix classes)
  // TODO: instead of injecting the start/end at this point, just return
  // the BODY of the regexp, along with the start/end portions suitable
  // for binding the start/end in either a joined full-path makeRe context
  // (where we bind to (^|/), or a standalone matchPart context (where
  // we bind to ^, and not /).  Otherwise slashes get duped!
  //
  // In part-matching mode, the start is:
  // - if not isStart: nothing
  // - if traversal possible, but not allowed: ^(?!\.\.?$)
  // - if dots allowed or not possible: ^
  // - if dots possible and not allowed: ^(?!\.)
  // end is:
  // - if not isEnd(): nothing
  // - else: $
  //
  // In full-path matching mode, we put the slash at the START of the
  // pattern, so start is:
  // - if first pattern: same as part-matching mode
  // - if not isStart(): nothing
  // - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
  // - if dots allowed or not possible: /
  // - if dots possible and not allowed: /(?!\.)
  // end is:
  // - if last pattern, same as part-matching mode
  // - else nothing
  //
  // Always put the (?:$|/) on negated tails, though, because that has to be
  // there to bind the end of the negated pattern portion, and it's easier to
  // just stick it in now rather than try to inject it later in the middle of
  // the pattern.
  //
  // We can just always return the same end, and leave it up to the caller
  // to know whether it's going to be used joined or in parts.
  // And, if the start is adjusted slightly, can do the same there:
  // - if not isStart: nothing
  // - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
  // - if dots allowed or not possible: (?:/|^)
  // - if dots possible and not allowed: (?:/|^)(?!\.)
  //
  // But it's better to have a simpler binding without a conditional, for
  // performance, so probably better to return both start options.
  //
  // Then the caller just ignores the end if it's not the first pattern,
  // and the start always gets applied.
  //
  // But that's always going to be $ if it's the ending pattern, or nothing,
  // so the caller can just attach $ at the end of the pattern when building.
  //
  // So the todo is:
  // - better detect what kind of start is needed
  // - return both flavors of starting pattern
  // - attach $ at the end of the pattern when creating the actual RegExp
  //
  // Ah, but wait, no, that all only applies to the root when the first pattern
  // is not an extglob. If the first pattern IS an extglob, then we need all
  // that dot prevention biz to live in the extglob portions, because eg
  // +(*|.x*) can match .xy but not .yx.
  //
  // So, return the two flavors if it's #root and the first child is not an
  // AST, otherwise leave it to the child AST to handle it, and there,
  // use the (?:^|/) style of start binding.
  //
  // Even simplified further:
  // - Since the start for a join is eg /(?!\.) and the start for a part
  // is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
  // or start or whatever) and prepend ^ or / at the Regexp construction.
  toRegExpSource(allowDot) {
    var _a;
    const dot = allowDot != null ? allowDot : !!__privateGet(this, _options).dot;
    if (__privateGet(this, _root) === this)
      __privateMethod(this, _AST_instances, fillNegs_fn).call(this);
    if (!this.type) {
      const noEmpty = this.isStart() && this.isEnd();
      const src = __privateGet(this, _parts).map((p) => {
        var _a2;
        const [re, _, hasMagic, uflag] = typeof p === "string" ? __privateMethod(_a2 = _AST, _AST_static, parseGlob_fn).call(_a2, p, __privateGet(this, _hasMagic), noEmpty) : p.toRegExpSource(allowDot);
        __privateSet(this, _hasMagic, __privateGet(this, _hasMagic) || hasMagic);
        __privateSet(this, _uflag, __privateGet(this, _uflag) || uflag);
        return re;
      }).join("");
      let start2 = "";
      if (this.isStart()) {
        if (typeof __privateGet(this, _parts)[0] === "string") {
          const dotTravAllowed = __privateGet(this, _parts).length === 1 && justDots.has(__privateGet(this, _parts)[0]);
          if (!dotTravAllowed) {
            const aps = addPatternStart;
            const needNoTrav = (
              // dots are allowed, and the pattern starts with [ or .
              dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
              src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
              src.startsWith("\\.\\.") && aps.has(src.charAt(4))
            );
            const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
            start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
          }
        }
      }
      let end = "";
      if (this.isEnd() && __privateGet(__privateGet(this, _root), _filledNegs) && ((_a = __privateGet(this, _parent)) == null ? void 0 : _a.type) === "!") {
        end = "(?:$|\\/)";
      }
      const final2 = start2 + src + end;
      return [
        final2,
        unescape(src),
        __privateSet(this, _hasMagic, !!__privateGet(this, _hasMagic)),
        __privateGet(this, _uflag)
      ];
    }
    const repeated = this.type === "*" || this.type === "+";
    const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
    let body = __privateMethod(this, _AST_instances, partsToRegExp_fn).call(this, dot);
    if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
      const s = this.toString();
      __privateSet(this, _parts, [s]);
      this.type = null;
      __privateSet(this, _hasMagic, void 0);
      return [s, unescape(this.toString()), false, false];
    }
    let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : __privateMethod(this, _AST_instances, partsToRegExp_fn).call(this, true);
    if (bodyDotAllowed === body) {
      bodyDotAllowed = "";
    }
    if (bodyDotAllowed) {
      body = `(?:${body})(?:${bodyDotAllowed})*?`;
    }
    let final = "";
    if (this.type === "!" && __privateGet(this, _emptyExt)) {
      final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
    } else {
      const close = this.type === "!" ? (
        // !() must match something,but !(x) can match ''
        "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star + ")"
      ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
      final = start + body + close;
    }
    return [
      final,
      unescape(body),
      __privateSet(this, _hasMagic, !!__privateGet(this, _hasMagic)),
      __privateGet(this, _uflag)
    ];
  }
};
_root = new WeakMap();
_hasMagic = new WeakMap();
_uflag = new WeakMap();
_parts = new WeakMap();
_parent = new WeakMap();
_parentIndex = new WeakMap();
_negs = new WeakMap();
_filledNegs = new WeakMap();
_options = new WeakMap();
_toString = new WeakMap();
_emptyExt = new WeakMap();
_AST_instances = new WeakSet();
fillNegs_fn = function() {
  if (this !== __privateGet(this, _root))
    throw new Error("should only call on root");
  if (__privateGet(this, _filledNegs))
    return this;
  this.toString();
  __privateSet(this, _filledNegs, true);
  let n;
  while (n = __privateGet(this, _negs).pop()) {
    if (n.type !== "!")
      continue;
    let p = n;
    let pp = __privateGet(p, _parent);
    while (pp) {
      for (let i2 = __privateGet(p, _parentIndex) + 1; !pp.type && i2 < __privateGet(pp, _parts).length; i2++) {
        for (const part of __privateGet(n, _parts)) {
          if (typeof part === "string") {
            throw new Error("string part in extglob AST??");
          }
          part.copyIn(__privateGet(pp, _parts)[i2]);
        }
      }
      p = pp;
      pp = __privateGet(p, _parent);
    }
  }
  return this;
};
_AST_static = new WeakSet();
parseAST_fn = function(str, ast, pos, opt) {
  var _a, _b;
  let escaping = false;
  let inBrace = false;
  let braceStart = -1;
  let braceNeg = false;
  if (ast.type === null) {
    let i3 = pos;
    let acc2 = "";
    while (i3 < str.length) {
      const c = str.charAt(i3++);
      if (escaping || c === "\\") {
        escaping = !escaping;
        acc2 += c;
        continue;
      }
      if (inBrace) {
        if (i3 === braceStart + 1) {
          if (c === "^" || c === "!") {
            braceNeg = true;
          }
        } else if (c === "]" && !(i3 === braceStart + 2 && braceNeg)) {
          inBrace = false;
        }
        acc2 += c;
        continue;
      } else if (c === "[") {
        inBrace = true;
        braceStart = i3;
        braceNeg = false;
        acc2 += c;
        continue;
      }
      if (!opt.noext && isExtglobType(c) && str.charAt(i3) === "(") {
        ast.push(acc2);
        acc2 = "";
        const ext2 = new _AST(c, ast);
        i3 = __privateMethod(_a = _AST, _AST_static, parseAST_fn).call(_a, str, ext2, i3, opt);
        ast.push(ext2);
        continue;
      }
      acc2 += c;
    }
    ast.push(acc2);
    return i3;
  }
  let i2 = pos + 1;
  let part = new _AST(null, ast);
  const parts = [];
  let acc = "";
  while (i2 < str.length) {
    const c = str.charAt(i2++);
    if (escaping || c === "\\") {
      escaping = !escaping;
      acc += c;
      continue;
    }
    if (inBrace) {
      if (i2 === braceStart + 1) {
        if (c === "^" || c === "!") {
          braceNeg = true;
        }
      } else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
        inBrace = false;
      }
      acc += c;
      continue;
    } else if (c === "[") {
      inBrace = true;
      braceStart = i2;
      braceNeg = false;
      acc += c;
      continue;
    }
    if (isExtglobType(c) && str.charAt(i2) === "(") {
      part.push(acc);
      acc = "";
      const ext2 = new _AST(c, part);
      part.push(ext2);
      i2 = __privateMethod(_b = _AST, _AST_static, parseAST_fn).call(_b, str, ext2, i2, opt);
      continue;
    }
    if (c === "|") {
      part.push(acc);
      acc = "";
      parts.push(part);
      part = new _AST(null, ast);
      continue;
    }
    if (c === ")") {
      if (acc === "" && __privateGet(ast, _parts).length === 0) {
        __privateSet(ast, _emptyExt, true);
      }
      part.push(acc);
      acc = "";
      ast.push(...parts, part);
      return i2;
    }
    acc += c;
  }
  ast.type = null;
  __privateSet(ast, _hasMagic, void 0);
  __privateSet(ast, _parts, [str.substring(pos - 1)]);
  return i2;
};
partsToRegExp_fn = function(dot) {
  return __privateGet(this, _parts).map((p) => {
    if (typeof p === "string") {
      throw new Error("string type in extglob ast??");
    }
    const [re, _, _hasMagic2, uflag] = p.toRegExpSource(dot);
    __privateSet(this, _uflag, __privateGet(this, _uflag) || uflag);
    return re;
  }).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
};
parseGlob_fn = function(glob, hasMagic, noEmpty = false) {
  let escaping = false;
  let re = "";
  let uflag = false;
  for (let i2 = 0; i2 < glob.length; i2++) {
    const c = glob.charAt(i2);
    if (escaping) {
      escaping = false;
      re += (reSpecials.has(c) ? "\\" : "") + c;
      continue;
    }
    if (c === "\\") {
      if (i2 === glob.length - 1) {
        re += "\\\\";
      } else {
        escaping = true;
      }
      continue;
    }
    if (c === "[") {
      const [src, needUflag, consumed, magic] = parseClass(glob, i2);
      if (consumed) {
        re += src;
        uflag = uflag || needUflag;
        i2 += consumed - 1;
        hasMagic = hasMagic || magic;
        continue;
      }
    }
    if (c === "*") {
      if (noEmpty && glob === "*")
        re += starNoEmpty;
      else
        re += star;
      hasMagic = true;
      continue;
    }
    if (c === "?") {
      re += qmark;
      hasMagic = true;
      continue;
    }
    re += regExpEscape(c);
  }
  return [re, unescape(glob), !!hasMagic, uflag];
};
__privateAdd(_AST, _AST_static);
var AST = _AST;

// node_modules/minimatch/dist/esm/escape.js
var escape = (s, { windowsPathsNoEscape = false } = {}) => {
  return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
};

// node_modules/minimatch/dist/esm/index.js
var minimatch = (p, pattern, options = {}) => {
  assertValidPattern(pattern);
  if (!options.nocomment && pattern.charAt(0) === "#") {
    return false;
  }
  return new Minimatch(pattern, options).match(p);
};
var starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
var starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2);
var starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2);
var starDotExtTestNocase = (ext2) => {
  ext2 = ext2.toLowerCase();
  return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2);
};
var starDotExtTestNocaseDot = (ext2) => {
  ext2 = ext2.toLowerCase();
  return (f) => f.toLowerCase().endsWith(ext2);
};
var starDotStarRE = /^\*+\.\*+$/;
var starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
var starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
var dotStarRE = /^\.\*+$/;
var dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
var starRE = /^\*+$/;
var starTest = (f) => f.length !== 0 && !f.startsWith(".");
var starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
var qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
var qmarksTestNocase = ([$0, ext2 = ""]) => {
  const noext = qmarksTestNoExt([$0]);
  if (!ext2)
    return noext;
  ext2 = ext2.toLowerCase();
  return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
};
var qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
  const noext = qmarksTestNoExtDot([$0]);
  if (!ext2)
    return noext;
  ext2 = ext2.toLowerCase();
  return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
};
var qmarksTestDot = ([$0, ext2 = ""]) => {
  const noext = qmarksTestNoExtDot([$0]);
  return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
};
var qmarksTest = ([$0, ext2 = ""]) => {
  const noext = qmarksTestNoExt([$0]);
  return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
};
var qmarksTestNoExt = ([$0]) => {
  const len = $0.length;
  return (f) => f.length === len && !f.startsWith(".");
};
var qmarksTestNoExtDot = ([$0]) => {
  const len = $0.length;
  return (f) => f.length === len && f !== "." && f !== "..";
};
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
var path = {
  win32: { sep: "\\" },
  posix: { sep: "/" }
};
var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
minimatch.sep = sep;
var GLOBSTAR = Symbol("globstar **");
minimatch.GLOBSTAR = GLOBSTAR;
var qmark2 = "[^/]";
var star2 = qmark2 + "*?";
var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
minimatch.filter = filter;
var ext = (a, b = {}) => Object.assign({}, a, b);
var defaults = (def) => {
  if (!def || typeof def !== "object" || !Object.keys(def).length) {
    return minimatch;
  }
  const orig = minimatch;
  const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
  return Object.assign(m, {
    Minimatch: class Minimatch extends orig.Minimatch {
      constructor(pattern, options = {}) {
        super(pattern, ext(def, options));
      }
      static defaults(options) {
        return orig.defaults(ext(def, options)).Minimatch;
      }
    },
    AST: class AST extends orig.AST {
      /* c8 ignore start */
      constructor(type, parent, options = {}) {
        super(type, parent, ext(def, options));
      }
      /* c8 ignore stop */
      static fromGlob(pattern, options = {}) {
        return orig.AST.fromGlob(pattern, ext(def, options));
      }
    },
    unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
    escape: (s, options = {}) => orig.escape(s, ext(def, options)),
    filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
    defaults: (options) => orig.defaults(ext(def, options)),
    makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
    braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
    match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
    sep: orig.sep,
    GLOBSTAR
  });
};
minimatch.defaults = defaults;
var braceExpand = (pattern, options = {}) => {
  assertValidPattern(pattern);
  if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
    return [pattern];
  }
  return (0, import_brace_expansion.default)(pattern);
};
minimatch.braceExpand = braceExpand;
var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
minimatch.makeRe = makeRe;
var match = (list, pattern, options = {}) => {
  const mm = new Minimatch(pattern, options);
  list = list.filter((f) => mm.match(f));
  if (mm.options.nonull && !list.length) {
    list.push(pattern);
  }
  return list;
};
minimatch.match = match;
var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
var Minimatch = class {
  options;
  set;
  pattern;
  windowsPathsNoEscape;
  nonegate;
  negate;
  comment;
  empty;
  preserveMultipleSlashes;
  partial;
  globSet;
  globParts;
  nocase;
  isWindows;
  platform;
  windowsNoMagicRoot;
  regexp;
  constructor(pattern, options = {}) {
    assertValidPattern(pattern);
    options = options || {};
    this.options = options;
    this.pattern = pattern;
    this.platform = options.platform || defaultPlatform;
    this.isWindows = this.platform === "win32";
    this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
    if (this.windowsPathsNoEscape) {
      this.pattern = this.pattern.replace(/\\/g, "/");
    }
    this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
    this.regexp = null;
    this.negate = false;
    this.nonegate = !!options.nonegate;
    this.comment = false;
    this.empty = false;
    this.partial = !!options.partial;
    this.nocase = !!this.options.nocase;
    this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
    this.globSet = [];
    this.globParts = [];
    this.set = [];
    this.make();
  }
  hasMagic() {
    if (this.options.magicalBraces && this.set.length > 1) {
      return true;
    }
    for (const pattern of this.set) {
      for (const part of pattern) {
        if (typeof part !== "string")
          return true;
      }
    }
    return false;
  }
  debug(..._) {
  }
  make() {
    const pattern = this.pattern;
    const options = this.options;
    if (!options.nocomment && pattern.charAt(0) === "#") {
      this.comment = true;
      return;
    }
    if (!pattern) {
      this.empty = true;
      return;
    }
    this.parseNegate();
    this.globSet = [...new Set(this.braceExpand())];
    if (options.debug) {
      this.debug = (...args) => console.error(...args);
    }
    this.debug(this.pattern, this.globSet);
    const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
    this.globParts = this.preprocess(rawGlobParts);
    this.debug(this.pattern, this.globParts);
    let set = this.globParts.map((s, _, __) => {
      if (this.isWindows && this.windowsNoMagicRoot) {
        const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
        const isDrive = /^[a-z]:/i.test(s[0]);
        if (isUNC) {
          return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
        } else if (isDrive) {
          return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
        }
      }
      return s.map((ss) => this.parse(ss));
    });
    this.debug(this.pattern, set);
    this.set = set.filter((s) => s.indexOf(false) === -1);
    if (this.isWindows) {
      for (let i2 = 0; i2 < this.set.length; i2++) {
        const p = this.set[i2];
        if (p[0] === "" && p[1] === "" && this.globParts[i2][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) {
          p[2] = "?";
        }
      }
    }
    this.debug(this.pattern, this.set);
  }
  // various transforms to equivalent pattern sets that are
  // faster to process in a filesystem walk.  The goal is to
  // eliminate what we can, and push all ** patterns as far
  // to the right as possible, even if it increases the number
  // of patterns that we have to process.
  preprocess(globParts) {
    if (this.options.noglobstar) {
      for (let i2 = 0; i2 < globParts.length; i2++) {
        for (let j = 0; j < globParts[i2].length; j++) {
          if (globParts[i2][j] === "**") {
            globParts[i2][j] = "*";
          }
        }
      }
    }
    const { optimizationLevel = 1 } = this.options;
    if (optimizationLevel >= 2) {
      globParts = this.firstPhasePreProcess(globParts);
      globParts = this.secondPhasePreProcess(globParts);
    } else if (optimizationLevel >= 1) {
      globParts = this.levelOneOptimize(globParts);
    } else {
      globParts = this.adjascentGlobstarOptimize(globParts);
    }
    return globParts;
  }
  // just get rid of adjascent ** portions
  adjascentGlobstarOptimize(globParts) {
    return globParts.map((parts) => {
      let gs = -1;
      while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
        let i2 = gs;
        while (parts[i2 + 1] === "**") {
          i2++;
        }
        if (i2 !== gs) {
          parts.splice(gs, i2 - gs);
        }
      }
      return parts;
    });
  }
  // get rid of adjascent ** and resolve .. portions
  levelOneOptimize(globParts) {
    return globParts.map((parts) => {
      parts = parts.reduce((set, part) => {
        const prev = set[set.length - 1];
        if (part === "**" && prev === "**") {
          return set;
        }
        if (part === "..") {
          if (prev && prev !== ".." && prev !== "." && prev !== "**") {
            set.pop();
            return set;
          }
        }
        set.push(part);
        return set;
      }, []);
      return parts.length === 0 ? [""] : parts;
    });
  }
  levelTwoFileOptimize(parts) {
    if (!Array.isArray(parts)) {
      parts = this.slashSplit(parts);
    }
    let didSomething = false;
    do {
      didSomething = false;
      if (!this.preserveMultipleSlashes) {
        for (let i2 = 1; i2 < parts.length - 1; i2++) {
          const p = parts[i2];
          if (i2 === 1 && p === "" && parts[0] === "")
            continue;
          if (p === "." || p === "") {
            didSomething = true;
            parts.splice(i2, 1);
            i2--;
          }
        }
        if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
          didSomething = true;
          parts.pop();
        }
      }
      let dd = 0;
      while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
        const p = parts[dd - 1];
        if (p && p !== "." && p !== ".." && p !== "**") {
          didSomething = true;
          parts.splice(dd - 1, 2);
          dd -= 2;
        }
      }
    } while (didSomething);
    return parts.length === 0 ? [""] : parts;
  }
  // First phase: single-pattern processing
  // <pre> is 1 or more portions
  // <rest> is 1 or more portions
  // <p> is any portion other than ., .., '', or **
  // <e> is . or ''
  //
  // **/.. is *brutal* for filesystem walking performance, because
  // it effectively resets the recursive walk each time it occurs,
  // and ** cannot be reduced out by a .. pattern part like a regexp
  // or most strings (other than .., ., and '') can be.
  //
  // <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
  // <pre>/<e>/<rest> -> <pre>/<rest>
  // <pre>/<p>/../<rest> -> <pre>/<rest>
  // **/**/<rest> -> **/<rest>
  //
  // **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
  // this WOULD be allowed if ** did follow symlinks, or * didn't
  firstPhasePreProcess(globParts) {
    let didSomething = false;
    do {
      didSomething = false;
      for (let parts of globParts) {
        let gs = -1;
        while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
          let gss = gs;
          while (parts[gss + 1] === "**") {
            gss++;
          }
          if (gss > gs) {
            parts.splice(gs + 1, gss - gs);
          }
          let next = parts[gs + 1];
          const p = parts[gs + 2];
          const p2 = parts[gs + 3];
          if (next !== "..")
            continue;
          if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
            continue;
          }
          didSomething = true;
          parts.splice(gs, 1);
          const other = parts.slice(0);
          other[gs] = "**";
          globParts.push(other);
          gs--;
        }
        if (!this.preserveMultipleSlashes) {
          for (let i2 = 1; i2 < parts.length - 1; i2++) {
            const p = parts[i2];
            if (i2 === 1 && p === "" && parts[0] === "")
              continue;
            if (p === "." || p === "") {
              didSomething = true;
              parts.splice(i2, 1);
              i2--;
            }
          }
          if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
            didSomething = true;
            parts.pop();
          }
        }
        let dd = 0;
        while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
          const p = parts[dd - 1];
          if (p && p !== "." && p !== ".." && p !== "**") {
            didSomething = true;
            const needDot = dd === 1 && parts[dd + 1] === "**";
            const splin = needDot ? ["."] : [];
            parts.splice(dd - 1, 2, ...splin);
            if (parts.length === 0)
              parts.push("");
            dd -= 2;
          }
        }
      }
    } while (didSomething);
    return globParts;
  }
  // second phase: multi-pattern dedupes
  // {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
  // {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
  // {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
  //
  // {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
  // ^-- not valid because ** doens't follow symlinks
  secondPhasePreProcess(globParts) {
    for (let i2 = 0; i2 < globParts.length - 1; i2++) {
      for (let j = i2 + 1; j < globParts.length; j++) {
        const matched = this.partsMatch(globParts[i2], globParts[j], !this.preserveMultipleSlashes);
        if (!matched)
          continue;
        globParts[i2] = matched;
        globParts[j] = [];
      }
    }
    return globParts.filter((gs) => gs.length);
  }
  partsMatch(a, b, emptyGSMatch = false) {
    let ai = 0;
    let bi = 0;
    let result = [];
    let which = "";
    while (ai < a.length && bi < b.length) {
      if (a[ai] === b[bi]) {
        result.push(which === "b" ? b[bi] : a[ai]);
        ai++;
        bi++;
      } else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
        result.push(a[ai]);
        ai++;
      } else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
        result.push(b[bi]);
        bi++;
      } else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
        if (which === "b")
          return false;
        which = "a";
        result.push(a[ai]);
        ai++;
        bi++;
      } else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
        if (which === "a")
          return false;
        which = "b";
        result.push(b[bi]);
        ai++;
        bi++;
      } else {
        return false;
      }
    }
    return a.length === b.length && result;
  }
  parseNegate() {
    if (this.nonegate)
      return;
    const pattern = this.pattern;
    let negate = false;
    let negateOffset = 0;
    for (let i2 = 0; i2 < pattern.length && pattern.charAt(i2) === "!"; i2++) {
      negate = !negate;
      negateOffset++;
    }
    if (negateOffset)
      this.pattern = pattern.slice(negateOffset);
    this.negate = negate;
  }
  // set partial to true to test if, for example,
  // "/a/b" matches the start of "/*/b/*/d"
  // Partial means, if you run out of file before you run
  // out of pattern, then that's fine, as long as all
  // the parts match.
  matchOne(file, pattern, partial = false) {
    const options = this.options;
    if (this.isWindows) {
      const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
      const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
      const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
      const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
      const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
      const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
      if (typeof fdi === "number" && typeof pdi === "number") {
        const [fd, pd] = [file[fdi], pattern[pdi]];
        if (fd.toLowerCase() === pd.toLowerCase()) {
          pattern[pdi] = fd;
          if (pdi > fdi) {
            pattern = pattern.slice(pdi);
          } else if (fdi > pdi) {
            file = file.slice(fdi);
          }
        }
      }
    }
    const { optimizationLevel = 1 } = this.options;
    if (optimizationLevel >= 2) {
      file = this.levelTwoFileOptimize(file);
    }
    this.debug("matchOne", this, { file, pattern });
    this.debug("matchOne", file.length, pattern.length);
    for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
      this.debug("matchOne loop");
      var p = pattern[pi];
      var f = file[fi];
      this.debug(pattern, p, f);
      if (p === false) {
        return false;
      }
      if (p === GLOBSTAR) {
        this.debug("GLOBSTAR", [pattern, p, f]);
        var fr = fi;
        var pr = pi + 1;
        if (pr === pl) {
          this.debug("** at the end");
          for (; fi < fl; fi++) {
            if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
              return false;
          }
          return true;
        }
        while (fr < fl) {
          var swallowee = file[fr];
          this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
          if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
            this.debug("globstar found match!", fr, fl, swallowee);
            return true;
          } else {
            if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
              this.debug("dot detected!", file, fr, pattern, pr);
              break;
            }
            this.debug("globstar swallow a segment, and continue");
            fr++;
          }
        }
        if (partial) {
          this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
          if (fr === fl) {
            return true;
          }
        }
        return false;
      }
      let hit;
      if (typeof p === "string") {
        hit = f === p;
        this.debug("string match", p, f, hit);
      } else {
        hit = p.test(f);
        this.debug("pattern match", p, f, hit);
      }
      if (!hit)
        return false;
    }
    if (fi === fl && pi === pl) {
      return true;
    } else if (fi === fl) {
      return partial;
    } else if (pi === pl) {
      return fi === fl - 1 && file[fi] === "";
    } else {
      throw new Error("wtf?");
    }
  }
  braceExpand() {
    return braceExpand(this.pattern, this.options);
  }
  parse(pattern) {
    assertValidPattern(pattern);
    const options = this.options;
    if (pattern === "**")
      return GLOBSTAR;
    if (pattern === "")
      return "";
    let m;
    let fastTest = null;
    if (m = pattern.match(starRE)) {
      fastTest = options.dot ? starTestDot : starTest;
    } else if (m = pattern.match(starDotExtRE)) {
      fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
    } else if (m = pattern.match(qmarksRE)) {
      fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
    } else if (m = pattern.match(starDotStarRE)) {
      fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
    } else if (m = pattern.match(dotStarRE)) {
      fastTest = dotStarTest;
    }
    const re = AST.fromGlob(pattern, this.options).toMMPattern();
    if (fastTest && typeof re === "object") {
      Reflect.defineProperty(re, "test", { value: fastTest });
    }
    return re;
  }
  makeRe() {
    if (this.regexp || this.regexp === false)
      return this.regexp;
    const set = this.set;
    if (!set.length) {
      this.regexp = false;
      return this.regexp;
    }
    const options = this.options;
    const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
    const flags = new Set(options.nocase ? ["i"] : []);
    let re = set.map((pattern) => {
      const pp = pattern.map((p) => {
        if (p instanceof RegExp) {
          for (const f of p.flags.split(""))
            flags.add(f);
        }
        return typeof p === "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
      });
      pp.forEach((p, i2) => {
        const next = pp[i2 + 1];
        const prev = pp[i2 - 1];
        if (p !== GLOBSTAR || prev === GLOBSTAR) {
          return;
        }
        if (prev === void 0) {
          if (next !== void 0 && next !== GLOBSTAR) {
            pp[i2 + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
          } else {
            pp[i2] = twoStar;
          }
        } else if (next === void 0) {
          pp[i2 - 1] = prev + "(?:\\/|" + twoStar + ")?";
        } else if (next !== GLOBSTAR) {
          pp[i2 - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
          pp[i2 + 1] = GLOBSTAR;
        }
      });
      return pp.filter((p) => p !== GLOBSTAR).join("/");
    }).join("|");
    const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
    re = "^" + open + re + close + "$";
    if (this.negate)
      re = "^(?!" + re + ").+$";
    try {
      this.regexp = new RegExp(re, [...flags].join(""));
    } catch (ex) {
      this.regexp = false;
    }
    return this.regexp;
  }
  slashSplit(p) {
    if (this.preserveMultipleSlashes) {
      return p.split("/");
    } else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
      return ["", ...p.split(/\/+/)];
    } else {
      return p.split(/\/+/);
    }
  }
  match(f, partial = this.partial) {
    this.debug("match", f, this.pattern);
    if (this.comment) {
      return false;
    }
    if (this.empty) {
      return f === "";
    }
    if (f === "/" && partial) {
      return true;
    }
    const options = this.options;
    if (this.isWindows) {
      f = f.split("\\").join("/");
    }
    const ff = this.slashSplit(f);
    this.debug(this.pattern, "split", ff);
    const set = this.set;
    this.debug(this.pattern, "set", set);
    let filename = ff[ff.length - 1];
    if (!filename) {
      for (let i2 = ff.length - 2; !filename && i2 >= 0; i2--) {
        filename = ff[i2];
      }
    }
    for (let i2 = 0; i2 < set.length; i2++) {
      const pattern = set[i2];
      let file = ff;
      if (options.matchBase && pattern.length === 1) {
        file = [filename];
      }
      const hit = this.matchOne(file, pattern, partial);
      if (hit) {
        if (options.flipNegate) {
          return true;
        }
        return !this.negate;
      }
    }
    if (options.flipNegate) {
      return false;
    }
    return this.negate;
  }
  static defaults(def) {
    return minimatch.defaults(def).Minimatch;
  }
};
minimatch.AST = AST;
minimatch.Minimatch = Minimatch;
minimatch.escape = escape;
minimatch.unescape = unescape;

// src/utils/result.ts
var result_exports = {};
__export(result_exports, {
  err: () => err,
  map: () => map,
  ok: () => ok,
  unwrap: () => unwrap,
  unwrapErr: () => unwrapErr
});
var ok = (value) => ({
  isOk: true,
  isErr: false,
  value
});
var err = (value) => ({
  isOk: false,
  isErr: true,
  value
});
function map(result, fn) {
  if (result.isOk) {
    const val = fn(result.value);
    if (val instanceof Promise) {
      return val.then((newVal) => ok(newVal));
    } else {
      return ok(val);
    }
  }
  if (result.isErr) {
    const value = result.value;
    return err(value);
  }
  throw "should never get here";
}
var unwrap = (result) => {
  if (result.isOk) {
    return result.value;
  } else {
    throw result.value;
  }
};
var unwrapErr = (result) => {
  if (result.isErr) {
    return result.value;
  } else {
    throw result.value;
  }
};

// src/hydrate/platform/proxy-host-element.ts
function proxyHostElement(elm, cstr) {
  const cmpMeta = cstr.cmpMeta;
  cmpMeta.$watchers$ = cmpMeta.$watchers$ || cstr.watchers;
  cmpMeta.$deserializers$ = cmpMeta.$deserializers$ || cstr.deserializers;
  cmpMeta.$serializers$ = cmpMeta.$serializers$ || cstr.serializers;
  if (typeof elm.componentOnReady !== "function") {
    elm.componentOnReady = componentOnReady;
  }
  if (typeof elm.forceUpdate !== "function") {
    elm.forceUpdate = forceUpdate2;
  }
  if (!elm.shadowRoot && !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) && !(cmpMeta.$flags$ & 128 /* shadowNeedsScopedCss */)) {
    createShadowRoot.call(elm, cmpMeta);
  }
  if (cmpMeta.$members$ != null) {
    const hostRef = getHostRef(elm);
    const members = Object.entries(cmpMeta.$members$);
    members.forEach(([memberName, [memberFlags, metaAttributeName]]) => {
      var _a, _b;
      if (memberFlags & 31 /* Prop */) {
        const attributeName = metaAttributeName || memberName;
        const attrValue = elm.getAttribute(attributeName);
        const propValue = elm[memberName];
        let attrPropVal;
        const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(cstr.prototype, memberName) || {};
        if (attrValue != null) {
          if ((_a = cmpMeta.$deserializers$) == null ? void 0 : _a[memberName]) {
            for (const deserializer of cmpMeta.$deserializers$[memberName]) {
              const [[methodName]] = Object.entries(deserializer);
              attrPropVal = cstr.prototype[methodName](attrValue, memberName);
            }
          } else {
            attrPropVal = parsePropertyValue(attrValue, memberFlags);
          }
        }
        if (propValue !== void 0) {
          attrPropVal = propValue;
          delete elm[memberName];
        }
        if (attrPropVal !== void 0) {
          if (origSetter) {
            origSetter.apply(elm, [attrPropVal]);
            attrPropVal = origGetter ? origGetter.apply(elm) : attrPropVal;
          }
          (_b = hostRef == null ? void 0 : hostRef.$instanceValues$) == null ? void 0 : _b.set(memberName, attrPropVal);
        }
        const getterSetterDescriptor = {
          get: function() {
            return getValue(this, memberName);
          },
          set: function(newValue) {
            setValue(this, memberName, newValue, cmpMeta);
          },
          configurable: true,
          enumerable: true
        };
        Object.defineProperty(elm, memberName, getterSetterDescriptor);
        Object.defineProperty(elm, metaAttributeName, getterSetterDescriptor);
        hostRef.$fetchedCbList$.push(() => {
          var _a2;
          if (!((_a2 = hostRef == null ? void 0 : hostRef.$instanceValues$) == null ? void 0 : _a2.has(memberName))) {
            setValue(
              elm,
              memberName,
              attrPropVal !== void 0 ? attrPropVal : hostRef.$lazyInstance$[memberName],
              cmpMeta
            );
          }
          Object.defineProperty(hostRef.$lazyInstance$, memberName, getterSetterDescriptor);
        });
      } else if (memberFlags & 64 /* Method */) {
        Object.defineProperty(elm, memberName, {
          value(...args) {
            var _a2;
            const ref = getHostRef(this);
            return (_a2 = ref == null ? void 0 : ref.$onInstancePromise$) == null ? void 0 : _a2.then(() => {
              var _a3;
              return (_a3 = ref == null ? void 0 : ref.$lazyInstance$) == null ? void 0 : _a3[memberName](...args);
            }).catch((e) => {
              consoleError(e, this);
            });
          }
        });
      }
    });
  }
}
function componentOnReady() {
  var _a;
  return (_a = getHostRef(this)) == null ? void 0 : _a.$onReadyPromise$;
}
function forceUpdate2() {
}

// src/hydrate/platform/hydrate-app.ts
function hydrateApp(win2, opts, results, afterHydrate, resolve) {
  const connectedElements = /* @__PURE__ */ new Set();
  const createdElements = /* @__PURE__ */ new Set();
  const waitingElements = /* @__PURE__ */ new Set();
  const orgDocumentCreateElement = win2.document.createElement;
  const orgDocumentCreateElementNS = win2.document.createElementNS;
  const resolved2 = Promise.resolve();
  let tmrId;
  let ranCompleted = false;
  function hydratedComplete() {
    globalThis.clearTimeout(tmrId);
    createdElements.clear();
    connectedElements.clear();
    if (!ranCompleted) {
      ranCompleted = true;
      try {
        if (opts.clientHydrateAnnotations) {
          insertVdomAnnotations(win2.document, opts.staticComponents);
        }
        win2.dispatchEvent(new win2.Event("DOMContentLoaded"));
        win2.document.createElement = orgDocumentCreateElement;
        win2.document.createElementNS = orgDocumentCreateElementNS;
      } catch (e) {
        renderCatchError(opts, results, e);
      }
    }
    afterHydrate(win2, opts, results, resolve);
  }
  function hydratedError(err2) {
    renderCatchError(opts, results, err2);
    hydratedComplete();
  }
  function timeoutExceeded() {
    hydratedError(`Hydrate exceeded timeout${waitingOnElementsMsg(waitingElements)}`);
  }
  try {
    let patchedConnectedCallback2 = function() {
      return connectElement2(this);
    }, patchElement2 = function(elm) {
      if (isValidComponent(elm, opts)) {
        const hostRef = getHostRef(elm);
        if (!hostRef) {
          const Cstr = loadModule(
            {
              $tagName$: elm.nodeName.toLowerCase()});
          if (Cstr != null && Cstr.cmpMeta != null) {
            if (opts.serializeShadowRoot !== false && !!(Cstr.cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) && tagRequiresScoped(elm.tagName, opts.serializeShadowRoot)) {
              const cmpMeta = Cstr.cmpMeta;
              cmpMeta.$flags$ |= 128 /* shadowNeedsScopedCss */;
              Object.defineProperty(Cstr, "cmpMeta", {
                get: function() {
                  return cmpMeta;
                }
              });
            }
            createdElements.add(elm);
            elm.connectedCallback = patchedConnectedCallback2;
            registerHost(elm, Cstr.cmpMeta);
            proxyHostElement(elm, Cstr);
          }
        }
      }
    }, patchChild2 = function(elm) {
      if (elm != null && elm.nodeType === 1) {
        patchElement2(elm);
        const children = elm.children;
        for (let i2 = 0, ii = children.length; i2 < ii; i2++) {
          patchChild2(children[i2]);
        }
      }
    }, connectElement2 = function(elm) {
      createdElements.delete(elm);
      if (isValidComponent(elm, opts) && results.hydratedCount < opts.maxHydrateCount) {
        if (!connectedElements.has(elm) && shouldHydrate(elm)) {
          connectedElements.add(elm);
          return hydrateComponent.call(elm, win2, results, elm.nodeName, elm, waitingElements);
        }
      }
      return resolved2;
    }, waitLoop2 = function() {
      const toConnect = Array.from(createdElements).filter((elm) => elm.parentElement);
      if (toConnect.length > 0) {
        return Promise.all(toConnect.map(connectElement2)).then(waitLoop2);
      }
      return resolved2;
    };
    win2.document.createElement = function patchedCreateElement(tagName) {
      const elm = orgDocumentCreateElement.call(win2.document, tagName);
      patchElement2(elm);
      return elm;
    };
    win2.document.createElementNS = function patchedCreateElement(namespaceURI, tagName) {
      const elm = orgDocumentCreateElementNS.call(win2.document, namespaceURI, tagName);
      patchElement2(elm);
      return elm;
    };
    tmrId = globalThis.setTimeout(timeoutExceeded, opts.timeout);
    plt.$resourcesUrl$ = new URL(opts.resourcesUrl || "./", win2.document.baseURI).href;
    patchChild2(win2.document.body);
    waitLoop2().then(hydratedComplete).catch(hydratedError);
  } catch (e) {
    hydratedError(e);
  }
}
async function hydrateComponent(win2, results, tagName, elm, waitingElements) {
  tagName = tagName.toLowerCase();
  const Cstr = loadModule(
    {
      $tagName$: tagName});
  if (Cstr != null) {
    const cmpMeta = Cstr.cmpMeta;
    if (cmpMeta != null) {
      waitingElements.add(elm);
      const hostRef = getHostRef(this);
      if (!hostRef) {
        return;
      }
      addHostEventListeners(this, hostRef, cmpMeta.$listeners$);
      try {
        connectedCallback(elm);
        await elm.componentOnReady();
        results.hydratedCount++;
        const ref = getHostRef(elm);
        const modeName = !(ref == null ? void 0 : ref.$modeName$) ? "$" : ref == null ? void 0 : ref.$modeName$;
        if (!results.components.some((c) => c.tag === tagName && c.mode === modeName)) {
          results.components.push({
            tag: tagName,
            mode: modeName,
            count: 0,
            depth: -1
          });
        }
      } catch (e) {
        win2.console.error(e);
      }
      waitingElements.delete(elm);
    }
  }
}
function isValidComponent(elm, opts) {
  if (elm != null && elm.nodeType === 1) {
    const tagName = elm.nodeName;
    if (typeof tagName === "string" && tagName.includes("-")) {
      if (opts.excludeComponents.includes(tagName.toLowerCase())) {
        return false;
      }
      return true;
    }
  }
  return false;
}
function shouldHydrate(elm) {
  if (elm.nodeType === 9) {
    return true;
  }
  if (NO_HYDRATE_TAGS.has(elm.nodeName)) {
    return false;
  }
  if (elm.hasAttribute("no-prerender")) {
    return false;
  }
  const parentNode = elm.parentNode;
  if (parentNode == null) {
    return true;
  }
  return shouldHydrate(parentNode);
}
var NO_HYDRATE_TAGS = /* @__PURE__ */ new Set([
  "CODE",
  "HEAD",
  "IFRAME",
  "INPUT",
  "OBJECT",
  "OUTPUT",
  "NOSCRIPT",
  "PRE",
  "SCRIPT",
  "SELECT",
  "STYLE",
  "TEMPLATE",
  "TEXTAREA"
]);
function renderCatchError(opts, results, err2) {
  const diagnostic = {
    level: "error",
    type: "build",
    header: "Hydrate Error",
    messageText: "",
    relFilePath: void 0,
    absFilePath: void 0,
    lines: []
  };
  if (opts.url) {
    try {
      const u = new URL(opts.url);
      if (u.pathname !== "/") {
        diagnostic.header += ": " + u.pathname;
      }
    } catch (e) {
    }
  }
  if (err2 != null) {
    if (err2.stack != null) {
      diagnostic.messageText = err2.stack.toString();
    } else if (err2.message != null) {
      diagnostic.messageText = err2.message.toString();
    } else {
      diagnostic.messageText = err2.toString();
    }
  }
  results.diagnostics.push(diagnostic);
}
function printTag(elm) {
  let tag = `<${elm.nodeName.toLowerCase()}`;
  if (Array.isArray(elm.attributes)) {
    for (let i2 = 0; i2 < elm.attributes.length; i2++) {
      const attr = elm.attributes[i2];
      tag += ` ${attr.name}`;
      if (attr.value !== "") {
        tag += `="${attr.value}"`;
      }
    }
  }
  tag += `>`;
  return tag;
}
function waitingOnElementMsg(waitingElement) {
  let msg = "";
  if (waitingElement) {
    const lines = [];
    msg = " - waiting on:";
    let elm = waitingElement;
    while (elm && elm.nodeType !== 9 && elm.nodeName !== "BODY") {
      lines.unshift(printTag(elm));
      elm = elm.parentElement;
    }
    let indent = "";
    for (const ln of lines) {
      indent += "  ";
      msg += `
${indent}${ln}`;
    }
  }
  return msg;
}
function waitingOnElementsMsg(waitingElements) {
  return Array.from(waitingElements).map(waitingOnElementMsg);
}
function tagRequiresScoped(tagName, opts) {
  if (typeof opts === "string") {
    return opts === "scoped";
  }
  if (typeof opts === "boolean") {
    return opts === true ? false : true;
  }
  if (typeof opts === "object") {
    tagName = tagName.toLowerCase();
    if (Array.isArray(opts["declarative-shadow-dom"]) && opts["declarative-shadow-dom"].includes(tagName)) {
      return false;
    } else if ((!Array.isArray(opts.scoped) || !opts.scoped.includes(tagName)) && opts.default === "declarative-shadow-dom") {
      return false;
    } else {
      return true;
    }
  }
  return false;
}
var cmpModules = /* @__PURE__ */ new Map();
var getModule = (tagName) => {
  if (typeof tagName === "string") {
    tagName = tagName.toLowerCase();
    const cmpModule = cmpModules.get(tagName);
    if (cmpModule != null) {
      return cmpModule[tagName];
    }
  }
  return null;
};
var loadModule = (cmpMeta, _hostRef, _hmrVersionId) => {
  return getModule(cmpMeta.$tagName$);
};
var isMemberInElement = (elm, memberName) => {
  if (elm != null) {
    if (memberName in elm) {
      return true;
    }
    const cstr = getModule(elm.nodeName);
    if (cstr != null) {
      const hostRef = cstr;
      if (hostRef != null && hostRef.cmpMeta != null && hostRef.cmpMeta.$members$ != null) {
        return memberName in hostRef.cmpMeta.$members$;
      }
    }
  }
  return false;
};
var registerComponents = (Cstrs) => {
  for (const Cstr of Cstrs) {
    const exportName = Cstr.cmpMeta.$tagName$;
    const transformedTagName = $stencilTagTransform.transformTag(exportName);
    cmpModules.set(exportName, {
      [exportName]: Cstr
    });
    if (transformedTagName !== exportName) {
      cmpModules.set(transformedTagName, {
        [transformedTagName]: Cstr
      });
    }
  }
};
var win = window;
var writeTask = (cb) => {
  nextTick(() => {
    try {
      cb();
    } catch (e) {
      consoleError(e);
    }
  });
};
var resolved = /* @__PURE__ */ Promise.resolve();
var nextTick = (cb) => resolved.then(cb);
var defaultConsoleError = (e) => {
  if (e != null) {
    console.error(e.stack || e.message || e);
  }
};
var consoleError = (e, el) => (defaultConsoleError)(e, el);
var plt = {
  $flags$: 0,
  $resourcesUrl$: "",
  jmp: (h2) => h2(),
  raf: (h2) => requestAnimationFrame(h2),
  ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
  rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
  ce: (eventName, opts) => new win.CustomEvent(eventName, opts)
};
var supportsShadow = BUILD.shadowDom;
var getHostRef = (ref) => {
  if (ref.__stencil__getHostRef) {
    return ref.__stencil__getHostRef();
  }
  return void 0;
};
var registerInstance = (lazyInstance, hostRef) => {
  if (!hostRef) return void 0;
  lazyInstance.__stencil__getHostRef = () => hostRef;
  hostRef.$lazyInstance$ = lazyInstance;
  if (hostRef.$cmpMeta$.$flags$ & 512 /* hasModernPropertyDecls */ && (BUILD.state)) {
    reWireGetterSetter(lazyInstance, hostRef);
  }
  return hostRef;
};
var registerHost = (elm, cmpMeta) => {
  const hostRef = {
    $flags$: 0,
    $cmpMeta$: cmpMeta,
    $hostElement$: elm,
    $instanceValues$: /* @__PURE__ */ new Map(),
    $serializerValues$: /* @__PURE__ */ new Map(),
    $renderCount$: 0
  };
  hostRef.$fetchedCbList$ = [];
  hostRef.$onInstancePromise$ = new Promise((r) => hostRef.$onInstanceResolve$ = r);
  hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
  elm["s-p"] = [];
  elm["s-rc"] = [];
  elm.__stencil__getHostRef = () => hostRef;
  return hostRef;
};
var styles = /* @__PURE__ */ new Map();

const pnAccordionCss = () => `${transformTag("pn-accordion")}{position:relative;background-color:#ffffff;display:flex;align-items:stretch;flex-direction:column;gap:0.25em}${transformTag("pn-accordion")}[data-transparent]{background-color:transparent}${transformTag("pn-accordion")}>${transformTag("pn-accordion-row")}+${transformTag("pn-accordion-row")}:after{content:"";position:absolute;top:-0.125em;left:0.25em;width:calc(100% - 0.5em);height:0;border-top:0.0625em solid #d3cecb}`;

/**
 * The `pn-accordion` is a wrapper for `pn-accordion-row` components.
 * This component gives the accordion rows some space between each one and provides the `single` feature.
 * Which will force the rule that only a single row to be open at one time.
 */
class PnAccordion {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    mo;
    closeEvent = new CustomEvent('rowstate', { detail: false });
    get hostElement() { return getElement(this); }
    /** Only allow a single row to be open at once. @since v7.8.0 */
    single = false;
    /** Optional prop that removes the default white background on the accordion row. @since v7.10.0 */
    transparent = false;
    connectedCallback() {
        this.mo = new MutationObserver(() => forceUpdate());
        this.mo.observe(this.hostElement, { childList: true, subtree: true });
    }
    disconnectedCallback() {
        this.mo.disconnect();
    }
    handleSingleRow({ detail }) {
        if (!this.single)
            return;
        const rowName = transformTag('pn-accordion-row');
        const element = detail.element;
        const activeRow = element.closest(rowName);
        const rows = Array.from(this.hostElement.querySelectorAll(rowName));
        rows.forEach(row => !row.isSameNode(activeRow) && row.dispatchEvent(this.closeEvent));
    }
    render() {
        return (hAsync(Host, { key: 'e6a1b3b18e0b6f366191f7b25154349e8fb3f81d', class: "pn-accordion", "data-transparent": this.transparent }, hAsync("slot", { key: '4bdd61aafbb42520ed3af9e50045376104bee491' })));
    }
    static get style() { return pnAccordionCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-accordion",
        "$members$": {
            "single": [4],
            "transparent": [4]
        },
        "$listeners$": [[0, "togglerow", "handleSingleRow"]],
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const icon$n = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0m8-10C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2m1.4 5.497-.334 5.005a1.069 1.069 0 0 1-2.133 0L10.6 7.497a1.403 1.403 0 1 1 2.8 0M12 18a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3" clip-rule="evenodd"/></svg>';
const alert_exclamation_circle = icon$n;

const icon$m = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M12.874 2.514a1 1 0 0 0-1.748 0l-10 18A1 1 0 0 0 2 22h20a1 1 0 0 0 .874-1.486zM12 5.06 20.3 20H3.7zm-1.375 4.936a1.38 1.38 0 1 1 2.75 0l-.292 3.509a1.087 1.087 0 0 1-2.166 0zM12 15.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3" clip-rule="evenodd"/></svg>';
const alert_exclamation_triangle = icon$m;

const icon$l = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0m8-10C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2m0 8a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m1 2v4.5a1 1 0 1 1-2 0V12a1 1 0 1 1 2 0" clip-rule="evenodd"/></svg>';
const alert_info_circle = icon$l;

const icon$k = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0m8-10C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2m-1.015 7.207c.14-.422.536-.707.981-.707h.18a.87.87 0 0 1 .854.871c0 .313-.179.6-.447.735A2.81 2.81 0 0 0 11 12.618V13a1 1 0 1 0 2 0v-.382a.81.81 0 0 1 .447-.724A2.83 2.83 0 0 0 15 9.371C15 7.807 13.734 6.5 12.146 6.5h-.18a3.03 3.03 0 0 0-2.878 2.075l-.037.109a1 1 0 1 0 1.898.632zM12 17.5a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3" clip-rule="evenodd"/></svg>';
const alert_question_circle = icon$k;

const icon$j = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M4.293 12.707a1 1 0 0 1 0-1.414l6-6a1 1 0 1 1 1.414 1.414L7.414 11H16a1 1 0 1 1 0 2H7.414l4.293 4.293a1 1 0 0 1-1.414 1.414zM18.99 11H19a1 1 0 1 1 0 2h-.01a1 1 0 1 1 0-2" clip-rule="evenodd"/></svg>';
const arrow_left = icon$j;

const icon$i = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M19.707 11.293a1 1 0 0 1 0 1.414l-6 6a1 1 0 0 1-1.414-1.414L16.586 13H8a1 1 0 1 1 0-2h8.586l-4.293-4.293a1 1 0 0 1 1.414-1.414zM5.01 13H5a1 1 0 1 1 0-2h.01a1 1 0 1 1 0 2" clip-rule="evenodd"/></svg>';
const arrow_right = icon$i;

const icon$h = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M9 7.5a4.5 4.5 0 1 1 9 0V16a6 6 0 0 1-12 0v-3a1 1 0 1 1 2 0v3a4 4 0 0 0 8 0V7.5a2.5 2.5 0 0 0-5 0V16a1 1 0 1 0 2 0v-6a1 1 0 1 1 2 0v6a3 3 0 1 1-6 0zM7 9a1 1 0 0 1 1 1v.1a1 1 0 1 1-2 0V10a1 1 0 0 1 1-1" clip-rule="evenodd"/></svg>';
const attachment = icon$h;

const icon$g = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M9 3.5a1 1 0 0 1 1 1V5h4v-.5a1 1 0 1 1 2 0V5h2a3 3 0 0 1 3 3v9a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V8a3 3 0 0 1 3-3h2v-.5a1 1 0 0 1 1-1M8 7H6a1 1 0 0 0-1 1v1.5h14V8a1 1 0 0 0-1-1h-2v.5a1 1 0 1 1-2 0V7h-4v.5a1 1 0 0 1-2 0zm11 4.5H5V17a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1z" clip-rule="evenodd"/></svg>';
const calendar = icon$g;

const icon$f = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12m10-8a8 8 0 1 0 0 16 8 8 0 0 0 0-16m5.207 4.793a1 1 0 0 1 0 1.414l-6 6a1 1 0 0 1-1.414 0l-3.5-3.5a1 1 0 1 1 1.414-1.414l2.793 2.793 5.293-5.293a1 1 0 0 1 1.414 0" clip-rule="evenodd"/></svg>';
const check_circle = icon$f;

const icon$e = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M19.207 7.793a1 1 0 0 1 0 1.414l-8 8a1 1 0 0 1-1.414 0l-5-5a1 1 0 1 1 1.414-1.414l4.293 4.293 7.293-7.293a1 1 0 0 1 1.414 0" clip-rule="evenodd"/></svg>';
const check = icon$e;

const icon$d = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M12.707 16.707a1 1 0 0 1-1.414 0l-8-8a1 1 0 0 1 1.414-1.414L12 14.586l7.293-7.293a1 1 0 1 1 1.414 1.414z" clip-rule="evenodd"/></svg>';
const chevron_down = icon$d;

const icon$c = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M6.293 12.707a1 1 0 0 1 0-1.414l8-8a1 1 0 1 1 1.414 1.414L8.414 12l7.293 7.293a1 1 0 0 1-1.414 1.414z" clip-rule="evenodd"/></svg>';
const chevron_left = icon$c;

const icon$b = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M17.707 11.293a1 1 0 0 1 0 1.414l-8 8a1 1 0 0 1-1.414-1.414L15.586 12 8.293 4.707a1 1 0 0 1 1.414-1.414z" clip-rule="evenodd"/></svg>';
const chevron_right = icon$b;

const icon$a = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M6.293 6.293a1 1 0 0 1 1.414 0L12 10.586l4.293-4.293a1 1 0 1 1 1.414 1.414L13.414 12l4.293 4.293a1 1 0 0 1-1.414 1.414L12 13.414l-4.293 4.293a1 1 0 0 1-1.414-1.414L10.586 12 6.293 7.707a1 1 0 0 1 0-1.414" clip-rule="evenodd"/></svg>';
const close_small = icon$a;

const icon$9 = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M4.293 4.293a1 1 0 0 1 1.414 0L12 10.586l6.293-6.293a1 1 0 1 1 1.414 1.414L13.414 12l6.293 6.293a1 1 0 0 1-1.414 1.414L12 13.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L10.586 12 4.293 5.707a1 1 0 0 1 0-1.414" clip-rule="evenodd"/></svg>';
const close = icon$9;

const icon$8 = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M2 12a1 1 0 0 1 1-1h18a1 1 0 1 1 0 2H3a1 1 0 0 1-1-1" clip-rule="evenodd"/></svg>';
const minus = icon$8;

const icon$7 = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M7 6a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1v-1a1 1 0 1 1 2 0v1a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3h1a1 1 0 0 1 0 2zm5-1a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v6a1 1 0 1 1-2 0V7.414l-5.293 5.293a1 1 0 0 1-1.414-1.414L16.586 6H13a1 1 0 0 1-1-1m-1.283 8.283a1 1 0 0 1 0 1.414l-.01.01a1 1 0 0 1-1.414-1.414l.01-.01a1 1 0 0 1 1.414 0" clip-rule="evenodd"/></svg>';
const open_in_new = icon$7;

const icon$6 = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M12 2a1 1 0 0 1 1 1v8h8a1 1 0 1 1 0 2h-8v8a1 1 0 1 1-2 0v-8H3a1 1 0 1 1 0-2h8V3a1 1 0 0 1 1-1" clip-rule="evenodd"/></svg>';
const plus = icon$6;

const icon$5 = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M1.81 11.727a1 1 0 0 1 1.363.378c.29.513.835 1.343 1.7 2.174a9.5 9.5 0 0 0 3.457 2.128c1.03.361 2.244.593 3.67.593s2.64-.232 3.67-.593a9.5 9.5 0 0 0 3.458-2.128 9.7 9.7 0 0 0 1.698-2.174 1 1 0 0 1 1.742.984 11.5 11.5 0 0 1-1.445 2.001l1.686 2.322a1 1 0 1 1-1.618 1.175l-1.537-2.116a11.4 11.4 0 0 1-2.453 1.48l.763 2.785a1 1 0 1 1-1.928.528l-.73-2.661c-.993.251-2.093.397-3.306.397s-2.313-.146-3.306-.397l-.73 2.661a1 1 0 1 1-1.928-.528l.763-2.786a11.4 11.4 0 0 1-2.453-1.479L2.81 18.587a1 1 0 0 1-1.618-1.175l1.686-2.322a11.5 11.5 0 0 1-1.445-2 1 1 0 0 1 .379-1.363" clip-rule="evenodd"/></svg>';
const preview_off = icon$5;

const icon$4 = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M12 7c-5.382 0-7.908 3.33-8.758 4.775a.43.43 0 0 0 0 .45C4.092 13.67 6.618 17 12 17s7.908-3.33 8.758-4.775a.43.43 0 0 0 0-.45C19.908 10.33 17.382 7 12 7M1.518 10.761C2.55 9.005 5.618 5 12 5s9.45 4.005 10.482 5.761a2.43 2.43 0 0 1 0 2.478C21.45 14.995 18.382 19 12 19s-9.45-4.005-10.482-5.761a2.43 2.43 0 0 1 0-2.478M8 12a4 4 0 1 1 8 0 4 4 0 0 1-8 0m4-2a2 2 0 1 0 0 4 2 2 0 0 0 0-4" clip-rule="evenodd"/></svg>';
const preview_on = icon$4;

const icon$3 = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M11.707 21.707a1 1 0 0 0 0-1.414L8.414 17H11.5a7.5 7.5 0 0 0 0-15H11a1 1 0 1 0 0 2h.5a5.5 5.5 0 1 1 0 11H8.414l3.293-3.293a1 1 0 0 0-1.414-1.414l-5 5a1 1 0 0 0 0 1.414l5 5a1 1 0 0 0 1.414 0M7 3a1 1 0 0 0 1 1h.01a1 1 0 0 0 0-2H8a1 1 0 0 0-1 1" clip-rule="evenodd"/></svg>';
const pn_return = icon$3;

const icon$2 = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M4 11.442A7.44 7.44 0 0 1 11.44 4c6.24 0 9.617 7.154 5.923 11.949l2.844 2.844a1 1 0 0 1-1.414 1.414l-2.837-2.837C11.21 21.045 4 17.73 4 11.441m11.277 3.867C11.846 18.714 6 16.284 6 11.442A5.44 5.44 0 0 1 11.44 6c4.724 0 7.204 5.605 4.026 9.1z" clip-rule="evenodd"/></svg>';
const search = icon$2;

const icon$1 = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M10.5 4a1 1 0 0 0-1 1h5a1 1 0 0 0-1-1zm6 1a3 3 0 0 0-3-3h-3a3 3 0 0 0-3 3h-2A2.5 2.5 0 0 0 5 9.95V19a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3V9.95A2.5 2.5 0 0 0 18.5 5zm.5 5H7v9a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1zM5.5 7a.5.5 0 0 0 0 1h13a.5.5 0 0 0 0-1zm4.5 5a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0v-4a1 1 0 0 1 1-1m4 0a1 1 0 0 1 1 1v4a1 1 0 1 1-2 0v-4a1 1 0 0 1 1-1" clip-rule="evenodd"/></svg>';
const trash_can = icon$1;

const icon = '<svg class="pn-icon-svg" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#000" fill-rule="evenodd" d="M3 8a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v7a3 3 0 0 1-3 3h-2a1 1 0 1 1 0-2h2a1 1 0 0 0 1-1V8a1 1 0 0 0-1-1H6a1 1 0 0 0-1 1v7a1 1 0 0 0 1 1h2a1 1 0 1 1 0 2H6a3 3 0 0 1-3-3zm9 0a1 1 0 0 1 .707.293l4 4a1 1 0 0 1-1.414 1.414L13 11.414V17a1 1 0 1 1-2 0v-5.586l-2.293 2.293a1 1 0 0 1-1.414-1.414l4-4A1 1 0 0 1 12 8m-1 12.1V20a1 1 0 1 1 2 0v.1a1 1 0 1 1-2 0" clip-rule="evenodd"/></svg>';
const upload = icon;

const byteToHex = [];
for (let i = 0; i < 256; ++i) {
    byteToHex.push((i + 0x100).toString(16).slice(1));
}
function unsafeStringify(arr, offset = 0) {
    return (byteToHex[arr[offset + 0]] +
        byteToHex[arr[offset + 1]] +
        byteToHex[arr[offset + 2]] +
        byteToHex[arr[offset + 3]] +
        '-' +
        byteToHex[arr[offset + 4]] +
        byteToHex[arr[offset + 5]] +
        '-' +
        byteToHex[arr[offset + 6]] +
        byteToHex[arr[offset + 7]] +
        '-' +
        byteToHex[arr[offset + 8]] +
        byteToHex[arr[offset + 9]] +
        '-' +
        byteToHex[arr[offset + 10]] +
        byteToHex[arr[offset + 11]] +
        byteToHex[arr[offset + 12]] +
        byteToHex[arr[offset + 13]] +
        byteToHex[arr[offset + 14]] +
        byteToHex[arr[offset + 15]]).toLowerCase();
}

let getRandomValues;
const rnds8 = new Uint8Array(16);
function rng() {
    if (!getRandomValues) {
        if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
            throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
        }
        getRandomValues = crypto.getRandomValues.bind(crypto);
    }
    return getRandomValues(rnds8);
}

const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
var native = { randomUUID };

function _v4(options, buf, offset) {
    options = options || {};
    const rnds = options.random ?? options.rng?.() ?? rng();
    if (rnds.length < 16) {
        throw new Error('Random bytes length must be >= 16');
    }
    rnds[6] = (rnds[6] & 0x0f) | 0x40;
    rnds[8] = (rnds[8] & 0x3f) | 0x80;
    return unsafeStringify(rnds);
}
function v4(options, buf, offset) {
    if (native.randomUUID && true && !options) {
        return native.randomUUID();
    }
    return _v4(options);
}

const SE = 'SE';
const NO = 'NO';
const sv$2 = 'sv';
const en$2 = 'en';
const humanReadableFileSize = {
    KB: 1024,
    MB: 1024 * 1024,
    GB: 1024 * 1024 * 1024,
    TB: 1024 * 1024 * 1024 * 1024,
};
const getBytesFromHumanReadableFileSize = function (sizeString) {
    const normalized = sizeString.trim();
    if (!normalized)
        return 0;
    const firstUnitCharIndex = normalized.search(/[a-zA-Z]/);
    const sizePart = firstUnitCharIndex === -1 ? normalized : normalized.slice(0, firstUnitCharIndex).trim();
    const unitPart = firstUnitCharIndex === -1 ? '' : normalized.slice(firstUnitCharIndex).trim();
    if (!sizePart || (unitPart && !/^[a-zA-Z]{2}$/.test(unitPart)))
        return 0;
    const size = Number(sizePart);
    if (!Number.isFinite(size))
        return 0;
    const unit = unitPart.toUpperCase();
    const baseSize = humanReadableFileSize[unit];
    return baseSize ? size * baseSize : size;
};
function isSmallScreen() {
    return window.innerWidth / 16 < 55;
}
function reduceMotion() {
    const { matches } = window.matchMedia('(prefers-reduced-motion: reduce)');
    return matches;
}
const uuidv4 = () => v4();
function getTopbarHeight() {
    return document?.querySelector('pn-topbar')?.offsetHeight || 0;
}
function getMenuHeight() {
    return isSmallScreen() ? document?.querySelector('pn-side-menu')?.offsetHeight || 0 : 0;
}
function getMenuWidth() {
    return isSmallScreen() ? 0 : document?.querySelector('pn-side-menu')?.offsetWidth || 0;
}
function getTotalHeightOffset() {
    const totalOffset = getTopbarHeight() + getMenuHeight();
    return totalOffset > window.scrollY ? totalOffset - window.scrollY : 0;
}
/**
 * @param {HTMLElement} host Use the `this.hostElement` property.
 *
 * @description The `awaitTopbar` function can be used to wait for the topbar to be available.
 *
 * The function will also setup listeners for any market/language changes from the topbar and updates the host element with the `setAttribute` function.
 *
 * Remember to use a Stencil `@Prop` named `market` and/or `language` to take advantage of the auto update feature.
 *
 * @returns The pnTopbar object.
 */
async function awaitTopbar(host) {
    const topbar = () => window.pnTopbar;
    function finishSetup(fallBack) {
        const data = fallBack || topbar();
        host.market = data.market;
        host.language = data.language;
        if (data.hasLoaded) {
            topbar().onChangeMarket = (market) => (host.market = market);
            topbar().onChangeLanguage = (language) => (host.language = language);
        }
        return data;
    }
    return await new Promise(resolve => {
        // If the pntopbar script does not exist. Resolve with default values.
        if (!document.querySelector('pn-topbar'))
            return resolve(finishSetup({ hasLoaded: false, market: host.market || SE, language: host.language || en$2 }));
        if (topbar()?.hasLoaded)
            return resolve(finishSetup());
        window.addEventListener('topbarLoaded', () => resolve(finishSetup()));
    });
}
/**
 * @description Apply the Ripple effect quick and easy.
 *
 * @example
 * ```css
 * // CSS
 * pn-component-name { `@include pn-ripple($blue700) }
 * ```
 *
 * ```js
 * // tsx
 * onClick((e) => ripple(e, this.hostElement, '.pn-ripple-container'))
 * ```
 * @param event The MouseEvent from a onClick handler.
 * @param host The hostElement of the component (root element).
 * @param rippleClass Append the ripple event to this selector instead of the host element.
 */
const ripple = (event, host, rippleClass) => {
    if (reduceMotion())
        return;
    const { left, top, width, height } = host.getBoundingClientRect();
    const { clientX = 0, clientY = 0 } = event || {};
    const elSize = width > height ? width : height;
    const element = document.createElement(transformTag('div'));
    element.classList.add('pn-ripple');
    element.style.height = `${elSize * 2}px`;
    element.style.width = `${elSize * 2}px`;
    element.style.left = clientX > 0 ? `${clientX - left}px` : `50%`;
    element.style.top = clientY > 0 ? `${clientY - top}px` : `50%`;
    if (rippleClass)
        host.querySelector(rippleClass).appendChild(element);
    else
        host.appendChild(element);
    setTimeout(() => element.remove(), 400);
};

const pnAccordionRowCss = () => `${transformTag("pn-accordion-row")}{position:relative;margin:0 -0.25em 0}${transformTag("pn-accordion-row")} .pn-accordion-row{width:100%;display:flex;flex-direction:column}${transformTag("pn-accordion-row")} .pn-accordion-row-summary{color:#2d2013;position:relative;border:none;outline:0;cursor:pointer;-webkit-tap-highlight-color:transparent;width:100%;padding:0.25em;font-size:1em;font-weight:400;border-radius:0.5em;list-style:none}${transformTag("pn-accordion-row")} .pn-accordion-row-summary:hover>.pn-accordion-row-text{background-color:#e0f8ff}${transformTag("pn-accordion-row")} .pn-accordion-row-summary:focus-visible>.pn-accordion-row-text{outline-color:#005d92}${transformTag("pn-accordion-row")} .pn-accordion-row-summary::-webkit-details-marker{display:none}${transformTag("pn-accordion-row")} .pn-accordion-row-text{position:relative;overflow:hidden;display:flex;align-items:center;padding:0.75em;background-color:#ffffff;border-radius:0.5em;-webkit-tap-highlight-color:transparent}${transformTag("pn-accordion-row")} .pn-accordion-row-text[data-transparent]{background-color:transparent}${transformTag("pn-accordion-row")} .pn-accordion-row-text{outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:background-color, outline-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-accordion-row")} .pn-accordion-row-text{transition-duration:0s;transition-delay:0s}}${transformTag("pn-accordion-row")} .pn-accordion-row-text .pn-ripple{animation:ripple 0.4s cubic-bezier(0.7, 0, 0.3, 1);position:absolute;border-radius:50%;background-color:#005d92;transform:translate(-50%, -50%) scale(0);opacity:0.1;pointer-events:none;z-index:3}@keyframes ripple{to{transform:translate(-50%, -50%) scale(1);opacity:0}}${transformTag("pn-accordion-row")} .pn-accordion-row-icon{margin-left:auto;flex-shrink:0;transition-property:transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-accordion-row")} .pn-accordion-row-icon{transition-duration:0s;transition-delay:0s}}${transformTag("pn-accordion-row")} .pn-accordion-row-icon path{fill:#005d92}${transformTag("pn-accordion-row")} .pn-accordion-row[open] .pn-accordion-row-icon{transform:rotate(-180deg)}${transformTag("pn-accordion-row")} .pn-accordion-row-content{color:#2d2013;display:block;padding:1em}`;

/**
 * Use this row component inside a `pn-accordion` to create an accordion group.
 *
 * **Note**: you can use the `pn-accordion-row` without the parent accordion.
 * But you will have to style the gap between each row.
 *
 * @slot label - Include your own HTML as the label.
 * ```
 * <h3 slot="label">Custom title</h3>
 * ```
 */
class PnAccordionRow {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.togglerow = createEvent(this, "togglerow", 7);
    }
    details;
    summary;
    content;
    animation;
    defaultAnimationDuration = 400;
    animationDuration = this.defaultAnimationDuration;
    get hostElement() { return getElement(this); }
    isClosing = false;
    isExpanding = false;
    /** The label/title of the accordion row, you can also pass a slot with the name "label" if you want to put custom HTML content in there. */
    label;
    /** The open/close status of the accordion row. */
    state = false;
    /** Optional unique id for the `summary` element. @category ID */
    buttonid;
    /** Optional unique id for the `div` element containing the content. @category ID */
    contentid;
    /** Optional prop that removes the default white background on the accordion row. @since v7.10.0 */
    transparent = false;
    /** Dispatched every time the row is toggled. Includes the row element and the boolean `state` prop. */
    togglerow;
    /** Internal function for closing rows when using the `single` prop on the `pn-accordion`. */
    handleRowState(event) {
        if (event.detail !== this.state) {
            this.details.style.overflow = 'hidden';
            this.closeAccordion();
        }
    }
    componentWillLoad() {
        const slottedLabel = !!this.hostElement.querySelector('[slot="label"]');
        this.label = slottedLabel ? null : this.label;
    }
    toggleOpen(open) {
        const state = open ?? !this.state;
        if (this.state !== open)
            this.togglerow.emit({ element: this.details, state });
        this.state = state;
    }
    clickHandler(e) {
        e.preventDefault();
        this.details.style.overflow = 'hidden';
        if (this.isClosing || !this.state)
            this.openAccordion();
        else if (this.isClosing || this.state)
            this.closeAccordion();
        const { x, width, y, top } = this.hostElement.getBoundingClientRect();
        const clientCor = e.clientX === 0 && e.clientY === 0 ? { clientX: x + width - 24, clientY: y - top } : e;
        ripple(clientCor, this.hostElement, '.pn-accordion-row-text');
    }
    openAccordion() {
        this.details.style.height = `${this.details.offsetHeight}px`;
        this.toggleOpen(true);
        requestAnimationFrame(() => {
            this.isExpanding = true;
            const startHeight = `${this.details.offsetHeight}px`;
            const endHeight = `${this.summary.offsetHeight + this.content.offsetHeight}px`;
            this.cancelAnimations();
            this.animate(true, startHeight, endHeight);
        });
    }
    closeAccordion() {
        this.isClosing = true;
        const startHeight = `${this.details.offsetHeight}px`;
        const endHeight = `${this.summary.offsetHeight}px`;
        this.cancelAnimations();
        this.animate(false, startHeight, endHeight);
    }
    animate(open, startHeight, endHeight) {
        if (reduceMotion())
            this.animationDuration = 0;
        else
            this.animationDuration = this.defaultAnimationDuration;
        this.animation = this.details.animate({
            height: [startHeight, endHeight],
        }, {
            duration: this.animationDuration,
            easing: 'cubic-bezier(0.6, 0, 0.2, 1)',
        });
        this.animation.onfinish = () => this.animationFinish(open);
        this.animation.oncancel = () => {
            if (open)
                this.isExpanding = false;
            else
                this.isClosing = false;
        };
    }
    animationFinish(open) {
        this.toggleOpen(open);
        this.cancelAnimations();
        this.isClosing = false;
        this.isExpanding = false;
        this.details.style.height = '';
        this.details.style.overflow = '';
    }
    cancelAnimations() {
        if (this.animation)
            this.animation.cancel();
    }
    render() {
        return (hAsync(Host, { key: '2b50f9026275b623128e0a441ec4434c50a54338' }, hAsync("details", { key: 'd60df44b58cd5c27306ec97dd42750bf1f01486c', class: "pn-accordion-row", open: this.state, ref: (el) => (this.details = el) }, hAsync("summary", { key: '448587e8102df440a0d633702ea4af8cfe1d9da3', id: this.buttonid, class: "pn-accordion-row-summary", onClick: e => this.clickHandler(e), ref: el => (this.summary = el) }, hAsync("div", { key: 'bef1fa9595b890919445a6631742c03fd7e18f3f', class: "pn-accordion-row-text", "data-transparent": this.transparent }, this.label ? this.label : '', hAsync("slot", { key: '30742c10f2f557f39f80e97ec3e1c5473400d128', name: "label" }), hAsync("pn-icon", { key: 'cfde3e68aab8348a0773c7aa41e02bb905a47e07', class: "pn-accordion-row-icon", icon: chevron_down }))), hAsync("div", { key: '054aae1bcf9fb3bf9a050c9fdf7cefef38f164d0', id: this.contentid, class: "pn-accordion-row-content", ref: (el) => (this.content = el) }, hAsync("slot", { key: '69378af205ca6c4c159c718f497a2ecf319be959' })))));
    }
    static get style() { return pnAccordionRowCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-accordion-row",
        "$members$": {
            "label": [1025],
            "state": [1028],
            "buttonid": [1],
            "contentid": [1],
            "transparent": [4],
            "isClosing": [32],
            "isExpanding": [32]
        },
        "$listeners$": [[0, "rowstate", "handleRowState"]],
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

/** Import the State and functions needed to easily animate the height of an element. */
function animateHeightFactory(Base) {
    const AnimateHeightMixin = class extends Base {
        constructor(hostRef) {
            super();
            registerInstance(this, hostRef);
        }
        animation;
        animationDurationDefault = 400;
        animationDuration = this.animationDurationDefault;
        isClosing = false;
        isExpanding = false;
        animateDropdown(element, open, startHeight, endHeight) {
            this.cancelAnimations();
            this.setAnimationDuration();
            element.dataset.moving = '';
            this.animation = element.animate({
                height: [startHeight, endHeight],
            }, {
                duration: this.animationDuration,
                easing: 'cubic-bezier(0.6, 0, 0.2, 1)',
            });
            this.animation.onfinish = () => this.animationFinish(element);
            this.animation.oncancel = () => (open ? (this.isExpanding = false) : (this.isClosing = false));
        }
        /** Open the dropdown by assigning the HTML element you want to animate. */
        openDropdown(element, heightOverride) {
            const { clientHeight, scrollHeight } = element;
            const height = this.isClosing ? clientHeight : 0;
            element.style.height = `${scrollHeight}px`;
            this.isExpanding = true;
            this.animateDropdown(element, true, `${height}px`, `${heightOverride || element.scrollHeight}px`);
        }
        /** Close the dropdown by assigning the HTML element you want to animate. */
        closeDropdown(element, heightOverride) {
            const { scrollHeight, clientHeight } = element;
            const height = this.isExpanding ? clientHeight : scrollHeight;
            element.style.height = `0px`;
            this.isClosing = true;
            this.animateDropdown(element, false, `${heightOverride || height}px`, `0px`);
        }
        animationFinish(element) {
            this.cancelAnimations();
            element.style.height = this.isClosing ? '0px' : '';
            delete element.dataset.moving;
            this.isClosing = false;
            this.isExpanding = false;
        }
        cancelAnimations() {
            if (this.animation)
                this.animation.cancel();
        }
        setAnimationDuration() {
            if (reduceMotion())
                this.animationDuration = 0;
            else
                this.animationDuration = this.animationDurationDefault;
        }
        isMoving() {
            return this.isClosing || this.isExpanding;
        }
    };
    return AnimateHeightMixin;
}

const translations$g = {
    BACK: {
        sv: 'Tillbaka',
        en: 'Back',
        da: 'Tilbage',
        fi: 'Takaisin',
        no: 'Tilbake',
    },
};

const pnActionMenuCss = () => `${transformTag("pn-action-menu")}{--pn-menu-height:unset;display:inline-block;position:relative}${transformTag("pn-action-menu")} .pn-action-menu{position:relative}${transformTag("pn-action-menu")} .pn-action-menu-container{--pn-action-menu-offset:0;scroll-behavior:smooth;list-style:none;text-align:left;position:absolute;z-index:100;top:calc(100% + 0.5em);left:var(--pn-action-menu-offset);right:0;background-color:#ffffff;box-shadow:0em 0.075em 0.225em 0em rgba(0, 0, 0, 0.1), 0em 0.4em 0.9em 0em rgba(0, 0, 0, 0.13);border-radius:0.5em;margin:0;padding:0;width:16em;visibility:hidden;overflow:hidden}${transformTag("pn-action-menu")} .pn-action-menu-container[data-open]{visibility:visible;overflow:unset}${transformTag("pn-action-menu")} .pn-action-menu-container[data-left]{right:0;left:unset}${transformTag("pn-action-menu")} .pn-action-menu-container[data-upwards]{top:unset;bottom:calc(100% + 0.5em);transform-origin:bottom left}${transformTag("pn-action-menu")} .pn-action-menu-container[data-moving]{overflow:hidden;visibility:visible;pointer-events:none}${transformTag("pn-action-menu")} .pn-action-menu-container{}${transformTag("pn-action-menu")} .pn-action-menu-container[data-small] .pn-action-menu-list{border-radius:0.5em;visibility:hidden;transition-property:visibility;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-action-menu")} .pn-action-menu-container[data-small] .pn-action-menu-list{transition-duration:0s;transition-delay:0s}}${transformTag("pn-action-menu")} .pn-action-menu-container[data-small] .pn-action-menu-list{transition-delay:0.2s}${transformTag("pn-action-menu")} .pn-action-menu-container[data-small] .pn-action-menu-list[data-current]{overflow-x:auto;visibility:visible;transition-delay:0s}${transformTag("pn-action-menu")} .pn-action-menu-container[data-small][data-moving]>.pn-action-menu-list{visibility:visible}${transformTag("pn-action-menu")} .pn-action-menu-container[data-small] .pn-action-menu-item{position:unset}${transformTag("pn-action-menu")} .pn-action-menu-container[data-small] .pn-action-menu-sub{left:0;height:100%;box-shadow:unset;transform:translateX(0);visibility:hidden}${transformTag("pn-action-menu")} .pn-action-menu-container[data-small] .pn-action-menu-sub[data-current]{visibility:visible;overflow-x:auto}${transformTag("pn-action-menu")} .pn-action-menu-container::-webkit-scrollbar{background-color:#ffffff;width:0.875em;border-radius:0.5em}${transformTag("pn-action-menu")} .pn-action-menu-container::-webkit-scrollbar-track{background-color:#ffffff;border-radius:0.5em}${transformTag("pn-action-menu")} .pn-action-menu-container::-webkit-scrollbar-thumb{cursor:pointer;background-color:#969087;border-radius:1em;border:0.25em solid #ffffff}${transformTag("pn-action-menu")} .pn-action-menu-container::-webkit-scrollbar-thumb:hover{background-color:#5e554a}${transformTag("pn-action-menu")} .pn-action-menu-container::-webkit-scrollbar-corner,${transformTag("pn-action-menu")} .pn-action-menu-container::-webkit-scrollbar-button{display:none}${transformTag("pn-action-menu")} .pn-action-menu-list{margin:0;padding:0;list-style:none;height:var(--pn-menu-height)}${transformTag("pn-action-menu")} .pn-action-menu-list::-webkit-scrollbar{background-color:#ffffff;width:0.875em;border-radius:0.5em}${transformTag("pn-action-menu")} .pn-action-menu-list::-webkit-scrollbar-track{background-color:#ffffff;border-radius:0.5em}${transformTag("pn-action-menu")} .pn-action-menu-list::-webkit-scrollbar-thumb{cursor:pointer;background-color:#969087;border-radius:1em;border:0.25em solid #ffffff}${transformTag("pn-action-menu")} .pn-action-menu-list::-webkit-scrollbar-thumb:hover{background-color:#5e554a}${transformTag("pn-action-menu")} .pn-action-menu-list::-webkit-scrollbar-corner,${transformTag("pn-action-menu")} .pn-action-menu-list::-webkit-scrollbar-button{display:none}${transformTag("pn-action-menu")} .pn-action-menu-group{margin:0;padding:0;list-style:none}${transformTag("pn-action-menu")} .pn-action-menu-group-label{display:block;color:#2d2013;font-weight:700;font-size:0.875em;padding:1em 1em 0.5em}${transformTag("pn-action-menu")} .pn-action-menu-group-helpertext{display:block;color:#5e554a;font-weight:400;margin:0.25em 0 0}${transformTag("pn-action-menu")} .pn-action-menu-sub{z-index:110;position:absolute;top:0;width:100%;min-width:12em;margin:0;padding:0;list-style:none;background:#ffffff;border-radius:0.5em;box-shadow:0em 0.075em 0.225em 0em rgba(0, 0, 0, 0.1), 0em 0.4em 0.9em 0em rgba(0, 0, 0, 0.13);transform:translateX(-0.5em);opacity:0;visibility:hidden}${transformTag("pn-action-menu")} .pn-action-menu-sub::-webkit-scrollbar{background-color:#ffffff;width:0.875em;border-radius:0.5em}${transformTag("pn-action-menu")} .pn-action-menu-sub::-webkit-scrollbar-track{background-color:#ffffff;border-radius:0.5em}${transformTag("pn-action-menu")} .pn-action-menu-sub::-webkit-scrollbar-thumb{cursor:pointer;background-color:#969087;border-radius:1em;border:0.25em solid #ffffff}${transformTag("pn-action-menu")} .pn-action-menu-sub::-webkit-scrollbar-thumb:hover{background-color:#5e554a}${transformTag("pn-action-menu")} .pn-action-menu-sub::-webkit-scrollbar-corner,${transformTag("pn-action-menu")} .pn-action-menu-sub::-webkit-scrollbar-button{display:none}${transformTag("pn-action-menu")} .pn-action-menu-sub{transition-property:transform, opacity, visibility;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-action-menu")} .pn-action-menu-sub{transition-duration:0s;transition-delay:0s}}${transformTag("pn-action-menu")} .pn-action-menu-sub{transition-delay:0s, 0s, 0.2s}${transformTag("pn-action-menu")} .pn-action-menu-sub[data-open=true]{transform:translateX(0);opacity:1;visibility:visible;transition-delay:0s, 0s, 0s}${transformTag("pn-action-menu")} .pn-action-menu-sub[data-open=false]{pointer-events:none}${transformTag("pn-action-menu")} .pn-action-menu-sub[data-x=left]{left:-100%}${transformTag("pn-action-menu")} .pn-action-menu-sub[data-x=center]{left:0}${transformTag("pn-action-menu")} .pn-action-menu-sub[data-x=right]{left:100%}${transformTag("pn-action-menu")} .pn-action-menu-sub[data-y=top]{top:unset;bottom:0}${transformTag("pn-action-menu")} .pn-action-menu-sub[data-y=bottom]{top:0}${transformTag("pn-action-menu")} .pn-action-menu-item{position:relative}${transformTag("pn-action-menu")} .pn-action-menu-item:first-child>.pn-action-menu-item-content>.pn-action-menu-button{border-top-left-radius:0.5em;border-top-right-radius:0.5em}${transformTag("pn-action-menu")} .pn-action-menu-item:last-child>.pn-action-menu-item-content>.pn-action-menu-button{border-bottom-right-radius:0.5em;border-bottom-left-radius:0.5em}${transformTag("pn-action-menu")} .pn-action-menu-item-text{display:flex;flex-direction:column;margin-right:auto}${transformTag("pn-action-menu")} .pn-action-menu-item-label{color:#005d92;font-weight:500;text-decoration:none}${transformTag("pn-action-menu")} .pn-action-menu-item-suffix{margin-left:auto;font-weight:400;color:#5e554a}${transformTag("pn-action-menu")} .pn-action-menu-item-helpertext{color:#5e554a;font-weight:400}${transformTag("pn-action-menu")} .pn-action-menu-item-content{display:flex;align-items:center;flex-direction:row;flex:1 1 100%;gap:0.5em;position:relative}${transformTag("pn-action-menu")} .pn-action-menu-item-content[data-close]{border-bottom:0.0625em solid #d3cecb}${transformTag("pn-action-menu")} .pn-action-menu-item-content>${transformTag("pn-icon")}{padding:0 0.25em}${transformTag("pn-action-menu")} .pn-action-menu-item[data-group],${transformTag("pn-action-menu")} .pn-action-menu-item[data-sub]{flex-direction:column}${transformTag("pn-action-menu")} .pn-action-menu-button{cursor:pointer;position:relative;-webkit-tap-highlight-color:transparent;line-height:1.5;padding:0.75em 1em;border:0;width:100%;text-align:left;text-decoration-color:transparent;overflow:hidden;display:flex;align-items:center;flex:1 1 100%;gap:0.5em;font-size:1em;min-height:1.5em;background-color:#ffffff;transition-property:background-color, color, outline-color, text-decoration-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-action-menu")} .pn-action-menu-button{transition-duration:0s;transition-delay:0s}}${transformTag("pn-action-menu")} .pn-action-menu-button .pn-ripple{animation:ripple 0.4s cubic-bezier(0.7, 0, 0.3, 1);position:absolute;border-radius:50%;background-color:#0d234b;transform:translate(-50%, -50%) scale(0);opacity:0.1;pointer-events:none;z-index:3}@keyframes ripple{to{transform:translate(-50%, -50%) scale(1);opacity:0}}${transformTag("pn-action-menu")} .pn-action-menu-button{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-action-menu")} .pn-action-menu-button:focus-visible{outline-color:#005d92}${transformTag("pn-action-menu")} .pn-action-menu-button{outline-offset:-0.2rem}${transformTag("pn-action-menu")} .pn-action-menu-button>${transformTag("pn-icon")} .pn-icon-svg>path{transform-origin:center;transform:rotate(0deg)}${transformTag("pn-action-menu")} .pn-action-menu-button>${transformTag("pn-icon")}[data-suffix][data-active] .pn-icon-svg>path{transform:rotate(180deg)}${transformTag("pn-action-menu")} .pn-action-menu-button>${transformTag("pn-icon")}:last-child{margin-left:auto}${transformTag("pn-action-menu")} .pn-action-menu-button:disabled{pointer-events:none;color:#5e554a;background-color:#f3f2f2}${transformTag("pn-action-menu")} .pn-action-menu-button:hover{background-color:#effbff}${transformTag("pn-action-menu")} .pn-action-menu-button:focus{background-color:#e0f8ff}${transformTag("pn-action-menu")} .pn-action-menu-button[href]:hover,${transformTag("pn-action-menu")} .pn-action-menu-button[href]:focus{text-decoration-color:#005d92}${transformTag("pn-action-menu")} .pn-action-menu-button{}${transformTag("pn-action-menu")} .pn-action-menu-checkbox{background-color:#ffffff;flex:0 0 1.5em;width:1.5em;height:1.5em;border:0.0625em solid #969087;border-radius:0.25em;margin-left:auto;outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:background-color, border-color, outline-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-action-menu")} .pn-action-menu-checkbox{transition-duration:0s;transition-delay:0s}}${transformTag("pn-action-menu")} .pn-action-menu-checkbox svg polyline{stroke:#ffffff;stroke-linecap:round;stroke-dasharray:23;transition-property:stroke-dashoffset;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-action-menu")} .pn-action-menu-checkbox svg polyline{transition-duration:0s;transition-delay:0s}}${transformTag("pn-action-menu")} .pn-action-menu-checkbox svg polyline{transition-delay:0s}${transformTag("pn-action-menu")} .pn-action-menu-checkbox svg polyline.pn-action-menu-checkbox-checkmark-path{stroke-dashoffset:23}${transformTag("pn-action-menu")} .pn-action-menu-radio{display:flex;gap:0.75em;padding:0;margin-left:auto}${transformTag("pn-action-menu")} .pn-action-menu-radio-outer{background-color:#ffffff;border:0.0625em solid #969087;border-radius:50%;height:1.5em;width:1.5em;display:flex;justify-content:center;align-items:center;outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:border-color, background-color, outline-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-action-menu")} .pn-action-menu-radio-outer{transition-duration:0s;transition-delay:0s}}${transformTag("pn-action-menu")} .pn-action-menu-radio-inner{transform:scale(0);height:0.75em;width:0.75em;background-color:#005d92;border-radius:50%;transform-origin:center center;transition-property:background-color, transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-action-menu")} .pn-action-menu-radio-inner{transition-duration:0s;transition-delay:0s}}${transformTag("pn-action-menu")} .pn-action-menu-input{position:absolute;z-index:10;cursor:pointer;height:100%;width:100%;top:0;left:0;margin:0;opacity:0;-webkit-tap-highlight-color:transparent}${transformTag("pn-action-menu")} .pn-action-menu-input:checked+.pn-action-menu-button{background-color:#effbff}${transformTag("pn-action-menu")} .pn-action-menu-input:checked+.pn-action-menu-button .pn-action-menu-checkbox{border-color:#005d92;background-color:#005d92}${transformTag("pn-action-menu")} .pn-action-menu-input:checked+.pn-action-menu-button .pn-action-menu-checkbox polyline.pn-action-menu-checkbox-checkmark-path{transition-delay:0.2s;stroke-dashoffset:0}${transformTag("pn-action-menu")} .pn-action-menu-input:checked+.pn-action-menu-button .pn-action-menu-radio-outer{border-color:#005d92}${transformTag("pn-action-menu")} .pn-action-menu-input:checked+.pn-action-menu-button .pn-action-menu-radio-inner{transform:scale(1);background-color:#005d92}${transformTag("pn-action-menu")} .pn-action-menu-input:checked:hover{background-color:#e0f8ff}${transformTag("pn-action-menu")} .pn-action-menu-input:focus-visible+.pn-action-menu-button{background-color:#e0f8ff}${transformTag("pn-action-menu")} .pn-action-menu-input:disabled{pointer-events:none}${transformTag("pn-action-menu")} .pn-action-menu-input:disabled+.pn-action-menu-button{pointer-events:none;color:#5e554a;background-color:#f3f2f2}${transformTag("pn-action-menu")} .pn-action-menu-input:disabled+.pn-action-menu-button .pn-action-menu-item-label{color:#5e554a}${transformTag("pn-action-menu")} .pn-action-menu-input:disabled+.pn-action-menu-button .pn-action-menu-checkbox{background-color:#f3f2f2}${transformTag("pn-action-menu")} .pn-action-menu-input:disabled+.pn-action-menu-button .pn-action-menu-radio-outer{border-color:#969087;background-color:#f3f2f2}${transformTag("pn-action-menu")} .pn-action-menu-input:disabled+.pn-action-menu-button .pn-icon-svg path{fill:#5e554a}${transformTag("pn-action-menu")} .pn-action-menu-input:disabled:checked+.pn-action-menu-button .pn-action-menu-radio-inner{background-color:#969087}${transformTag("pn-action-menu")} .pn-action-menu-input:disabled:checked+.pn-action-menu-button .pn-action-menu-checkbox{border-color:#969087;background-color:#969087}${transformTag("pn-action-menu")} .pn-action-menu-input:hover+.pn-action-menu-button{background-color:#e0f8ff}${transformTag("pn-action-menu")} .pn-action-menu-input:hover+.pn-action-menu-button .pn-action-menu-radio-outer{border-color:#005d92;background-color:#e0f8ff}${transformTag("pn-action-menu")} .pn-action-menu-input:focus-visible+.pn-action-menu-button{background-color:#e0f8ff}${transformTag("pn-action-menu")} .pn-action-menu-input:focus-visible+.pn-action-menu-button .pn-action-menu-checkbox,${transformTag("pn-action-menu")} .pn-action-menu-input:focus-visible+.pn-action-menu-button .pn-action-menu-radio .pn-action-menu-radio-outer{outline-color:#005d92}${transformTag("pn-action-menu")} .pn-action-menu-p{margin:0}${transformTag("pn-action-menu")} .pn-action-menu>${transformTag("pn-button")}[data-default-icon] .pn-button[aria-expanded=true] .pn-icon-svg{transform:rotate(180deg);transition-delay:0s}${transformTag("pn-action-menu")} .pn-action-menu>${transformTag("pn-button")}[data-default-icon] .pn-button .pn-icon-svg{transform:rotate(0deg);transition-delay:0.2s;transition-property:transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-action-menu")} .pn-action-menu>${transformTag("pn-button")}[data-default-icon] .pn-button .pn-icon-svg{transition-duration:0s;transition-delay:0s}}`;

/**
 * Create a list of actions in an accessible way.
 *
 * Option types include:
 *
 * - Regular button, click and it will collapse the menu,
 * - Checkbox/radio, toggle the option on/off
 * - Link, behaves like a regular `a[href]` element.
 *
 * You can group these actions in groups and/or sub menus.
 *
 * - `group`, an array of options. The label will act as a title for the items.
 * - `options`, an array of options. These items will appear in a sub-menu that can be toggled.
 *
 * @since v7.13.0
 * @see {@link PnActionMenuItem}
 */
class PnActionMenu extends Mixin(animateHeightFactory) {
    constructor(hostRef) {
        super();
        registerInstance(this, hostRef);
        this.menuToggle = createEvent(this, "menuToggle", 7);
        this.menuVisible = createEvent(this, "menuVisible", 7);
        this.menuOption = createEvent(this, "menuOption", 7);
    }
    id = `pn-action-menu-${uuidv4()}`;
    menuButtonId = `${this.id}-button`;
    menuListId = `${this.id}-list`;
    menuTrigger;
    menuContainer;
    menuList;
    timeout;
    /** 16em */
    menuWidth = 256;
    get hostElement() { return getElement(this); }
    smallMenu = null;
    upwards = false;
    activeSubmenu = [];
    /** Array of action menu options. @see {@link PnActionMenuItem} */
    options = [];
    /** Set any prop from the `pn-button` component here. @see {@link Components.PnButton} */
    button;
    /** Set a custom ID for the menu. */
    menuId = this.id;
    /** Manually set the language. */
    language = null;
    /** Open/close the action menu manually. @category Features */
    open = false;
    /** Prefer that the menu open upwards, if there is enough space. @category Features */
    menuUp = false;
    /** Prefer that the submenus opens to the left, if there is enough space. @category Features */
    menuLeft = false;
    /** Emitted when the menu is opened or closed. */
    menuToggle;
    /** Emitted when the menu is fully hidden/visible after the animation has played. */
    menuVisible;
    /** Emitted when an option is clicked (button, link, input or submenus). */
    menuOption;
    handleOptions() {
        this.setMenuLayout();
    }
    openHandler() {
        this.setAnimationDuration();
        requestAnimationFrame(() => {
            if (this.open && !this.isMoving()) {
                this.setOffset();
                this.setMenuLayout();
            }
            this.dropdownHandler();
            this.menuToggle.emit({ open: this.open });
            clearTimeout(this.timeout);
            this.timeout = setTimeout(() => {
                if (!this.open) {
                    this.activeSubmenu = [];
                    const subMenus = this.hostElement.querySelectorAll('[data-x]');
                    Array.from(subMenus).forEach(el => {
                        el.removeAttribute('data-x');
                        el.removeAttribute('data-y');
                    });
                }
                this.menuVisible.emit({ visible: this.open });
            }, this.animationDuration);
        });
    }
    handleMenuId() {
        this.menuButtonId = `${this.menuId}-button`;
        this.menuListId = `${this.menuId}-list`;
    }
    handleResize() {
        if (this.open)
            this.toggleActionMenu(false);
    }
    async componentWillLoad() {
        if (!this.options.length)
            console.warn(`${this.hostElement.localName}: No options set.`);
        this.handleMenuId();
        this.setAnimationDuration();
        if (this.language !== null)
            await awaitTopbar(this.hostElement);
    }
    componentDidLoad() {
        this.setOffset();
        requestAnimationFrame(() => this.open && this.dropdownHandler());
    }
    translate(prop) {
        return translations$g[prop][this.language || en$2];
    }
    globalEvents = (event) => {
        const target = event.target;
        const isWithinActionMenu = target?.closest(this.hostElement.localName);
        if (!isWithinActionMenu)
            this.closeEachSubMenu(true);
    };
    addGlobalEventListeners() {
        const root = this.hostElement.getRootNode();
        root.addEventListener('click', this.globalEvents);
    }
    removeGlobalEventListeners() {
        const root = this.hostElement.getRootNode();
        root.removeEventListener('click', this.globalEvents);
    }
    /** Open/close the action menu. */
    toggleActionMenu(state) {
        this.open = state ?? !this.open;
    }
    setMenuLayout() {
        if (!this.menuContainer)
            return;
        if (!this.isMoving())
            this.resetMaxHeight();
        const measurements = this.getMenuMeasurements();
        this.setDirection(measurements);
        this.setMenuSize(measurements);
        this.setMaxHeight(measurements);
    }
    setDirection({ hUp, hDown, sUp, sDown }) {
        const fitsUpwards = sUp > hUp;
        const fitsDownards = sDown > hDown;
        const moreSpaceDown = sDown > sUp;
        this.upwards = (this.menuUp && fitsUpwards) || (!fitsDownards && !moreSpaceDown);
    }
    setMenuSize({ hUp, hDown, sUp, sDown }) {
        const isWidthSmall = isSmallScreen();
        const menuFits = this.upwards ? sUp > hUp : sDown > hDown;
        const isSmall = isWidthSmall || !menuFits;
        if (isSmall !== this.smallMenu) {
            this.smallMenu = isSmall;
        }
    }
    setMaxHeight({ hUp, hDown, sUp, sDown }) {
        if (this.smallMenu) {
            const heightUp = hUp > sUp ? hUp - 16 : hUp;
            const heightDown = hDown > sDown ? hDown - 8 : hDown;
            this.hostElement.style.setProperty('--pn-menu-height', `${this.upwards ? heightUp : heightDown}px`);
        }
        else
            this.resetMaxHeight();
    }
    resetMaxHeight() {
        this.hostElement.style.setProperty('--pn-menu-height', 'unset');
    }
    getRect(element) {
        return element.getBoundingClientRect();
    }
    getMenuMeasurements() {
        const allLists = Array.from(this.menuContainer.querySelectorAll('menu'));
        const maxHeight = Math.max(...allLists.map(el => el.scrollHeight));
        const rectButton = this.getRect(this.menuTrigger);
        const rectMenu = this.getRect(this.menuContainer);
        /** Measurements upwards. */
        const sUp = rectButton.top - getTotalHeightOffset();
        const hUp = sUp > maxHeight ? maxHeight : sUp;
        /** Measurements downwards. */
        const sDown = innerHeight - rectMenu.top;
        const hDown = sDown > maxHeight ? maxHeight : sDown;
        return {
            hUp,
            hDown,
            sUp,
            sDown,
        };
    }
    setOffset() {
        const data = this.getRect(this.hostElement);
        const sideMenuWidth = getMenuWidth();
        // Calculate potential menu position
        const menuLeft = data.left;
        const menuRight = data.left + this.menuWidth;
        // Define boundaries
        const leftBoundary = sideMenuWidth + 16; // Left menu + buffer
        const rightBoundary = innerWidth - 16; // Right edge - buffer
        let offset = 0;
        // Check if menu would overlap left menu or go off left edge
        if (menuLeft < leftBoundary) {
            offset = leftBoundary - menuLeft;
        }
        // Check if menu would go off right edge
        else if (menuRight > rightBoundary) {
            offset = rightBoundary - menuRight;
        }
        if (this.menuContainer)
            this.menuContainer.style.setProperty('--pn-action-menu-offset', `${offset}px`);
    }
    getListId(option) {
        return `pn-menu-${option.value}-list`;
    }
    getButtonId(option) {
        return `pn-menu-${option.value}-button`;
    }
    getTriggerIcon() {
        if (this.button?.icon)
            return;
        return chevron_down;
    }
    /** Set the path of open sub menus. */
    getSubMenuPath(options, value, path = []) {
        for (const item of options) {
            const newPath = [...path, item.value];
            if (item.value === value)
                return newPath;
            if (item.options || item.group) {
                const result = this.getSubMenuPath(item.options || item.group, value, newPath);
                if (result)
                    return result;
            }
        }
        return null;
    }
    closeEachSubMenu(preventFocus = false) {
        if (!preventFocus)
            this.menuTrigger?.querySelector('button')?.focus({ preventScroll: true });
        const interval = setInterval(() => {
            if (this.smallMenu || this.activeSubmenu.length === 0) {
                clearInterval(interval);
                this.toggleActionMenu(false);
            }
            else {
                this.activeSubmenu.pop();
                this.activeSubmenu = [...this.activeSubmenu];
            }
        }, 150);
    }
    escButton(event, option) {
        const { key } = event;
        if (key === 'Escape') {
            event.preventDefault();
            event.stopImmediatePropagation();
            this.isSubmenuActive(option.value) ? this.toggleSub(option) : this.toggleActionMenu();
        }
    }
    // Animation Start
    dropdownHandler() {
        if (this.open) {
            this.addGlobalEventListeners();
            this.openDropdown(this.menuContainer, this.menuList.clientHeight);
        }
        else {
            this.removeGlobalEventListeners();
            this.closeDropdown(this.menuContainer, this.menuList.clientHeight);
        }
    }
    // Animation end
    async optionSelect(option, click) {
        const type = option?.options?.length ? 'submenu' : !!option.input ? 'input' : option.href ? 'link' : 'button';
        const isSubMenu = type === 'submenu';
        if (isSubMenu)
            this.toggleSub(option);
        else if (type === 'button')
            this.closeEachSubMenu();
        else if (type === 'input')
            option.checked = click.target.checked;
        this.menuOption.emit({
            option,
            type,
            click,
            open: isSubMenu ? this.isSubmenuActive(option.value) : null,
        });
        const target = click.target;
        const element = target.localName === 'input'
            ? target.nextElementSibling
            : target.className === 'pn-action-menu-button'
                ? target
                : target.closest('.pn-action-menu-button');
        const { x, width, y, top } = this.getRect(element);
        const clientCor = { clientX: x + width - 24, clientY: y - top };
        ripple(click.type === 'click' ? click : clientCor, element);
        this.menuContainer.scrollTo({ top: 0 });
    }
    /** Toggle individual sub-menus inside the action menu by using the `option['value']`. */
    toggleSub(option) {
        const { value } = option;
        const path = this.getSubMenuPath(this.options, value);
        const isActive = this.activeSubmenu.includes(value);
        isActive && path.splice(this.activeSubmenu.indexOf(value), 1);
        const item = this.hostElement.querySelector(`#${this.getListId(option)}`);
        const data = this.getRect(item);
        const spaceLeft = data.left;
        const spaceRight = innerWidth - data.right - 8;
        const fitsLeft = spaceLeft > data.width;
        const fitsRight = spaceRight > data.width;
        const climbUp = this.menuUp && data.top - data.height > 0;
        const yDirection = climbUp ? 'top' : 'bottom';
        if (!isActive && !item.dataset.x)
            item.setAttribute('data-x', this.menuLeft && fitsLeft ? 'left' : fitsRight ? 'right' : fitsLeft ? 'left' : 'center');
        if (!isActive && !item.dataset.y)
            item.setAttribute('data-y', yDirection);
        if (JSON.stringify(path) === JSON.stringify(this.activeSubmenu))
            this.activeSubmenu = this.activeSubmenu.filter(item => item !== value);
        else
            this.activeSubmenu = [...path];
    }
    /** Check if a sub-menu is active. */
    isSubmenuActive(value) {
        return this.activeSubmenu.includes(value);
    }
    isMenuActive() {
        const isRootSubInsideGroup = this.options.find(({ value }) => this.activeSubmenu.every(val => val === value));
        return this.smallMenu && (this.activeSubmenu?.length === 0 || isRootSubInsideGroup);
    }
    isCurrentSubMenu(value) {
        return Boolean(this.activeSubmenu[this.activeSubmenu.length - 1] === value);
    }
    getOptionTrailing(option) {
        const useButtonIcon = option.options?.length && chevron_right;
        const useTrailingIcon = option.trailingIcon;
        const useLinkIcon = option.target === '_blank' && open_in_new;
        /** If the user has defined a trialing icon, use it first. */
        const icon = useButtonIcon || useTrailingIcon || useLinkIcon;
        if (icon) {
            return hAsync("pn-icon", { icon: icon, color: "blue700", "data-suffix": true, "data-active": this.isSubmenuActive(option.value) });
        }
        if (option.suffix) {
            return hAsync("span", { class: "pn-action-menu-item-suffix" }, option.suffix);
        }
    }
    renderCheckbox(option) {
        const id = `pn-menu-${option.value}-label`;
        const idHelper = `pn-menu-${option.value}-helpertext`;
        return (hAsync("div", { class: "pn-action-menu-item-content" }, hAsync("input", { type: option.input, id: id, class: "pn-action-menu-input", name: option.name, value: option.value, checked: option.checked, disabled: option.disabled, "aria-describedby": option.helpertext ? idHelper : null, onInput: event => this.optionSelect(option, event), tabIndex: this.open ? null : -1 }), hAsync("div", { class: "pn-action-menu-button" }, !!option.icon && hAsync("pn-icon", { icon: option.icon, color: "blue700" }), hAsync("div", { class: "pn-action-menu-item-text" }, hAsync("label", { htmlFor: id, class: "pn-action-menu-item-label" }, option.label), option.helpertext && (hAsync("p", { id: idHelper, class: "pn-action-menu-item-helpertext" }, hAsync("span", null, option.helpertext)))), option.input === 'checkbox' ? (hAsync("div", { class: "pn-action-menu-checkbox" }, hAsync("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none" }, hAsync("polyline", { class: "pn-action-menu-checkbox-checkmark-path", points: "4,12 9,17 20,6", "stroke-width": "3" })))) : (hAsync("div", { class: "pn-action-menu-radio" }, hAsync("div", { class: "pn-action-menu-radio-outer" }, hAsync("div", { class: "pn-action-menu-radio-inner" })))))));
    }
    renderButton(option) {
        const isCloseButton = option.label === 'BACK';
        const isSub = !!option?.options?.length;
        const isGroup = !!option?.group?.length;
        const isLink = !!option.href && !isSub && !isGroup;
        const appendedId = isCloseButton ? '-close' : '';
        const hasIcon = isCloseButton || !!option.icon;
        const trailingObject = isCloseButton ? null : this.getOptionTrailing(option);
        const open = this.isSubmenuActive(option.value);
        const subMenuAttrs = isSub
            ? {
                'aria-haspopup': 'true',
                'aria-controls': open ? this.getListId(option) : null,
                'aria-expanded': open?.toString(),
            }
            : {};
        const attrs = isLink
            ? {
                href: option.href,
                target: option.target,
            }
            : {
                disabled: option.disabled,
            };
        const Tag = isLink ? 'a' : 'button';
        return isGroup ? (hAsync("div", { class: "pn-action-menu-group-label" }, hAsync("p", { class: "pn-action-menu-p" }, option.label), option.helpertext && hAsync("p", { class: "pn-action-menu-group-helpertext" }, option.helpertext))) : (hAsync("div", { class: "pn-action-menu-item-content", "data-close": isCloseButton }, hAsync(Tag, { id: this.getButtonId(option) + appendedId, class: "pn-action-menu-button", ...subMenuAttrs, ...attrs, tabIndex: this.open ? null : -1, onClick: event => this.optionSelect(option, event), onKeyDown: (event) => this.escButton(event, option) }, hasIcon && hAsync("pn-icon", { icon: isCloseButton ? chevron_left : option.icon, color: "blue700" }), hAsync("div", { class: "pn-action-menu-item-text" }, hAsync("span", { class: "pn-action-menu-item-label" }, isCloseButton ? this.translate('BACK') : option.label), option.helpertext && !isLink && hAsync("span", { class: "pn-action-menu-item-helpertext" }, option.helpertext)), trailingObject)));
    }
    renderSub(option) {
        return (hAsync("menu", { id: this.getListId(option), "aria-labelledby": this.getButtonId(option), class: "pn-action-menu-sub", "data-open": this.isSubmenuActive(option.value)?.toString(), "data-current": this.isCurrentSubMenu(option.value) }, this.smallMenu && (hAsync("li", { class: "pn-action-menu-item" }, this.renderButton({
            label: 'BACK',
            value: option.value,
            options: option.options,
        }))), option.options.map(item => this.renderMenuItem(item))));
    }
    renderGroup(option) {
        return hAsync("menu", { class: "pn-action-menu-group" }, option.group.map(item => this.renderMenuItem(item)));
    }
    renderMenuItem(option) {
        const isSub = !!option?.options?.length;
        const isGroup = !isSub && !!option?.group?.length;
        const isCheckbox = !!option.input && !isSub && !isGroup;
        return (hAsync("li", { class: "pn-action-menu-item", "data-group": isGroup, "data-sub": isSub }, isCheckbox ? this.renderCheckbox(option) : this.renderButton(option), isSub ? this.renderSub(option) : isGroup && this.renderGroup(option)));
    }
    renderMenu() {
        return (hAsync("div", { id: this.menuListId, class: "pn-action-menu-container", role: "region", "aria-labelledby": this.menuButtonId, "data-open": this.open, "data-upwards": this.upwards, "data-small": this.smallMenu, style: { height: '0px' }, ref: el => (this.menuContainer = el) }, hAsync("menu", { class: "pn-action-menu-list", "data-current": this.isMenuActive(), ref: el => (this.menuList = el) }, this.options?.map(option => this.renderMenuItem(option)))));
    }
    render() {
        return (hAsync(Host, { key: 'd77e6c7f658e2552260f5a8a30034a8d68d9bfa2' }, hAsync("div", { key: '3d2584a7c12abf5948cec24c967ab573d33dafa0', id: this.menuId !== this.id ? this.menuId : null, class: "pn-action-menu" }, hAsync("pn-button", { key: 'f8460fca3784d2cb04ac55bfa0070935006c864d', icon: this.getTriggerIcon(), ...this.button, buttonId: this.menuButtonId, tooltipUp: !this.upwards, ariahaspopup: "true", ariacontrols: this.open ? this.menuListId : null, ariaexpanded: this.open.toString(), "data-default-icon": !this.button?.icon, onPnClick: () => this.toggleActionMenu(), ref: el => (this.menuTrigger = el) }), this.renderMenu())));
    }
    static get watchers() { return {
        "options": [{
                "handleOptions": 0
            }],
        "open": [{
                "openHandler": 0
            }],
        "menuId": [{
                "handleMenuId": 0
            }]
    }; }
    static get style() { return pnActionMenuCss(); }
    static get cmpMeta() { return {
        "$flags$": 512,
        "$tagName$": "pn-action-menu",
        "$members$": {
            "options": [16],
            "button": [16],
            "menuId": [1, "menu-id"],
            "language": [1025],
            "open": [1540],
            "menuUp": [4, "menu-up"],
            "menuLeft": [4, "menu-left"],
            "isClosing": [32],
            "isExpanding": [32],
            "smallMenu": [32],
            "upwards": [32],
            "activeSubmenu": [32]
        },
        "$listeners$": [[9, "resize", "handleResize"]],
        "$lazyBundleId$": "-",
        "$attrsToReflect$": [["open", "open"]]
    }; }
}

const pnButtonCss = () => `${transformTag("pn-button")}{display:inline-block}${transformTag("pn-button")} .pn-button{position:relative;cursor:pointer;padding:0.75em 1.5em;width:round(up, 100%, 1px);min-height:3em;min-width:5.5em;border:none;border-radius:3em;font-family:inherit;font-size:1em;font-weight:500;color:#ffffff;background-color:transparent;display:flex;justify-content:center;align-items:center;text-decoration:none;line-height:1.5em;-webkit-tap-highlight-color:transparent;transition-property:color, outline-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-button")} .pn-button{transition-duration:0s;transition-delay:0s}}${transformTag("pn-button")} .pn-button{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-button")} .pn-button:focus-visible{outline-color:#005d92}${transformTag("pn-button")} .pn-button:disabled,${transformTag("pn-button")} .pn-button[aria-disabled]{cursor:auto;pointer-events:none}${transformTag("pn-button")} .pn-button-content{z-index:2;display:flex;justify-content:center;align-items:center;gap:0.5em;transition-property:opacity, transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-button")} .pn-button-content{transition-duration:0s;transition-delay:0s}}${transformTag("pn-button")} .pn-button-content{transition-delay:0.2s}${transformTag("pn-button")} .pn-button-bg{position:absolute;width:100%;height:100%;top:0;left:50%;transform:translateX(-50%) translateY(0);border-radius:3em;border:none;background-color:#005d92;overflow:hidden;transition-property:width, background-color, border-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-button")} .pn-button-bg{transition-duration:0s;transition-delay:0s}}${transformTag("pn-button")} .pn-button-bg{transition-delay:0.2s, 0s, 0s}${transformTag("pn-button")} .pn-button-bg::after{content:"";position:absolute;will-change:transform;width:100%;height:100%;background-color:#0d234b;border-radius:inherit;left:0;transform:translateX(-103%);opacity:0.5;transition-property:transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-button")} .pn-button-bg::after{transition-duration:0s;transition-delay:0s}}${transformTag("pn-button")} .pn-button .pn-ripple{animation:ripple 0.4s cubic-bezier(0.7, 0, 0.3, 1);position:absolute;border-radius:50%;background-color:#ffffff;transform:translate(-50%, -50%) scale(0);opacity:0.1;pointer-events:none;z-index:3}@keyframes ripple{to{transform:translate(-50%, -50%) scale(1);opacity:0}}${transformTag("pn-button")} .pn-button-tooltip{z-index:5;position:absolute;top:calc(100% + 0.35em);left:50%;pointer-events:none;color:#ffffff;background-color:#0d234b;box-shadow:0 0.075em 0.225em rgba(0, 0, 0, 0.1), 0 0.4em 0.9em rgba(0, 0, 0, 0.13);padding:0.25em 0.75em;border-radius:inherit;max-width:min(95vw, 40em);transform:translateX(-50%) translateX(var(--pn-dx));width:max-content;opacity:0;transition-property:opacity;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-button")} .pn-button-tooltip{transition-duration:0s;transition-delay:0s}}${transformTag("pn-button")} .pn-button-tooltip-text{font-size:0.875em;font-weight:300}${transformTag("pn-button")} .pn-button ${transformTag("pn-icon")}{flex-shrink:0}${transformTag("pn-button")} .pn-button ${transformTag("pn-icon")} .pn-icon-svg path{fill:#ffffff}${transformTag("pn-button")} .pn-button ${transformTag("pn-spinner")}{position:absolute;transform:scale(0)}${transformTag("pn-button")} .pn-button:hover .pn-button-bg:after,${transformTag("pn-button")} .pn-button:focus .pn-button-bg:after{transform:translateX(0)}${transformTag("pn-button")} .pn-button[data-appearance=light]{color:#005d92}${transformTag("pn-button")} .pn-button[data-appearance=light] ${transformTag("pn-icon")} .pn-icon-svg path{fill:#005d92}${transformTag("pn-button")} .pn-button[data-appearance=light] ${transformTag("pn-spinner")} .pn-spinner-circle{stroke:#005d92}${transformTag("pn-button")} .pn-button[data-appearance=light] ${transformTag("pn-spinner")} .pn-spinner-dot{fill:#005d92}${transformTag("pn-button")} .pn-button[data-appearance=light] .pn-button-bg{border-color:#005d92;background-color:#ffffff}${transformTag("pn-button")} .pn-button[data-appearance=light] .pn-button-bg:after{background-color:#e0f8ff;opacity:1}${transformTag("pn-button")} .pn-button[data-appearance=light] .pn-button-bg .pn-ripple{background-color:#005d92}${transformTag("pn-button")} .pn-button[data-appearance=warning]{color:#a70707}${transformTag("pn-button")} .pn-button[data-appearance=warning] ${transformTag("pn-icon")} .pn-icon-svg path{fill:#a70707}${transformTag("pn-button")} .pn-button[data-appearance=warning] ${transformTag("pn-spinner")} .pn-spinner-circle{stroke:#a70707}${transformTag("pn-button")} .pn-button[data-appearance=warning] ${transformTag("pn-spinner")} .pn-spinner-dot{fill:#a70707}${transformTag("pn-button")} .pn-button[data-appearance=warning] .pn-button-bg{border:0.0625em solid #a70707;background-color:#fdefee}${transformTag("pn-button")} .pn-button[data-appearance=warning] .pn-button-bg:after{background-color:#a70707;opacity:1}${transformTag("pn-button")} .pn-button[data-appearance=warning]:hover,${transformTag("pn-button")} .pn-button[data-appearance=warning]:focus{color:#ffffff}${transformTag("pn-button")} .pn-button[data-appearance=warning]:hover ${transformTag("pn-icon")} .pn-icon-svg path,${transformTag("pn-button")} .pn-button[data-appearance=warning]:focus ${transformTag("pn-icon")} .pn-icon-svg path{fill:#ffffff}${transformTag("pn-button")} .pn-button[data-appearance=warning]:hover ${transformTag("pn-spinner")} .pn-spinner-circle,${transformTag("pn-button")} .pn-button[data-appearance=warning]:focus ${transformTag("pn-spinner")} .pn-spinner-circle{stroke:#ffffff}${transformTag("pn-button")} .pn-button[data-appearance=warning]:hover ${transformTag("pn-spinner")} .pn-spinner-dot,${transformTag("pn-button")} .pn-button[data-appearance=warning]:focus ${transformTag("pn-spinner")} .pn-spinner-dot{fill:#ffffff}${transformTag("pn-button")} .pn-button[data-appearance=warning]{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-button")} .pn-button[data-appearance=warning]:focus-visible{outline-color:#a70707}${transformTag("pn-button")} .pn-button[data-variant=borderless] .pn-button-bg{border:none;background-color:transparent}${transformTag("pn-button")} .pn-button[data-variant=borderless] .pn-button-bg:after{background-color:#ffffff;opacity:0.1}${transformTag("pn-button")} .pn-button[data-variant=borderless][data-appearance=light] .pn-button-bg:after{background-color:#e0f8ff;opacity:1}${transformTag("pn-button")} .pn-button[data-variant=borderless][data-appearance=warning] .pn-button-bg:after{background-color:#a70707;opacity:1}${transformTag("pn-button")} .pn-button[data-variant=outlined] .pn-button-bg{border:0.0625em solid #ffffff;background-color:transparent}${transformTag("pn-button")} .pn-button[data-variant=outlined] .pn-button-bg:after{background-color:#ffffff;opacity:0.1}${transformTag("pn-button")} .pn-button[data-variant=outlined][data-appearance=light] .pn-button-bg{border-color:#005d92;background-color:#ffffff}${transformTag("pn-button")} .pn-button[data-variant=outlined][data-appearance=light] .pn-button-bg:after{background-color:#00a0d6;opacity:0.1}${transformTag("pn-button")} .pn-button[data-variant=outlined][data-appearance=warning] .pn-button-bg{border-color:#a70707}${transformTag("pn-button")} .pn-button[data-variant=outlined][data-appearance=warning] .pn-button-bg:after{background-color:#a70707;opacity:1}${transformTag("pn-button")} .pn-button[data-left-icon] .pn-button-content{flex-direction:row-reverse}${transformTag("pn-button")} .pn-button[data-icon-only]{width:3em;min-width:0}${transformTag("pn-button")} .pn-button[data-icon-only][data-small]{width:2em;min-width:0;padding:0}${transformTag("pn-button")} .pn-button[data-small]{padding:0.375em 1em;min-height:2em;min-width:unset;line-height:1.25em}${transformTag("pn-button")} .pn-button[data-small] .pn-button-content{gap:0.25em}${transformTag("pn-button")} .pn-button[data-small] .pn-button-text{font-size:0.875em}${transformTag("pn-button")} .pn-button[data-small] ${transformTag("pn-icon")} .pn-icon-svg{height:1.25em;width:1.25em}${transformTag("pn-button")} .pn-button[data-tooltip-open] .pn-button-tooltip{opacity:1}${transformTag("pn-button")} .pn-button[data-tooltip-upwards] .pn-button-tooltip{top:auto;bottom:calc(100% + 0.35em)}${transformTag("pn-button")} .pn-button[data-loading] ${transformTag("pn-spinner")}{transform:scale(1);transition-property:transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-button")} .pn-button[data-loading] ${transformTag("pn-spinner")}{transition-duration:0s;transition-delay:0s}}${transformTag("pn-button")} .pn-button[data-loading] ${transformTag("pn-spinner")}{transition-delay:0.2s}${transformTag("pn-button")} .pn-button[data-loading] .pn-button-content{pointer-events:none;opacity:0;transition-delay:0s;transform:translateY(100%)}${transformTag("pn-button")} .pn-button[data-loading] .pn-button-bg{width:3em}${transformTag("pn-button")} .pn-button[data-loading][data-small] .pn-button-bg{width:2em}`;

/**
 * The `pn-button` is built with a native `button` or `a` element, if you use the `href` attribute.
 *
 * @nativeClick Use the `click` event to listen when the button is clicked.
 */
class PnButton {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.pnClick = createEvent(this, "pnClick", 7);
    }
    buttonEl;
    tooltipEl;
    tooltipDx;
    openEvents = ['mouseover', 'focus'];
    closeEvents = ['mouseleave', 'blur', 'touchcancel', 'touchleave'];
    eventListeners = [...this.openEvents, ...this.closeEvents];
    get hostElement() { return getElement(this); }
    tooltipOpen = false;
    tooltipUpwards = false;
    /** The label of the button, this is the same as using the default slot. @since v7.4.0 */
    label = '';
    /**
     * Select the button appearance: default (blue), `light` (white) and  `warning` (red).
     *
     * @category Visual
     */
    appearance = '';
    /**
     * Select the button variant: default (colored background), `outlined` (bordered, no background) and `borderless` (borderless, no background).
     *
     * @category Visual
     */
    variant = '';
    /** Use the small button. @category Visual */
    small = false;
    /** Display the loading indicator. @category Visual */
    loading = false;
    /**
     * The SVG content of the icon you want.
     * @see {@link https://portal.postnord.com/web-components/?path=/docs/docs-assets--docs pn-design-assets}
     * @category Icon
     */
    icon;
    /**
     * Turn the button into an icon only. Requires `icon` and one of the following props to work: `tooltip`, `arialabel` or `arialabelledby`.
     * @summary __You need an `icon` selected, as well as either `tooltip`, `arialabel` or `arialabelledby` for this to work__.
     * @see {@link icon}
     * @since v7.4.0
     * @category Icon
     */
    iconOnly = false;
    /**
     * Place the `icon` to the left of the button.
     *
     * @summary __You need an `icon` selected for this to work__.
     * @see {@link icon}
     * @category Icon
     */
    leftIcon = false;
    /**
     * When the user focus/hover the button, the `tooltip` text will show up.
     *
     * @category Tooltip
     */
    tooltip;
    /**
     * Prefer the tooltip to open upwards. Will still go downwards if there is no space.
     * @since v7.4.0
     * @category Tooltip
     */
    tooltipUp = false;
    /** Select HTML button type. @category Button */
    type = 'button';
    /**
     * Connect this button to a HTML form.
     * @category Button
     * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#form HTML button form}
     */
    form;
    /** Pass an href to make the button into link (a-tag). @category Link */
    href;
    /** The rel attribute of the link. @category Link */
    rel;
    /** The target attribute of the link. @category Link */
    target;
    /** The download attribute of the link. @category Link */
    download;
    /** HTML ID. @category HTML attributes */
    buttonId = null;
    /** HTML aria-label attribute. @category HTML attributes */
    arialabel = null;
    /** HTML aria-labelledby attribute. @category HTML attributes */
    arialabelledby = null;
    /** HTML aria-current attribute. @since v7.9.0 @category HTML attributes */
    ariacurrent = null;
    /** HTML aria-controls attribute. @category HTML attributes */
    ariacontrols = null;
    /** HTML aria-pressed attribute. @category HTML attributes */
    ariapressed = null;
    /** HTML aria-haspopup attribute. @category HTML attributes */
    ariahaspopup = null;
    /** HTML aria-expanded attribute. @category HTML attributes */
    ariaexpanded = null;
    /** HTML tabindex. @category HTML attributes */
    noTab = false;
    openHandler() {
        if (this.tooltipOpen)
            this.checkTooltipPosition();
    }
    iconOnlyHandler() {
        this.checkTooltipPosition();
        if (this.tooltip)
            this.initTooltip();
        else
            this.removeTooltip();
    }
    /**
     * This event is fired when the `button`/`a` element of the `pn-button` is clicked.
     * Setting an eventListener for `click` on the `pn-button` will trigger if you click outside of the button area
     * or if the button is `disabled` with the `loading` prop.
     * @since v7.4.0
     **/
    pnClick;
    componentWillLoad() {
        this.tooltipUpwards = this.tooltipUp;
    }
    componentDidLoad() {
        this.iconOnlyHandler();
    }
    getRect(element) {
        return element.getBoundingClientRect();
    }
    initTooltip() {
        this.eventListeners.forEach(e => this.buttonEl.addEventListener(e, this.toggleTooltip));
    }
    removeTooltip() {
        this.eventListeners.forEach(e => this.buttonEl.removeEventListener(e, this.toggleTooltip));
    }
    toggleTooltip = (event) => {
        this.tooltipOpen = this.openEvents.includes(event.type);
    };
    setTooltipOffset() {
        this.tooltipEl.style.setProperty('--pn-dx', `${this.tooltipDx}px`);
    }
    checkTooltipPosition() {
        this.tooltipEl.style.transform = 'translateX(-50%)';
        this.tooltipUpwards = this.tooltipUp;
        requestAnimationFrame(() => {
            const { top, x, y, right, height } = this.getRect(this.tooltipEl);
            const extraMargin = 16;
            this.tooltipDx = 0;
            this.tooltipUpwards = this.tooltipUp ? top > height : y + height > window.innerHeight;
            this.tooltipEl.style.transform = '';
            if (x < 0)
                this.tooltipDx = x * -1 + extraMargin;
            if (right > window.innerWidth)
                this.tooltipDx = window.innerWidth - right - extraMargin - 8;
            requestAnimationFrame(() => this.setTooltipOffset());
        });
    }
    getAttributes() {
        const attrs = this.href
            ? {
                'href': this.href,
                'rel': !this.rel && this.target === '_blank' ? 'noopener' : this.rel,
                'target': this.target ?? null,
                'download': this.download ?? null,
                'aria-current': this.ariacurrent,
                'aria-disabled': this.loading ? 'true' : null,
            }
            : {
                'type': this.type,
                'form': this.form,
                'disabled': this.loading,
                'aria-pressed': this.ariapressed,
                'aria-controls': this.ariacontrols,
                'aria-haspopup': this.ariahaspopup,
                'aria-expanded': this.ariaexpanded,
            };
        const appearances = ['light', 'warning'];
        const variations = ['borderless', 'outlined'];
        return {
            'tabindex': this.noTab || (this.href && this.loading) ? '-1' : null,
            'data-small': this.small,
            'data-loading': this.loading,
            'data-tooltip-open': this.tooltipOpen,
            'data-tooltip-upwards': this.tooltipUpwards,
            'data-icon-only': this.showIconOnly(),
            'data-left-icon': this.leftIcon,
            'data-appearance': appearances.includes(this.appearance) ? this.appearance : null,
            'data-variant': variations.includes(this.variant) ? this.variant : null,
            ...attrs,
        };
    }
    getTagName() {
        return this.href ? 'a' : 'button';
    }
    showIconOnly() {
        return !!this.icon && this.iconOnly && !!(this.tooltip || this.arialabel || this.arialabelledby);
    }
    handleClick(event) {
        ripple(event, this.hostElement, '.pn-button-bg');
        this.pnClick.emit(event);
    }
    render() {
        const TagName = this.getTagName();
        return (hAsync(Host, { key: '9fd62df52e09b5f7915c1652c3bd23c47c40db42' }, hAsync(TagName, { key: 'aecef05e4c20bb9c501399f18b7290a33e5d82e7', class: "pn-button", id: this.buttonId, "aria-label": this.arialabel, "aria-labelledby": this.arialabelledby, onClick: e => this.handleClick(e), ...this.getAttributes(), ref: (el) => (this.buttonEl = el) }, hAsync("div", { key: '9cb56181926a77cd985be9447dd5277720370bf6', class: "pn-button-bg" }), hAsync("div", { key: 'f81963c493162009d2219d72171f753c3ba5dcb8', class: "pn-button-content" }, hAsync("div", { key: 'd6cc476c9bb3eaa59ae9cf80700b33e4bc836494', class: "pn-button-text", hidden: this.showIconOnly() }, this.label, hAsync("slot", { key: '83b07110e17088f980e4a7f0094f5330f7dcc17b' })), !!this.icon && hAsync("pn-icon", { key: '6d352caac885f7f5cf3819a7b555e278e7761259', icon: this.icon })), hAsync("pn-spinner", { key: '3176c1f592b5e48c14f7baccc9366bf0fc0187dd', light: true }), hAsync("div", { key: 'b97ecf99cdf1c4fa0c8db3b26c2eac33c5c9bba4', class: "pn-button-tooltip", hidden: !this.tooltip, ref: el => (this.tooltipEl = el) }, hAsync("span", { key: '7825cd9635f5897db28ee4b32d2ac56a8c9a9b0d', class: "pn-button-tooltip-text" }, this.tooltip)))));
    }
    static get watchers() { return {
        "tooltipOpen": [{
                "openHandler": 0
            }],
        "tooltip": [{
                "iconOnlyHandler": 0
            }]
    }; }
    static get style() { return pnButtonCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-button",
        "$members$": {
            "label": [1],
            "appearance": [1],
            "variant": [1],
            "small": [4],
            "loading": [516],
            "icon": [1],
            "iconOnly": [4, "icon-only"],
            "leftIcon": [4, "left-icon"],
            "tooltip": [1],
            "tooltipUp": [4, "tooltip-up"],
            "type": [1],
            "form": [1],
            "href": [1],
            "rel": [1],
            "target": [1],
            "download": [1],
            "buttonId": [1, "button-id"],
            "arialabel": [1],
            "arialabelledby": [1],
            "ariacurrent": [1],
            "ariacontrols": [1],
            "ariapressed": [1],
            "ariahaspopup": [1],
            "ariaexpanded": [1],
            "noTab": [4, "no-tab"],
            "tooltipOpen": [32],
            "tooltipUpwards": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": [["loading", "loading"]]
    }; }
}

const pnButtonDropdownCss = () => `${transformTag("pn-button-dropdown")}{display:inline-block;position:relative}${transformTag("pn-button-dropdown")} .pn-button-dropdown-container{z-index:10;position:absolute;top:130%;left:0;background-color:#ffffff;border-radius:1em;box-shadow:0 0.125em 1em rgba(0, 0, 0, 0.2);overflow-y:auto;max-width:95vw;max-width:min(95vw, 40em);max-height:80vh;transform:scale(0);transform-origin:top left;transition-property:transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-button-dropdown")} .pn-button-dropdown-container{transition-duration:0s;transition-delay:0s}}${transformTag("pn-button-dropdown")} .pn-button-dropdown-container{transition-delay:0.2s}${transformTag("pn-button-dropdown")} .pn-button-dropdown-container[data-right]{left:unset;right:0;transform-origin:top right}${transformTag("pn-button-dropdown")} .pn-button-dropdown-container[data-top]{top:unset;bottom:130%;transform-origin:bottom left}${transformTag("pn-button-dropdown")} .pn-button-dropdown-content{position:relative;padding:1em;opacity:0;width:max-content;max-width:100%;visibility:hidden;transition-property:opacity, visibility;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-button-dropdown")} .pn-button-dropdown-content{transition-duration:0s;transition-delay:0s}}${transformTag("pn-button-dropdown")} .pn-button-dropdown-content{transition-delay:0s, 0.2s}${transformTag("pn-button-dropdown")} .pn-button-dropdown[data-open=true] .pn-button-dropdown-container{transition-delay:0s}${transformTag("pn-button-dropdown")} .pn-button-dropdown[data-open=true] .pn-button-dropdown-content{opacity:1;visibility:visible}`;

/**
 * The open/closing of the dropdown is handled by the component itself.
 *
 * @nativeClick Use the `click` event to listen when the button is clicked.
 */
class PnButtonDropdown {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    id = `pn-button-${uuidv4()}`;
    focusableElements;
    container;
    dropdownButtonId = `${this.id}-dropdown`;
    dropdownContentId = `${this.id}-content`;
    get hostElement() { return getElement(this); }
    right = false;
    top = false;
    /** The required label on the button. */
    label;
    /** The optional SVG content of the icon you want. */
    icon;
    /** Select between `light` and `warning`. */
    appearance = '';
    /** Select between `outlined` and `borderless`. */
    variant = '';
    /** Smaller button. */
    small = false;
    /** Tooltip (required for Icon Only). */
    tooltip;
    /** Open/close the dropdown without user interaction. */
    open = false;
    openHandler() {
        this.toggleDropdown();
        if (this.open) {
            document.addEventListener('click', this.globalHandler);
            document.addEventListener('keyup', this.globalHandler);
        }
        else {
            document.removeEventListener('click', this.globalHandler);
            document.removeEventListener('keyup', this.globalHandler);
        }
    }
    componentDidLoad() {
        if (this.open)
            this.openHandler();
    }
    getRect(element) {
        return element.getBoundingClientRect();
    }
    globalHandler = (e) => {
        // global events that we want to track to close the select, like "click outside" or tab out
        if (!this.hostElement.contains(e.target) || e?.key === 'Escape') {
            this.open = false;
        }
    };
    toggleDropdown() {
        this.right = this.hostElement.offsetLeft > window.innerWidth / 2;
        requestAnimationFrame(() => {
            if (this.open) {
                this.container.style.transition = 'none';
                this.container.style.transform = 'none';
            }
            const containerRect = this.getRect(this.container);
            const hostElementRect = this.getRect(this.hostElement);
            // Calculate if dropdown should open upwards
            // if there is enough space above button
            const enoughSpaceAbove = hostElementRect.top > containerRect.height + window.innerWidth * 0.025;
            this.top =
                enoughSpaceAbove &&
                    hostElementRect.top + hostElementRect.height + containerRect.height >
                        window.innerHeight - window.innerWidth * 0.025;
            let xAxis = 0;
            if (containerRect.right > window.innerWidth || containerRect.x < 0) {
                // 0.025 because the max width of the element is 95vw and we want the same margin on both sides
                xAxis = containerRect.x + containerRect.width + window.innerWidth * 0.025 - window.innerWidth;
            }
            this.container.style.transform = '';
            requestAnimationFrame(() => {
                this.container.style.transition = '';
                this.container.style.transform = this.open ? `scale(1) translateX(-${xAxis}px)` : '';
                requestAnimationFrame(() => {
                    this.hostElement.querySelector('.pn-button-dropdown').dataset.open = `${this.open}`;
                });
            });
        });
    }
    toggle = () => {
        this.open = !this.open;
    };
    render() {
        return (hAsync(Host, { key: '0b6deb752a9f01bea9571627205b5cd3efbc1c66' }, hAsync("div", { key: 'c7833d539d682a980bb7cc529f17d9942ffd7eb2', class: "pn-button-dropdown" }, hAsync("pn-button", { key: '42d252b99f98b0c3f51795c894e899c6489839c2', label: this.label, buttonId: this.dropdownButtonId, class: "pn-button-dropdown-label", appearance: this.appearance, variant: this.variant, small: this.small, icon: this.icon, iconOnly: !!this.tooltip && !!this.icon && !this.label, ariacontrols: this.dropdownContentId, ariahaspopup: "true", ariaexpanded: this.open.toString(), tooltip: this.tooltip, tooltipUp: !this.top, onPnClick: this.toggle }), hAsync("div", { key: 'dd494c992ef2b51f31ed5c48d87fb3044ed40009', ref: el => (this.container = el), id: this.dropdownContentId, class: "pn-button-dropdown-container", role: "region", "aria-labelledby": this.dropdownButtonId, "data-right": this.right, "data-top": this.top }, hAsync("div", { key: 'e217ae843fa641335ce0714272f68f9a080afe7d', class: "pn-button-dropdown-content" }, hAsync("slot", { key: 'f52ad763a52e9ee17d9a95a1e3a959d61fae2fe1' }))))));
    }
    static get watchers() { return {
        "open": [{
                "openHandler": 0
            }]
    }; }
    static get style() { return pnButtonDropdownCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-button-dropdown",
        "$members$": {
            "label": [1],
            "icon": [1],
            "appearance": [1],
            "variant": [1],
            "small": [4],
            "tooltip": [1],
            "open": [1540],
            "right": [32],
            "top": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": [["open", "open"]]
    }; }
}

const pnCardCss = () => `${transformTag("pn-card")}{position:relative;display:block}${transformTag("pn-card")} .pn-card{position:relative;background-color:#ffffff;color:#2d2013;border-radius:0.5em;display:flex;flex-direction:column;height:100%;overflow:hidden;box-shadow:0em 0.0625em 0.125em 0em rgba(20, 20, 20, 0.11), 0em 0.1875em 0.4375em 0em rgba(0, 0, 0, 0.13);outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:background-color, outline-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-card")} .pn-card{transition-duration:0s;transition-delay:0s}}${transformTag("pn-card")} .pn-card[data-link]:hover{background-color:#e0f8ff}${transformTag("pn-card")} .pn-card[data-link][data-focus]{outline-color:#005d92}${transformTag("pn-card")} .pn-card{}${transformTag("pn-card")} .pn-card[data-link] .pn-card-navigation>[slot=navigation]{display:none}${transformTag("pn-card")} .pn-card[data-horizontal]{flex-direction:row}${transformTag("pn-card")} .pn-card[data-horizontal][data-reverse]{flex-direction:row-reverse}${transformTag("pn-card")} .pn-card[data-horizontal][data-reverse] .pn-card-picture{clip-path:ellipse(100% 175% at right center)}${transformTag("pn-card")} .pn-card[data-horizontal] .pn-card-content{flex:1 1 50%}${transformTag("pn-card")} .pn-card[data-horizontal] .pn-card-image{flex:1 1 50%;flex-direction:row}${transformTag("pn-card")} .pn-card[data-horizontal] .pn-card-picture{width:100%;clip-path:ellipse(100% 175% at left center)}${transformTag("pn-card")} .pn-card[data-reverse]{flex-direction:column-reverse}${transformTag("pn-card")} .pn-card[data-reverse] .pn-card-picture{clip-path:ellipse(175% 100% at bottom center)}${transformTag("pn-card")} .pn-card-header{display:flex;flex-direction:column;gap:clamp(0.5em, 5vw, 0.75em)}${transformTag("pn-card")} .pn-card-label{font-size:clamp(1.125em, 5vw, 1.5em);font-weight:700;margin:0}${transformTag("pn-card")} .pn-card-label-overline{color:#5e554a;font-size:0.875em;font-weight:400;margin:0}${transformTag("pn-card")} .pn-card-link{display:inline-flex;align-items:center;gap:0.25em;color:#005d92;text-decoration-color:transparent;-webkit-tap-highlight-color:transparent;transition-property:color, text-decoration-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-card")} .pn-card-link{transition-duration:0s;transition-delay:0s}}${transformTag("pn-card")} .pn-card-link:hover{color:#0d234b;text-decoration-color:#0d234b}${transformTag("pn-card")} .pn-card-link:hover>${transformTag("pn-icon")} .pn-icon-svg>path{fill:#0d234b}${transformTag("pn-card")} .pn-card-link:focus{outline:0;color:#0d234b;text-decoration-color:#0d234b}${transformTag("pn-card")} .pn-card-link:focus>${transformTag("pn-icon")} .pn-icon-svg>path{fill:#0d234b}${transformTag("pn-card")} .pn-card-link:before{content:"";position:absolute;top:0;left:0;width:100%;height:100%}${transformTag("pn-card")} .pn-card-content{display:flex;flex-direction:column;flex-wrap:nowrap;flex:1;gap:clamp(0.5em, 5vw, 0.75em);padding:clamp(0.75em, 5vw, 1.5em) clamp(0.75em, 5vw, 1.5em)}${transformTag("pn-card")} .pn-card-section{display:flex;flex-direction:column;gap:0.5em;color:#5e554a}${transformTag("pn-card")} .pn-card-section-paragraph,${transformTag("pn-card")} .pn-card-section p{margin:0 0 0.25em}${transformTag("pn-card")} .pn-card-section-paragraph:last-child,${transformTag("pn-card")} .pn-card-section p:last-child{margin:0em}${transformTag("pn-card")} .pn-card-navigation{margin-top:auto;padding-top:clamp(0.5em, 5vw, 0.75em);display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;gap:0.5em}${transformTag("pn-card")} .pn-card-navigation>${transformTag("pn-button")}{flex:1 1 12em}${transformTag("pn-card")} .pn-card-navigation:empty{display:none}${transformTag("pn-card")} .pn-card-image{position:relative;display:flex;flex-direction:column}${transformTag("pn-card")} .pn-card-picture{margin:0;padding:0;display:block;overflow:hidden;clip-path:ellipse(175% 100% at top center);aspect-ratio:var(--pn-card-aspect-ratio)}${transformTag("pn-card")} .pn-card-picture:empty{display:none}${transformTag("pn-card")} .pn-card-picture>*[slot=image]{display:block;height:100%;width:100%;object-fit:cover}${transformTag("pn-card")} .pn-card-tags{display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;gap:0.5em}${transformTag("pn-card")} .pn-card-tags:empty{display:none}${transformTag("pn-card")} .pn-card>.pn-ripple{animation:ripple 0.4s cubic-bezier(0.7, 0, 0.3, 1);position:absolute;border-radius:50%;background-color:#005d92;transform:translate(-50%, -50%) scale(0);opacity:0.1;pointer-events:none;z-index:3}@keyframes ripple{to{transform:translate(-50%, -50%) scale(1);opacity:0}}`;

/**
 * The card component is more than just a navigational element.
 * It is a flexible component that can be used as a product item, a clickable link card, etc...
 *
 * Setting the `href` prop will transform the entire `pn-card` into a clickable element.
 * If you need content to be interactable inside the card, do not use the `href` prop.
 *
 * @slot - The default slot is the primary content of the card. This is the same area where the `text` prop is located.
 * @slot image - Set a custom image/svg/illustration. Simply use an `img` tag with the slot "image".
 * @slot tags - Add `pn-tags` that will be positioned above the `label` and `overline` if used.
 * @slot header - The header content, same area that the `label` and `overline` props will appear.
 * @slot navigation - This slot is intended for one or more `pn-button` components.
 * Only use **without** the `href` prop. Having both at the same time makes the component inaccessible.
 *
 * @since v7.12.0
 */
class PnCard {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.pnCard = createEvent(this, "pnCard", 7);
    }
    id = `pn-card-${uuidv4()}`;
    idTitle = `${this.id}-title`;
    visibleOutline = false;
    get hostElement() { return getElement(this); }
    /** Headline of the card. Will act as label for the link if there is no `href-label` set. */
    label;
    /** The label HTML tag. Default is `h3`. */
    labelTag = 'h3';
    /** Set a smaller text above the `label` text. */
    overline;
    /** Text content of the card. */
    text;
    /** Set a HTML id for the card. Optional and not required. */
    cardId = null;
    /**
     * Uee the horizontal card layout.
     * @category Features
     * */
    horizontal = false;
    /** Reverse the order of which the image will wrap. @category Features */
    reverse = false;
    /**
     * Select image aspect ratio. Example: '3/3', '16/9'.
     * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio CSS documentation.}
     * @category Features
     * */
    aspectRatio = '';
    /** The card link. @category Href */
    href;
    /** The link text. @category Href */
    hrefLabel;
    /** The target attribute of the link. @category Href */
    target;
    /** The rel attribute of the link. @category Href */
    rel = 'noopener noreferrer';
    /** The link icon. Defaults to `arrow_right` or `open_in_new` if `target="_blank"`. @category Href */
    icon = null;
    watchCardId() {
        const id = this.cardId || this.id;
        this.idTitle = `${id}-title`;
    }
    /** Emitted when you click on the card link (if you use the `href` prop). */
    pnCard;
    componentWillLoad() {
        this.watchCardId();
    }
    isExternal() {
        return this.target === '_blank';
    }
    showTitle() {
        return !!this.label;
    }
    showHref() {
        return !!this.href && (this.hrefLabel || this.showTitle());
    }
    getTitleId() {
        return this.hrefLabel ? null : this.idTitle;
    }
    getLabelledby() {
        return this.hrefLabel ? null : this.showTitle() ? this.idTitle : null;
    }
    getIcon() {
        if (!!this.icon)
            return this.icon;
        return this.isExternal() ? open_in_new : arrow_right;
    }
    getHeadingTag() {
        const tags = ['h2', 'h3', 'h4', 'h5', 'h6', 'p'];
        return tags.includes(this.labelTag) ? this.labelTag : 'h3';
    }
    handleFocus({ type, target }) {
        this.visibleOutline = type === 'focus' && target.matches(':focus-visible');
    }
    handleClick(event) {
        ripple(event, this.hostElement, '.pn-card');
        this.pnCard.emit({ click: event });
    }
    render() {
        const TitleTag = this.getHeadingTag();
        return (hAsync(Host, { key: '65ed28a0a625760d11f9bd7961978af7573f7062' }, hAsync("article", { key: '2f05480099b5bedddba115a3f00174d0ed4f9658', id: this.cardId, class: "pn-card", "data-link": !!this.href, "data-horizontal": this.horizontal, "data-reverse": this.reverse, "data-focus": this.visibleOutline }, hAsync("div", { key: '1ec2a31f2e71b9f4a511efb49461541f141ff077', class: "pn-card-image" }, hAsync("picture", { key: '869648c55b9e64091b55f501b759ffcddc33a8c5', class: "pn-card-picture", style: { '--pn-card-aspect-ratio': this.aspectRatio || 'unset' } }, hAsync("slot", { key: '9e31feb5e4c486159fb4f9ebb57cefbd7d156988', name: "image" }))), hAsync("div", { key: 'e2cfd35b304c05fb569da26aa7f248ed53b1e7aa', class: "pn-card-content" }, hAsync("header", { key: 'a5730ce876dd1b5fa0c6c37ba400801530bf99ea', class: "pn-card-header" }, hAsync("div", { key: '4e9566e679185db1704e313002d20d7016558c25', class: "pn-card-tags" }, hAsync("slot", { key: '0c4863c1ef7b69ef8a333dd7ac834f76b8a3fc00', name: "tags" })), !!this.overline && hAsync("p", { key: '8129ee0e178e4db9fcbf9895e75d64c02279a0a6', class: "pn-card-label-overline" }, this.overline), !!this.label && (hAsync(TitleTag, { key: '62a8d9c1512683f3e4248eac05bf2f33e0374fe9', id: this.getTitleId(), class: "pn-card-label" }, this.label)), hAsync("slot", { key: '13f3c2e3e182ce134dc7be0af3c8c2dec1c1f751', name: "header" })), hAsync("section", { key: 'c34ddb8484423b65927ace2e0b46deed6b1d3b64', class: "pn-card-section" }, !!this.text && hAsync("p", { key: '8370b223a2af93f64eb2efd84dda0b172324be54', class: "pn-card-section-paragraph" }, this.text), hAsync("slot", { key: '363cc14089263d2e640f35707a6503aeb77ae8a6' })), hAsync("nav", { key: '5636561cc2dc0eb1a1f42d213e87e73da9a3ce98', class: "pn-card-navigation" }, this.showHref() && (hAsync("a", { key: '9c7be2037e54320ccb2668170828e7ffc8fd7d25', class: "pn-card-link", href: this.href, target: this.target, rel: this.rel, "aria-labelledby": this.getLabelledby(), onClick: event => this.handleClick(event), onFocus: event => this.handleFocus(event), onBlur: event => this.handleFocus(event) }, this.hrefLabel, hAsync("pn-icon", { key: 'd77e3349eb1ed2cb3e8e72418c70d66b93ad5b20', color: "blue700", icon: this.getIcon() }))), hAsync("slot", { key: 'c28d4208e146a77f334fc326e7abbbf53e86e028', name: "navigation" }))))));
    }
    static get watchers() { return {
        "cardId": [{
                "watchCardId": 0
            }]
    }; }
    static get style() { return pnCardCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-card",
        "$members$": {
            "label": [1],
            "labelTag": [1, "label-tag"],
            "overline": [1],
            "text": [1],
            "cardId": [1, "card-id"],
            "horizontal": [4],
            "reverse": [4],
            "aspectRatio": [1, "aspect-ratio"],
            "href": [1],
            "hrefLabel": [1, "href-label"],
            "target": [1],
            "rel": [1],
            "icon": [1],
            "visibleOutline": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnCheckboxCss = () => `${transformTag("pn-checkbox")}{position:relative;display:inline-block}${transformTag("pn-checkbox")} .pn-checkbox{position:relative;display:flex;flex-wrap:wrap;flex-direction:row}${transformTag("pn-checkbox")} .pn-checkbox-label{cursor:pointer;color:#2d2013;-webkit-tap-highlight-color:transparent}${transformTag("pn-checkbox")} .pn-checkbox-helpertext{color:#5e554a;margin:0 0 0.5em 0;display:flex;flex-direction:column}${transformTag("pn-checkbox")} .pn-checkbox-helpertext:last-child{margin:0}${transformTag("pn-checkbox")} .pn-checkbox-content{display:flex;flex-direction:column;align-items:flex-start;font-weight:400;line-height:1.5;flex:1;margin:0 0 0 0.75em}${transformTag("pn-checkbox")} .pn-checkbox-outer{width:1.5em;height:1.5em;background-color:#ffffff;display:flex;align-items:center;justify-content:center;position:relative;border:0.0625em solid #969087;border-radius:0.25em;outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:outline-color, border-color, background-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-checkbox")} .pn-checkbox-outer{transition-duration:0s;transition-delay:0s}}${transformTag("pn-checkbox")} .pn-checkbox-svg{width:1.25em;fill:none}${transformTag("pn-checkbox")} .pn-checkbox-svg-line{stroke:#ffffff;transform-origin:0 0;stroke-linecap:round;stroke-dasharray:23;stroke-dashoffset:23;transition-property:stroke-dashoffset;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-checkbox")} .pn-checkbox-svg-line{transition-duration:0s;transition-delay:0s}}${transformTag("pn-checkbox")} .pn-checkbox-svg-line{transition-delay:0s}${transformTag("pn-checkbox")} .pn-checkbox[data-tile]{position:relative;background-color:#ffffff;border:0.0625em solid #969087;border-radius:0.5em;padding:1em;outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:outline-color, background-color, border-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-checkbox")} .pn-checkbox[data-tile]{transition-duration:0s;transition-delay:0s}}${transformTag("pn-checkbox")} .pn-checkbox[data-tile][data-invalid]{border-color:#a70707}${transformTag("pn-checkbox")} .pn-checkbox[data-invalid] .pn-checkbox-outer{border-color:#a70707}${transformTag("pn-checkbox")} .pn-checkbox-container{flex:1 1 100%;overflow:hidden;visibility:hidden}${transformTag("pn-checkbox")} .pn-checkbox-container[data-open]{visibility:visible;overflow:unset}${transformTag("pn-checkbox")} .pn-checkbox-container[data-moving]{visibility:visible;overflow:hidden}${transformTag("pn-checkbox")} .pn-checkbox-area{padding:0.75em 0 0 2.25em;display:flex;flex-direction:column;flex-wrap:nowrap;gap:1em}${transformTag("pn-checkbox")} .pn-checkbox>${transformTag("pn-icon")}{margin-left:0.75em}${transformTag("pn-checkbox")}>input{cursor:pointer;opacity:0;position:absolute;margin:0;z-index:1;top:0;left:0;font-size:1em;width:1.5em;height:1.5em;-webkit-tap-highlight-color:transparent}${transformTag("pn-checkbox")}>input[data-tile]:not([data-expand]){width:100%;height:100%}${transformTag("pn-checkbox")}>input[data-expand]{top:1em;left:1em}${transformTag("pn-checkbox")}>input[aria-describedby]+.pn-checkbox[data-tile] .pn-checkbox-label{font-weight:500}${transformTag("pn-checkbox")}>input:hover+.pn-checkbox>.pn-checkbox-outer{background-color:#e0f8ff;border-color:#005d92}${transformTag("pn-checkbox")}>input:hover+.pn-checkbox[data-tile]{background-color:#e0f8ff;border-color:#005d92}${transformTag("pn-checkbox")}>input:hover+.pn-checkbox[data-tile][data-invalid]{background-color:#fdefee;border-color:#a70707}${transformTag("pn-checkbox")}>input:hover+.pn-checkbox[data-invalid]>.pn-checkbox-outer{background-color:#fdefee;border-color:#a70707}${transformTag("pn-checkbox")}>input:focus-visible+.pn-checkbox>.pn-checkbox-outer{outline-color:#005d92}${transformTag("pn-checkbox")}>input:focus-visible+.pn-checkbox[data-tile]{outline-color:#005d92;border-color:#005d92}${transformTag("pn-checkbox")}>input:focus-visible+.pn-checkbox[data-tile][data-invalid]{outline-color:#a70707;border-color:#a70707}${transformTag("pn-checkbox")}>input:focus-visible+.pn-checkbox[data-tile][data-invalid]>.pn-checkbox-outer{outline-color:transparent}${transformTag("pn-checkbox")}>input:focus-visible+.pn-checkbox[data-tile]>.pn-checkbox-outer{outline-color:transparent}${transformTag("pn-checkbox")}>input:focus-visible+.pn-checkbox[data-invalid]>.pn-checkbox-outer{outline-color:#a70707}${transformTag("pn-checkbox")}>input:checked+.pn-checkbox>.pn-checkbox-outer{background-color:#005d92;border-color:#005d92}${transformTag("pn-checkbox")}>input:checked+.pn-checkbox>.pn-checkbox-outer .pn-checkbox-svg>.pn-checkbox-svg-indeterminate{stroke-dashoffset:23}${transformTag("pn-checkbox")}>input:checked+.pn-checkbox>.pn-checkbox-outer .pn-checkbox-svg>.pn-checkbox-svg-checkmark{transition-delay:0.2s;stroke-dashoffset:0}${transformTag("pn-checkbox")}>input:checked+.pn-checkbox[data-tile]{background-color:#e0f8ff;border-color:#005d92}${transformTag("pn-checkbox")}>input:checked+.pn-checkbox[data-tile][data-invalid]{background-color:#fdefee;border-color:#a70707}${transformTag("pn-checkbox")}>input:checked+.pn-checkbox[data-invalid]>.pn-checkbox-outer{background-color:#a70707;border-color:#a70707}${transformTag("pn-checkbox")}>input:checked:hover+.pn-checkbox[data-tile]{border-color:#0d234b}${transformTag("pn-checkbox")}>input:checked:hover+.pn-checkbox>.pn-checkbox-outer{background-color:#0d234b;border-color:#0d234b}${transformTag("pn-checkbox")}>input:checked:hover+.pn-checkbox[data-invalid]{border-color:#500715}${transformTag("pn-checkbox")}>input:checked:hover+.pn-checkbox[data-invalid]>.pn-checkbox-outer{background-color:#500715;border-color:#500715}${transformTag("pn-checkbox")}>input:indeterminate+.pn-checkbox>.pn-checkbox-outer{background-color:#005d92;border-color:#005d92}${transformTag("pn-checkbox")}>input:indeterminate+.pn-checkbox>.pn-checkbox-outer .pn-checkbox-svg>.pn-checkbox-svg-checkmark{stroke-dashoffset:23}${transformTag("pn-checkbox")}>input:indeterminate+.pn-checkbox>.pn-checkbox-outer .pn-checkbox-svg>.pn-checkbox-svg-indeterminate{stroke-dashoffset:0}${transformTag("pn-checkbox")}>input:indeterminate+.pn-checkbox[data-invalid]>.pn-checkbox-outer{background-color:#a70707;border-color:#a70707}${transformTag("pn-checkbox")}>input:indeterminate:hover+.pn-checkbox>.pn-checkbox-outer{background-color:#0d234b;border-color:#0d234b}${transformTag("pn-checkbox")}>input:indeterminate:hover+.pn-checkbox[data-invalid]>.pn-checkbox-outer{background-color:#500715;border-color:#500715}${transformTag("pn-checkbox")}>input:disabled{pointer-events:none}${transformTag("pn-checkbox")}>input:disabled+.pn-checkbox .pn-checkbox-label{pointer-events:none}${transformTag("pn-checkbox")}>input:disabled+.pn-checkbox>.pn-checkbox-outer{background-color:#f3f2f2;border-color:#969087}${transformTag("pn-checkbox")}>input:disabled+.pn-checkbox[data-tile]{background-color:#f3f2f2;border-color:#f3f2f2}${transformTag("pn-checkbox")}>input:disabled+.pn-checkbox[data-tile]>${transformTag("pn-icon")} .pn-icon-svg path{fill:#5e554a}${transformTag("pn-checkbox")}>input:disabled+.pn-checkbox[data-tile]>.pn-checkbox-content>.pn-checkbox-label{color:#5e554a}${transformTag("pn-checkbox")}>input:disabled:checked+.pn-checkbox>.pn-checkbox-outer{background-color:#969087;border-color:#969087}${transformTag("pn-checkbox")}>input:disabled:indeterminate+.pn-checkbox>.pn-checkbox-outer{background-color:#969087;border-color:#969087}`;

/**
 * The `pn-checkbox` is built with a native `input[type="checkbox"]` in the background.
 * This means you can use native events to listen to the changes.
 *
 * @nativeChange Use the `change` event to listen when the checkbox state is being toggled.
 *
 * @slot - The default slot for adding custom HTML under the label/helpertext. {@since v7.17.0}
 * @slot helpertext - Use this slot to add custom HTML inside of the helpertext element.
 * Only recommended if you need a link without the `tile` prop. {@since v7.17.0}
 * @slot content - When using the `tile` and `expand` props, this slot will be revealed when the input is checked. {@since v7.17.0}
 */
class PnCheckbox extends Mixin(animateHeightFactory) {
    constructor(hostRef) {
        super();
        registerInstance(this, hostRef);
        this.pnCheckboxChange = createEvent(this, "pnCheckboxChange", 3);
    }
    id = `pn-checkbox-${uuidv4()}`;
    idHelpertext = `${this.id}-helpertext`;
    contentArea;
    get hostElement() { return getElement(this); }
    /** The checkbox label, this is required for the checkbox to be 100% accessible out of the box. */
    label;
    /** This adds an optional helpertext under the label. */
    helpertext;
    /** This will be emitted on change and input events. @category Native attributes  */
    value;
    /** The name of the checkbox group. @category Native attributes  */
    name;
    /** Programmatically check the input. @category Native attributes  */
    checked = false;
    /** Set the checkbox as required. @category Native attributes */
    required = false;
    /** Disable the checkbox. @category Native attributes */
    disabled = false;
    /**
     * If set to true, color scheme will turn red, indicating that there is an issue related to the checkbox.
     * @category Native attributes
     */
    invalid = false;
    /**
     * Sets the checkbox to an indeterminate state, allowing for a mixed or intermediate checkbox state.
     * @category Native attributes
     */
    indeterminate = false;
    /**
     * Turn the checkbox into a clickable tile. A border and padding is added.
     *
     * **Do not** use interactive elements (links/buttons) inside of the slots when using this prop.
     * An exception is made when using the `tile` + `expand` props together,
     * which allows you to use interactive elements.
     *
     * @category Features
     */
    tile = false;
    /**
     * Allow the checkbox to control the slot area "content".
     * When checked, the area is visible, when unchecked, the area is hidden.
     *
     * The prop `tile` must be used at the same time.
     * @see {@link tile}
     * @since v7.17.0
     * @category Features
     */
    expand = false;
    /**
     * Add an icon on the right of your checkbox tile. The `tile` prop must be `true` for the icon to work.
     * @see {@link tile}
     * @category Features
     */
    icon = null;
    /** A unique HTML ID for the checkbox. @since v7.25.0 @category HTML attributes */
    pnId;
    /**
     * Provide the label via an aria attribute.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabel;
    /**
     * Provide the label from another element via its ID.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabelledby;
    /** A unique HTML ID for the checkbox. @deprecated Use `pn-id` instead. @category HTML attributes */
    checkboxid;
    handleId() {
        this.idHelpertext = `${this.getId()}-helpertext`;
    }
    handleChecked() {
        if (this.displayContent()) {
            this.checked ? this.openDropdown(this.contentArea) : this.closeDropdown(this.contentArea);
        }
    }
    /**
     * This is the same as the native `change` event, but without bubbling.
     * This is useful when you want to listen to the event directly on the `pn-checkbox` element without
     * having to worry about catching events from nested pn-checkboxes.
     *
     * @since v7.25.0
     **/
    pnCheckboxChange;
    componentDidLoad() {
        if (this.displayContent() && this.checked) {
            requestAnimationFrame(() => this.openDropdown(this.contentArea));
        }
    }
    getId() {
        return this.pnId || this.checkboxid || this.id;
    }
    handleChange(e) {
        const { checked } = e.target;
        this.indeterminate = false;
        this.checked = checked;
        this.pnCheckboxChange.emit(e);
    }
    isInvalid() {
        return this.invalid && !this.disabled;
    }
    displayText() {
        return this.displayLabel() || this.displayHelpertext();
    }
    displayLabel() {
        return !!this.label;
    }
    displayHelpertext() {
        return !!(this.helpertext || this.hostElement.querySelector('[slot="helpertext"]')?.textContent);
    }
    displayIcon() {
        return this.tile && !!this.icon;
    }
    /** Allow the checkbox to expand and control the slot area "content". */
    displayContent() {
        return this.tile && this.expand;
    }
    getAriaLabel() {
        return !this.displayLabel() && !this.pnAriaLabelledby ? this.pnAriaLabel : null;
    }
    getAriaLabelledby() {
        return !this.displayLabel() && !this.pnAriaLabel ? this.pnAriaLabelledby : null;
    }
    render() {
        return (hAsync(Host, { key: '4952d473c243232a6ee267cfac9414c8feb3e9c7' }, hAsync("input", { key: 'e478ca15bde8fdf54833fe5b5a834513813db65e', type: "checkbox", id: this.getId(), class: "pn-checkbox-input", value: this.value, name: this.name, disabled: this.disabled, checked: this.checked, required: this.required, indeterminate: this.indeterminate, "aria-label": this.getAriaLabel(), "aria-labelledby": this.getAriaLabelledby(), "aria-describedby": this.displayHelpertext() && this.idHelpertext, "aria-invalid": this.isInvalid()?.toString(), "data-tile": this.tile, "data-expand": this.expand, onChange: e => this.handleChange(e) }), hAsync("div", { key: 'e918f05ea8a0f5e26a7963dcdbd9cef7a1ae8a57', class: "pn-checkbox", "data-tile": this.tile, "data-expand": this.expand, "data-invalid": this.isInvalid() }, hAsync("div", { key: 'e876cc7ae77d0496c745da65de5883404d0a01c7', class: "pn-checkbox-outer" }, hAsync("svg", { key: '2349e0a978e6824658b572462eb5baf9ccda2ec9', class: "pn-checkbox-svg", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none" }, hAsync("polyline", { key: 'c01925a07dfb5bbed352ecb741a3e9c830a32b3b', class: "pn-checkbox-svg-line pn-checkbox-svg-checkmark", points: "4,12 9,17 20,6", "stroke-width": "3" }), hAsync("polyline", { key: '0d4dfa8da28e602bf0c579c6ca48fda9f1748a38', class: "pn-checkbox-svg-line pn-checkbox-svg-indeterminate", points: "4,12 20,12", "stroke-width": "3" }))), hAsync("div", { key: 'd3c1f4a8d7aa27d7d9ca192438b84619574fcf39', class: "pn-checkbox-content", hidden: !this.displayText() }, hAsync("label", { key: '467ca071291cbd977670300bb45affc7153ae7f4', htmlFor: this.getId(), class: "pn-checkbox-label", hidden: !this.displayLabel() }, this.label), hAsync("p", { key: '5c790a6b8583415168a3e92c7b6d3a38125b39cd', id: this.idHelpertext, class: "pn-checkbox-helpertext", hidden: !this.displayHelpertext() }, this.helpertext && hAsync("span", { key: 'e35b4ac4a6abd759d7fb5e1d41fd2f198515e106' }, this.helpertext), hAsync("slot", { key: 'ac060762533af07379cc80225a83de6e01ca26e4', name: "helpertext" })), hAsync("slot", { key: '4f0309028f9266d016f19d8983343ff010d89195' })), this.displayIcon() && hAsync("pn-icon", { key: '742b544ed4ed61ff311de992eea37b768cc6efef', icon: this.icon, color: "gray900" }), hAsync("div", { key: '45cdad0df43248b340feed887659d6c63e90b85f', class: "pn-checkbox-container", "data-open": this.checked, hidden: !this.displayContent(), style: { height: '0px' }, ref: el => (this.contentArea = el) }, hAsync("div", { key: '060550d9876021ba85a1821c51c60b1bb34b8a3c', class: "pn-checkbox-area" }, hAsync("slot", { key: 'bbe34f9d29a922ab20b8696595a9ed469005f59e', name: "content" }))))));
    }
    static get watchers() { return {
        "checkboxid": [{
                "handleId": 0
            }],
        "pnId": [{
                "handleId": 1
            }],
        "checked": [{
                "handleChecked": 0
            }]
    }; }
    static get style() { return pnCheckboxCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-checkbox",
        "$members$": {
            "label": [1],
            "helpertext": [1],
            "value": [513],
            "name": [1],
            "checked": [1540],
            "required": [4],
            "disabled": [4],
            "invalid": [4],
            "indeterminate": [1028],
            "tile": [4],
            "expand": [4],
            "icon": [1],
            "pnId": [1, "pn-id"],
            "pnAriaLabel": [1, "pn-aria-label"],
            "pnAriaLabelledby": [1, "pn-aria-labelledby"],
            "checkboxid": [1],
            "isClosing": [32],
            "isExpanding": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": [["value", "value"], ["checked", "checked"]]
    }; }
}

const pnChoiceChipCss = () => `${transformTag("pn-choice-chip")}{display:inline-block}${transformTag("pn-choice-chip")} .pn-choice-chip{position:relative;font-size:1em;font-weight:500;text-align:center}${transformTag("pn-choice-chip")} .pn-choice-chip-container{cursor:pointer;position:relative;display:flex;align-items:center;gap:0;padding:0.5em 1em;border:0.0625em solid #969087;border-radius:0.5em;background-color:#ffffff;transition-property:border-color, outline-color, background-color, padding, gap;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-choice-chip")} .pn-choice-chip-container{transition-duration:0s;transition-delay:0s}}${transformTag("pn-choice-chip")} .pn-choice-chip-container{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-choice-chip")} .pn-choice-chip-container[data-icon]{gap:0.25em;padding-left:0.75em}${transformTag("pn-choice-chip")} .pn-choice-chip-container[data-icon][data-small]{padding-left:0.5em}${transformTag("pn-choice-chip")} .pn-choice-chip-container[data-icon][data-large]{padding-left:1em}${transformTag("pn-choice-chip")} .pn-choice-chip-container[data-icon]>.pn-choice-chip-icon{width:1.5em}${transformTag("pn-choice-chip")} .pn-choice-chip-container[data-small]{padding:0.25em 0.75em}${transformTag("pn-choice-chip")} .pn-choice-chip-container[data-small] .pn-choice-chip-label{line-height:1.25em}${transformTag("pn-choice-chip")} .pn-choice-chip-container[data-small] .pn-choice-chip-label>span{font-size:0.875em}${transformTag("pn-choice-chip")} .pn-choice-chip-container[data-large]{padding:0.6875em 1.25em}${transformTag("pn-choice-chip")} .pn-choice-chip-icon{position:relative;width:0;height:1.5em;transition-property:width;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-choice-chip")} .pn-choice-chip-icon{transition-duration:0s;transition-delay:0s}}${transformTag("pn-choice-chip")} .pn-choice-chip-icon ${transformTag("pn-icon")}{opacity:0;transform:scale(0);position:absolute;top:0;left:0;transition-property:transform, opacity;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-choice-chip")} .pn-choice-chip-icon ${transformTag("pn-icon")}{transition-duration:0s;transition-delay:0s}}${transformTag("pn-choice-chip")} .pn-choice-chip-icon ${transformTag("pn-icon")}.pn-choice-chip-icon-user{opacity:1;transform:scale(1)}${transformTag("pn-choice-chip")} .pn-choice-chip-label{color:#005d92;line-height:1.5em;transition-property:color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-choice-chip")} .pn-choice-chip-label{transition-duration:0s;transition-delay:0s}}${transformTag("pn-choice-chip")} .pn-choice-chip-label{cursor:pointer;display:flex;align-items:center;flex-grow:1;height:100%}${transformTag("pn-choice-chip")} .pn-choice-chip>input{position:absolute;z-index:1;opacity:0;top:0;left:0;width:100%;height:100%;margin:0;cursor:pointer}${transformTag("pn-choice-chip")} .pn-choice-chip>input:not(:checked)~.pn-choice-chip-container>.pn-choice-chip-icon>.pn-choice-chip-icon-user{transform:scale(1);opacity:1}${transformTag("pn-choice-chip")} .pn-choice-chip>input:hover~.pn-choice-chip-container{background-color:#effbff;border-color:#005d92}${transformTag("pn-choice-chip")} .pn-choice-chip>input:hover~.pn-choice-chip-container .pn-choice-chip-icon-user .pn-icon-svg path,${transformTag("pn-choice-chip")} .pn-choice-chip>input:hover~.pn-choice-chip-container .pn-choice-chip-icon-check .pn-icon-svg path{fill:#005d92}${transformTag("pn-choice-chip")} .pn-choice-chip>input:hover~.pn-choice-chip-container .pn-choice-chip-label{color:#005d92}${transformTag("pn-choice-chip")} .pn-choice-chip>input:checked~.pn-choice-chip-container{gap:0.25em;background-color:#e0f8ff;border-color:#005d92}${transformTag("pn-choice-chip")} .pn-choice-chip>input:checked~.pn-choice-chip-container>.pn-choice-chip-icon{width:1.5em;stroke-dashoffset:23}${transformTag("pn-choice-chip")} .pn-choice-chip>input:checked~.pn-choice-chip-container>.pn-choice-chip-icon>.pn-choice-chip-icon-check{transform:scale(1);opacity:1}${transformTag("pn-choice-chip")} .pn-choice-chip>input:checked~.pn-choice-chip-container>.pn-choice-chip-icon>.pn-choice-chip-icon-user{transform:scale(0);opacity:0}${transformTag("pn-choice-chip")} .pn-choice-chip>input:checked~.pn-choice-chip-container>.pn-choice-chip-label{color:#0d234b}${transformTag("pn-choice-chip")} .pn-choice-chip>input:checked:hover~.pn-choice-chip-container{background-color:#effbff;border-color:#0d234b}${transformTag("pn-choice-chip")} .pn-choice-chip>input:checked:hover~.pn-choice-chip-container>.pn-choice-chip-icon>.pn-choice-chip-icon-check path{fill:#0d234b}${transformTag("pn-choice-chip")} .pn-choice-chip>input:checked:hover~.pn-choice-chip-container>.pn-choice-chip-label{color:#0d234b}${transformTag("pn-choice-chip")} .pn-choice-chip>input:focus-visible~.pn-choice-chip-container{outline-color:#005d92;border-color:#005d92}${transformTag("pn-choice-chip")} .pn-choice-chip>input:disabled{cursor:not-allowed}${transformTag("pn-choice-chip")} .pn-choice-chip>input:disabled:active~.pn-choice-chip-container{outline:none}${transformTag("pn-choice-chip")} .pn-choice-chip>input:disabled~.pn-choice-chip-container{background-color:#f3f2f2;border-color:#f3f2f2;cursor:not-allowed}${transformTag("pn-choice-chip")} .pn-choice-chip>input:disabled~.pn-choice-chip-container .pn-choice-chip-label{color:#5e554a;cursor:not-allowed}${transformTag("pn-choice-chip")} .pn-choice-chip>input:disabled~.pn-choice-chip-container ${transformTag("pn-icon")} .pn-icon-svg path{fill:#5e554a}`;

/**
 * The `pn-choice-chip` is built with a native `input[type="checkbox|radio"]` in the background.
 * This means you can use native events to listen to the changes.
 *
 * @nativeChange Use the `change` event to listen when the choice chip state is being toggled. Works for both checkbox/radio variant.
 */
class PnChoiceChip {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    id = `pn-choice-chip-${uuidv4()}`;
    get hostElement() { return getElement(this); }
    /** The choice chip label. This is required for the component to be accessible. */
    label;
    /** This will be emitted on change and input. @category Native attributes */
    value;
    /** The name of the checkbox group. This is required if you use the `radio` prop. @category Native attributes */
    name;
    /** Programatically check the input. @category Native attributes */
    checked = false;
    /** Set the input as required. @category Native attributes */
    required = false;
    /** Disable the input. @category Native attributes */
    disabled = false;
    /**
     * Make the choice chip a radio input. By default, it behaves as a checkbox.
     * You must assign a `name` for the radio to work.
     *  @category Features
     */
    radio = false;
    /** Add an icon to the choice chip. @category Features */
    icon;
    /** Use the small size for the choice chip. @category Features */
    small = false;
    /** Use the large size for the choice chip. @category Features*/
    large = false;
    /**
     * A unique HTML ID for the choice chip
     * @since v7.25.0
     * @category HTML attributes
     */
    pnId;
    /**
     * A unique HTML ID for the choice chip.
     * @deprecated Use the `pn-id` prop instead.
     * @category HTML attributes
     */
    choiceid;
    inputType() {
        return this.radio ? 'radio' : 'checkbox';
    }
    getId() {
        return this.pnId || this.choiceid || this.id;
    }
    render() {
        return (hAsync(Host, { key: '34b4a84a6fa6ebd0c592a4d585d333084e72c89f' }, hAsync("div", { key: '66c7aa91b09795d9d452b1d6c0b65f0b64ba25f9', class: "pn-choice-chip" }, hAsync("input", { key: '8723fd54d3ff2fed1a64c955ab3ea2e4812ff04f', type: this.inputType(), id: this.getId(), value: this.value, name: this.name, checked: this.checked, required: this.required, disabled: this.disabled }), hAsync("div", { key: '9fd84d08b519181f954c3b62b1644afab67569ad', class: "pn-choice-chip-container", "data-icon": !!this.icon, "data-small": this.small, "data-large": this.large }, hAsync("div", { key: '29b394a6806acbd2d9f905971555242f8bf81d32', class: "pn-choice-chip-icon" }, hAsync("pn-icon", { key: '22031f1693f50efa6b9e049c643e9ecbc931bea6', color: "blue700", class: "pn-choice-chip-icon-check", icon: check }), !!this.icon && hAsync("pn-icon", { key: '573e411940efa3054290a5cb574978dddddfb766', color: "blue700", class: "pn-choice-chip-icon-user", icon: this.icon })), hAsync("label", { key: 'c0deb7c6cd33da32bc4b89af84d04a7383664024', class: "pn-choice-chip-label", htmlFor: this.getId() }, hAsync("span", { key: 'ea43103d3f3d2332a52e9191ff37262bce642dbb' }, this.label), hAsync("slot", { key: '904ac98a84bd191e74323154b7ea6de39dca964a' }))))));
    }
    static get style() { return pnChoiceChipCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-choice-chip",
        "$members$": {
            "label": [1],
            "value": [513],
            "name": [1],
            "checked": [1028],
            "required": [4],
            "disabled": [4],
            "radio": [4],
            "icon": [1],
            "small": [4],
            "large": [4],
            "pnId": [1, "pn-id"],
            "choiceid": [1]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": [["value", "value"]]
    }; }
}

const translations$f = {
    DECREASE: {
        en: 'Decrease',
        sv: 'Minska',
        da: 'Reducere',
        fi: 'Vähentää',
        no: 'Redusere',
    },
    INCREASE: {
        en: 'Increase',
        sv: 'Öka',
        da: 'Øge',
        fi: 'Lisääntyä',
        no: 'Øke',
    },
    MAX_VALUE_MESSAGE: {
        en: 'Maximum value is ',
        sv: 'Högsta värde är ',
        da: 'Højeste værdi er',
        fi: 'Korkein arvo on',
        no: 'Høyeste verdi er',
    },
    MIN_VALUE_MESSAGE: {
        en: 'Minimum value is ',
        sv: 'Lägsta värde är ',
        da: 'Laveste værdi er ',
        fi: 'Pienin arvo on ',
        no: 'Laveste verdi er ',
    },
};

const pnCounterCss = () => `${transformTag("pn-counter")}{display:inline-block}${transformTag("pn-counter")} .pn-counter{display:flex;flex-direction:column}${transformTag("pn-counter")} .pn-counter-label{cursor:pointer;display:flex;justify-content:space-between;align-items:flex-end;font-weight:400;color:#2d2013;margin:0 0 0.25em 0;gap:0.5em;-webkit-tap-highlight-color:transparent;transition-property:color, transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-counter")} .pn-counter-label{transition-duration:0s;transition-delay:0s}}${transformTag("pn-counter")} .pn-counter-label[data-compact]{position:absolute;top:1.5625em;left:calc(var(--pn-input-offset-left, 0px) + 0.75em + 0.0625em);margin:0;pointer-events:none;align-items:center;height:1.5em;max-width:calc(100% - (var(--pn-input-offset-left, 0px) + 0.75em) - (var(--pn-input-offset-right, 0px) + 0.75em));transform:translateY(-50%) scale(1) translateZ(0);transform-origin:0 0;transition-delay:0.2s}${transformTag("pn-counter")} .pn-counter-label[data-compact]>span{font-size:1em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;line-height:1.5em}${transformTag("pn-counter")} .pn-counter-label>span{font-size:0.875em}${transformTag("pn-counter")} .pn-counter-input{position:relative;flex:1 1 auto}${transformTag("pn-counter")} .pn-counter-element{text-align:center;width:100%;appearance:textfield;color:#2d2013;background-color:#ffffff;border:0.0625em solid #969087;border-radius:0.5em;padding:0.75em;font-family:inherit;font-size:1em;font-weight:500;line-height:1.5em;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent}${transformTag("pn-counter")} .pn-counter-element:-webkit-autofill,${transformTag("pn-counter")} .pn-counter-element:-webkit-autofill:hover,${transformTag("pn-counter")} .pn-counter-element:-webkit-autofill:focus,${transformTag("pn-counter")} .pn-counter-element:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #e0f8ff inset;-webkit-text-fill-color:#2d2013}${transformTag("pn-counter")} .pn-counter-element{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-counter")} .pn-counter-element:focus-visible{outline-color:#005d92;background-color:#ffffff;border-color:#005d92}${transformTag("pn-counter")} .pn-counter-element{transition-property:outline-color, background-color, border-color, color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-counter")} .pn-counter-element{transition-duration:0s;transition-delay:0s}}${transformTag("pn-counter")} .pn-counter-element[data-compact]{text-align:left;padding-top:1.125em;padding-bottom:0.375em;max-width:unset}${transformTag("pn-counter")} .pn-counter-element[data-compact]::placeholder{color:transparent}${transformTag("pn-counter")} .pn-counter-element[data-compact]:focus+.pn-counter-label,${transformTag("pn-counter")} .pn-counter-element[data-compact]:not(:placeholder-shown)+.pn-counter-label{transform:translateY(-85%) scale(0.75);transition-delay:0s}${transformTag("pn-counter")} .pn-counter-element::placeholder{color:#5e554a;font-weight:normal}${transformTag("pn-counter")} .pn-counter-element:hover{border-color:#005d92}${transformTag("pn-counter")} .pn-counter-element:disabled{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2}${transformTag("pn-counter")} .pn-counter-element:read-only{border-color:#ffffff}${transformTag("pn-counter")} .pn-counter-element:disabled{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2}${transformTag("pn-counter")} .pn-counter-element:out-of-range{border-color:#a70707}${transformTag("pn-counter")} .pn-counter-element:out-of-range:hover{border-color:#500715}${transformTag("pn-counter")} .pn-counter-element:out-of-range:focus-visible{background-color:#ffffff;border-color:#a70707;outline-color:#a70707}${transformTag("pn-counter")} .pn-counter-element:out-of-range:-webkit-autofill,${transformTag("pn-counter")} .pn-counter-element:out-of-range:-webkit-autofill:hover,${transformTag("pn-counter")} .pn-counter-element:out-of-range:-webkit-autofill:focus,${transformTag("pn-counter")} .pn-counter-element:out-of-range:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #fef7f6 inset;-webkit-text-fill-color:#2d2013}${transformTag("pn-counter")} .pn-counter-element::-webkit-inner-spin-button,${transformTag("pn-counter")} .pn-counter-element::-webkit-outer-spin-button{-webkit-appearance:none;-moz-appearance:none;appearance:none}${transformTag("pn-counter")} .pn-counter-items{display:inline-flex;flex-direction:row;gap:0.5em;transition-property:gap;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-counter")} .pn-counter-items{transition-duration:0s;transition-delay:0s}}${transformTag("pn-counter")} .pn-counter-items[data-hidebuttons]{gap:0}${transformTag("pn-counter")} .pn-counter-items[data-hidebuttons]>${transformTag("pn-button")}{transform:scale(0) translateZ(0);width:0}${transformTag("pn-counter")} .pn-counter-items>${transformTag("pn-button")}{transform:scale(1) translateZ(0);transform-origin:center center;width:3em;will-change:width, transform;transition-property:transform, width;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-counter")} .pn-counter-items>${transformTag("pn-button")}{transition-duration:0s;transition-delay:0s}}${transformTag("pn-counter")} .pn-counter-helpertext{color:#5e554a;font-size:0.875em;font-weight:400;margin:0.25em 0 0 0;display:flex;flex-direction:column;gap:0.25em}${transformTag("pn-counter")} .pn-counter-sr-only{position:absolute;height:1px;width:1px;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);margin:-1px;white-space:nowrap}`;

/**
 * The `pn-counter` is an input with a button on each side that can be used to increase and decrease the input value.
 *
 * @slot helpertext - Use this slot to add custom HTML inside of the helpertext element. Recommended if you need a link. {@since v7.25.0}
 *
 * @nativeInput Use the `input` event to listen to content being modified by the user. It is emitted everytime a user writes or removes content in the input.
 * @nativeChange The `change` event is emitted when the input loses focus, the user clicks `Enter` or makes a selection (such as auto complete or suggestions).
 */
class PnCounter {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.counterInput = createEvent(this, "counterInput", 7);
    }
    id = `pn-counter-${uuidv4()}`;
    idLabel = `${this.id}-label`;
    idText = `${this.id}-text`;
    idAmount = `${this.id}-count`;
    get hostElement() { return getElement(this); }
    clearAriaTimer;
    displaySrValue = false;
    showMinMaxMessage = false;
    /** Prevent double events when reaching min/max values. */
    lastDispatchedValue;
    interactType;
    /** Label for the counter. This is required for the counter to be 100% accessible out of the box. */
    label;
    /** Set a helpertext for the counter. */
    helpertext;
    /** Set the language manually for the built in translations.  */
    language = undefined;
    /** Set a predefined value. @category Native attributes */
    value = 0;
    /** HTML input name. @category Native attributes */
    name;
    /** Minimum value. @category Native attributes */
    min;
    /** Maximum value. @category Native attributes */
    max;
    /** Increase/decrease the value in steps, default is 1. @category Native attributes */
    step = 1;
    /** Suggest values for the counter input. @category Native attributes */
    list;
    /** Set the counter as required. @category Native attributes */
    required = false;
    /** Set the counter as readonly. @category Native attributes */
    readonly = false;
    /** Set the counter as disabled. @category Native attributes */
    disabled = false;
    /** Use the compact label variant. @since v7.21.0 @category Features */
    compact = false;
    /** Text for the decrease button. Default is "Decrease". @category Features */
    labelDecrease;
    /** Text for the increase button. Default is "Increase". @category Features */
    labelIncrease;
    /** Hide the tooltips for the increase/decrease button. @since v7.25.0 @category Features */
    hideTooltips = false;
    /** Set a message that shows below input when user wants to set a value that is below `min`. Default is "Minimum value is x" @category Features */
    minMessage;
    /** Set a message that shows below input when user wants to set a value that is above `max`. Default is "Maximum value is x"  @category Features */
    maxMessage;
    /** Set a unique HTML ID for the counter. @since v7.25.0 @category HTML attributes */
    pnId;
    /**
     * Provide the label via an aria attribute.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabel;
    /**
     * Provide the label from another element via its ID.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabelledby;
    /** Set a unique HTML ID for the counter. @deprecated Use `pn-id` instead. @category HTML attributes */
    counterid;
    /**
     * Instead of listening to multiple input, change and/or click events, we bundled them into one.
     * - `value` is the current counter value.
     * - `input` is true if the user changed the value with the HTML input.
     * - `decrease` is true if the user clicked on the decrease button.
     * - `increase` is true if the user clicked on the increase button.
     */
    counterInput;
    watchValue() {
        this.showSrContent();
        this.showMinMaxMessage = false;
        if (this.hasMin() && this.value < this.min) {
            this.setMin();
            this.showMinMaxMessage = true;
        }
        if (this.hasMax() && this.value > this.max) {
            this.setMax();
            this.showMinMaxMessage = true;
        }
        if (this.lastDispatchedValue !== this.value)
            this.counterInput.emit({
                value: this.value,
                input: this.interactType === 'input',
                decrease: this.interactType === 'decrease',
                increase: this.interactType === 'increase',
            });
        this.lastDispatchedValue = this.value;
    }
    handleId() {
        this.idLabel = `${this.getId()}-label`;
        this.idText = `${this.getId()}-text`;
        this.idAmount = `${this.getId()}-count`;
    }
    async componentWillLoad() {
        if (this.language === undefined)
            await awaitTopbar(this.hostElement);
    }
    getId() {
        return this.pnId || this.counterid || this.id;
    }
    setVal(event) {
        const { valueAsNumber } = event.target;
        if (isNaN(valueAsNumber))
            return;
        this.interactType = 'input';
        this.value = valueAsNumber;
    }
    setMin() {
        if (this.hasMin())
            this.value = this.min;
    }
    setMax() {
        if (this.hasMax())
            this.value = this.max;
    }
    hasMin() {
        return typeof this.min === 'number';
    }
    hasMax() {
        return typeof this.max === 'number';
    }
    getAriaLabel() {
        return !this.label && !this.pnAriaLabelledby ? this.pnAriaLabel : null;
    }
    getAriaLabelledby() {
        return !this.label && !this.pnAriaLabel ? this.pnAriaLabelledby : null;
    }
    decreaseAmount() {
        if (this.hasMin() && this.value <= this.min)
            this.showMinMaxMessage = true;
        this.interactType = 'decrease';
        this.value = this.value - this.step;
    }
    increaseAmount() {
        if (this.hasMax() && this.value >= this.max)
            this.showMinMaxMessage = true;
        this.interactType = 'increase';
        this.value = this.value + this.step;
    }
    keyBoardInput(event) {
        event.stopImmediatePropagation();
        if (!/^(Home|End)$/.test(event.key))
            return;
        event.preventDefault();
        this.interactType = 'input';
        if (event.key === 'Home')
            this.setMin();
        if (event.key === 'End')
            this.setMax();
    }
    showSrContent() {
        if (this.clearAriaTimer) {
            clearTimeout(this.clearAriaTimer);
        }
        this.displaySrValue = true;
        this.clearAriaTimer = setTimeout(() => {
            this.displaySrValue = false;
        }, 4000);
    }
    toggleMinMaxMessage() {
        const isMax = this.value === this.max;
        const i18ntxt = `${isMax ? 'MAX' : 'MIN'}_VALUE_MESSAGE`;
        const message = this.translate(i18ntxt) + `${isMax ? this.max : this.min}`.toString();
        return isMax ? this.maxMessage || message : this.minMessage || message;
    }
    getTextMessage(showValue = false) {
        if (this.showMinMaxMessage)
            return this.toggleMinMaxMessage();
        return showValue ? this.value.toString() : this.helpertext;
    }
    hideHelpertext() {
        const slotHelpertext = this.hostElement.querySelector('[slot="helpertext"]');
        return !(this.getTextMessage() || !!slotHelpertext?.textContent);
    }
    describedbyIds() {
        const list = [];
        if (!this.hideHelpertext())
            list.push(this.idText);
        if (this.displaySrValue)
            list.push(this.idAmount);
        if (list.length === 0)
            return null;
        return list.join(' ');
    }
    translate(prop) {
        return translations$f?.[prop]?.[this.language || en$2];
    }
    noButtons() {
        return this.disabled || this.readonly;
    }
    renderLabel() {
        if (!this.label)
            return null;
        return (hAsync("label", { htmlFor: this.getId(), class: "pn-counter-label", id: this.idLabel, "data-compact": this.compact }, hAsync("span", null, this.label)));
    }
    renderButton(increase = false) {
        const label = increase
            ? this.labelIncrease || this.translate('INCREASE')
            : this.labelDecrease || this.translate('DECREASE');
        return (hAsync("pn-button", { "data-increase": increase ? true : null, "data-decrease": increase ? null : true, appearance: "light", variant: "outlined", "no-tab": this.noButtons(), icon: increase ? plus : minus, iconOnly: true, tooltip: this.hideTooltips ? null : label, arialabel: this.hideTooltips ? label : null, onPnClick: () => (increase ? this.increaseAmount() : this.decreaseAmount()) }));
    }
    render() {
        return (hAsync(Host, { key: 'f1ff6cf51a77b28c5375f80c686106f82026eda8' }, hAsync("div", { key: 'a6080106e0bf5ca0246e5a47a114c5ba967be4ef', class: "pn-counter", role: "group", "aria-labelledby": this.idLabel, "aria-describedby": this.describedbyIds() }, !this.compact && this.renderLabel(), hAsync("div", { key: 'ef3c419277ca2f2a2f8fe8cefad5633c893b4736', class: "pn-counter-items", "data-hidebuttons": this.noButtons() }, this.renderButton(), hAsync("div", { key: 'c130e8c0d812eaad1cf794e9417ab62d3c12e1a7', class: "pn-counter-input" }, hAsync("input", { key: '908746fc89d2d70fb6f26f0f13bbe99961d66222', id: this.getId(), class: "pn-counter-element", type: "number", min: this.min, max: this.max, step: this.step, value: this.value, name: this.name, placeholder: this.compact ? ' ' : null, required: this.required, readonly: this.readonly, disabled: this.disabled, "aria-label": this.getAriaLabel(), "aria-labelledby": this.getAriaLabelledby(), "aria-describedby": this.describedbyIds(), "data-compact": this.compact, onInput: e => this.setVal(e), onKeyDown: (e) => this.keyBoardInput(e) }), this.compact && this.renderLabel()), this.renderButton(true)), hAsync("p", { key: 'a25cd6e9abdb9fe8077e345cef828e187a11d260', id: this.idText, class: "pn-counter-helpertext", hidden: this.hideHelpertext() }, hAsync("span", { key: '533d9836452f3b21a176eb594c225ad44c21956e' }, this.getTextMessage()), hAsync("slot", { key: '35f10d13c8a1c65e6fc7b1a75b864e1cfd268837', name: "helpertext" })), hAsync("p", { key: '1009ba0ea75131d6c19e3fb8960c39fc9d565d16', id: this.idAmount, class: "pn-counter-sr-only", "aria-live": "assertive" }, this.displaySrValue ? this.getTextMessage(true) : ''))));
    }
    static get watchers() { return {
        "value": [{
                "watchValue": 0
            }],
        "counterid": [{
                "handleId": 0
            }],
        "pnId": [{
                "handleId": 1
            }]
    }; }
    static get style() { return pnCounterCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-counter",
        "$members$": {
            "label": [1],
            "helpertext": [1],
            "language": [1],
            "value": [1538],
            "name": [1],
            "min": [2],
            "max": [2],
            "step": [2],
            "list": [1],
            "required": [4],
            "readonly": [4],
            "disabled": [4],
            "compact": [4],
            "labelDecrease": [1, "label-decrease"],
            "labelIncrease": [1, "label-increase"],
            "hideTooltips": [4, "hide-tooltips"],
            "minMessage": [1, "min-message"],
            "maxMessage": [1, "max-message"],
            "pnId": [1, "pn-id"],
            "pnAriaLabel": [1, "pn-aria-label"],
            "pnAriaLabelledby": [1, "pn-aria-labelledby"],
            "counterid": [1],
            "clearAriaTimer": [32],
            "displaySrValue": [32],
            "showMinMaxMessage": [32],
            "lastDispatchedValue": [32],
            "interactType": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": [["value", "value"]]
    }; }
}

const translations$e = {
    CALENDAR_NAVIGATION: {
        en: 'Calendar',
        sv: 'Kalender',
        da: 'Kalender',
        fi: 'Kalenteri',
        no: 'Kalender',
    },
    NEXT_YEAR: {
        en: 'Scroll forward',
        sv: 'Bläddra framåt',
        da: 'Rul frem',
        fi: 'Vieritä eteenpäin',
        no: 'Rull fremover',
    },
    PREVIOUS_YEAR: {
        en: 'Scroll backwards',
        sv: 'Bläddra bakåt',
        da: 'Rul baglæns',
        fi: 'Vieritä taaksepäin',
        no: 'Bla bakover',
    },
    NEXT_DATE: {
        en: 'Next month',
        sv: 'Nästa månad',
        da: 'Næste måned',
        fi: 'Ensi kuussa',
        no: 'Neste måned',
    },
    PREVIOUS_DATE: {
        en: 'Previous month',
        sv: 'Föregående månad',
        da: 'Forrige måned',
        fi: 'Edellinen kuukausi',
        no: 'Forrige måned',
    },
    SELECT_YEAR: {
        en: 'Choose year',
        sv: 'Välj år',
        da: 'Vælg år',
        fi: 'Valitse vuosi',
        no: 'Velg år',
    },
    SELECT_MONTH: {
        en: 'Choose month',
        sv: 'Välj månad',
        da: 'Vælg måned',
        fi: 'Valitse kuukausi',
        no: 'Velg måned',
    },
    SELECT_DATE: {
        en: 'Choose date',
        sv: 'Välj datum',
        da: 'Vælg dato',
        fi: 'Valitse päivämäärä',
        no: 'Velg dato',
    },
    SELECTED_DATE: {
        en: 'selected date is {date}.',
        sv: 'valt datum är {date}.',
        da: 'den valgte dato er {date}.',
        fi: 'valittu päivämäärä on {date}.',
        no: 'valgt dato er {date}.',
    },
    SELECTED_START_DATE: {
        en: 'selected start date is {date}.',
        sv: 'valt startdatum är {date}.',
        da: 'den valgte startdato er {date}.',
        fi: 'valittu aloituspäivä on {date}.',
        no: 'valgt startdato er {date}.',
    },
    SELECTED_END_DATE: {
        en: 'selected end date is {date}.',
        sv: 'valt slutdatum är {date}.',
        da: 'den valgte slutdato er {date}.',
        fi: 'valittu lopetuspäivä on {date}.',
        no: 'valgt sluttdato er {date}.',
    },
    WEEK_NAME: {
        en: 'Week',
        sv: 'Vecka',
        da: 'Uge',
        fi: 'Viikko',
        no: 'Uke',
    },
    GO_CALENDAR: {
        en: 'Calendar view',
        sv: 'Kalendervyn',
        da: 'Kalendervisning',
        fi: 'Kalenterinäkymä',
        no: 'Kalendervisning',
    },
};

function getDefaultExportFromCjs (x) {
	return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}

var dayjs_min$1 = {exports: {}};

var dayjs_min = dayjs_min$1.exports;

var hasRequiredDayjs_min;

function requireDayjs_min () {
	if (hasRequiredDayjs_min) return dayjs_min$1.exports;
	hasRequiredDayjs_min = 1;
	(function (module, exports) {
		!function(t,e){module.exports=e();}(dayjs_min,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,true),this.parse(t),this.$x=this.$x||t.x||{},this[p]=true;}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return b},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,false)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case "YY":return String(e.$y).slice(-2);case "YYYY":return b.s(e.$y,4,"0");case "M":return a+1;case "MM":return b.s(a+1,2,"0");case "MMM":return h(n.monthsShort,a,c,3);case "MMMM":return h(c,a);case "D":return e.$D;case "DD":return b.s(e.$D,2,"0");case "d":return String(e.$W);case "dd":return h(n.weekdaysMin,e.$W,o,2);case "ddd":return h(n.weekdaysShort,e.$W,o,3);case "dddd":return o[e.$W];case "H":return String(s);case "HH":return b.s(s,2,"0");case "h":return d(1);case "hh":return d(2);case "a":return $(s,u,true);case "A":return $(s,u,false);case "m":return String(u);case "mm":return b.s(u,2,"0");case "s":return String(e.$s);case "ss":return b.s(e.$s,2,"0");case "SSS":return b.s(e.$ms,3,"0");case "Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g;}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,true);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=true),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O})); 
	} (dayjs_min$1));
	return dayjs_min$1.exports;
}

var dayjs_minExports = requireDayjs_min();
var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);

var weekOfYear$2 = {exports: {}};

var weekOfYear$1 = weekOfYear$2.exports;

var hasRequiredWeekOfYear;

function requireWeekOfYear () {
	if (hasRequiredWeekOfYear) return weekOfYear$2.exports;
	hasRequiredWeekOfYear = 1;
	(function (module, exports) {
		!function(e,t){module.exports=t();}(weekOfYear$1,(function(){var e="week",t="year";return function(i,n,r){var f=n.prototype;f.week=function(i){if(void 0===i&&(i=null),null!==i)return this.add(7*(i-this.week()),"day");var n=this.$locale().yearStart||1;if(11===this.month()&&this.date()>25){var f=r(this).startOf(t).add(1,t).date(n),s=r(this).endOf(e);if(f.isBefore(s))return 1}var a=r(this).startOf(t).date(n).startOf(e).subtract(1,"millisecond"),o=this.diff(a,e,true);return o<0?r(this).startOf("week").week():Math.ceil(o)},f.weeks=function(e){return void 0===e&&(e=null),this.week(e)};}})); 
	} (weekOfYear$2));
	return weekOfYear$2.exports;
}

var weekOfYearExports = requireWeekOfYear();
var weekOfYear = /*@__PURE__*/getDefaultExportFromCjs(weekOfYearExports);

var customParseFormat$2 = {exports: {}};

var customParseFormat$1 = customParseFormat$2.exports;

var hasRequiredCustomParseFormat;

function requireCustomParseFormat () {
	if (hasRequiredCustomParseFormat) return customParseFormat$2.exports;
	hasRequiredCustomParseFormat = 1;
	(function (module, exports) {
		!function(e,t){module.exports=t();}(customParseFormat$1,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d/,r=/\d\d/,i=/\d\d?/,o=/\d*[^-_:/,()\s\d]+/,s={},a=function(e){return (e=+e)+(e>68?1900:2e3)};var f=function(e){return function(t){this[e]=+t;}},h=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e);}],u=function(e){var t=s[e];return t&&(t.indexOf?t:t.s.concat(t.f))},d=function(e,t){var n,r=s.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},c={A:[o,function(e){this.afternoon=d(e,false);}],a:[o,function(e){this.afternoon=d(e,true);}],Q:[n,function(e){this.month=3*(e-1)+1;}],S:[n,function(e){this.milliseconds=100*+e;}],SS:[r,function(e){this.milliseconds=10*+e;}],SSS:[/\d{3}/,function(e){this.milliseconds=+e;}],s:[i,f("seconds")],ss:[i,f("seconds")],m:[i,f("minutes")],mm:[i,f("minutes")],H:[i,f("hours")],h:[i,f("hours")],HH:[i,f("hours")],hh:[i,f("hours")],D:[i,f("day")],DD:[r,f("day")],Do:[o,function(e){var t=s.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r);}],w:[i,f("week")],ww:[r,f("week")],M:[i,f("month")],MM:[r,f("month")],MMM:[o,function(e){var t=u("months"),n=(u("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[o,function(e){var t=u("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t;}],Y:[/[+-]?\d+/,f("year")],YY:[r,function(e){this.year=a(e);}],YYYY:[/\d{4}/,f("year")],Z:h,ZZ:h};function l(n){var r,i;r=n,i=s&&s.formats;for(var o=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),a=o.length,f=0;f<a;f+=1){var h=o[f],u=c[h],d=u&&u[0],l=u&&u[1];o[f]=l?{regex:d,parser:l}:h.replace(/^\[|\]$/g,"");}return function(e){for(var t={},n=0,r=0;n<a;n+=1){var i=o[n];if("string"==typeof i)r+=i.length;else {var s=i.regex,f=i.parser,h=e.slice(r),u=s.exec(h)[0];f.call(t,u),e=e.replace(u,"");}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon;}}(t),t}}return function(e,t,n){n.p.customParseFormat=true,e&&e.parseTwoDigitYear&&(a=e.parseTwoDigitYear);var r=t.prototype,i=r.parse;r.parse=function(e){var t=e.date,r=e.utc,o=e.args;this.$u=r;var a=o[1];if("string"==typeof a){var f=true===o[2],h=true===o[3],u=f||h,d=o[2];h&&(d=o[2]),s=this.$locale(),!f&&d&&(s=n.Ls[d]),this.$d=function(e,t,n,r){try{if(["x","X"].indexOf(t)>-1)return new Date(("X"===t?1e3:1)*e);var i=l(t)(e),o=i.year,s=i.month,a=i.day,f=i.hours,h=i.minutes,u=i.seconds,d=i.milliseconds,c=i.zone,m=i.week,M=new Date,Y=a||(o||s?1:M.getDate()),p=o||M.getFullYear(),v=0;o&&!s||(v=s>0?s-1:M.getMonth());var D,w=f||0,g=h||0,y=u||0,L=d||0;return c?new Date(Date.UTC(p,v,Y,w,g,y,L+60*c.offset*1e3)):n?new Date(Date.UTC(p,v,Y,w,g,y,L)):(D=new Date(p,v,Y,w,g,y,L),m&&(D=r(D).week(m).toDate()),D)}catch(e){return new Date("")}}(t,a,r,n),this.init(),d&&true!==d&&(this.$L=this.locale(d).$L),u&&t!=this.format(a)&&(this.$d=new Date("")),s={};}else if(a instanceof Array)for(var c=a.length,m=1;m<=c;m+=1){o[1]=a[m-1];var M=n.apply(this,o);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}m===c&&(this.$d=new Date(""));}else i.call(this,e);};}})); 
	} (customParseFormat$2));
	return customParseFormat$2.exports;
}

var customParseFormatExports = requireCustomParseFormat();
var customParseFormat = /*@__PURE__*/getDefaultExportFromCjs(customParseFormatExports);

var isSameOrBefore$2 = {exports: {}};

var isSameOrBefore$1 = isSameOrBefore$2.exports;

var hasRequiredIsSameOrBefore;

function requireIsSameOrBefore () {
	if (hasRequiredIsSameOrBefore) return isSameOrBefore$2.exports;
	hasRequiredIsSameOrBefore = 1;
	(function (module, exports) {
		!function(e,i){module.exports=i();}(isSameOrBefore$1,(function(){return function(e,i){i.prototype.isSameOrBefore=function(e,i){return this.isSame(e,i)||this.isBefore(e,i)};}})); 
	} (isSameOrBefore$2));
	return isSameOrBefore$2.exports;
}

var isSameOrBeforeExports = requireIsSameOrBefore();
var isSameOrBefore = /*@__PURE__*/getDefaultExportFromCjs(isSameOrBeforeExports);

var isSameOrAfter$2 = {exports: {}};

var isSameOrAfter$1 = isSameOrAfter$2.exports;

var hasRequiredIsSameOrAfter;

function requireIsSameOrAfter () {
	if (hasRequiredIsSameOrAfter) return isSameOrAfter$2.exports;
	hasRequiredIsSameOrAfter = 1;
	(function (module, exports) {
		!function(e,t){module.exports=t();}(isSameOrAfter$1,(function(){return function(e,t){t.prototype.isSameOrAfter=function(e,t){return this.isSame(e,t)||this.isAfter(e,t)};}})); 
	} (isSameOrAfter$2));
	return isSameOrAfter$2.exports;
}

var isSameOrAfterExports = requireIsSameOrAfter();
var isSameOrAfter = /*@__PURE__*/getDefaultExportFromCjs(isSameOrAfterExports);

var toObject$2 = {exports: {}};

var toObject$1 = toObject$2.exports;

var hasRequiredToObject;

function requireToObject () {
	if (hasRequiredToObject) return toObject$2.exports;
	hasRequiredToObject = 1;
	(function (module, exports) {
		!function(t,e){module.exports=e();}(toObject$1,(function(){return function(t,e){e.prototype.toObject=function(){return {years:this.$y,months:this.$M,date:this.$D,hours:this.$H,minutes:this.$m,seconds:this.$s,milliseconds:this.$ms}};}})); 
	} (toObject$2));
	return toObject$2.exports;
}

var toObjectExports = requireToObject();
var toObject = /*@__PURE__*/getDefaultExportFromCjs(toObjectExports);

var sv$1 = {exports: {}};

var sv = sv$1.exports;

var hasRequiredSv;

function requireSv () {
	if (hasRequiredSv) return sv$1.exports;
	hasRequiredSv = 1;
	(function (module, exports) {
		!function(e,t){module.exports=t(requireDayjs_min());}(sv,(function(e){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=t(e),d={name:"sv",weekdays:"söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"),weekdaysShort:"sön_mån_tis_ons_tor_fre_lör".split("_"),weekdaysMin:"sö_må_ti_on_to_fr_lö".split("_"),months:"januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),weekStart:1,yearStart:4,ordinal:function(e){var t=e%10;return "["+e+(1===t||2===t?"a":"e")+"]"},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY-MM-DD",LL:"D MMMM YYYY",LLL:"D MMMM YYYY [kl.] HH:mm",LLLL:"dddd D MMMM YYYY [kl.] HH:mm",lll:"D MMM YYYY HH:mm",llll:"ddd D MMM YYYY HH:mm"},relativeTime:{future:"om %s",past:"för %s sedan",s:"några sekunder",m:"en minut",mm:"%d minuter",h:"en timme",hh:"%d timmar",d:"en dag",dd:"%d dagar",M:"en månad",MM:"%d månader",y:"ett år",yy:"%d år"}};return a.default.locale(d,null,true),d})); 
	} (sv$1));
	return sv$1.exports;
}

requireSv();

var en$1 = {exports: {}};

var en = en$1.exports;

var hasRequiredEn;

function requireEn () {
	if (hasRequiredEn) return en$1.exports;
	hasRequiredEn = 1;
	(function (module, exports) {
		!function(e,n){module.exports=n();}(en,(function(){return {name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var n=["th","st","nd","rd"],t=e%100;return "["+e+(n[(t-20)%10]||n[t]||n[0])+"]"}}})); 
	} (en$1));
	return en$1.exports;
}

requireEn();

var da$1 = {exports: {}};

var da = da$1.exports;

var hasRequiredDa;

function requireDa () {
	if (hasRequiredDa) return da$1.exports;
	hasRequiredDa = 1;
	(function (module, exports) {
		!function(e,t){module.exports=t(requireDayjs_min());}(da,(function(e){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=t(e),a={name:"da",weekdays:"søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag".split("_"),weekdaysShort:"søn._man._tirs._ons._tors._fre._lør.".split("_"),weekdaysMin:"sø._ma._ti._on._to._fr._lø.".split("_"),months:"januar_februar_marts_april_maj_juni_juli_august_september_oktober_november_december".split("_"),monthsShort:"jan._feb._mar._apr._maj_juni_juli_aug._sept._okt._nov._dec.".split("_"),weekStart:1,yearStart:4,ordinal:function(e){return e+"."},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY HH:mm",LLLL:"dddd [d.] D. MMMM YYYY [kl.] HH:mm"},relativeTime:{future:"om %s",past:"%s siden",s:"få sekunder",m:"et minut",mm:"%d minutter",h:"en time",hh:"%d timer",d:"en dag",dd:"%d dage",M:"en måned",MM:"%d måneder",y:"et år",yy:"%d år"}};return d.default.locale(a,null,true),a})); 
	} (da$1));
	return da$1.exports;
}

requireDa();

var fi$1 = {exports: {}};

var fi = fi$1.exports;

var hasRequiredFi;

function requireFi () {
	if (hasRequiredFi) return fi$1.exports;
	hasRequiredFi = 1;
	(function (module, exports) {
		!function(u,e){module.exports=e(requireDayjs_min());}(fi,(function(u){function e(u){return u&&"object"==typeof u&&"default"in u?u:{default:u}}var t=e(u);function n(u,e,t,n){var i={s:"muutama sekunti",m:"minuutti",mm:"%d minuuttia",h:"tunti",hh:"%d tuntia",d:"päivä",dd:"%d päivää",M:"kuukausi",MM:"%d kuukautta",y:"vuosi",yy:"%d vuotta",numbers:"nolla_yksi_kaksi_kolme_neljä_viisi_kuusi_seitsemän_kahdeksan_yhdeksän".split("_")},a={s:"muutaman sekunnin",m:"minuutin",mm:"%d minuutin",h:"tunnin",hh:"%d tunnin",d:"päivän",dd:"%d päivän",M:"kuukauden",MM:"%d kuukauden",y:"vuoden",yy:"%d vuoden",numbers:"nollan_yhden_kahden_kolmen_neljän_viiden_kuuden_seitsemän_kahdeksan_yhdeksän".split("_")},s=n&&!e?a:i,_=s[t];return u<10?_.replace("%d",s.numbers[u]):_.replace("%d",u)}var i={name:"fi",weekdays:"sunnuntai_maanantai_tiistai_keskiviikko_torstai_perjantai_lauantai".split("_"),weekdaysShort:"su_ma_ti_ke_to_pe_la".split("_"),weekdaysMin:"su_ma_ti_ke_to_pe_la".split("_"),months:"tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu".split("_"),monthsShort:"tammi_helmi_maalis_huhti_touko_kesä_heinä_elo_syys_loka_marras_joulu".split("_"),ordinal:function(u){return u+"."},weekStart:1,yearStart:4,relativeTime:{future:"%s päästä",past:"%s sitten",s:n,m:n,mm:n,h:n,hh:n,d:n,dd:n,M:n,MM:n,y:n,yy:n},formats:{LT:"HH.mm",LTS:"HH.mm.ss",L:"DD.MM.YYYY",LL:"D. MMMM[ta] YYYY",LLL:"D. MMMM[ta] YYYY, [klo] HH.mm",LLLL:"dddd, D. MMMM[ta] YYYY, [klo] HH.mm",l:"D.M.YYYY",ll:"D. MMM YYYY",lll:"D. MMM YYYY, [klo] HH.mm",llll:"ddd, D. MMM YYYY, [klo] HH.mm"}};return t.default.locale(i,null,true),i})); 
	} (fi$1));
	return fi$1.exports;
}

requireFi();

var nb$1 = {exports: {}};

var nb = nb$1.exports;

var hasRequiredNb;

function requireNb () {
	if (hasRequiredNb) return nb$1.exports;
	hasRequiredNb = 1;
	(function (module, exports) {
		!function(e,t){module.exports=t(requireDayjs_min());}(nb,(function(e){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e),a={name:"nb",weekdays:"søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag".split("_"),weekdaysShort:"sø._ma._ti._on._to._fr._lø.".split("_"),weekdaysMin:"sø_ma_ti_on_to_fr_lø".split("_"),months:"januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember".split("_"),monthsShort:"jan._feb._mars_april_mai_juni_juli_aug._sep._okt._nov._des.".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY [kl.] HH:mm",LLLL:"dddd D. MMMM YYYY [kl.] HH:mm"},relativeTime:{future:"om %s",past:"%s siden",s:"noen sekunder",m:"ett minutt",mm:"%d minutter",h:"en time",hh:"%d timer",d:"en dag",dd:"%d dager",M:"en måned",MM:"%d måneder",y:"ett år",yy:"%d år"}};return n.default.locale(a,null,true),a})); 
	} (nb$1));
	return nb$1.exports;
}

requireNb();

dayjs.extend(weekOfYear);
dayjs.extend(customParseFormat);
dayjs.extend(isSameOrBefore);
dayjs.extend(isSameOrAfter);
dayjs.extend(toObject);
const CALENDAR = 'calendar';
const MONTHS = 'months';
const YEARS = 'years';
function getToday() {
    return dayjs();
}
function getDayjsObject({ year, month, date }) {
    return dayjs().set('year', year).set('month', month).set('date', date);
}
/** Validate the date. */
function validateDate(value, format) {
    if (!value)
        return false;
    const val = typeof value === 'string' ? value : getDayjsObject(value);
    return dayjs(val, format, true).isValid();
}
/**
 * Get the Dayjs object with the value & format param.
 **/
function getDate(value, format) {
    const val = typeof value === 'string' ? value : getDayjsObject(value);
    return dayjs(val, format);
}
/** Get a readable i18n format of the date. */
function getReadableDate(date, lang, format) {
    const data = getDateJs(date);
    return data.locale(lang === 'no' ? 'nb' : lang).format(format);
}
function getDateJs({ year, month, date, day }) {
    const dateObject = dayjs().set('y', year).set('M', month).set('D', date);
    if (typeof day === 'number')
        return dateObject.set('d', day);
    return dateObject;
}
function getDateObject(data, format) {
    const dateObj = typeof data === 'string' ? getDate(data, format) : data;
    const year = dateObj.get('year');
    const month = dateObj.get('month');
    const date = dateObj.get('date');
    const day = dateObj.get('day');
    return {
        year,
        month,
        date,
        day,
    };
}
function getDiff(from, to, format) {
    const dateFrom = getDate(from, format);
    const dateTo = getDate(to, format);
    return dateTo.diff(dateFrom, 'd');
}
function isBefore(data, max, format, type) {
    const date = getDate(data, format);
    const dateMax = getDate(max, format);
    return date.isSameOrBefore(dateMax, type);
}
function isAfter(data, min, format, type) {
    const date = getDate(data, format);
    const dateMin = getDate(min, format);
    return date.isSameOrAfter(dateMin, type);
}
function selectedDate(dateOne, dateTwo, format, type) {
    if (!validateDate(dateOne, format) || !validateDate(dateTwo, format))
        return false;
    let date = getDate(dateOne, format);
    let compare = getDate(dateTwo, format);
    if (type === 'month') {
        date = date.set('year', 2000);
        compare = compare.set('year', 2000);
    }
    return date.isSame(compare, type);
}
function modifyDate({ data, amount = 1, unit, minus, plus, }) {
    if (minus)
        return data.subtract(amount, unit);
    if (plus)
        return data.add(amount, unit);
    return data;
}
/** Set another year for the value. */
function setYear({ year, minus = false, plus = false, }) {
    const data = dayjs().set('year', year);
    return modifyDate({ data, unit: 'y', plus, minus }).year();
}
/**
 * You select a month you wish to decrease or increase by 1.
 */
function setMonth({ month, minus = false, plus = false, }) {
    const data = dayjs().set('month', month);
    return modifyDate({ data, unit: 'M', plus, minus }).month();
}
function navigateGrid(code, data, disableWeekends, type) {
    if (type === 'date')
        return navDate(code, data, disableWeekends);
    return navList(code, data, type);
}
function navDate(code, data, disableWeekend) {
    const date = getDayjsObject(data);
    const { space, enter, next, down, previous, upwards, pageDown, pageUp, end, home } = getCode(code);
    if (space || enter)
        return date;
    if (next || down)
        return date.add(next ? 1 : 7, 'day');
    if (previous || upwards)
        return date.subtract(previous ? 1 : 7, 'day');
    if (pageDown)
        return date.add(1, 'month');
    if (pageUp)
        return date.subtract(1, 'month');
    const day = date.get('day');
    const endDay = disableWeekend ? 5 : 7;
    const startDay = day === 0 ? -6 : 1;
    if (end && day !== 0)
        return date.set('day', endDay);
    if (home && day !== 1)
        return date.set('day', startDay);
    return date;
}
function navList(key, data, type) {
    const date = getDayjsObject(data);
    const enter = key.match(/^(Enter|Space)$/);
    if (enter)
        return date;
    // Add one day
    const next = key === 'ArrowRight';
    // Minus one day
    const previous = key === 'ArrowLeft';
    // Add one week
    const down = key === 'ArrowDown';
    // Minus one week
    const upwards = key === 'ArrowUp';
    const setNumber = next || previous ? 1 : 3;
    const { years, months } = date.toObject();
    const dateValue = type === 'year' ? years : months;
    const oppositeType = type === 'year' ? 'month' : 'year';
    if (next || down)
        return date.set(type, dateValue + setNumber).set(oppositeType, data[oppositeType]);
    if (previous || upwards)
        return date.set(type, dateValue - setNumber).set(oppositeType, data[oppositeType]);
    return date;
}
function getGrid(year, month) {
    const allDays = [];
    const grid = [];
    const date = dayjs().set('year', year).set('month', month);
    const numberOfDays = date.daysInMonth();
    for (let i = 0; numberOfDays > i; i++) {
        const day = date.set('date', i);
        const week = day.week();
        allDays.push({
            week,
            day: day.day() + 1,
            date: i + 1,
        });
    }
    const weeks = [...new Set(allDays.map(({ week }) => week))];
    weeks.forEach((week, index) => {
        const list = allDays.filter(day => day.week === week);
        if (index === 0 && list.length !== 7) {
            const numberOfDaysOutsideWeek = 7 - list.length;
            for (let i = 0; numberOfDaysOutsideWeek > i; i++) {
                list.unshift({ week, blank: true });
            }
        }
        if (index + 1 === weeks.length && list.length !== 7) {
            const numberOfDaysOutsideWeek = 7 - list.length;
            for (let i = 0; numberOfDaysOutsideWeek > i; i++) {
                list.push({ week, blank: true });
            }
        }
        grid.push({ week: week, list });
    });
    return grid;
}
function getCode(code) {
    const enter = code === 'Enter';
    const space = code === 'Space';
    // Add/sub one day
    const next = code === 'ArrowRight';
    const previous = code === 'ArrowLeft';
    // Add/sub one week
    const down = code === 'ArrowDown';
    const upwards = code === 'ArrowUp';
    // Add/sub one month
    const pageDown = code === 'PageDown';
    const pageUp = code === 'PageUp';
    // Go the first/last day of the week
    const end = code === 'End';
    const home = code === 'Home';
    return {
        enter,
        space,
        next,
        previous,
        down,
        upwards,
        pageDown,
        pageUp,
        end,
        home,
    };
}

const pnDatePickerCss = () => `${transformTag("pn-date-picker")}{position:relative;display:block}${transformTag("pn-date-picker")} .pn-date-picker{width:100%;display:flex;flex-wrap:wrap;gap:0.25em;container-type:inline-size}@container (max-width: 24em){${transformTag("pn-date-picker")} .pn-date-picker .pn-date-picker-container{flex:1 1 20em}${transformTag("pn-date-picker")} .pn-date-picker .pn-date-picker-range-icon{display:none}}${transformTag("pn-date-picker")} .pn-date-picker-container{display:block;flex:1 1 11em}${transformTag("pn-date-picker")} .pn-date-picker-container[data-error]>.pn-date-picker-label{color:#a70707}${transformTag("pn-date-picker")} .pn-date-picker-container[data-error]>.pn-date-picker-field .pn-date-picker-input{border-color:#a70707}${transformTag("pn-date-picker")} .pn-date-picker-container[data-error]>.pn-date-picker-field .pn-date-picker-input:hover{border-color:#500715}${transformTag("pn-date-picker")} .pn-date-picker-container[data-error]>.pn-date-picker-field .pn-date-picker-input:focus-visible{background-color:#ffffff;border-color:#a70707;outline-color:#a70707}${transformTag("pn-date-picker")} .pn-date-picker-container[data-error]>.pn-date-picker-field .pn-date-picker-input:-webkit-autofill,${transformTag("pn-date-picker")} .pn-date-picker-container[data-error]>.pn-date-picker-field .pn-date-picker-input:-webkit-autofill:hover,${transformTag("pn-date-picker")} .pn-date-picker-container[data-error]>.pn-date-picker-field .pn-date-picker-input:-webkit-autofill:focus,${transformTag("pn-date-picker")} .pn-date-picker-container[data-error]>.pn-date-picker-field .pn-date-picker-input:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #fef7f6 inset;-webkit-text-fill-color:#2d2013}${transformTag("pn-date-picker")} .pn-date-picker-label{cursor:pointer;display:flex;justify-content:space-between;align-items:flex-end;font-weight:400;color:#2d2013;margin:0 0 0.25em 0;gap:0.5em;-webkit-tap-highlight-color:transparent;transition-property:color, transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-date-picker")} .pn-date-picker-label{transition-duration:0s;transition-delay:0s}}${transformTag("pn-date-picker")} .pn-date-picker-label[data-compact]{position:absolute;top:1.5625em;left:calc(var(--pn-input-offset-left, 0px) + 0.75em + 0.0625em);margin:0;pointer-events:none;align-items:center;height:1.5em;max-width:calc(100% - (var(--pn-input-offset-left, 0px) + 0.75em) - (var(--pn-input-offset-right, 0px) + 0.75em));transform:translateY(-50%) scale(1) translateZ(0);transform-origin:0 0;transition-delay:0.2s}${transformTag("pn-date-picker")} .pn-date-picker-label[data-compact]>span{font-size:1em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;line-height:1.5em}${transformTag("pn-date-picker")} .pn-date-picker-label>span{font-size:0.875em}${transformTag("pn-date-picker")} .pn-date-picker-field{position:relative;display:flex}${transformTag("pn-date-picker")} .pn-date-picker-input{color:#2d2013;background-color:#ffffff;border:0.0625em solid #969087;border-radius:0.5em;padding:0.75em;font-family:inherit;font-size:1em;font-weight:500;line-height:1.5em;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent}${transformTag("pn-date-picker")} .pn-date-picker-input:-webkit-autofill,${transformTag("pn-date-picker")} .pn-date-picker-input:-webkit-autofill:hover,${transformTag("pn-date-picker")} .pn-date-picker-input:-webkit-autofill:focus,${transformTag("pn-date-picker")} .pn-date-picker-input:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #e0f8ff inset;-webkit-text-fill-color:#2d2013}${transformTag("pn-date-picker")} .pn-date-picker-input{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-date-picker")} .pn-date-picker-input:focus-visible{outline-color:#005d92;background-color:#ffffff;border-color:#005d92}${transformTag("pn-date-picker")} .pn-date-picker-input{transition-property:outline-color, background-color, border-color, color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-date-picker")} .pn-date-picker-input{transition-duration:0s;transition-delay:0s}}${transformTag("pn-date-picker")} .pn-date-picker-input[data-compact]{text-align:left;padding-top:1.125em;padding-bottom:0.375em;max-width:unset}${transformTag("pn-date-picker")} .pn-date-picker-input[data-compact]::placeholder{color:transparent}${transformTag("pn-date-picker")} .pn-date-picker-input[data-compact]:focus+.pn-date-picker-label,${transformTag("pn-date-picker")} .pn-date-picker-input[data-compact]:not(:placeholder-shown)+.pn-date-picker-label{transform:translateY(-85%) scale(0.75);transition-delay:0s}${transformTag("pn-date-picker")} .pn-date-picker-input::placeholder{color:#5e554a;font-weight:normal}${transformTag("pn-date-picker")} .pn-date-picker-input:hover{border-color:#005d92}${transformTag("pn-date-picker")} .pn-date-picker-input:disabled{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2}${transformTag("pn-date-picker")} .pn-date-picker-input{padding-right:3em;flex:auto;width:100%}${transformTag("pn-date-picker")} .pn-date-picker-input::-webkit-calendar-picker-indicator{visibility:hidden;inline-size:0}${transformTag("pn-date-picker")} .pn-date-picker-input::-webkit-textfield-decoration-container,${transformTag("pn-date-picker")} .pn-date-picker-input::-webkit-search-cancel-button,${transformTag("pn-date-picker")} .pn-date-picker-input::-webkit-inner-spin-button,${transformTag("pn-date-picker")} .pn-date-picker-input::-webkit-outer-spin-button,${transformTag("pn-date-picker")} .pn-date-picker-input::-webkit-search-decoration{-webkit-appearance:none;-moz-appearance:none;appearance:none}${transformTag("pn-date-picker")} .pn-date-picker-input[data-active]{border-color:#005d92}${transformTag("pn-date-picker")} .pn-date-picker-input:read-only{border-color:#ffffff}${transformTag("pn-date-picker")} .pn-date-picker-range-icon{width:1.5em;margin-bottom:0.8125em;align-self:end}${transformTag("pn-date-picker")} .pn-date-picker-helpertext,${transformTag("pn-date-picker")} .pn-date-picker-error{color:#5e554a;font-size:0.875em;font-weight:400;margin:0.25em 0 0 0;display:flex;flex-direction:column;gap:0.25em;text-align:left}${transformTag("pn-date-picker")} .pn-date-picker-helpertext[hidden],${transformTag("pn-date-picker")} .pn-date-picker-error[hidden]{display:none}${transformTag("pn-date-picker")} .pn-date-picker-error{color:#a70707}${transformTag("pn-date-picker")} .pn-date-picker-toggle{position:absolute;top:0.5em;right:0.5em;border-radius:50%}${transformTag("pn-date-picker")} .pn-date-picker-button{cursor:pointer;font-size:1em;background-color:transparent;border:0.0625em solid #969087;border-color:transparent;padding:0.25em;margin:0;flex:auto;border-radius:3em}${transformTag("pn-date-picker")} .pn-date-picker-button:first-child,${transformTag("pn-date-picker")} .pn-date-picker-button:last-child{flex:0 0 auto}${transformTag("pn-date-picker")} .pn-date-picker-button{transition-property:outline-color, background-color, border-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-date-picker")} .pn-date-picker-button{transition-duration:0s;transition-delay:0s}}${transformTag("pn-date-picker")} .pn-date-picker-button{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-date-picker")} .pn-date-picker-button:focus{background-color:#ffffff;outline-color:#005d92}${transformTag("pn-date-picker")} .pn-date-picker-button:hover{background-color:#e0f8ff}${transformTag("pn-date-picker")} .pn-date-picker-button[data-active],${transformTag("pn-date-picker")} .pn-date-picker-button[data-range]{background-color:#e0f8ff;border-color:#005d92}${transformTag("pn-date-picker")} .pn-date-picker-button:disabled{cursor:not-allowed}${transformTag("pn-date-picker")} .pn-date-picker-button:disabled:hover{background-color:transparent}${transformTag("pn-date-picker")} .pn-date-picker-month{text-transform:capitalize}${transformTag("pn-date-picker")} .pn-date-picker-month[data-full]{display:none}@media (min-width: 25em){${transformTag("pn-date-picker")} .pn-date-picker-month[data-full]{display:inline}}${transformTag("pn-date-picker")} .pn-date-picker-month[data-abbr]{display:inline}@media (min-width: 25em){${transformTag("pn-date-picker")} .pn-date-picker-month[data-abbr]{display:none}}${transformTag("pn-date-picker")} .pn-date-picker-sr-only{position:absolute;height:1px;width:1px;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);margin:-1px;white-space:nowrap}${transformTag("pn-date-picker")} .pn-date-picker{}${transformTag("pn-date-picker")} .pn-date-picker-calendar{position:absolute;z-index:4;top:calc(100% + 0.5em);left:var(--pn-calendar-offset-left);width:clamp(100%, 95vw, 20em);max-width:20em;text-align:center;border-radius:0.5em;background-color:#ffffff;overflow:hidden;visibility:hidden;box-shadow:0 0.25em 0.5em rgba(0, 0, 0, 0.1)}${transformTag("pn-date-picker")} .pn-date-picker-calendar[data-range]{max-width:unset}${transformTag("pn-date-picker")} .pn-date-picker-calendar[data-open],${transformTag("pn-date-picker")} .pn-date-picker-calendar[data-moving]{visibility:visible}${transformTag("pn-date-picker")} .pn-date-picker-calendar[data-direction=top]{top:unset;bottom:calc(100% + 0.5em);transform-origin:bottom left}${transformTag("pn-date-picker")} .pn-date-picker-calendar ${transformTag("pn-button")}[hidden]{display:none}${transformTag("pn-date-picker")} .pn-date-picker-calendar ${transformTag("pn-button")} span{text-transform:capitalize}${transformTag("pn-date-picker")} .pn-date-picker-wrapper{padding:0.5em}${transformTag("pn-date-picker")} .pn-date-picker-title{margin:0.5em auto 0;font-size:0.875em;font-weight:500;color:#2d2013}${transformTag("pn-date-picker")} .pn-date-picker-nav{display:flex;flex-direction:row;justify-content:space-between;margin-bottom:1em}${transformTag("pn-date-picker")} .pn-date-picker-table{width:100%;table-layout:fixed;border-spacing:0;border:0;margin:0 0 0.5em}${transformTag("pn-date-picker")} .pn-date-picker-th{font-size:0.75em;font-weight:500;color:#5e554a;padding:0.25em;border:0;text-transform:capitalize}${transformTag("pn-date-picker")} .pn-date-picker-td{cursor:pointer;position:relative;padding:0.25em;outline:0;border:0;line-height:0;width:2em;height:2em;-webkit-tap-highlight-color:transparent}${transformTag("pn-date-picker")} .pn-date-picker-td-text{position:relative;display:block;line-height:1.5em;border-radius:0.5em;color:#2d2013;padding:0.25em;transition-property:color, background-color, outline-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-date-picker")} .pn-date-picker-td-text{transition-duration:0s;transition-delay:0s}}${transformTag("pn-date-picker")} .pn-date-picker-td-text{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-date-picker")} .pn-date-picker-td[data-blank]{cursor:auto}${transformTag("pn-date-picker")} .pn-date-picker-td[data-blank] .pn-date-picker-td-text{background-color:transparent}${transformTag("pn-date-picker")} .pn-date-picker-td-week{font-size:0.75em;color:#5e554a;display:block}${transformTag("pn-date-picker")} .pn-date-picker-td:before{content:"";position:absolute;left:0;top:0.25em;height:calc(100% - 0.5em);width:100%;background-color:transparent;border:0.0625em solid transparent;border-radius:0.5em;transition-property:border-color, background-color, width, transform, left;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-date-picker")} .pn-date-picker-td:before{transition-duration:0s;transition-delay:0s}}${transformTag("pn-date-picker")} .pn-date-picker-td[aria-disabled=true]{cursor:not-allowed;pointer-events:none}${transformTag("pn-date-picker")} .pn-date-picker-td[aria-disabled=true]>.pn-date-picker-td-text{color:#5e554a;background-color:#f3f2f2}${transformTag("pn-date-picker")} .pn-date-picker-td[aria-disabled=true]:focus>.pn-date-picker-td-text{outline-color:#a70707}${transformTag("pn-date-picker")} .pn-date-picker-td[aria-disabled=true]:hover>.pn-date-picker-td-text,${transformTag("pn-date-picker")} .pn-date-picker-td[aria-disabled=true]:focus>.pn-date-picker-td-text{background-color:#f3f2f2}${transformTag("pn-date-picker")} .pn-date-picker-td[aria-selected=true] .pn-date-picker-td-text{font-weight:500}${transformTag("pn-date-picker")} .pn-date-picker-td[aria-selected=true]:before{border-color:#005d92;background-color:#effbff}${transformTag("pn-date-picker")} .pn-date-picker-td[aria-selected=true][data-single]:before{width:2em;left:50%;transform:translateX(-50%)}${transformTag("pn-date-picker")} .pn-date-picker-td[aria-selected=true][data-range]:before{border-radius:0;border-left-width:0;border-right-width:0}${transformTag("pn-date-picker")} .pn-date-picker-td[aria-selected=true][data-range-from]:before{border-radius:0.5em 0 0 0.5em;border-right-width:0;border-left-width:0.0625em}${transformTag("pn-date-picker")} .pn-date-picker-td[aria-selected=true][data-range-to]:before{border-radius:0 0.5em 0.5em 0;border-right-width:0.0625em;border-left-width:0}${transformTag("pn-date-picker")} .pn-date-picker-td[aria-selected=true][aria-disabled=true]:before{border-color:#a70707;background-color:#fdefee}${transformTag("pn-date-picker")} .pn-date-picker-td[aria-selected=true][aria-disabled=true]>.pn-date-picker-td-text{background-color:unset}${transformTag("pn-date-picker")} .pn-date-picker-td[aria-selected=true][aria-disabled=true]:focus>.pn-date-picker-td-text{background-color:#f3f2f2}${transformTag("pn-date-picker")} .pn-date-picker-td[aria-selected=false]:hover>.pn-date-picker-td-text{background-color:#e0f8ff}${transformTag("pn-date-picker")} .pn-date-picker-td[data-today]>.pn-date-picker-td-text{font-weight:500}${transformTag("pn-date-picker")} .pn-date-picker-td[data-today]>.pn-date-picker-td-text::after{content:"";position:absolute;bottom:0.25em;left:calc(50% - 0.125em);height:0.25em;width:0.25em;background-color:#005d92;border-radius:50%}${transformTag("pn-date-picker")} .pn-date-picker-td[data-today]>.pn-date-picker-td-text:after{bottom:0.15em}${transformTag("pn-date-picker")} .pn-date-picker-td[data-active][data-today]>.pn-date-picker-td-text:after{background-color:#005d92}${transformTag("pn-date-picker")} .pn-date-picker-td:focus-visible>.pn-date-picker-td-text{outline-color:#005d92}${transformTag("pn-date-picker")} .pn-date-picker{}${transformTag("pn-date-picker")} .pn-date-picker-list{margin:0 0 1em;padding:0;list-style:none;display:grid;grid-template-columns:repeat(3, 1fr);grid-gap:0.5em}${transformTag("pn-date-picker")} .pn-date-picker-item>.pn-date-picker-button{display:block;width:100%;border-radius:0.5em;padding:0.5em 0.25em}${transformTag("pn-date-picker")} .pn-date-picker-item>.pn-date-picker-button[data-today]{position:relative;font-weight:500}${transformTag("pn-date-picker")} .pn-date-picker-item>.pn-date-picker-button[data-today]::after{content:"";position:absolute;bottom:0.25em;left:calc(50% - 0.125em);height:0.25em;width:0.25em;background-color:#005d92;border-radius:50%}${transformTag("pn-date-picker")} .pn-date-picker-chips>[slot=chips]{display:flex;justify-content:flex-start;flex-wrap:wrap;gap:0.5em;margin-bottom:0.5em}${transformTag("pn-date-picker")} .pn-date-picker-chips>[slot=chips]:empty{display:none}${transformTag("pn-date-picker")} .pn-date-picker-bottom{display:flex;justify-content:flex-end;gap:0.5em}${transformTag("pn-date-picker")} .pn-date-picker-bottom[hidden]{display:none}`;

/**
 * The date picker allows a single or a range of dates to be selected.
 *
 * Based on the `format` prop, separators will automatically be added if you type the date.
 *
 * You can navigate the calendar grid with your keyboard.
 *
 * @nativeInput Use the `input` event to listen to content being modified by the user. It is emitted everytime a user writes or removes content in the input.
 * @nativeChange The `change` event is emitted when the input loses focus, the user clicks `Enter` or makes a selection (such as auto complete or suggestions).
 *
 * @slot chips - Introduce some quick date selectors underneath the calendar grid. Use the `pn-choice-chip` component. {@since v7.6.0}
 * @slot helpertext - You can use this slot instead of the prop `helpertext`. Recommended, only if you need to include additional HTML markup. Such as a `pn-text-link`. Use a `span` element to wrap the text and link. {@since v7.6.0}
 * @slot error - You can use this slot instead of the prop `error`. Recommended, only if you need to include additional HTML markup. Such as a `pn-text-link`. Use a `span` element to wrap the text and link. {@since v7.6.0}
 */
class PnDatePicker extends Mixin(animateHeightFactory) {
    constructor(hostRef) {
        super();
        registerInstance(this, hostRef);
        this.dateselection = createEvent(this, "dateselection", 7);
        this.dateSelection = createEvent(this, "dateSelection", 7);
        this.dateInvalid = createEvent(this, "dateInvalid", 7);
        this.toggleCalendar = createEvent(this, "toggleCalendar", 7);
        this.currentView = createEvent(this, "currentView", 7);
    }
    id = `pn-date-picker-${uuidv4()}`;
    idStart = `${this.id}-from`;
    idEnd = `${this.id}-to`;
    idStartButton = `${this.id}-from-button`;
    idEndButton = `${this.id}-to-button`;
    idHelper = `${this.id}-helper`;
    idError = `${this.id}-error`;
    idCalendar = `${this.id}-calendar`;
    mo;
    calendarElement;
    today = getToday();
    separators = [];
    separatorRegex = /[^a-zA-Z\d\s:]/g;
    listMonths = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
    listWeek = [1, 2, 3, 4, 5, 6, 0];
    get hostElement() { return getElement(this); }
    open = false;
    openUp = false;
    selectingEnd = false;
    grid;
    viewYearStart = null;
    dateViewYear;
    dateViewMonth;
    dateViewDate;
    showHelperSlot;
    showErrorSlot;
    /** Set a label for the from date. */
    labelFrom;
    /** Set a label for the to date. @see {@link range} */
    labelTo;
    /** Provide a helpertext for the date input. */
    helpertext;
    /** Manually set language; this will be inherited from the topbar. */
    language = undefined;
    /** Set a predefined value for the from date (input value). @see {@link format} @category Native attributes */
    start = '';
    /**
     * Set a predefined value for the from date. (input value end)
     *
     * @see {@link range}
     * @see {@link format}
     * @category Native attributes
     */
    end = '';
    /** HTML input name @since v7.6.0 @category Native attributes*/
    name;
    /** HTML input name @since v7.25.0 @category Native attributes */
    nameEnd;
    /**
     * Placeholder for the input field (defaults to the format prop).
     * @see {@link format}
     * @category Native attributes
     **/
    placeholder;
    /**
     * Placeholder for end date (defaults to the format prop).
     * @see {@link format}
     * @deprecated Use `placeholder-end` instead
     * @category Native attributes
     **/
    endPlaceholder;
    /**
     * Placeholder for end date (defaults to the format prop).
     * @see {@link format}
     * @since v7.25.0
     * @category Native attributes
     **/
    placeholderEnd;
    /** Set the input `autocomplete` attribute. @category Native attributes */
    autocomplete;
    /** Set the input `list` attribute for the first date input. @since v7.6.0 @category Native attributes */
    list;
    /** Set the input `list` attribute for the second date input. @since v7.6.0 @category Native attributes */
    listEnd;
    /** Set the HTML pattern prop on the input elements. Make sure it matches the format. @since v7.6.0 @category Native attributes */
    pattern;
    /** Set the date picker as required. @category Native attributes */
    required = false;
    /** Set the date picker as readonly. @since v7.6.0 @category Native attributes */
    readonly = false;
    /** Set the date picker as disabled. @since v7.6.0 @category Native attributes */
    disabled = false;
    /**
     * Set the date format of the value.
     *
     * While you can set any date value from the Dayjs documentation,
     * we strongly recommend you pick a simple format that you can also type manually.
     *
     * @since v7.6.0
     * @see {@link https://day.js.org/docs/en/display/format Day.js format documentation.}
     * @category Features
     */
    format = 'YYYY-MM-DD';
    /** Disable the automatic insertion of separators when typing in the input. @since v7.6.0 @category Features */
    disableTypeAhead = false;
    /** Remove the option to select dates on weekends. @category Features */
    disableWeekends = false;
    /**
     * Individual dates you want to disable. Use a comma separated string.
     *
     * Remember to use the same format that you have in the `format` prop.
     * @see {@link format}
     * @example "YYYY-MM-DD,YYYY-MM-DD"
     * @category Features
     **/
    disabledDates;
    /** If you use a format with an unknown length, disable the max length. @since 7.11.3 @category Features */
    disableMaxLength = false;
    /** Allow the selection of a date range. @category Features */
    range = false;
    /**
     * Set a limit on how many days one may select.
     * By default, you can select an unlimited range.
     *
     * @todo Create a range limit function.
     * @see {@link range}
     *
     * @category Features
     * @hide true
     **/
    rangeLimit;
    /** Show weekend numbers to the left of the calendar grid. @since v7.6.0 @category Features */
    weekNumbers = false;
    /** Set the date picker label as compact. If used, the `placeholder` will no longer be displayed. @since v7.21.0 @category Features */
    compact = false;
    /** Make the calendar open upwards by default. Opens downwards if there is not enough space. @since v7.6.0 @category Features */
    calendarUp = false;
    /** The calendar grid is shown as default. You can set either `months` or `years` as your first choice. @since v7.6.0 @category Features */
    view = 'calendar';
    /** Trigger the invalid state without an error message. @since v7.6.0 @category Features */
    invalid = false;
    /** Set an error message for the date picker. Overwrites the helpertext if used at the same time. @since v7.6.0 @category Features */
    error;
    /** Set a custom ID for the calendar. If you use `range`, the end input will use `${pn-id}-end`. @since v7.25.0 @category HTML attributes */
    pnId;
    /**
     * Provide the label via an aria attribute.
     * We strongly recommend you use the `label-from` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabel;
    /**
     * Provide the label for the end input via an aria attribute.
     * We strongly recommend you use the `label-to` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabelEnd;
    /**
     * Provide the label from another element via its ID.
     * We strongly recommend you use the `label-from` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabelledby;
    /**
     * Provide the label for the end input from another element via its ID.
     * We strongly recommend you use the `label-to` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabelledbyEnd;
    /** Set a custom ID for the calendar. @since v7.6.0 @deprecated Use `pn-id` instead. @category HTML attributes */
    dateId;
    /**
     * Earliest date possible, this will determine how many years back the date picker will show.
     *
     * Remember to use the same format that you have in the `format` prop.
     * @see {@link format}
     * @example "2024-05-25"
     * @category Features
     **/
    minDate = null;
    watchMin() {
        if (this.minDate === null)
            return;
        if (!validateDate(this.minDate, this.format))
            this.minDate = null;
    }
    /**
     * Latest date possible, this will determine how many years forward the date picker will show.
     *
     * Remember to use the same format that you have in the `format` prop.
     * @see {@link format}
     * @example "2024-06-25"
     * @category Features
     **/
    maxDate = null;
    watchMax() {
        if (this.maxDate === null)
            return;
        if (!validateDate(this.maxDate, this.format))
            this.maxDate = null;
    }
    watchValue() {
        if (!validateDate(this.start, this.format))
            return this.dateInvalid.emit({ start: this.start });
        const { year, month, date } = getDateObject(this.start, this.format);
        this.setViewYear({ year });
        this.setViewMonth({ month });
        this.setViewDate({ date });
        if (this.range && isAfter(this.start, this.end, this.format, 'date')) {
            this.end = '';
        }
        this.emitSelection();
    }
    watchValueTo() {
        if (!this.range)
            return;
        if (!validateDate(this.end, this.format))
            return this.dateInvalid.emit({ end: this.end });
        const date = getDate(this.end, this.format);
        this.setViewYear({ year: date.year() });
        this.setViewMonth({ month: date.month() });
        this.setViewDate({ date: date.date() });
        if (isAfter(this.start, this.end, this.format, 'date')) {
            const value = this.start;
            this.start = this.end;
            this.end = value;
        }
        this.emitSelection();
    }
    handleFormat() {
        this.separators.length = 0;
        this.format
            .split('')
            .forEach((item, index) => this.separatorRegex.exec(item) && this.separators.push({ name: item, index }));
    }
    watchId() {
        this.idStart = this.getId();
        this.idEnd = `${this.getId()}-end`;
        this.idStartButton = `${this.idStart}-from-button`;
        this.idEndButton = `${this.idEnd}-to-button`;
        this.idHelper = `${this.idStart}-helper`;
        this.idError = `${this.idStart}-error`;
        this.idCalendar = `${this.idStart}-calendar`;
    }
    watchView() {
        const data = this.getCurrentDateObject();
        if (validateDate(data, this.format))
            this.updateGrid();
    }
    watchOpen() {
        this.toggleCalendar.emit(this.open);
        this.dropdownHandler();
        if (this.open)
            this.addGlobalEventListeners();
        else
            return this.removeGlobalEventListeners();
        this.calendarElement.style.removeProperty('--pn-calendar-offset-left');
        this.openUp = this.calendarUp;
        requestAnimationFrame(() => {
            const rectHost = this.getRect(this.hostElement);
            const { scrollHeight } = this.calendarElement;
            const { innerHeight, innerWidth } = window;
            const offsetTop = getTotalHeightOffset();
            const spaceUpwards = rectHost.y - offsetTop;
            const spaceDownwards = innerHeight - rectHost.bottom;
            const fitUpwards = spaceUpwards > scrollHeight;
            const fitDownwards = spaceDownwards > scrollHeight;
            const openTop = (this.openUp && (fitUpwards || spaceUpwards > spaceDownwards)) || (!fitDownwards && fitUpwards);
            this.openUp = openTop;
            // Calc horizontal positioning - center calendar relative to host element
            const rectCal = this.getRect(this.calendarElement);
            const menuWidth = getMenuWidth();
            // Calculate center position: host center minus half of calendar width
            const hostCenterX = rectHost.x + rectHost.width / 2;
            const calendarHalfWidth = rectCal.width / 2;
            const idealCenterOffset = hostCenterX - calendarHalfWidth - rectCal.x;
            // Check boundaries, accounting for menu width on the left
            const calendarLeftEdge = rectCal.x + idealCenterOffset;
            const calendarRightEdge = calendarLeftEdge + rectCal.width;
            const leftBoundary = menuWidth + 16; // Menu width + buffer
            let finalOffset = idealCenterOffset;
            // Adjust if calendar would go beyond left edge of viewport or over the menu
            if (calendarLeftEdge < leftBoundary) {
                finalOffset = leftBoundary - rectCal.x;
            }
            // Adjust if calendar would go beyond right edge of viewport
            else if (calendarRightEdge > innerWidth - 16) {
                finalOffset = innerWidth - 16 - rectCal.width - rectCal.x;
            }
            this.calendarElement.style.setProperty('--pn-calendar-offset-left', `${Math.floor(finalOffset)}px`);
        });
    }
    handleMessage() {
        this.checkSlottedHelper();
        this.checkSlottedError();
    }
    handleView() {
        this.currentView.emit(this.view);
    }
    /**
     * Use the new `dateSelection`. Its here for compatibility. Will be removed in v8.
     * @deprecated Use the new `dateSelection`. Will be removed in v8.
     **/
    dateselection;
    /**
     * Emits on valid date selection. Either if the user selects a date in the calendar or writes it manually.
     * @since v7.6.0
     */
    dateSelection;
    emitSelection() {
        const data = {
            start: this.start,
        };
        if (this.range) {
            const days = getDiff(this.start, this.end, this.format);
            data.end = this.end;
            data.days = typeof days === 'number' ? days + 1 : null;
        }
        this.dateSelection.emit(data);
        this.dateselection.emit(data);
    }
    /** Emitted when an invalid value is set. This can only be done if the user writes in the input itself. @since v7.6.0 */
    dateInvalid;
    /** Emitted when the calendar is toggled. @since v7.6.0 */
    toggleCalendar;
    /** Emmitted when you select a new view. @since v7.6.0 */
    currentView;
    /**
     * If the select is open and you resize the window.
     * Remove all css props and disable the animations entierly.
     **/
    handleResize() {
        if (!this.open)
            return;
        this.toggleGrid(false);
    }
    connectedCallback() {
        this.mo = new MutationObserver(() => {
            this.handleMessage();
        });
        this.mo.observe(this.hostElement, { childList: true, subtree: true });
    }
    disconnectedCallback() {
        if (this.mo)
            this.mo.disconnect();
    }
    async componentWillLoad() {
        this.handleFormat();
        this.handleMessage();
        const valid = validateDate(this.start || this.end, this.format);
        const data = valid && getDateObject(this.start || this.end, this.format);
        const { year, month, date } = getDateObject(this.today);
        this.setViewDate({ date: data.date || date });
        this.setViewMonth({ month: data.month || month });
        this.setViewYear({ year: data.year || year });
        if (this.language === undefined)
            await awaitTopbar(this.hostElement);
    }
    getId() {
        return this.pnId || this.dateId || this.id;
    }
    getAriaLabel(end) {
        if (end)
            return !this.labelTo && !this.pnAriaLabelledbyEnd ? this.pnAriaLabelEnd : null;
        return !this.labelFrom && !this.pnAriaLabelledby ? this.pnAriaLabel : null;
    }
    getAriaLabelledby(end) {
        if (end)
            return !this.labelTo && !this.pnAriaLabelEnd ? this.pnAriaLabelledbyEnd : null;
        return !this.labelFrom && !this.pnAriaLabel ? this.pnAriaLabelledby : null;
    }
    getPlaceholder(end) {
        if (this.compact)
            return ' ';
        if (end)
            return this.placeholderEnd || this.endPlaceholder || this.format;
        return this.placeholder || this.format;
    }
    dropdownHandler() {
        if (this.open)
            this.openDropdown(this.calendarElement);
        else
            this.closeDropdown(this.calendarElement);
    }
    globalEvents = (event) => {
        const target = event.target;
        const isWithinCalendar = target?.closest(this.hostElement.localName);
        if (!isWithinCalendar)
            this.toggleGrid(false);
    };
    addGlobalEventListeners() {
        const root = this.hostElement.getRootNode();
        root.addEventListener('click', this.globalEvents);
    }
    removeGlobalEventListeners() {
        const root = this.hostElement.getRootNode();
        root.removeEventListener('click', this.globalEvents);
    }
    translate(prop) {
        return translations$e?.[prop?.toUpperCase()]?.[this.language || en$2] || prop?.toUpperCase();
    }
    translateDateText(customDate, format) {
        return getReadableDate({ ...this.getCurrentDateObject(), ...customDate }, this.language, format);
    }
    getRect(element) {
        return element.getBoundingClientRect();
    }
    toggleGrid(state, selecting) {
        this.open = state ?? !this.open;
        this.selectingEnd = selecting;
    }
    hasHelperText() {
        return this.helpertext?.length > 0 || this.showHelperSlot;
    }
    /** If any `error` text is present, either via prop/slot. */
    hasErrorMessage() {
        return this.error?.length > 0 || this.showErrorSlot;
    }
    /** If any `error` is active, either via the prop `invalid` or `error` prop/slot. */
    hasError() {
        return this.hasErrorMessage() || this.invalid || this.showErrorSlot;
    }
    checkSlottedHelper() {
        const slottedHelper = this.hostElement.querySelector('[slot=helpertext]')?.textContent;
        this.showHelperSlot = !!slottedHelper?.length;
    }
    checkSlottedError() {
        const slottedError = this.hostElement.querySelector('[slot=error]')?.textContent;
        this.showErrorSlot = !!slottedError?.length;
    }
    hideHelpertext() {
        return this.hasErrorMessage() || !this.hasHelperText();
    }
    hideError() {
        return !this.hasErrorMessage();
    }
    viewingCalendar() {
        return this.view === CALENDAR;
    }
    viewingMonth() {
        return this.view === MONTHS;
    }
    viewingYears() {
        return this.view === YEARS;
    }
    viewType() {
        return this.viewingCalendar() ? 'date' : this.viewingMonth() ? 'month' : 'year';
    }
    isBeforeMax(data) {
        if (this.maxDate)
            return isBefore(data, this.maxDate, this.format, this.viewType());
        return true;
    }
    isAfterMin(data) {
        if (this.minDate)
            return isAfter(data, this.minDate, this.format, this.viewType());
        return true;
    }
    isDisabledWeekend(day) {
        if (!this.viewingCalendar())
            return false;
        return this.disableWeekends ? day >= 6 : false;
    }
    isDisabledDate(data) {
        if (!this.disabledDates?.length || !this.viewingCalendar())
            return false;
        const list = this.disabledDates.split(',');
        return !!list.find(disabledDate => selectedDate(disabledDate, data, this.format, this.viewType()));
    }
    isDisabled(data) {
        const isAfterMaxDate = !this.isBeforeMax(data);
        const isBeforeMinDate = !this.isAfterMin(data);
        const weekendDisable = this.viewingCalendar() && this.isDisabledWeekend(data.day);
        const manualDisable = this.isDisabledDate(data);
        const disabled = isAfterMaxDate || isBeforeMinDate || weekendDisable || manualDisable;
        return {
            disabled,
            manualDisable,
            weekendDisable,
            minMaxDisable: isAfterMaxDate || isBeforeMinDate,
        };
    }
    updateGrid() {
        this.grid = getGrid(this.dateViewYear, this.dateViewMonth);
    }
    getCurrentViewDate(data = this.getCurrentDateObject()) {
        return getReadableDate(data, this.language, 'MMMM YYYY');
    }
    isSelected(data, end = false) {
        const value = end ? this.end : this.start;
        return selectedDate(value, this.getCurrentDateObject(data), this.format, this.viewType());
    }
    isToday(data) {
        return selectedDate(this.today.format(this.format), this.getCurrentDateObject(data), this.format, this.viewType());
    }
    getCurrentDateObject({ year = this.dateViewYear, month = this.dateViewMonth, date = this.dateViewDate, day, } = {}) {
        return {
            year,
            month,
            date,
            day,
        };
    }
    /** Handle keyboard navigation in the calendar grid. */
    calendarKeyboardNavigation(event, data, disabled = false) {
        const validCodes = [
            'Enter',
            'Space',
            'ArrowRight',
            'ArrowLeft',
            'ArrowUp',
            'ArrowDown',
            'Home',
            'End',
            'PageDown',
            'PageUp',
            'Escape',
        ];
        if (!validCodes.includes(event.code))
            return;
        event.preventDefault();
        if (event.code === 'Escape')
            return this.toggleGrid(false);
        const select = !disabled && event.code.match(/^(Enter|Space)$/);
        if (select && this.viewingYears())
            return this.setViewYear({ year: data.year, reset: true });
        if (select && this.viewingMonth())
            return this.setViewMonth({ month: data.month, grid: true, reset: true });
        if (select && this.viewingCalendar())
            return this.setValue(data.date);
        const goToDate = this.navDirection(event, data);
        if (!goToDate)
            return;
        const { year, month, date } = goToDate;
        this.setViewYear({ year });
        this.setViewMonth({ month, grid: true });
        this.setViewDate({ date });
        this.resetFocus();
    }
    navDirection(event, data) {
        const { code } = event;
        const nextDate = navigateGrid(code, data, this.disableWeekends, this.viewType());
        const date = getDateObject(nextDate);
        return date;
    }
    getYearGrid() {
        const list = [];
        let oldestInList = this.viewYearStart - 7;
        for (let i = 0; 15 > i; i++) {
            list.push(oldestInList++);
        }
        return list;
    }
    /** Defaults to the calendar view. */
    setView(view) {
        this.view = view;
        requestAnimationFrame(() => this.focusCalendar());
    }
    setNavView(data) {
        if (this.viewingYears())
            return this.setViewYear({ ...data, grid: true });
        return this.setViewMonth(data);
    }
    setViewYear({ year = this.dateViewYear, minus = false, plus = false, reset = false, grid = false, }) {
        const nextYear = setYear({ year, minus, plus });
        const start = this.viewYearStart;
        const max = start + 7;
        const min = start - 7;
        if (grid) {
            const minusVal = this.viewYearStart - 15;
            const plusVal = this.viewYearStart + 15;
            this.viewYearStart = minus ? minusVal : plusVal;
            this.dateViewYear = this.viewYearStart;
        }
        else
            this.dateViewYear = nextYear;
        if (start === null || nextYear > max || min > nextYear)
            this.viewYearStart = nextYear;
        if (reset)
            this.setView(CALENDAR);
    }
    setViewMonth({ month = this.dateViewMonth, minus = false, plus = false, reset = false, grid = false, }) {
        const nextMonth = setMonth({ month, minus, plus });
        this.dateViewMonth = nextMonth;
        if (!grid && month === 0 && minus)
            this.setViewYear({ minus: true });
        if (!grid && month === 11 && plus)
            this.setViewYear({ plus: true });
        if (reset)
            this.setView(CALENDAR);
    }
    setViewDate({ date }) {
        this.dateViewDate = date;
    }
    handleSeparator(event) {
        let value = event.target.value;
        const foundSeparator = this.separators.find(({ index }) => index === value.length);
        if (foundSeparator?.name) {
            value += foundSeparator.name;
        }
        return value;
    }
    inputHandler(event, end = false) {
        const propName = end ? 'end' : 'start';
        const value = this.disableTypeAhead ? event.target.value : this.handleSeparator(event);
        this[propName] = value;
    }
    setValue(date) {
        const value = getReadableDate(this.getCurrentDateObject({ date }), this.language, this.format);
        if (this.selectingEnd)
            this.end = value;
        else
            this.start = value;
        this.setViewDate({ date });
        if (!this.range || this.selectingEnd) {
            this.toggleGrid(false);
            this.focusToggleCalendarButton();
        }
        if (this.range && !this.selectingEnd)
            this.selectingEnd = true;
    }
    getDayAttributes(dateObject, blank) {
        const data = this.getCurrentDateObject(dateObject);
        const { disabled } = this.isDisabled(data);
        if (blank)
            return { 'data-blank': true };
        function capitalize(text) {
            return text.charAt(0).toUpperCase() + text.slice(1);
        }
        const type = this.viewType();
        const value = data[type];
        const disabledProp = type !== 'date' ? 'disabled' : 'aria-disabled';
        const selectedProp = type !== 'date' ? 'aria-pressed' : 'aria-selected';
        const selectedFrom = this.isSelected(data);
        const selectedTo = this.isSelected(data, true);
        const selected = selectedFrom || selectedTo;
        const after = this.range && isAfter(data, this.start, this.format, this.viewType());
        const before = this.range && isBefore(data, this.end, this.format, this.viewType());
        const isBetween = after && before;
        const isDisabled = disabled && (type === 'date' || !selected);
        const tabbable = this[`dateView${capitalize(type)}`] === value;
        const props = {
            'onKeyDown': (e) => this.calendarKeyboardNavigation(e, data, isDisabled),
            'tabindex': tabbable ? '0' : '-1',
            [selectedProp]: (selected || isBetween)?.toString(),
            'aria-current': this.isToday(data) ? 'date' : null,
            'data-active': isDisabled ? null : selected,
            'data-today': this.isToday(data),
            'data-option': 'true',
            [`data-${type}`]: value,
            [disabledProp]: isDisabled ? 'true' : null,
        };
        const singleDate = selectedDate(this.start, this.end, this.format, 'date');
        if (this.range && !singleDate) {
            props['data-range'] = isBetween;
            props['data-range-from'] = selectedFrom && this.end !== '';
            props['data-range-to'] = selectedTo && this.start !== '';
        }
        else {
            props['data-single'] = true;
        }
        if (this.viewingCalendar())
            props.onClick = () => this.setValue(data.date);
        if (this.viewingMonth())
            props.onClick = () => this.setViewMonth({ month: data.month, reset: true });
        if (this.viewingYears())
            props.onClick = () => this.setViewYear({ year: data.year, reset: true });
        if (isDisabled)
            delete props.onClick;
        return props;
    }
    /** Focus the button toggling the calendar. Handles the start/from date on its own. */
    focusToggleCalendarButton() {
        requestAnimationFrame(() => {
            const id = this.range ? this.idEndButton : this.idStartButton;
            this.hostElement.querySelector(`#${id}`).focus({ preventScroll: true });
        });
    }
    focusCalendar() {
        requestAnimationFrame(() => {
            const element = this.calendarTabElement({ first: true, grid: true });
            element?.focus({ preventScroll: true });
        });
    }
    resetFocus() {
        if (this.open)
            return this.focusCalendar();
        else
            this.focusToggleCalendarButton();
    }
    handleButtonBlur(event) {
        if (event.code === 'Escape') {
            event.preventDefault();
            event.stopImmediatePropagation();
        }
        if (this.open && event.key === 'Tab')
            return this.focusCalendar();
    }
    /**
     * This function queries all tabbable elements inside the calendar popup.
     * Since we allow slotted content it important that we have a function that takes all elements into account.
     * With the `first` and `grid` argument, you can decide which one you want to get.
     * There are fallbacks so you should never get an empty list of elements.
     */
    calendarTabElement({ first, grid }) {
        const focusableElements = ':is(input, select, button:not([tabindex="-1"]), td[tabindex="0"])';
        const elements = this.calendarElement.querySelectorAll(focusableElements);
        const list = Array.from(elements).filter(({ localName, offsetParent }) => focusableElements.includes(localName) && offsetParent !== null);
        const gridEl = list.find(({ dataset, tabIndex }) => dataset.option && tabIndex === 0);
        if (grid && gridEl)
            return gridEl;
        if (first)
            return list.shift();
        else
            return list.pop();
    }
    /**
     * We need to listen to the `Esc` and `Tab` key for the entire calendar popup.
     * Regardless if you focus the grid, the nav buttons or slotted content,
     * the popup will close if you press `Esc`. We also need to reset the focus when the user tabs.
     */
    handleCalendarTabEsc(event) {
        const target = event.target;
        const tabElement = this.calendarTabElement({ first: event.shiftKey });
        event.stopImmediatePropagation();
        if (event.code === 'Escape') {
            event.preventDefault();
            this.toggleGrid(false);
            this.focusToggleCalendarButton();
            return;
        }
        if (event.code === 'Tab' && target.isEqualNode(tabElement)) {
            event.preventDefault();
            this.calendarTabElement({ first: !event.shiftKey }).focus({ preventScroll: true });
        }
    }
    ariaDescribedby() {
        const list = [];
        if (this.hasErrorMessage())
            list.push(this.idError);
        else if (this.hasHelperText())
            list.push(this.idHelper);
        return list.length ? list.join(' ') : null;
    }
    /** Renders the date calendar grid.  */
    renderDateGrid() {
        return (hAsync("table", { role: "grid", class: "pn-date-picker-table", "aria-multiselectable": this.range ? 'true' : null }, hAsync("caption", { class: "pn-date-picker-sr-only", key: this.getCurrentViewDate() }, this.getCurrentViewDate()), hAsync("thead", { class: "pn-date-picker-thead" }, hAsync("tr", { class: "pn-date-picker-tr" }, this.weekNumbers && hAsync("th", { class: "pn-date-picker-th", scope: "col", "aria-hidden": "true" }), this.listWeek.map(index => (hAsync("th", { class: "pn-date-picker-th", scope: "col", abbr: this.translateDateText({ day: index }, 'dddd') }, this.translateDateText({ day: index }, 'ddd')))))), hAsync("tbody", { class: "pn-date-picker-tbody" }, this.grid?.map(({ week, list }) => (hAsync("tr", { key: `${this.dateViewYear}-${week}`, class: "pn-date-picker-tr" }, this.weekNumbers && (hAsync("td", { class: "pn-date-picker-td", "data-blank": true, "data-week": true, title: `${this.translate('WEEK_NAME')} ${week}`, "aria-hidden": "true" }, hAsync("span", { class: "pn-date-picker-td-week" }, week))), list.map(({ day, date, blank }) => (hAsync("td", { key: `${this.dateViewYear}-${this.dateViewMonth}-${date}`, class: "pn-date-picker-td", ...this.getDayAttributes({ date, day }, blank) }, hAsync("span", { class: "pn-date-picker-td-text" }, date))))))))));
    }
    /** Renders the month calendar grid.  */
    renderMonthGrid() {
        return (hAsync("ul", { class: "pn-date-picker-list" }, this.listMonths.map(month => (hAsync("li", { key: month, class: "pn-date-picker-item", "data-item": "month" }, hAsync("button", { type: "button", class: "pn-date-picker-button", ...this.getDayAttributes({ month }, false) }, hAsync("span", { class: "pn-date-picker-month", "data-full": true }, this.translateDateText({ month }, 'MMMM')), hAsync("span", { class: "pn-date-picker-month", "data-abbr": true }, this.translateDateText({ month }, 'MMM'))))))));
    }
    /** Renders the year calendar grid.  */
    renderYearGrid() {
        return (hAsync("ul", { class: "pn-date-picker-list" }, this.getYearGrid()?.map(year => (hAsync("li", { key: year, class: "pn-date-picker-item", "data-item": "year" }, hAsync("button", { type: "button", class: "pn-date-picker-button", ...this.getDayAttributes({ year }, false) }, hAsync("span", null, year)))))));
    }
    renderLabel(end = false) {
        const id = end ? this.idEnd : this.idStart;
        const label = end ? this.labelTo : this.labelFrom;
        if (!label)
            return null;
        return (hAsync("label", { class: "pn-date-picker-label", htmlFor: id, "data-compact": this.compact }, hAsync("span", null, label)));
    }
    renderInput({ end = false } = {}) {
        const id = end ? this.idEnd : this.idStart;
        const idButton = end ? this.idEndButton : this.idStartButton;
        const value = end ? this.end : this.start;
        const list = end ? this.listEnd : this.list;
        const name = end ? this.nameEnd : this.name;
        const editing = this.open ? (this.selectingEnd ? end : !end) : false;
        const defaultText = this.translate('SELECT_DATE');
        const textProp = this.range ? (end ? 'END_' : 'START_') : '';
        const dateText = this.translate(`SELECTED_${textProp}DATE`);
        let textButton = defaultText;
        if (value) {
            textButton += `, ${dateText.replace('{date}', value)}`;
        }
        const showButton = !(this.disabled || this.readonly);
        return (hAsync("div", { class: "pn-date-picker-container", "data-error": this.hasError() }, !this.compact && this.renderLabel(end), hAsync("div", { class: "pn-date-picker-field" }, hAsync("input", { type: "text", id: id, class: "pn-date-picker-input", name: name, placeholder: this.getPlaceholder(end), autocomplete: this.autocomplete, maxlength: this.disableMaxLength ? null : this.format.length, list: list, pattern: this.pattern, value: value, disabled: this.disabled, required: this.required, readonly: this.readonly, "aria-label": this.getAriaLabel(end), "aria-labelledby": this.getAriaLabelledby(end), "aria-describedby": this.ariaDescribedby(), "aria-invalid": this.hasError()?.toString(), "data-active": editing, "data-compact": this.compact, onInput: e => this.inputHandler(e, end) }), this.compact && this.renderLabel(end), showButton && (hAsync("pn-button", { class: "pn-date-picker-toggle", buttonId: idButton, icon: calendar, iconOnly: true, appearance: "light", arialabel: textButton, ariaexpanded: this.open.toString(), ariacontrols: this.idCalendar, "data-active": this.open, "data-input": true, small: true, onPnClick: () => this.toggleGrid(null, end), onKeyDown: e => this.handleButtonBlur(e) })))));
    }
    render() {
        return (hAsync(Host, { key: 'dbe09316ddf6365ad119afe9fd01a363aa3cf9bf' }, hAsync("div", { key: 'b6aa1c922859c282529ff9e1297aacc79111a0f9', class: "pn-date-picker" }, this.renderInput(), this.range && (hAsync("div", { key: '48d050a834a2df16b33759bbe117a5c378dfa069', class: "pn-date-picker-range-icon test" }, hAsync("pn-icon", { key: '6b6507409ba5eaf3de232dff28785d9c7c0a85f0', icon: arrow_right }))), this.range && this.renderInput({ end: this.range })), hAsync("div", { key: '9a9d31f221aabbf0927bcc8ae602d1330d75b4d3', id: this.idCalendar, class: "pn-date-picker-calendar", role: "dialog", "aria-label": this.translate('CALENDAR_NAVIGATION'), "data-open": this.open, "data-direction": this.openUp ? 'top' : 'bottom', "data-range": this.range, style: { height: '0px' }, ref: el => (this.calendarElement = el), onKeyDown: e => this.handleCalendarTabEsc(e) }, hAsync("div", { key: '56137ab966418bda3abd61bbcc12ff004feca5c0', class: "pn-date-picker-wrapper" }, hAsync("nav", { key: '67a2fea072a8e4953fa9803e77d0245760b7195a', class: "pn-date-picker-nav", "aria-labelledby": this.idCalendar }, hAsync("pn-button", { key: '9d9d0aa471baa6d6183a4b3b920cf8d05737e8a1', hidden: this.viewingMonth(), small: true, appearance: "light", arialabel: this.translate(`PREVIOUS_${this.viewType().toUpperCase()}`), icon: arrow_left, iconOnly: true, onPnClick: () => this.setNavView({ minus: true }) }), hAsync("pn-button", { key: '57988169fdd38cb05c18c6d4f8e71ded23f97f5f', hidden: !this.viewingCalendar(), small: true, appearance: "light", onPnClick: () => this.setView(MONTHS) }, hAsync("span", { key: '93c98b9aeabdc4b08e59afdaf8655dfe3c440b13', class: "pn-date-picker-month", "data-full": true }, this.translateDateText({ date: 1 }, 'MMMM')), hAsync("span", { key: '9c0b0c3378f00755ef84e5e87426c1a9bedb0651', class: "pn-date-picker-month", "data-abbr": true }, this.translateDateText({ date: 1 }, 'MMM'))), hAsync("h2", { key: '02d40d1aa03dd69f5b344295713ec9c45431b3e9', hidden: this.viewingCalendar(), class: "pn-date-picker-title" }, this.translate(`SELECT_${this.viewType().toUpperCase()}`)), hAsync("pn-button", { key: '4f953719a89967b10c98472b24f732c42cd61e3c', hidden: !this.viewingCalendar(), small: true, appearance: "light", onPnClick: () => this.setView(YEARS) }, hAsync("span", { key: 'a91a0dd940b94d0f71d887508644d6acfa3ef098' }, this.dateViewYear)), hAsync("pn-button", { key: '3eabe547992de22014f3e229c9e7e17eab395d56', hidden: this.viewingMonth(), small: true, appearance: "light", arialabel: this.translate(`NEXT_${this.viewType().toUpperCase()}`), icon: arrow_right, iconOnly: true, onPnClick: () => this.setNavView({ plus: true }) })), this.viewingYears() && this.renderYearGrid(), this.viewingMonth() && this.renderMonthGrid(), this.viewingCalendar() && this.renderDateGrid(), hAsync("aside", { key: '6eaefead16141908688578834b1e6a2ba87e8161', class: "pn-date-picker-chips" }, hAsync("slot", { key: '43bcfa9bb50d6dbd912ae8cfee339b642b9363a5', name: "chips" })), hAsync("nav", { key: 'b22d7112ba5d3d012f5d2617586bd251547f4ed7', class: "pn-date-picker-bottom", hidden: this.viewingCalendar() }, hAsync("pn-button", { key: '41031640dbac5130b3fb9029b36c5e732068c78f', appearance: "light", variant: "outlined", small: true, icon: pn_return, onPnClick: () => this.setView(CALENDAR) }, hAsync("span", { key: '08568a439547db8728c3f110c00854d49ec7eb77' }, this.translate('GO_CALENDAR')))))), hAsync("p", { key: 'e890351198e9eaa85e9db3bcc55bc8bdd48f3538', id: this.idHelper, class: "pn-date-picker-helpertext", hidden: this.hideHelpertext() }, hAsync("span", { key: '0b776595b33ed64cb73b5060d023eb89421ad758' }, this.helpertext), hAsync("slot", { key: 'e9ef3797e3baae78dca7efc2313e1b6cf9c7efd7', name: "helpertext" })), hAsync("p", { key: 'aa43fb6eaf42251bb7dadab0f724edee0e6d42b2', id: this.idError, class: "pn-date-picker-error", role: "alert", hidden: this.hideError() }, hAsync("span", { key: '556bfbb5e5ba697234734eb601445150b23ddcf2' }, this.error), hAsync("slot", { key: '21dd12fd2c3f1ac814699f4785ece567136cedd2', name: "error" }))));
    }
    static get watchers() { return {
        "minDate": [{
                "watchMin": 1
            }],
        "maxDate": [{
                "watchMax": 1
            }],
        "start": [{
                "watchValue": 0
            }],
        "end": [{
                "watchValueTo": 0
            }],
        "format": [{
                "handleFormat": 0
            }],
        "dateId": [{
                "watchId": 0
            }],
        "pnId": [{
                "watchId": 1
            }],
        "dateViewYear": [{
                "watchView": 0
            }],
        "dateViewMonth": [{
                "watchView": 0
            }],
        "dateViewDate": [{
                "watchView": 0
            }],
        "open": [{
                "watchOpen": 0
            }],
        "helpertext": [{
                "handleMessage": 0
            }],
        "error": [{
                "handleMessage": 0
            }],
        "view": [{
                "handleView": 0
            }]
    }; }
    static get style() { return pnDatePickerCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-date-picker",
        "$members$": {
            "labelFrom": [1, "label-from"],
            "labelTo": [1, "label-to"],
            "helpertext": [1],
            "language": [1],
            "start": [1025],
            "end": [1025],
            "name": [1],
            "nameEnd": [1, "name-end"],
            "placeholder": [1],
            "endPlaceholder": [1, "end-placeholder"],
            "placeholderEnd": [1, "placeholder-end"],
            "autocomplete": [1],
            "list": [1],
            "listEnd": [1, "list-end"],
            "pattern": [1],
            "required": [4],
            "readonly": [4],
            "disabled": [4],
            "format": [1],
            "disableTypeAhead": [4, "disable-type-ahead"],
            "disableWeekends": [4, "disable-weekends"],
            "disabledDates": [1, "disabled-dates"],
            "disableMaxLength": [4, "disable-max-length"],
            "range": [4],
            "rangeLimit": [2, "range-limit"],
            "weekNumbers": [4, "week-numbers"],
            "compact": [4],
            "calendarUp": [4, "calendar-up"],
            "view": [1025],
            "invalid": [4],
            "error": [1],
            "pnId": [1, "pn-id"],
            "pnAriaLabel": [1, "pn-aria-label"],
            "pnAriaLabelEnd": [1, "pn-aria-label-end"],
            "pnAriaLabelledby": [1, "pn-aria-labelledby"],
            "pnAriaLabelledbyEnd": [1, "pn-aria-labelledby-end"],
            "dateId": [1, "date-id"],
            "minDate": [1025, "min-date"],
            "maxDate": [1025, "max-date"],
            "isClosing": [32],
            "isExpanding": [32],
            "open": [32],
            "openUp": [32],
            "selectingEnd": [32],
            "grid": [32],
            "viewYearStart": [32],
            "dateViewYear": [32],
            "dateViewMonth": [32],
            "dateViewDate": [32],
            "showHelperSlot": [32],
            "showErrorSlot": [32]
        },
        "$listeners$": [[9, "resize", "handleResize"]],
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnFieldsetCss = () => `${transformTag("pn-fieldset")}{display:inline-block}${transformTag("pn-fieldset")} .pn-fieldset{border:0;padding:0;margin:0;color:#2d2013;display:flex;flex-direction:column;font-size:1em}${transformTag("pn-fieldset")} .pn-fieldset-legend{float:left;font-weight:500;line-height:1.4;padding:0}${transformTag("pn-fieldset")} .pn-fieldset-message{color:#5e554a;font-size:0.875em;font-weight:400;margin:0.25em 0 0 0;display:flex;flex-direction:column;gap:0.25em}${transformTag("pn-fieldset")} .pn-fieldset-message[hidden]{display:none}${transformTag("pn-fieldset")} .pn-fieldset-error{display:flex;flex-direction:row;flex-wrap:nowrap;gap:0.25em}${transformTag("pn-fieldset")} .pn-fieldset-error[hidden]{display:none}${transformTag("pn-fieldset")} .pn-fieldset-error>.pn-fieldset-message{color:#a70707}${transformTag("pn-fieldset")} .pn-fieldset-items{padding:0.75em 0;display:flex;flex-direction:column;gap:0.75em}${transformTag("pn-fieldset")} .pn-fieldset[aria-invalid=true]>.pn-fieldset-legend,${transformTag("pn-fieldset")} .pn-fieldset[aria-invalid=true]>.pn-fieldset-message-wrapper{color:#a70707}${transformTag("pn-fieldset")} .pn-fieldset[aria-invalid=true]>.pn-fieldset-legend>${transformTag("pn-icon")} .pn-icon-svg>path,${transformTag("pn-fieldset")} .pn-fieldset[aria-invalid=true]>.pn-fieldset-message-wrapper>${transformTag("pn-icon")} .pn-icon-svg>path{fill:#a70707}${transformTag("pn-fieldset")} .pn-fieldset:disabled>.pn-fieldset-legend,${transformTag("pn-fieldset")} .pn-fieldset:disabled>.pn-fieldset-helpertext,${transformTag("pn-fieldset")} .pn-fieldset:disabled>.pn-fieldset-message,${transformTag("pn-fieldset")} .pn-fieldset:disabled>.pn-fieldset-message-wrapper{color:#2d2013}${transformTag("pn-fieldset")} .pn-fieldset:disabled>.pn-fieldset-legend>${transformTag("pn-icon")} .pn-icon-svg>path,${transformTag("pn-fieldset")} .pn-fieldset:disabled>.pn-fieldset-helpertext>${transformTag("pn-icon")} .pn-icon-svg>path,${transformTag("pn-fieldset")} .pn-fieldset:disabled>.pn-fieldset-message>${transformTag("pn-icon")} .pn-icon-svg>path,${transformTag("pn-fieldset")} .pn-fieldset:disabled>.pn-fieldset-message-wrapper>${transformTag("pn-icon")} .pn-icon-svg>path{fill:#2d2013}`;

/**
 * The fielset is a wrapper to give context and information about inputs. Most commonly, a set of radio/checkboxes.
 * However, you may include any type of input such as textareas, toggles and selects.
 *
 * @slot - Default slot is the content of the fieldset, where you can add your inputs.
 * @slot helpertext - Use this slot to add custom HTML inside of the helpertext element. {@since v7.25.0}
 * @slot error - Use this slot to add custom HTML inside of the `error` element. {@since v7.25.0}
 */
class PnFieldset {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    mo;
    id = `pn-fieldset-${uuidv4()}`;
    idHelpertext = `${this.id}-helpertext`;
    get hostElement() { return getElement(this); }
    /**
     * The legend provides a caption for the fieldset group.
     * This should be a question or heading that describes the inputs/fields.
     */
    legend;
    /** Text message underneath the legend for more instruction or hints on how to fill in controls correctly. */
    helpertext;
    /** Give the fieldset a HTML name. @category Native attributes */
    name;
    /**
     * The id of the form you want the fieldset to be part of.
     * If you want the inputs inside to be associated with a specific form, you need to set on those elements directly.
     * @category Native attributes
     */
    form;
    /** Disable all of the inputs inside of the fieldset. @category Native attributes */
    disabled = false;
    /** Set the fieldset as `invalid`, will add red error styles. @category Features */
    invalid = false;
    /** Error message, applies warning styles and icon. @category Features */
    error;
    /** Set a custom ID for the fieldset. @since v7.25.0 @category HTML attributes  */
    pnId = this.id;
    /** Set a custom ID for the fieldset. @deprecated Use `pn-id` instead. @category HTML attributes */
    fieldsetId = this.id;
    handleId() {
        this.idHelpertext = `${this.getId()}-helpertext`;
    }
    connectedCallback() {
        this.mo = new MutationObserver(() => forceUpdate());
        this.mo.observe(this.hostElement, { childList: true, subtree: true });
    }
    disconnectedCallback() {
        if (this.mo)
            this.mo.disconnect();
    }
    getId() {
        return this.pnId || this.fieldsetId || this.id;
    }
    hasHelpertext() {
        const helpertextSlot = this.hostElement.querySelector('[slot="helpertext"]');
        return !!this.helpertext || helpertextSlot?.textContent?.trim().length > 0;
    }
    hasError() {
        const errorSlot = this.hostElement.querySelector('[slot="error"]');
        return !!this.error || errorSlot?.textContent?.trim().length > 0;
    }
    isInvalid() {
        return this.invalid || this.hasError();
    }
    getIcon() {
        if (this.disabled)
            return alert_info_circle;
        return alert_exclamation_circle;
    }
    render() {
        return (hAsync(Host, { key: '908a403f3fb8b4779393f4ca0a4f17f518ba53a7' }, hAsync("fieldset", { key: '97b321f776944a0d27f1b1096a967b2c9d9c9fcd', id: this.getId(), name: this.name, form: this.form, class: "pn-fieldset", disabled: this.disabled, "aria-describedby": this.hasHelpertext() ? this.idHelpertext : undefined, "aria-invalid": this.isInvalid().toString() }, hAsync("legend", { key: 'a230416f33f787624f90977054c6492f1516dba6', class: "pn-fieldset-legend" }, this.legend), hAsync("p", { key: '6911c6e63588c36bc0e314d7b3c8b81df2282579', id: this.idHelpertext, class: "pn-fieldset-message", hidden: !this.hasHelpertext() }, hAsync("span", { key: '3370e13a7cf93741a4aa76880533b11c320aea03' }, this.helpertext), hAsync("slot", { key: '0365489d121f3fcfa1211e3c2dcf2881f849940d', name: "helpertext" })), hAsync("div", { key: '23d806e61d39d509ad07f0f68c002a1962332bf4', class: "pn-fieldset-items" }, hAsync("slot", { key: 'a2ead121001e5f751f779957fbbb44716e64274c' })), hAsync("div", { key: '075c709c13a8363be1b1a0b661e3621419a69333', class: "pn-fieldset-error", role: "alert", hidden: !this.hasError() }, hAsync("pn-icon", { key: '0c4e969436033de98814135853e51388862e0812', icon: this.getIcon(), color: "warning" }), hAsync("p", { key: 'd94095bee0a7e4fdc3962db9666dd4ffba7dfa50', class: "pn-fieldset-message" }, hAsync("span", { key: '0c3808a66242f11afdc1ea5053517e965eeb3a93' }, this.error), hAsync("slot", { key: 'ad9604de305ce00ef164cc999562707e923bdd83', name: "error" }))))));
    }
    static get watchers() { return {
        "fieldsetId": [{
                "handleId": 0
            }],
        "pnId": [{
                "handleId": 1
            }]
    }; }
    static get style() { return pnFieldsetCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-fieldset",
        "$members$": {
            "legend": [1],
            "helpertext": [1],
            "name": [1],
            "form": [1],
            "disabled": [4],
            "invalid": [4],
            "error": [1],
            "pnId": [1, "pn-id"],
            "fieldsetId": [1, "fieldset-id"]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

class PnFileUploadError extends Error {
    element;
    code;
    data;
    constructor(message, element, code = 'INVALID', data = null) {
        super(message);
        this.name = 'PNFileUploadError';
        this.element = element;
        this.code = code;
        this.data = data;
    }
}

const translations$d = {
    CLICKORDRAG: {
        sv: 'Klicka eller dra en fil hit',
        en: 'Click or drag a file here',
        da: 'Klik eller træk en fil hertil',
        fi: 'Klikkaa tai vedä tiedosto tähän',
        no: 'Klikk eller dra en fil hit',
    },
    ACCEPTEDFORMATS: {
        sv: 'Filformat som stöds',
        en: 'Supported formats',
        da: 'Støttede filformater',
        fi: 'Tuetut tiedostomuodot',
        no: 'Understøttede filformater',
    },
    MAXFILESIZE: {
        sv: 'Max filstorlek',
        en: 'Max filesize',
        da: 'Max filstørrelse',
        fi: 'Maksimitiedostokoko',
        no: 'Maks filstørrelse',
    },
    REMOVE_FILE: {
        sv: 'Ta bort filen',
        en: 'Remove file',
        da: 'Fjern fil',
        fi: 'Poista tiedosto',
        no: 'Fjern fil',
    },
    LIMIT: {
        sv: 'Max antal filer',
        en: 'Max number of files',
        da: 'Maks antal filer',
        fi: 'Maksimimäärä tiedostoja',
        no: 'Maks antall filer',
    },
};

const pnFileUploadCss = () => `${transformTag("pn-file-upload")} .pn-file-upload{position:relative;display:flex;flex-direction:column;gap:1em}${transformTag("pn-file-upload")} .pn-file-upload-container{position:relative}${transformTag("pn-file-upload")} .pn-file-upload-input{position:absolute;z-index:1;left:0;top:0;opacity:0;height:100%;width:100%;-webkit-tap-highlight-color:transparent}${transformTag("pn-file-upload")} .pn-file-upload-input:hover{cursor:pointer}${transformTag("pn-file-upload")} .pn-file-upload-input:hover+.pn-file-upload-dropzone{border-color:#005d92;background-color:#e0f8ff}${transformTag("pn-file-upload")} .pn-file-upload-input:focus-visible+.pn-file-upload-dropzone{border-color:#005d92;outline-color:#005d92}${transformTag("pn-file-upload")} .pn-file-upload-input:disabled{pointer-events:none}${transformTag("pn-file-upload")} .pn-file-upload-input:disabled+.pn-file-upload-dropzone{pointer-events:none;background-color:#f3f2f2;border-color:#2d2013}${transformTag("pn-file-upload")} .pn-file-upload-input:disabled+.pn-file-upload-dropzone .pn-icon-svg path{fill:#5e554a}${transformTag("pn-file-upload")} .pn-file-upload-dropzone{position:relative;text-align:center;overflow:hidden;padding:clamp(1em, 5vw, 2.5em);border:0.0625em #969087 dashed;border-radius:0.5em;display:flex;flex-direction:column;align-items:center;gap:0.5em;outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:background-color, outline-color, border-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-file-upload")} .pn-file-upload-dropzone{transition-duration:0s;transition-delay:0s}}${transformTag("pn-file-upload")} .pn-file-upload-dropzone .pn-ripple{animation:ripple 0.4s cubic-bezier(0.7, 0, 0.3, 1);position:absolute;border-radius:50%;background-color:#005d92;transform:translate(-50%, -50%) scale(0);opacity:0.1;pointer-events:none;z-index:3}@keyframes ripple{to{transform:translate(-50%, -50%) scale(1);opacity:0}}${transformTag("pn-file-upload")} .pn-file-upload-dropzone[data-hover]{background-color:#e0f8ff;border-color:#005d92}${transformTag("pn-file-upload")} .pn-file-upload-dropzone[data-invalid]{border-color:#a70707}${transformTag("pn-file-upload")} .pn-file-upload-title{color:#2d2013}${transformTag("pn-file-upload")} .pn-file-upload-subtitle{color:#5e554a;font-size:0.75em}${transformTag("pn-file-upload")} .pn-file-upload-files{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:1em}${transformTag("pn-file-upload")} .pn-file-upload-file{display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:space-between;align-items:center;background:#f9f8f8;padding:1em;border-radius:0.5em}${transformTag("pn-file-upload")} .pn-file-upload-file-title{display:flex;align-items:center;gap:0.5em;flex:1;margin-right:0.5em}${transformTag("pn-file-upload")} .pn-file-upload-file-name{font-weight:400;font-size:0.75em}${transformTag("pn-file-upload")} .pn-file-upload-file-error{color:#a70707;font-size:0.875em;font-weight:300;margin-top:0.25em}${transformTag("pn-file-upload")} .pn-file-upload-file[data-error]{color:#a70707;background-color:#fdefee}${transformTag("pn-file-upload")} .pn-file-upload-file ${transformTag("pn-progress-bar")}{flex:1}`;

/**
 * Users can drop files directly into the upload area of the component
 * or simply click on it to open their native file explorer.
 *
 * @nativeChange Use the `change` event to listen when the input receives files.
 *
 * @nativeCancel The `cancel` event lets you know the user canceled their selection.
 * Either via clicking on the "Cancel" button or pressing `ESC`.
 * */
class PnFileUpload {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.filesAdded = createEvent(this, "filesAdded", 7);
        this.update = createEvent(this, "update", 7);
        this.fileuploaderror = createEvent(this, "fileuploaderror", 7);
        this.valid = createEvent(this, "valid", 7);
        this.uploadFile = createEvent(this, "uploadFile", 7);
        this.uploadCancelled = createEvent(this, "uploadCancelled", 7);
        this.uploadCompleted = createEvent(this, "uploadCompleted", 7);
    }
    id = `pn-file-upload-${uuidv4()}`;
    idHelpertext = `${this.id}-helpertext`;
    idAccepttext = `${this.id}-accept`;
    fileInputElement;
    invalid = false;
    maxSizeInBytes = 0;
    rippleClass = '.pn-file-upload-dropzone';
    get hostElement() { return getElement(this); }
    files = [];
    isHovering = false;
    /** The default label is "Click or drag a file here". @since v7.1.0 */
    label;
    /**
     * The helpertext defaults to "Supported formats {x} and max filesize {y}",
     * if there is a value set for the prop `accept`.
     * @since v7.1.0
     **/
    helpertext;
    /** Manually set the language. @since v7.1.0 */
    language = undefined;
    /**
     * Set a HTML name.
     * @since v7.1.0
     * @category Native attributes
     */
    name;
    /** Set which file types the input accepts. Ex: .docs,.xml @category Native attributes */
    accept;
    /**
     * Use the capture mode.
     * @since v7.1.0
     * @category Native attributes
     */
    capture;
    /** Allow multiple files to be selected. Will be overwritten to true, if `limit` is above 1. @category Native attributes */
    multiple;
    /** Set the input as required. @category Native attributes */
    required = false;
    /** Disable the input. @category Native attributes */
    disabled = false;
    /**
     * Set maximum amount of files to be selected.
     * Any value above 1 will force the `multiple` to be `true`.
     * @category Features
     **/
    limit = 1;
    /** Set the maximum upload size. @category Features */
    maxSize = '';
    /**
     * Always hide the progress bar, even when upload has begun.
     * @since v7.1.0
     * @category Features
     */
    hideProgress = false;
    /** Set a custom ID for the file upload. @since v7.25.0 @category HTML attributes */
    pnId = this.id;
    handleId() {
        this.idHelpertext = `${this.getId()}-helpertext`;
        this.idAccepttext = `${this.getId()}-accept`;
    }
    handleLimit() {
        this.multiple = this.limit > 1;
    }
    handleMaxBytes() {
        this.maxSizeInBytes = getBytesFromHumanReadableFileSize(this.maxSize);
    }
    /** This event is emitted when you add files. Either via drag and drop or using the file explorer. */
    filesAdded;
    /** Emitted everytime an update is made to one of the files. */
    update;
    /** If any error occurs, such as: invalid file type, size, limit or error during upload. */
    fileuploaderror;
    /** Emitted everytime you select a valid file. It's a good idea to use this event in order to make use of the built in validation features. */
    valid;
    /** Emitted once the file upload has begun. */
    uploadFile;
    /** Emitted when an upload has been cancelled before completion. */
    uploadCancelled;
    /** Emitted once the upload is finished. */
    uploadCompleted;
    async componentWillLoad() {
        if (this.language === undefined)
            await awaitTopbar(this.hostElement);
    }
    getId() {
        return this.pnId || this.id;
    }
    /** Start the upload of all selected files (excludes invalid files). */
    async startUpload() {
        if (!this.files.length)
            return;
        this.files = this.files.map((file, index) => {
            if (file.status === 'queue') {
                file.status = 'start';
                this.uploadFile.emit({
                    file: file,
                    index: index,
                    uploader: this,
                });
            }
            return file;
        });
        const promises = this.files.map(file => file.xhrPromise().catch(() => { }));
        return Promise.all(promises).then(data => {
            const added = data.filter(item => item);
            this.uploadCompleted.emit(added);
        });
    }
    /** Clear the selected files, state and input value. */
    async clearUpload() {
        this.files = [];
        this.fileInputElement.value = '';
        this.invalid = false;
        this.filesAdded.emit([]);
    }
    /** Remove the selected file. */
    async removeFile(targetFile) {
        let valid = true;
        const files = [];
        for (const fileIndex in this.files) {
            const file = this.files[fileIndex];
            if (!file.filename) {
                continue;
            }
            // add to files if the uuid doesn't match
            if (file.uuid !== targetFile.uuid) {
                try {
                    this._validateFileSize(file);
                    this._validateFileType(file);
                    valid = true;
                }
                catch (error) {
                    valid = false;
                    file.error = error;
                    file.progress = 0;
                    file.status = 'error';
                }
                files.push(file);
            }
            else if (file.status === 'start') {
                file.xhr.abort();
                this.uploadCancelled.emit(file);
            }
        }
        this.filesAdded.emit(files);
        this.files = files;
        this.invalid = !valid || !this._isNotGreaterThanLimit();
        this._checkValidity();
        this._emitUpdateEvent();
    }
    /** Update an existing file. */
    async updateFile(file, index = null) {
        let files = this.files;
        // find the index if not defined
        if (index === null) {
            for (const fIndex in files) {
                const fFile = files[fIndex];
                if (fFile.uuid === file.uuid) {
                    index = fIndex;
                    break;
                }
            }
        }
        if (files[index]) {
            if (file.progress >= 100) {
                file.progress = 100;
                file.status = 'completed';
            }
            else if (file.progress < 0) {
                file.status = 'start';
                file.progress = 0;
            }
            if (file.error) {
                file.progress = 0;
                file.status = 'error';
                file.errorMessage = file.errorMessage || 'There was an error uploading your file, please try again';
            }
            files[index] = file;
        }
        this.files = [...files];
    }
    async _addFilesFromFileList(fileList) {
        if (this.disabled || this.invalid) {
            return;
        }
        const files = Array.from(fileList);
        const promises = [];
        if (this.multiple) {
            files.forEach(file => promises.push(this._addFile(file)));
        }
        else {
            const file = files[0];
            if (this.limit === 1) {
                this.files = [];
                promises.push(this._addFile(file));
            }
            else {
                promises.push(this._addFile(file));
            }
        }
        return Promise.all(promises).then(() => {
            this.filesAdded.emit(this.files);
            this._isNotGreaterThanLimit();
            this._checkValidity();
            this._emitUpdateEvent();
        });
    }
    async _onAddFile() {
        const files = this.fileInputElement.files;
        return await this._addFilesFromFileList(files);
    }
    _onDragOverFile(event) {
        event.preventDefault();
        event.stopPropagation();
        this.isHovering = true;
    }
    _onDragLeaveFile(event) {
        event.preventDefault();
        event.stopPropagation();
        this.isHovering = false;
    }
    _onDropFile(event) {
        event.preventDefault();
        event.stopPropagation();
        this.isHovering = false;
        ripple(event, this.hostElement, this.rippleClass);
        this._addFilesFromFileList(event.dataTransfer.files);
    }
    _validateFileType(file) {
        const accepts = this.accept ? this.accept.split(',') : [];
        if (accepts.length) {
            let valid = false;
            for (const accept of accepts) {
                const type = accept.trim().toLowerCase();
                const isMimeType = /^\w+\/[a-z\.\-]+$/i;
                const extension = file.filename.match(/\.\w{3,4}($|\?)/)?.[0]?.toLowerCase();
                if ((isMimeType.test(type) && file.contentType === type) || extension === type) {
                    valid = true;
                    break;
                }
            }
            if (!valid) {
                const error = new PnFileUploadError(`Invalid file type.`, this.hostElement, 'INVALID_FILE_TYPE', file);
                this.invalid = true;
                this.fileuploaderror.emit(error);
                throw error;
            }
        }
    }
    _validateFileSize(file) {
        if (this.maxSizeInBytes > 0 && file.filesize > this.maxSizeInBytes) {
            const error = new PnFileUploadError(`You can only add up to ${this.maxSize}.`, this.hostElement, 'MAX_FILE_SIZE', file);
            this.invalid = true;
            this.fileuploaderror.emit(error);
            throw error;
        }
    }
    _validateLimit() {
        if (this.limit && this.files.length > this.limit) {
            const error = new PnFileUploadError(`You can only add up to ${this.limit} files.`, this.hostElement, 'MAX_LIMIT', this.files);
            this.invalid = true;
            this.fileuploaderror.emit(error);
            throw error;
        }
    }
    _isNotGreaterThanLimit() {
        try {
            this._validateLimit();
            return true;
        }
        catch (error) {
            return false;
        }
    }
    _checkValidity() {
        if (!this.invalid) {
            this.valid.emit(this);
        }
        return !this.invalid;
    }
    _createBase64FromFile(file) {
        return new Promise((resolve, reject) => {
            const reader = new FileReader();
            reader.onload = () => resolve(reader.result);
            reader.onerror = error => reject(error);
            reader.onabort = () => reject('ABORTED');
            reader.readAsDataURL(file);
        });
    }
    async _addFile(file) {
        return this._createBase64FromFile(file).then(data => {
            const split = data.split(',');
            const base64 = split[1];
            const contentType = split[0].split(':')[1].split(';')[0];
            const request = new XMLHttpRequest();
            const uploadFile = {
                uuid: uuidv4(),
                filename: file.name,
                filesize: file.size,
                progress: 0,
                status: 'queue',
                base64,
                contentType,
                error: null,
                errorMessage: '',
                file,
                xhr: request,
            };
            try {
                this._validateFileSize(uploadFile);
                this._validateFileType(uploadFile);
            }
            catch (error) {
                uploadFile.error = error;
                uploadFile.progress = 0;
                uploadFile.status = 'error';
            }
            uploadFile.xhrPromise = () => {
                return new Promise((resolve, reject) => {
                    request.responseType = 'json';
                    request.addEventListener('progress', event => {
                        if (event.lengthComputable) {
                            uploadFile.progress = (event.loaded / event.total) * 100;
                            this.updateFile(uploadFile);
                        }
                        else {
                            uploadFile.progress = 100;
                            this.updateFile(uploadFile);
                        }
                    });
                    request.addEventListener('load', (response) => resolve(response.target.response));
                    request.addEventListener('error', error => {
                        uploadFile.error = error;
                        uploadFile.errorMessage = 'There was an error uploading your file, please try again';
                        this.updateFile(uploadFile);
                        const errorEvent = new PnFileUploadError('There was an error uploading your file, please try again', this.hostElement, 'UPLOAD_SERVER_ERROR', uploadFile);
                        this.fileuploaderror.emit(errorEvent);
                        reject(error);
                    });
                });
            };
            this.files = [...this.files, uploadFile];
            return uploadFile;
        });
    }
    _emitUpdateEvent() {
        this.update.emit({
            files: this.files,
            element: this.hostElement,
        });
    }
    translate(prop) {
        return translations$d?.[prop]?.[this.language || en$2] || prop;
    }
    isLoading(file) {
        return file.status === 'start';
    }
    getFileIcon(file) {
        if (file.error)
            return alert_exclamation_circle;
        if (file.progress === 100)
            return check;
        return attachment;
    }
    getFileColor(file) {
        if (file.error)
            return 'warning';
        if (file.progress === 100)
            return 'green700';
        return 'gray900';
    }
    describedBy() {
        const list = [this.showAcceptText() && this.idAccepttext, this.helpertext && this.idHelpertext].filter(Boolean);
        if (!list.length)
            return null;
        return list.join(' ');
    }
    showAcceptText() {
        return !!this.accept || !!this.maxSize || this.limit > 1;
    }
    getAcceptText() {
        const list = [];
        if (this.accept)
            list.push(`${this.translate('ACCEPTEDFORMATS')}: ${this.accept}`);
        if (this.maxSize) {
            const maxSizeText = this.translate('MAXFILESIZE');
            list.push(`${list.length ? maxSizeText.toLowerCase() : maxSizeText}: ${this.maxSize}`);
        }
        if (this.limit > 1) {
            const limitText = this.translate('LIMIT');
            list.push(`${list.length ? limitText.toLowerCase() : limitText}: ${this.limit}`);
        }
        return list.join(', ');
    }
    render() {
        return (hAsync(Host, { key: 'bda8680e48b7537469f7a348134552cc40201ff3' }, hAsync("div", { key: '6e661705703b2b2d50a794619f1ed4ad123a05e0', class: "pn-file-upload" }, hAsync("div", { key: 'd2d17b3cd8cd15564a63a82d544af8c06b9e6fb5', class: "pn-file-upload-container" }, hAsync("input", { key: '0e8801c1478852c946e8f31d1dd6dde1ee5b4441', id: this.getId(), class: "pn-file-upload-input", type: "file", name: this.name, multiple: this.multiple, accept: this.accept, capture: this.capture, disabled: this.disabled, required: this.required, "aria-describedby": this.describedBy(), "aria-invalid": this.invalid?.toString(), onClick: e => ripple(e, this.hostElement, this.rippleClass), onChange: () => this._onAddFile(), onDragOver: e => this._onDragOverFile(e), onDragLeave: e => this._onDragLeaveFile(e), onDrop: e => this._onDropFile(e), ref: el => (this.fileInputElement = el) }), hAsync("div", { key: '802d986996b9cdc9f577906631dfa1d3eed8f8e4', class: "pn-file-upload-dropzone", "data-hover": this.isHovering, "data-invalid": this.invalid }, hAsync("pn-icon", { key: '1c4e0120ebdf2f06401f130549fb9e8c9e97c920', class: "pn-file-upload-icon-element", icon: upload, color: "blue700" }), hAsync("label", { key: '8f5275d7e7591aee9167cf3fc858b8ec22070d4f', class: "pn-file-upload-title", htmlFor: this.getId() }, this.label || this.translate('CLICKORDRAG')), this.helpertext && (hAsync("p", { key: 'f0a1bc0aaece7c470a756c46aefee84f7059b548', class: "pn-file-upload-subtitle", id: this.idHelpertext }, this.helpertext)), this.showAcceptText() && (hAsync("p", { key: '4d8d595fe7e10bdf5cb01c4b7b448b3b11458c15', class: "pn-file-upload-subtitle", id: this.idAccepttext }, this.getAcceptText())))), !!this.files.length && (hAsync("ul", { key: '55bb12c9e21aceae0bffd49b400f1902f7edb564', class: "pn-file-upload-files" }, this.files.map((file) => (hAsync("li", { class: "pn-file-upload-files-item", key: file.uuid }, hAsync("div", { class: "pn-file-upload-file", "data-error": !!file.error }, hAsync("div", { class: "pn-file-upload-file-title" }, hAsync("pn-icon", { icon: this.getFileIcon(file), color: this.getFileColor(file) }), this.hideProgress || file.progress === 0 ? (hAsync("div", { class: "pn-file-upload-file-name" }, file.filename)) : (hAsync("pn-progress-bar", { label: file.filename, progress: file.progress, error: file.error && file.errorMessage }))), hAsync("pn-button", { small: true, variant: "borderless", arialabel: `${this.translate('REMOVE_FILE')} ${file.filename}`, appearance: file.error ? 'warning' : 'light', icon: trash_can, iconOnly: true, tooltip: this.translate('REMOVE_FILE'), loading: this.isLoading(file), onClick: () => this.removeFile(file) })), file.error ? (hAsync("div", { class: "pn-file-upload-file-error" }, file.errorMessage || file.error.message)) : null))))), hAsync("slot", { key: 'd5e2793ee8d72550129b38825dde9d25768d8528' }))));
    }
    static get watchers() { return {
        "pnId": [{
                "handleId": 1
            }],
        "limit": [{
                "handleLimit": 1
            }],
        "maxSize": [{
                "handleMaxBytes": 1
            }]
    }; }
    static get style() { return pnFileUploadCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-file-upload",
        "$members$": {
            "label": [1],
            "helpertext": [1],
            "language": [1],
            "name": [1],
            "accept": [1],
            "capture": [1],
            "multiple": [1028],
            "required": [4],
            "disabled": [4],
            "limit": [2],
            "maxSize": [1, "max-size"],
            "hideProgress": [4, "hide-progress"],
            "pnId": [1, "pn-id"],
            "files": [32],
            "isHovering": [32],
            "startUpload": [64],
            "clearUpload": [64],
            "removeFile": [64],
            "updateFile": [64]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const URLS = {
    SE: {
        domain: {
            sv: 'https://www.postnord.se',
            en: 'https://www.postnord.se/en',
        },
        contact: {
            sv: 'https://www.postnord.se/kundservice',
            en: 'https://www.postnord.se/en/help-and-support/contact-us',
        },
        cookies: {
            sv: 'https://www.postnord.se/cookies',
            en: 'https://www.postnord.se/en/cookies',
        },
        privacy: {
            sv: 'https://www.postnord.se/integritetspolicy',
            en: 'https://www.postnord.se/en/privacy-policy',
        },
        terms: {
            sv: 'https://www.postnord.se/siteassets/pdf/villkor/anvandarvillkor-postnord-konto.pdf',
            en: 'https://www.postnord.se/siteassets/pdf/villkor/anvandarvillkor-postnord-konto.pdf',
        },
    },
    DK: {
        domain: {
            da: 'https://www.postnord.dk',
            en: 'https://www.postnord.com/en',
        },
        contact: {
            da: 'https://www.postnord.dk/kundeservice',
            en: 'https://www.postnord.dk/en/help-and-support',
        },
        cookies: {
            da: 'https://www.postnord.dk/cookies',
            en: 'https://www.postnord.dk/en/cookies',
        },
        privacy: {
            da: 'https://www.postnord.dk/personlige-oplysninger',
            en: 'https://www.postnord.se/en/privacy-policy',
        },
        terms: {
            da: 'https://www.postnord.dk/contentassets/4806069a7d6c44959c94b13417d78f22/kundeportalen.pdf',
            en: 'https://www.postnord.dk/kundeservice/kundeservice-erhverv/forretningsbetingelser',
        },
    },
    FI: {
        domain: {
            fi: 'https://www.postnord.fi',
            sv: 'https://www.postnord.fi/sv',
            en: 'https://www.postnord.fi/en',
        },
        contact: {
            fi: 'https://www.postnord.fi/asiakaspalvelu/ota-yhteytta',
            sv: 'https://www.postnord.fi/sv/kundtjanst',
            en: 'https://www.postnord.fi/en/customer-service',
        },
        cookies: {
            fi: 'https://www.postnord.fi/yksityisyydensuoja/tietoa-evasteista',
            sv: 'https://www.postnord.fi/sv/integritetspolicy/information-om-cookies',
            en: 'https://www.postnord.fi/en/privacy-policy/information-about-the-cookies',
        },
        privacy: {
            fi: 'https://www.postnord.fi/yksityisyydensuoja',
            sv: 'https://www.postnord.fi/sv/integritetspolicy',
            en: 'https://www.postnord.se/en/privacy-policy',
        },
        terms: {
            fi: 'https://www.postnord.fi/laheta/sopimusehdot',
            sv: 'https://www.postnord.fi/sv/skicka/villkor',
            en: 'https://www.postnord.fi/en/sending/terms',
        },
    },
    NO: {
        domain: {
            no: 'https://www.postnord.no',
            en: 'https://www.postnord.no/en',
        },
        contact: {
            no: 'https://www.postnord.no/kundeservice',
            en: 'https://www.postnord.no/en/contact-postnord',
        },
        cookies: {
            no: 'https://www.postnord.no/cookies',
            en: 'https://www.postnord.no/en/cookies',
        },
        privacy: {
            no: 'https://www.postnord.no/personvernerklaering',
            en: 'https://www.postnord.se/en/privacy-policy',
        },
    },
    contact: 'https://portal.postnord.com/customerservice',
};

const translations$c = {
    cookies: {
        sv: 'Cookies',
        en: 'Cookies',
        da: 'Cookies',
        fi: 'Evästeet',
        no: 'Cookies',
    },
    questions: {
        sv: 'Undrar du över något?',
        en: 'Do you have any questions?',
        da: 'Har du nogen spørgsmål?',
        fi: 'Onko sinulla kysyttävää?',
        no: 'Har du noen spørsmål?',
    },
    contact: {
        sv: 'Kontakta oss',
        en: 'Get in touch',
        da: 'Kontakt os',
        fi: 'Ota yhteyttä',
        no: 'Ta kontakt',
    },
    info: {
        sv: 'Mer information om PostNord hittar du på',
        en: 'More information about PostNord can be found at',
        da: 'Mere information om PostNord findes på',
        fi: 'Lisää tietoa PostNordista löydät osoitteesta',
        no: 'Du finner mer informasjon om PostNord på',
    },
    privacy: {
        sv: 'Integritetspolicy',
        en: 'Privacy policy',
        da: 'Integritetspolitik',
        fi: 'Yksityisyysasetukset',
        no: 'Privacy policy',
    },
    terms: {
        sv: 'Villkor',
        en: 'Terms and conditions',
        da: 'Vilkår og betingelser',
        fi: 'Sopimusehdot',
        no: 'Betingelser og vilkår',
    },
};

const pnFooterCss = () => `${transformTag("pn-footer")}{color:#5e554a;padding-bottom:2em;display:block}${transformTag("pn-footer")} .pn-footer-row{padding:0.2em 0;font-size:0.9em;text-align:center}${transformTag("pn-footer")} .pn-footer-row p{margin:0 0.2em 0 0;display:inline-block}${transformTag("pn-footer")} ${transformTag("pn-text-link")}{margin-right:0.5em}${transformTag("pn-footer")} ${transformTag("pn-text-link")}:last-child{margin-right:0}`;

/**
 * The default market and language is SE/en.
 *
 * Make sure you set the market **and** language prop.
 * Example: Setting the `language` prop `da` will not display anything, as `da` does not exist on the `SE` market.
 *
 * @deprecated This component has been replaced with the pn-footer-nav.
 * @see {@link https://portal.postnord.com/web-components/?path=/docs/external-components-pn-footer-nav--docs pn-footer-nav}
 */
class PnFooter {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    get hostElement() { return getElement(this); }
    /** Set the market for the footer. */
    market = null;
    /** Set the language for the footer. */
    language = null;
    async componentWillLoad() {
        if (this.market && this.language)
            return;
        await awaitTopbar(this.hostElement);
    }
    getLink(name) {
        return URLS?.[this.market || SE]?.[name]?.[this.language || en$2];
    }
    getText(name) {
        if (name === 'domain')
            return this.getLink(name)?.replace('https://www.', '');
        return translations$c?.[name]?.[this.language];
    }
    renderLink(name) {
        const url = this.getLink(name);
        const text = this.getText(name);
        if (url && text) {
            return hAsync("pn-text-link", { label: text, target: "_blank", rel: "noopener noreferrer", href: url, icon: open_in_new });
        }
    }
    render() {
        return (hAsync(Host, { key: '61cf8e26fec57dff5d84b3bdbf6d72cb90dcf3c2' }, hAsync("div", { key: 'b796d5ac1f8755487ca528d9ebe6422b488ad211', class: "pn-footer-row" }, hAsync("p", { key: '9605f844d588bb9beecbdf8825de7062d2307b84' }, this.getText('questions')), this.renderLink('contact')), hAsync("div", { key: 'd9c7999ad9ba1590855037c1d9c3b660f8c6baf9', class: "pn-footer-row" }, this.market !== NO && this.renderLink('terms'), this.renderLink('privacy'), this.renderLink('cookies')), hAsync("div", { key: '2fbccb619a895f09f01e5d97c9530717fe5b38b1', class: "pn-footer-row" }, hAsync("p", { key: '9505adff1fb347f7eba8c7a4db771a7ba9b5a65c' }, this.getText('info')), this.renderLink('domain'))));
    }
    static get style() { return pnFooterCss(); }
    static get cmpMeta() { return {
        "$flags$": 512,
        "$tagName$": "pn-footer",
        "$members$": {
            "market": [1],
            "language": [1]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnHeaderCss = () => `${transformTag("pn-header")}{display:block}${transformTag("pn-header")} h1{color:#2d2013;margin:0}${transformTag("pn-header")} p{color:#5e554a;margin:0}${transformTag("pn-header")} .pn-header-breadcrumbs{width:100%}${transformTag("pn-header")} .pn-header-container{position:relative;width:100%;max-width:var(--max-width);margin:0 auto;padding:clamp(1em, 3vw, 2em) clamp(0.5em, 3vw, 2em);display:flex;flex-wrap:wrap;align-items:center;gap:1.5em}${transformTag("pn-header")} .pn-header-container>${transformTag("pn-text-link")}{display:block}${transformTag("pn-header")} .pn-header-content{flex:1 1 auto;display:flex;flex-direction:column;gap:1em}${transformTag("pn-header")} .pn-header [slot=buttons]{display:flex;flex-direction:column;gap:1em}`;

const translations$b = {
    sv: 'Tillbaka',
    en: 'Back',
    da: 'Tilbage',
    fi: 'Takaisin',
    no: 'Tilbake',
};
/**
 * The header component is a simple layout component used to display a page heading with optional text, buttons and tablist menu.
 *
 * @slot - The default slot is positioned below the heading and can be used to add additional text or elements.
 * @slot breadcrumb - This slot is reserved for a `pn-text-link` or another complex breadcrumb links structure.
 * Do not use this slot and the `go-back-href` prop at the same time.
 * @slot buttons - This slot is used to align multiple `pn-button` elements. However, we recommend a single button.
 * @slot menu - This slot is reserved for a `pn-tablist`.
 * This slot allows you to use the `href` prop on `pn-tab`, turning them into links instead of buttons.
 */
class PnHeader {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    mo;
    hasBreadcrumb = false;
    hasButtons = false;
    get hostElement() { return getElement(this); }
    /** The `h1` text content. */
    heading;
    /** Set a inner container max-width, any width CSS value is accepted.  */
    maxWidth;
    setMaxWidth() {
        if (!this.maxWidth)
            return;
        this.hostElement.style.setProperty('--max-width', this.maxWidth);
    }
    /** The href for the go back link. If this is provided a button be displayed. */
    goBackHref;
    /** The text for the back link. */
    goBackText;
    /** Set the language manually, only use this prop if the pnTopbar is not loaded. Supported: sv, en, da, fi and no. */
    language = null;
    connectedCallback() {
        this.mo = new MutationObserver(() => {
            this.checkSlots();
        });
        this.mo.observe(this.hostElement, { subtree: true, childList: true });
    }
    disconnectedCallback() {
        this.mo?.disconnect();
    }
    async componentWillLoad() {
        this.checkSlots();
        this.setMaxWidth();
        if (this.language === null)
            await awaitTopbar(this.hostElement);
    }
    checkSlots() {
        this.hasBreadcrumb = !!this.hostElement.querySelector('[slot="breadcrumb"]');
        this.hasButtons = !!this.hostElement.querySelector('[slot="buttons"]');
    }
    showBreadcrumb() {
        return this.hasBreadcrumb || !!this.goBackHref?.length;
    }
    getButtonText() {
        return this.goBackText || translations$b[this.language || en$2];
    }
    render() {
        return (hAsync(Host, { key: '82364cab3b3aece27e10f06e565b8ce0d6597f14' }, hAsync("header", { key: '368dfc4db49a8903c8cad81c9b161fe25095e2d1', class: "pn-header" }, hAsync("div", { key: 'f98b1ba196ed150cc27f9136f25ad46c31d7424e', class: "pn-header-container" }, hAsync("div", { key: '6c7465e8060690aa36a4e405f640cd23bfa0c0f2', class: "pn-header-breadcrumbs", hidden: !this.showBreadcrumb() }, this.goBackHref && (hAsync("pn-text-link", { key: 'd6dc1b2b5a22e80c95d42fadcd4912de1df35bb8', label: this.getButtonText(), href: this.goBackHref, icon: arrow_left, leftIcon: true })), hAsync("slot", { key: '44f163e4552a10f1340e51752bc2d825d74391ad', name: "breadcrumb" })), hAsync("div", { key: 'afb2d897acf67744c1a0eac4d5089f40bec07d40', class: "pn-header-content" }, this.heading && hAsync("h1", { key: '8135619a44048a4072453140f6bd0e4fb5e349aa' }, this.heading), hAsync("slot", { key: 'c013b74286636fd9ebfe575161ba8829d0eac903' })), hAsync("div", { key: '5942ae47d1426f033565d20f294a9e0906600dbb', class: "pn-header-buttons", hidden: !this.hasButtons }, hAsync("slot", { key: '287ff16c616bf76f832a867ad077d1f62a29d9e0', name: "buttons" })), hAsync("slot", { key: '7e9778bf8258cae60e27ceb3c1638f759ff02e82', name: "menu" })))));
    }
    static get watchers() { return {
        "maxWidth": [{
                "setMaxWidth": 0
            }]
    }; }
    static get style() { return pnHeaderCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-header",
        "$members$": {
            "heading": [1],
            "maxWidth": [1, "max-width"],
            "goBackHref": [1, "go-back-href"],
            "goBackText": [1, "go-back-text"],
            "language": [1]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const black = '#000000';
const gray900 = '#2d2013';
const gray700 = '#5e554a';
const gray400 = '#969087';
const gray200 = '#d3cecb';
const gray100 = '#e9e6e5';
const gray50 = '#f3f2f2';
const gray25 = '#f9f8f8';
const white = '#ffffff';
const blue900 = '#0d234b';
const blue700 = '#005d92';
const blue400 = '#00a0d6';
const blue200 = '#8eddf9';
const blue50 = '#e0f8ff';
const blue25 = '#effbff';
const coral900 = '#500715';
const coral700 = '#9b1c2e';
const coral400 = '#f06365';
const coral200 = '#fbc2c1';
const coral50 = '#fdefee';
const coral25 = '#fef7f6';
const orange900 = '#4f1600';
const orange700 = '#99290a';
const orange500 = '#ed7123';
const orange400 = '#f89142';
const orange200 = '#ffc8a3';
const orange50 = '#fff1e3';
const orange25 = '#fff8f1';
const green900 = '#002f24';
const green700 = '#005e41';
const green500 = '#0aa85c';
const green400 = '#5ec584';
const green200 = '#abe3bb';
const green50 = '#dcf6e7';
const green25 = '#edfbf3';
const warning = '#a70707';

var colors = /*#__PURE__*/Object.freeze({
  __proto__: null,
  black: black,
  blue200: blue200,
  blue25: blue25,
  blue400: blue400,
  blue50: blue50,
  blue700: blue700,
  blue900: blue900,
  coral200: coral200,
  coral25: coral25,
  coral400: coral400,
  coral50: coral50,
  coral700: coral700,
  coral900: coral900,
  gray100: gray100,
  gray200: gray200,
  gray25: gray25,
  gray400: gray400,
  gray50: gray50,
  gray700: gray700,
  gray900: gray900,
  green200: green200,
  green25: green25,
  green400: green400,
  green50: green50,
  green500: green500,
  green700: green700,
  green900: green900,
  orange200: orange200,
  orange25: orange25,
  orange400: orange400,
  orange50: orange50,
  orange500: orange500,
  orange700: orange700,
  orange900: orange900,
  warning: warning,
  white: white
});

const pnIconCss = () => `${transformTag("pn-icon")}{display:inline-block;vertical-align:top;--pn-icon-color:main.$gray900}${transformTag("pn-icon")} .pn-icon{margin:0}${transformTag("pn-icon")} .pn-icon svg{display:block;height:1.5em;width:1.5em}${transformTag("pn-icon")} .pn-icon svg>circle,${transformTag("pn-icon")} .pn-icon svg>path{fill:var(--pn-icon-color);transition-property:fill, transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-icon")} .pn-icon svg>circle,${transformTag("pn-icon")} .pn-icon svg>path{transition-duration:0s;transition-delay:0s}}${transformTag("pn-icon")} .pn-icon[data-small] svg{height:1em;width:1em}`;

/**
 * The `pn-icon` is a wrapper for an SVG string.
 * While its built with PostNords specific icon dimensions in mind (24x24px), you can use any SVG content in this component.
 * As long as its 3x3 in size, there should be no problem.
 *
 * The color feature will not overwrite the color of flags.
 **/
class PnIcon {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    get hostElement() { return getElement(this); }
    /**
     * The SVG content of the icon you want to use.
     * @see {@link https://portal.postnord.com/web-components/?path=/docs/components-design-tokens-icon--docs|Icons (Storybook)}
     * @see {@link https://portal.postnord.com/web-components/?path=/docs/components-design-tokens-flag--docs|Flags (Storybook)}
     **/
    icon = '';
    /** Make the icon small (16 instead of 24px). */
    small = false;
    /**
     * Color the icon with one of the following colors from our library.
     * Has no effects if you use flags from our library.
     * @see {@link https://portal.postnord.com/web-components/?path=/docs/components-design-tokens-colors--docs|Colors (Storybook)}
     **/
    color = 'gray900';
    handleColor() {
        const color = colors[this.color] || gray900;
        this.hostElement.style.setProperty('--pn-icon-color', color);
    }
    componentWillLoad() {
        this.handleColor();
    }
    render() {
        return (hAsync(Host, { key: 'f4d252ce71c0e0c83d352447bdd0c195de49196f' }, hAsync("span", { key: 'adc6e3dd5d4d45ed9a154f07bd3e3fce8dbf6981', role: "presentation", class: "pn-icon", "data-small": this.small, innerHTML: this.icon })));
    }
    static get watchers() { return {
        "color": [{
                "handleColor": 0
            }]
    }; }
    static get style() { return pnIconCss(); }
    static get cmpMeta() { return {
        "$flags$": 512,
        "$tagName$": "pn-icon",
        "$members$": {
            "icon": [1],
            "small": [4],
            "color": [1]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnIllustrationCss = () => `${transformTag("pn-illustration")}{display:inline-block}${transformTag("pn-illustration")} .pn-illustration{display:inline-block}${transformTag("pn-illustration")} .pn-illustration[data-fill]{display:block}${transformTag("pn-illustration")} .pn-illustration>svg{width:var(--pn-width);height:var(--pn-height);display:block}`;

/**
 * The `pn-illustration` is a wrapper for an SVG string.
 * The component will look at the viewBox property of the SVG to determine the default width and height,
 * but you can also set these manually with the `width` and `height` props.
 * Setting the `fill` prop will make the illustration fill its parent container, which is useful for responsive designs.
 */
class PnIllustration {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    get hostElement() { return getElement(this); }
    /** The SVG content of the illustration you want to use. The viewBox property will be used to determine width/height */
    illustration;
    /** Set the width of the SVG element. Any valid CSS width value is allowed */
    width;
    /** Set the height of the SVG element. Any valid CSS height value is allowed */
    height;
    /** Make the SVG fill to its parent size (sets width/height 100% and `display: block` instead of `inline-block`) */
    fill = false;
    handleFill() {
        if (this.fill) {
            this.width = '100%';
            this.height = '100%';
        }
    }
    componentWillRender() {
        this.handleFill();
        if (this.width || this.height)
            return this.setSizes();
        this.getSizeFromSvg();
    }
    componentDidRender() {
        this.hostElement.querySelector('svg')?.setAttribute('width', this.width);
        this.hostElement.querySelector('svg')?.setAttribute('height', this.height);
    }
    getSizeFromSvg() {
        const viewBox = this.illustration?.match(/<svg[^>]*?viewBox=(["\'])?((?:.(?!\1|>))*.?)\1?/)?.[2];
        if (!viewBox)
            return;
        const [, , width = '', height = ''] = viewBox?.split(' ') || [];
        if (!width || !height)
            return;
        this.width = `${Number(width)}px`;
        this.height = `${Number(height)}px`;
        this.setSizes();
    }
    setSizes() {
        this.hostElement.style.setProperty('--pn-width', this.width);
        this.hostElement.style.setProperty('--pn-height', this.height);
    }
    render() {
        return (hAsync(Host, { key: '30a6824eaa6972efee63b5f893defb80bac7821c' }, hAsync("span", { key: 'd27b45f1789b6c93d34ab0b1c673bda9fff60c0b', role: "presentation", class: "pn-illustration", "data-fill": this.fill, innerHTML: this.illustration })));
    }
    static get watchers() { return {
        "fill": [{
                "handleFill": 0
            }]
    }; }
    static get style() { return pnIllustrationCss(); }
    static get cmpMeta() { return {
        "$flags$": 512,
        "$tagName$": "pn-illustration",
        "$members$": {
            "illustration": [1],
            "width": [1025],
            "height": [1025],
            "fill": [4]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const translations$a = {
    SHOW: {
        sv: 'Visa',
        en: 'Show',
        da: 'At vise',
        fi: 'Näytä',
        no: 'Vise',
    },
    HIDE: {
        sv: 'Dölj',
        en: 'Hide',
        da: 'Skjule',
        fi: 'Piilottaa',
        no: 'Gjemme seg',
    },
    CLEAR: {
        sv: 'Rensa',
        en: 'Clear',
        da: 'Klar',
        fi: 'Asia selvä',
        no: 'Klar',
    },
};

const pnInputCss = () => `${transformTag("pn-input")}{display:inline-flex;flex-direction:column}${transformTag("pn-input")} .pn-input{--pn-input-offset-left:0em;--pn-input-offset-right:0em}${transformTag("pn-input")} .pn-input-label{cursor:pointer;display:flex;justify-content:space-between;align-items:flex-end;font-weight:400;color:#2d2013;margin:0 0 0.25em 0;gap:0.5em;-webkit-tap-highlight-color:transparent;transition-property:color, transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-input")} .pn-input-label{transition-duration:0s;transition-delay:0s}}${transformTag("pn-input")} .pn-input-label[data-compact]{position:absolute;top:1.5625em;left:calc(var(--pn-input-offset-left, 0px) + 0.75em + 0.0625em);margin:0;pointer-events:none;align-items:center;height:1.5em;max-width:calc(100% - (var(--pn-input-offset-left, 0px) + 0.75em) - (var(--pn-input-offset-right, 0px) + 0.75em));transform:translateY(-50%) scale(1) translateZ(0);transform-origin:0 0;transition-delay:0.2s}${transformTag("pn-input")} .pn-input-label[data-compact]>span{font-size:1em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;line-height:1.5em}${transformTag("pn-input")} .pn-input-label>span{font-size:0.875em}${transformTag("pn-input")} .pn-input-group{position:relative}${transformTag("pn-input")} .pn-input-element{width:100%;color:#2d2013;background-color:#ffffff;border:0.0625em solid #969087;border-radius:0.5em;padding:0.75em calc(0.75em + var(--pn-input-offset-right)) 0.75em calc(0.75em + var(--pn-input-offset-left));font-family:inherit;font-size:1em;font-weight:500;line-height:1.5em;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent}${transformTag("pn-input")} .pn-input-element:-webkit-autofill,${transformTag("pn-input")} .pn-input-element:-webkit-autofill:hover,${transformTag("pn-input")} .pn-input-element:-webkit-autofill:focus,${transformTag("pn-input")} .pn-input-element:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #e0f8ff inset;-webkit-text-fill-color:#2d2013}${transformTag("pn-input")} .pn-input-element{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-input")} .pn-input-element:focus-visible{outline-color:#005d92;background-color:#ffffff;border-color:#005d92}${transformTag("pn-input")} .pn-input-element{transition-property:outline-color, background-color, border-color, color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-input")} .pn-input-element{transition-duration:0s;transition-delay:0s}}${transformTag("pn-input")} .pn-input-element[data-compact]{text-align:left;padding-top:1.125em;padding-bottom:0.375em;max-width:unset}${transformTag("pn-input")} .pn-input-element[data-compact]::placeholder{color:transparent}${transformTag("pn-input")} .pn-input-element[data-compact]:focus+.pn-input-label,${transformTag("pn-input")} .pn-input-element[data-compact]:not(:placeholder-shown)+.pn-input-label{transform:translateY(-85%) scale(0.75);transition-delay:0s}${transformTag("pn-input")} .pn-input-element::placeholder{color:#5e554a;font-weight:normal}${transformTag("pn-input")} .pn-input-element:hover{border-color:#005d92}${transformTag("pn-input")} .pn-input-element:disabled{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2}${transformTag("pn-input")} .pn-input-element:read-only{border-color:#ffffff}${transformTag("pn-input")} .pn-input-element:disabled~.pn-input-eyecandy>${transformTag("pn-icon")} .pn-icon-svg>path{fill:#969087}${transformTag("pn-input")} .pn-input-element::-webkit-calendar-picker-indicator{visibility:hidden;display:none !important}${transformTag("pn-input")} .pn-input-element::-webkit-textfield-decoration-container,${transformTag("pn-input")} .pn-input-element::-webkit-search-cancel-button,${transformTag("pn-input")} .pn-input-element::-webkit-inner-spin-button,${transformTag("pn-input")} .pn-input-element::-webkit-outer-spin-button,${transformTag("pn-input")} .pn-input-element::-webkit-search-decoration{-webkit-appearance:none;-moz-appearance:none;appearance:none}${transformTag("pn-input")} .pn-input-element[type=number]{appearance:textfield}${transformTag("pn-input")} .pn-input-eyecandy{position:absolute;top:50%;transform:translateY(-50%);display:inline-flex;align-items:center;gap:0.5em;height:1.5em}${transformTag("pn-input")} .pn-input-eyecandy[data-prefix]{left:0.75em}${transformTag("pn-input")} .pn-input-eyecandy[data-suffix]{right:0.75em}${transformTag("pn-input")} .pn-input-text{color:#5e554a;font-weight:400;line-height:1.5em}${transformTag("pn-input")} .pn-input-message{color:#5e554a;font-size:0.875em;font-weight:400;margin:0.25em 0 0 0;display:flex;flex-direction:column;gap:0.25em}${transformTag("pn-input")} .pn-input-message[hidden],${transformTag("pn-input")} .pn-input-message>span[hidden]{display:none}${transformTag("pn-input")} .pn-input[data-error]>.pn-input-label{color:#a70707}${transformTag("pn-input")} .pn-input[data-error]>.pn-input-group>.pn-input-element{border-color:#a70707}${transformTag("pn-input")} .pn-input[data-error]>.pn-input-group>.pn-input-element:hover{border-color:#500715}${transformTag("pn-input")} .pn-input[data-error]>.pn-input-group>.pn-input-element:focus-visible{background-color:#ffffff;border-color:#a70707;outline-color:#a70707}${transformTag("pn-input")} .pn-input[data-error]>.pn-input-group>.pn-input-element:-webkit-autofill,${transformTag("pn-input")} .pn-input[data-error]>.pn-input-group>.pn-input-element:-webkit-autofill:hover,${transformTag("pn-input")} .pn-input[data-error]>.pn-input-group>.pn-input-element:-webkit-autofill:focus,${transformTag("pn-input")} .pn-input[data-error]>.pn-input-group>.pn-input-element:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #fef7f6 inset;-webkit-text-fill-color:#2d2013}${transformTag("pn-input")} .pn-input[data-error]>.pn-input-message[role=alert]{color:#a70707}${transformTag("pn-input")} .pn-input[data-valid]>.pn-input-label{color:#005e41}${transformTag("pn-input")} .pn-input[data-valid]>.pn-input-group>.pn-input-element{border-color:#005e41}${transformTag("pn-input")} .pn-input[data-valid]>.pn-input-group>.pn-input-element:hover{border-color:#002f24}${transformTag("pn-input")} .pn-input[data-valid]>.pn-input-group>.pn-input-element:focus-visible{background-color:#ffffff;border-color:#005e41;outline-color:#005e41}${transformTag("pn-input")} .pn-input[data-valid]>.pn-input-group>.pn-input-element:-webkit-autofill,${transformTag("pn-input")} .pn-input[data-valid]>.pn-input-group>.pn-input-element:-webkit-autofill:hover,${transformTag("pn-input")} .pn-input[data-valid]>.pn-input-group>.pn-input-element:-webkit-autofill:focus,${transformTag("pn-input")} .pn-input[data-valid]>.pn-input-group>.pn-input-element:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #edfbf3 inset;-webkit-text-fill-color:#2d2013}`;

/**
 * The `pn-input` is a regular `input` but styled. This means you can use native events to listen to the changes.
 * Always use the `label` prop to make sure the input is accessible.
 *
 * @nativeInput Use the `input` event to listen to content being modified by the user. It is emitted everytime a user writes or removes content in the input.
 * @nativeChange The `change` event is emitted when the input loses focus, the user clicks `Enter` or makes a selection (such as auto complete or suggestions).
 *
 * @slot helpertext - You can use this slot instead of the prop `helpertext`. Recommended, only if you need to include additional HTML markup.
 * Such as a `pn-text-link`. Use a `span` element to wrap the text and link. {@since v7.2.0}
 * @slot error - You can use this slot instead of the prop `error`. Recommended, only if you need to include additional HTML markup.
 * Such as a `pn-text-link`. Use a `span` element to wrap the text and link. {@since v7.2.0}
 */
class PnInput {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    id = `pn-input-${uuidv4()}`;
    idHelper = `${this.id}-helper`;
    idError = `${this.id}-error`;
    prefix;
    suffix;
    mo;
    get hostElement() { return getElement(this); }
    offsetLeft = 0;
    offsetRight = 0;
    showPassword = false;
    togglePassword() {
        this.showPassword = !this.showPassword;
    }
    /** Text label placed above the input field. */
    label;
    /** Text message placed underneath the input field. */
    helpertext;
    /**
     * Set the language manually for the translations of show/hide/clear button text.
     * Not needed if you have the pntopbar on the page.
     **/
    language = undefined;
    /** Set the value of the input. @category Native attributes */
    value = '';
    /** pn-input supports: `text`, `password`, `url`, `tel`, `search`, `number` & `email`. @category Native attributes */
    type = 'text';
    /**
     * HTML input name. Setting a name will help the browser understand what type of data the input have
     * and can better assist with autofill data based on previous entires much better.
     * @category Native attributes
     **/
    name;
    /**
     * Provide a placeholder text. Remember that this is no replacement for a label.
     * The placeholder should be a nice addition to the label/helpertext, not important information.
     *
     * @category Native attributes
     **/
    placeholder;
    /**
     * Let the browser know what type of autocorrects the input should use.
     * Works much better if a `name` and `pn-id` is supplied.
     * @see {@link name}
     * @see {@link inputid}
     *
     * @category Native attributes
     */
    autocomplete;
    /** The maximum number of characters the user should be able to add, also adds a visible counter. @category Native attributes */
    maxlength;
    /**
     * Hint the browser about what type of virtual keyboard should be used.
     * The browser will be able to decide this on its own most of the time,
     * especially if you use the `type`, `name` and `inputid` props.
     *
     * Leave empty or with a `''` value if you want the browsers default behaviour (`text`).
     *
     * @category Native attributes
     **/
    inputmode;
    /** Point to a datalist element for this input. @category Native attributes */
    list;
    /** Pattern prop. @category Native attributes */
    pattern;
    /** Set the `min` value of the `number` input. @category Native attributes */
    min;
    /** Set the `max` value of the `number` input. @category Native attributes */
    max;
    /** Set a `step` for the number input. @category Native attributes */
    step;
    /** Set the input as `required`. @category Native attributes */
    required = false;
    /** Set the input as `readonly`. @category Native attributes */
    readonly = false;
    /** Set the input as `disabled`. @category Native attributes */
    disabled = false;
    /**
     * Use the compact label variant. The `placeholder` you provide will not be visible if used at the same time.
     * @since v7.21.0
     * @category Features
     */
    compact = false;
    /**
     * Select an icon to display before the input field value.
     * `icon` takes precedence over the `text-prefix` prop.
     *
     * @see {@link textPrefix}
     * @category Features
     **/
    icon;
    /**
     * Set a small text before the input field value.
     * Cannot be used together with an `icon` at the same time.
     *
     * @see {@link icon}
     * @see {@link textSuffix}
     * @category Features
     **/
    textPrefix;
    /**
     * Set a small text after the input field value.
     * Cannot be used with the `text-prefix` prop at the same time.
     *
     * @see {@link textPrefix}
     * @category Features
     **/
    textSuffix;
    /** Set the input as `valid`. Provides a green color and a check icon. @category Features */
    valid = false;
    /**
     * Set the input as `invalid`. Provides a red color and red warning icon.
     * @see{@link error Provide an error message.}
     * @category Features
     **/
    invalid = false;
    /**
     * Set the input as `invalid` and display an error message (applies the same style as `invalid`).
     *
     * Error message; will take precedence over helpertext if both are provided.
     * @see{@link invalid Set invalid without an error message.}
     * @category Features
     **/
    error;
    /** Set a custom ID for the input (default is a generated UUID). @since v7.25.0 @category HTML attributes */
    pnId;
    /**
     * Provide the label via an aria attribute.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabel;
    /**
     * Provide the label from another element via its ID.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabelledby;
    /** Set the ID of what this input controls. @since v7.25.0 @category HTML attributes */
    pnAriaControls;
    /** Set a custom ID for the input (default is a generated UUID). @deprecated Use `pn-id` instead. @category HTML attributes */
    inputid;
    /** While you can use the `aria-label`, using a `label` is far more accessible. @deprecated Use `pn-aria-label` instead. @category HTML attributes */
    arialabel;
    /** Set the ID of what this input controls. @deprecated Use `pn-aria-controls` instead. @category HTML attributes */
    ariacontrols;
    handleOffset() {
        requestAnimationFrame(() => {
            const left = this.prefix?.clientWidth ? this.prefix.clientWidth + 8 : 0;
            const right = this.suffix?.clientWidth ? this.suffix.clientWidth + 8 : 0;
            this.offsetLeft = left;
            this.offsetRight = right;
        });
    }
    handleId() {
        this.idHelper = `${this.getId()}-helper`;
        this.idError = `${this.getId()}-error`;
    }
    connectedCallback() {
        this.mo = new MutationObserver(() => {
            this.handleOffset();
        });
        this.mo.observe(this.hostElement, { childList: true, subtree: true });
    }
    disconnectedCallback() {
        if (this.mo)
            this.mo.disconnect();
    }
    async componentWillLoad() {
        if (this.language === undefined)
            await awaitTopbar(this.hostElement);
    }
    componentDidLoad() {
        this.handleOffset();
    }
    getId() {
        return this.pnId || this.inputid || this.id;
    }
    setVal(event) {
        const target = event.composedPath?.()[0];
        this.value = target.value;
    }
    clearVal() {
        const inputClear = new InputEvent('input', { bubbles: true, data: '' });
        const input = this.hostElement.querySelector('input');
        this.value = '';
        input.focus();
        input.value = this.value;
        input.dispatchEvent(inputClear);
    }
    translate(prop) {
        return translations$a?.[prop]?.[this.language || en$2];
    }
    hasHelperText() {
        return this.helpertext?.length > 0 || this.checkSlottedHelper();
    }
    hasErrorMessage() {
        return this.error?.length > 0 || this.checkSlottedError();
    }
    /** If any error is active, either via the prop `invalid` or `error` prop/slot. */
    hasError() {
        return this.hasErrorMessage() || this.invalid;
    }
    hideHelpertext() {
        return this.hasErrorMessage() || !this.hasHelperText();
    }
    hideError() {
        return !this.hasErrorMessage();
    }
    checkSlottedHelper() {
        return !!this.hostElement.querySelector('[slot=helpertext]');
    }
    checkSlottedError() {
        return !!this.hostElement.querySelector('[slot=error]');
    }
    getInputType() {
        const types = ['text', 'password', 'url', 'tel', 'search', 'number', 'email'];
        return types.includes(this.type) && !this.showPassword ? this.type : 'text';
    }
    isPassword() {
        if (this.disabled)
            return false;
        return this.type === 'password' || (this.type === 'text' && this.showPassword);
    }
    passwordText() {
        return this.translate(this.showPassword ? 'HIDE' : 'SHOW');
    }
    /** Check if there is a valid or error state active. Returns false if neither is true. */
    displayState() {
        return this.valid || this.hasError();
    }
    /**
     * Returns the correct icon for the current state (valid or error).
     * Defaults to error icon.
     * @see {@link displayState}
     */
    stateIcon() {
        if (this.valid)
            return check;
        return alert_exclamation_circle;
    }
    /**
     * Returns the correct color for the validation icon. Defaults to red.
     * @see {@link displayState}
     */
    stateColor() {
        if (this.valid)
            return 'green700';
        return 'warning';
    }
    showPrefix() {
        return this.textPrefix && !this.icon;
    }
    showSuffix() {
        return !this.showPrefix() && !!this.textSuffix?.length && !this.isPassword() && this.type !== 'search';
    }
    showClear() {
        if (this.disabled || this.readonly)
            return false;
        return this.type === 'search' && !!this.value?.length;
    }
    validLabel() {
        return this.label?.length > 0 || this.maxlength >= 1;
    }
    useLabel() {
        return this.validLabel() && !this.compact;
    }
    /** Compact label must be positioned after the input element in order to work. */
    useCompactLabel() {
        return this.validLabel() && this.compact;
    }
    displayLabel() {
        return !!this.label;
    }
    getAriaLabel() {
        return !this.displayLabel() && !this.pnAriaLabelledby ? this.pnAriaLabel : null;
    }
    getAriaLabelledby() {
        return !this.displayLabel() && !(this.pnAriaLabel || this.arialabel) ? this.pnAriaLabelledby : null;
    }
    getAriaDescribedby() {
        if (this.hasErrorMessage())
            return this.idError;
        else if (this.hasHelperText())
            return this.idHelper;
        return null;
    }
    renderLabel() {
        return (hAsync("label", { htmlFor: this.getId(), class: "pn-input-label", "data-compact": this.compact }, this.label && hAsync("span", null, this.label), this.maxlength >= 0 && hAsync("span", null, `${this.value.length}/${this.maxlength}`)));
    }
    render() {
        return (hAsync(Host, { key: '800f4fb8490656e28657f7a4a041ba0c6dc46af2' }, hAsync("div", { key: '8defa078a3e541509bc17278751f8e59f59f3bd7', class: "pn-input", "data-valid": this.valid, "data-error": this.hasError(), style: {
                '--pn-input-offset-left': `${this.offsetLeft}px`,
                '--pn-input-offset-right': `${this.offsetRight}px`,
            } }, this.useLabel() && this.renderLabel(), hAsync("div", { key: 'dc01fb7fdb2a60ee89473f0152d833243be4ff8d', class: "pn-input-group" }, hAsync("input", { key: '32f63d4aa1c6edd2d10f8876ebd3371cff366eb7', type: this.getInputType(), id: this.getId(), class: "pn-input-element", name: this.name, placeholder: this.compact ? this.placeholder || ' ' : this.placeholder, autocomplete: this.autocomplete, maxlength: this.maxlength, list: this.list, pattern: this.pattern, min: this.min, max: this.max, step: this.step, value: this.value, inputmode: this.inputmode, disabled: this.disabled, required: this.required, readonly: this.readonly, "aria-label": this.getAriaLabel(), "aria-labelledby": this.getAriaLabelledby(), "aria-describedby": this.getAriaDescribedby(), "aria-controls": this.pnAriaControls || this.ariacontrols, "aria-invalid": this.hasError()?.toString(), "data-compact": this.compact, "data-value": this.value?.length > 0, onInput: e => this.setVal(e) }), this.useCompactLabel() && this.renderLabel(), hAsync("div", { key: 'b52d9bfa61569635f422fedc22edd09c768ab9d8', class: "pn-input-eyecandy", "data-prefix": true, ref: el => (this.prefix = el) }, !!this.icon && hAsync("pn-icon", { key: 'e5035273e663855094ba88ed0b485a4e8ffed56c', icon: this.icon, "aria-hidden": "true" }), this.showPrefix() && hAsync("span", { key: '1d0e5355c5dbfecf3dbb693589726a233e3b7df6', class: "pn-input-text" }, this.textPrefix)), hAsync("div", { key: 'e1faa82f19dcfdb6c427d5d2967bfb6694508675', class: "pn-input-eyecandy", "data-suffix": true, ref: el => (this.suffix = el) }, this.showSuffix() && hAsync("span", { key: '4c5ecf7c19bf64eea77b21b05d9ffe491bf4b91c', class: "pn-input-text" }, this.textSuffix), this.displayState() && hAsync("pn-icon", { key: 'f7014e0c31faf3c563c846e4a7061c6f4b35a64a', "aria-hidden": "true", icon: this.stateIcon(), color: this.stateColor() }), this.isPassword() && (hAsync("pn-button", { key: '21518c4f16245de370fcba302b177cfe04e91904', icon: this.showPassword ? preview_on : preview_off, iconOnly: true, arialabel: this.passwordText(), small: true, appearance: "light", variant: "borderless", onClick: () => this.togglePassword() })), this.showClear() && (hAsync("pn-button", { key: '60263a255ee8c8d3ed72ea89a26abfbe9be11d0d', icon: close, iconOnly: true, arialabel: this.translate('CLEAR'), small: true, appearance: "light", variant: "borderless", onClick: () => this.clearVal() })))), hAsync("p", { key: 'd23165556ffcdbfcf7229a04f5c1ea8686432c97', id: this.idHelper, class: "pn-input-message", hidden: this.hideHelpertext() }, !!this.helpertext && hAsync("span", { key: 'b7e31855d677953bbc7a4f65cb0b26a5eac8887b' }, this.helpertext), hAsync("slot", { key: 'a6bbaeceb31e2cc38d1e110b900e13b4f0957c6e', name: "helpertext" })), hAsync("p", { key: '3668fbc1a512f92d3f5a2c6f1f7d86cf04df148b', id: this.idError, class: "pn-input-message", role: "alert", hidden: this.hideError() }, !!this.error && hAsync("span", { key: 'c14fb6ab8e17c7d17813c83c0993f95d079f8274' }, this.error), hAsync("slot", { key: '75ba01e945315e6a3bbf2f5e5ac34c73fe7ab57f', name: "error" })))));
    }
    static get watchers() { return {
        "textPrefix": [{
                "handleOffset": 0
            }],
        "textSuffix": [{
                "handleOffset": 0
            }],
        "inputid": [{
                "handleId": 0
            }],
        "pnId": [{
                "handleId": 1
            }]
    }; }
    static get style() { return pnInputCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-input",
        "$members$": {
            "label": [1],
            "helpertext": [1],
            "language": [1],
            "value": [1025],
            "type": [1025],
            "name": [1],
            "placeholder": [1],
            "autocomplete": [1],
            "maxlength": [2],
            "inputmode": [1],
            "list": [1],
            "pattern": [1],
            "min": [8],
            "max": [8],
            "step": [8],
            "required": [4],
            "readonly": [4],
            "disabled": [4],
            "compact": [4],
            "icon": [1],
            "textPrefix": [1, "text-prefix"],
            "textSuffix": [1, "text-suffix"],
            "valid": [4],
            "invalid": [4],
            "error": [1],
            "pnId": [1, "pn-id"],
            "pnAriaLabel": [1, "pn-aria-label"],
            "pnAriaLabelledby": [1, "pn-aria-labelledby"],
            "pnAriaControls": [1, "pn-aria-controls"],
            "inputid": [1],
            "arialabel": [1],
            "ariacontrols": [1],
            "offsetLeft": [32],
            "offsetRight": [32],
            "showPassword": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnInputChipCss = () => `${transformTag("pn-input-chip")}{display:inline-block}${transformTag("pn-input-chip")} .pn-input-chip{position:relative;font-size:1em;font-weight:500;text-align:center;display:flex;align-items:center;gap:0.25em;padding:0.5em 0.5em 0.5em 1em;border:0.0625em solid #969087;border-radius:0.5em;background-color:#ffffff;cursor:pointer;transition-property:border-color, background-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-input-chip")} .pn-input-chip{transition-duration:0s;transition-delay:0s}}${transformTag("pn-input-chip")} .pn-input-chip{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-input-chip")} .pn-input-chip[data-icon]{padding-left:0.75em}${transformTag("pn-input-chip")} .pn-input-chip[data-icon][data-small]{padding-left:0.5em}${transformTag("pn-input-chip")} .pn-input-chip[data-icon][data-large]{padding-left:1em}${transformTag("pn-input-chip")} .pn-input-chip[data-small]{padding:0.25em 0.25em 0.25em 0.75em}${transformTag("pn-input-chip")} .pn-input-chip[data-small] .pn-input-chip-label{line-height:1.25em;font-size:0.875em}${transformTag("pn-input-chip")} .pn-input-chip[data-large]{padding:0.6875em 0.6875em 0.6875em 1.25em}${transformTag("pn-input-chip")} .pn-input-chip:hover{background-color:#effbff;border-color:#005d92}${transformTag("pn-input-chip")} .pn-input-chip:hover .pn-input-chip-label{color:#005d92}${transformTag("pn-input-chip")} .pn-input-chip:hover .pn-input-chip-icon .pn-icon-svg path{fill:#005d92}${transformTag("pn-input-chip")} .pn-input-chip:focus-visible{outline-color:#005d92;border-color:#005d92}${transformTag("pn-input-chip")} .pn-input-chip:active{background-color:#e0f8ff;border-color:#005d92}${transformTag("pn-input-chip")} .pn-input-chip:active .pn-input-chip-label{color:#0d234b}${transformTag("pn-input-chip")} .pn-input-chip:active .pn-input-chip-icon .pn-icon-svg path{fill:#0d234b}${transformTag("pn-input-chip")} .pn-input-chip:disabled{background-color:#f3f2f2;border-color:#f3f2f2;cursor:not-allowed}${transformTag("pn-input-chip")} .pn-input-chip:disabled .pn-input-chip-label{color:#5e554a;margin-right:0.5em}${transformTag("pn-input-chip")} .pn-input-chip:disabled .pn-input-chip-icon .pn-icon-svg path{fill:#5e554a}${transformTag("pn-input-chip")} .pn-input-chip-icon{flex-shrink:0;width:1.5em;height:1.5em}${transformTag("pn-input-chip")} .pn-input-chip-label{color:#005d92;line-height:1.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}${transformTag("pn-input-chip")} .pn-input-chip-close{flex-shrink:0;width:1.5em;height:1.5em;display:flex;align-items:center;justify-content:center}`;

/**
 * The `pn-input-chip` represents a confirmed user input value that can be removed.
 * It is visually similar to the `pn-choice-chip` but its only action is deletion.
 * Clicking anywhere on the chip removes it.
 */
class PnInputChip {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.pnDelete = createEvent(this, "pnDelete", 7);
    }
    id = `pn-input-chip-${uuidv4()}`;
    /** The chip label text. */
    label;
    /** Optional value identifier emitted with the delete event. @category Native attributes */
    value;
    /** Add a leading icon to the chip. @category Features */
    icon;
    /** Use the small size for the input chip. @category Features */
    small = false;
    /** Use the large size for the input chip. @category Features */
    large = false;
    /** Disable the chip. When disabled, the chip is not interactive. @category Native attributes */
    disabled = false;
    /** Emitted when the chip is clicked (removed). */
    pnDelete;
    /**
     * A unique HTML ID for the input chip.
     * @category HTML attributes
     */
    pnId;
    handleDelete = () => {
        if (!this.disabled) {
            this.pnDelete.emit({ label: this.label, value: this.value });
        }
    };
    getId() {
        return this.pnId || this.id;
    }
    render() {
        return (hAsync(Host, { key: '38bf6d618ac176e63fc2da44b20aa45b744c3ff8' }, hAsync("button", { key: '43a8fa2b75eedefef49ce8881c72e86cf1323486', type: "button", class: "pn-input-chip", id: this.getId(), "data-icon": !!this.icon, "data-small": this.small, "data-large": this.large, disabled: this.disabled, "aria-label": `Remove ${this.label}`, onClick: this.handleDelete }, !!this.icon && hAsync("pn-icon", { key: '53b015eba2c0a074febc78089bcdefc9cb799ad1', class: "pn-input-chip-icon", icon: this.icon }), hAsync("span", { key: '0baa4ef7ebe84ac5102f295c02ad3f0e08a6516e', class: "pn-input-chip-label" }, this.label), !this.disabled && hAsync("pn-icon", { key: '320c04a05bb38411734a77c085bd536c29296423', color: "blue700", icon: close_small }))));
    }
    static get style() { return pnInputChipCss(); }
    static get cmpMeta() { return {
        "$flags$": 512,
        "$tagName$": "pn-input-chip",
        "$members$": {
            "label": [1],
            "value": [513],
            "icon": [1],
            "small": [4],
            "large": [4],
            "disabled": [4],
            "pnId": [1, "pn-id"]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": [["value", "value"]]
    }; }
}

const translations$9 = {
    CLOSE_MODAL: {
        en: 'Close dialog',
        sv: 'Stäng dialogrutan',
        da: 'Luk dialogboks',
        fi: 'Sulje valintaikkuna',
        no: 'Lukk dialogboksen',
    },
};

const pnModalCss = () => `${transformTag("pn-modal")} .pn-modal{--pn-modal-max-width:45em;z-index:10000;position:fixed;top:0;inset-block-start:0;inset-block-end:0;margin:auto;padding:0;max-width:var(--pn-modal-max-width);overflow:hidden;border:0;border-radius:1.5em;box-shadow:0 0.25em 0.875em rgba(0, 0, 0, 0.18), 0 1.625em 3.5em rgba(0, 0, 0, 0.22);background-color:#ffffff;display:none;opacity:0;transform:translate(0%, 20%);outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-modal")} .pn-modal:focus-visible{outline-color:#ffffff}${transformTag("pn-modal")} .pn-modal{transition-property:opacity, overlay, display, transform, outline-color, border-radius;transition-duration:0.4s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-modal")} .pn-modal{transition-duration:0s;transition-delay:0s}}${transformTag("pn-modal")} .pn-modal{transition-behavior:allow-discrete}${transformTag("pn-modal")} .pn-modal[data-allow-overflow]{overflow:unset}${transformTag("pn-modal")} .pn-modal[data-allow-overflow] .pn-modal-container{overflow:unset}${transformTag("pn-modal")} .pn-modal[data-allow-overflow] .pn-modal-picture{border-top-right-radius:1.5em}${transformTag("pn-modal")} .pn-modal[data-image]{padding-top:0}${transformTag("pn-modal")} .pn-modal[data-sheet]{margin:0 0 0 auto;height:100%;max-height:unset;border-radius:1.5em 0 0 1.5em;transform:translate(20%, 0%)}${transformTag("pn-modal")} .pn-modal[data-sheet] .pn-modal-container{max-height:unset}${transformTag("pn-modal")} .pn-modal[open]{display:flex;opacity:1;transform:translate(0%, 0%)}@starting-style{${transformTag("pn-modal")} .pn-modal[open]{display:flex;opacity:0;transform:translate(0%, 20%)}}${transformTag("pn-modal")} .pn-modal[open][data-sheet]{transform:translate(0%, 0%)}@starting-style{${transformTag("pn-modal")} .pn-modal[open][data-sheet]{transform:translate(20%, 0%)}}${transformTag("pn-modal")} .pn-modal::backdrop{background-color:rgba(0, 0, 0, 0);transition-property:opacity, background-color, overlay, display;transition-duration:0.4s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-modal")} .pn-modal::backdrop{transition-duration:0s;transition-delay:0s}}${transformTag("pn-modal")} .pn-modal::backdrop{transition-behavior:allow-discrete}${transformTag("pn-modal")} .pn-modal[open]::backdrop{background-color:rgba(0, 0, 0, 0.55)}@starting-style{${transformTag("pn-modal")} .pn-modal[open]::backdrop{background-color:rgba(0, 0, 0, 0)}}${transformTag("pn-modal")} .pn-modal-container{max-height:85vh;display:flex;flex-direction:column;align-items:stretch;overflow:hidden auto}${transformTag("pn-modal")} .pn-modal-container::-webkit-scrollbar{background-color:#ffffff;width:0.875em;border-radius:0.5em}${transformTag("pn-modal")} .pn-modal-container::-webkit-scrollbar-track{background-color:#ffffff;border-radius:0.5em}${transformTag("pn-modal")} .pn-modal-container::-webkit-scrollbar-thumb{cursor:pointer;background-color:#969087;border-radius:1em;border:0.25em solid #ffffff}${transformTag("pn-modal")} .pn-modal-container::-webkit-scrollbar-thumb:hover{background-color:#5e554a}${transformTag("pn-modal")} .pn-modal-container::-webkit-scrollbar-corner,${transformTag("pn-modal")} .pn-modal-container::-webkit-scrollbar-button{display:none}${transformTag("pn-modal")} .pn-modal-close-button{position:absolute;z-index:10;right:0.75em;top:0.75em}${transformTag("pn-modal")} .pn-modal-header{display:flex;flex-direction:column;gap:0.5em;padding:clamp(1em, 5vw, 1.5em)}${transformTag("pn-modal")} .pn-modal-header[hidden]{display:none}${transformTag("pn-modal")} .pn-modal-header:not([hidden])+.pn-modal-content:not([hidden]){padding-top:0}${transformTag("pn-modal")} .pn-modal-label{line-height:1.5;padding-right:1.5em;margin:0}${transformTag("pn-modal")} .pn-modal-text{margin:0}${transformTag("pn-modal")} .pn-modal-content{padding:clamp(1em, 5vw, 1.5em)}${transformTag("pn-modal")} .pn-modal-image{position:relative;display:flex;flex-direction:column}${transformTag("pn-modal")} .pn-modal-image[hidden]{display:none}${transformTag("pn-modal")} .pn-modal-picture{margin:0;padding:0;display:block;overflow:hidden;border-radius:1.5em 0 0 0}${transformTag("pn-modal")} .pn-modal-picture>*[slot=image]{display:block;height:100%;width:100%;object-fit:cover}${transformTag("pn-modal")} .pn-modal-buttons{background-color:#ffffff;padding:clamp(1em, 5vw, 1.5em);display:flex;justify-content:flex-end;gap:0.5em;border-radius:0 0 1.5em 1.5em}${transformTag("pn-modal")} .pn-modal-buttons[data-divider]{border-top:0.0625em solid #d3cecb;margin-top:auto}${transformTag("pn-modal")} .pn-modal-buttons>[slot=buttons]:not(${transformTag("pn-button")}){display:flex;justify-content:flex-end;gap:0.5em}${transformTag("pn-modal")} .pn-modal-buttons>[slot=buttons]:not(${transformTag("pn-button")})>[data-left]{margin-right:auto}${transformTag("pn-modal")} .pn-modal-buttons>[data-left]{margin-right:auto}${transformTag("pn-modal")} .pn-modal-buttons:empty{display:none}@media (max-width: 55em){${transformTag("pn-modal")} .pn-modal{max-height:95vh;margin-bottom:0;bottom:0;transform:translate(0%, 20%);border-bottom-left-radius:0;border-bottom-right-radius:0}}`;

/**
 * Present content in a modal that overlays everything on the current page.
 * Use the prop `open` to toggle the visiblity.
 * Use the event `modalToggle` to determine when the modal is being closed/opened by the user.
 *
 * @slot - The default slot, will be placed in the middle content area.
 * @slot image - Place an image or illustration at the top of the modal. {@since v7.15.0}
 * @slot header - Place the title + lead text in the header. {@since v7.14.0}
 * @slot buttons - Place buttons inside the modal at the bottom.
 * pn-buttons aligns automatically to the right, set the data-left attribute on the button you want to align to the left.
 */
class PnModal {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.modalToggle = createEvent(this, "modalToggle", 7);
        this.modalVisibility = createEvent(this, "modalVisibility", 7);
        this.modalVisiblity = createEvent(this, "modalVisiblity", 7);
        this.close = createEvent(this, "close", 7);
    }
    mo;
    standardAnimationDuration = 400;
    animationDuration = this.standardAnimationDuration;
    modalTimeout;
    modalElement;
    modalContainer;
    modalPicture;
    get hostElement() { return getElement(this); }
    isClosing = false;
    isOpening = false;
    /** If true, the modal content will remove overflow CSS property. */
    removeOverflow = false;
    /** Set a label for the modal. @since v7.14.0 */
    label;
    /** Set a descriptive text for the modal. @since v7.14.0 */
    helpertext;
    /** Set the language. @since v7.14.0 */
    language = null;
    /** Set a custom HTML id. @since v7.24.0 */
    pnId = null;
    /** Use this prop if you want to control the visibility of the modal programmatically. @category Features */
    open = false;
    /**
     * Prevent users from closing the modal by clicking on the backdrop or the `ESC` key.
     * @since v7.14.0
     * @category Features
     */
    persistent = false;
    /**
     * Hide the close button. If you enable this, make sure you build your own cancel button.
     * @since v7.14.0
     * @category Features
     */
    hideClose = false;
    /**
     * Allow overflow *when* it is possible.
     * Do not use if you have a lot of conditional rendering inside the modal as it can cause layout shifts.
     * @since v7.14.0
     * @category Features
     */
    allowOverflow = false;
    /**
     * Use the `sheet` visual. Aligns the modal to the right instead of the center.
     * @since v7.14.0
     * @category Visual
     */
    sheet = false;
    /**
     * Define your own max width of the modal. Default is `45em`.
     * @category Visual
     * @since v7.14.0
     */
    maxWidth = null;
    handleOpen() {
        if (this.open)
            this.openModal();
        else {
            this.closeModal();
            /** In the next update, we can remove this one so you can finally stack modals. */
            this.close.emit(true);
        }
        this.handleOverflow();
        clearTimeout(this.modalTimeout);
        this.isClosing = !this.open && true;
        if (reduceMotion())
            this.animationDuration = 0;
        else
            this.animationDuration = this.standardAnimationDuration;
        this.modalTimeout = setTimeout(() => {
            this.isClosing = false;
            /** @todo remove in v8.0.0 */
            this.modalVisiblity.emit({ visible: this.open });
            this.modalVisibility.emit({ visible: this.open });
        }, this.animationDuration);
    }
    handleMaxWidth() {
        const width = this.maxWidth || '45em';
        this.modalElement.style.setProperty('--pn-modal-max-width', width);
    }
    handleOverflow() {
        if (this.allowOverflow)
            this.setOverflow();
    }
    /** This event is fired when the modal is toggled. {@since v7.14.0} */
    modalToggle;
    /** This event is dispatched after the opening/closing animation has finished playing. {@since v7.22.0} */
    modalVisibility;
    /**
     * This event is dispatched after the opening/closing animation has finished playing.
     * @since v7.14.0
     * @deprecated v7.22.0. Use `modalVisibility` instead due to typo.
     */
    modalVisiblity;
    /**
     * Event fired when the modal is closed, either by clicking on the dark background or by clicking on the close button.
     * @deprecated Use the new `modalToggle` event instead.
     */
    close;
    connectedCallback() {
        this.mo = new MutationObserver(() => forceUpdate());
        this.mo.observe(this.hostElement, { childList: true, subtree: true });
    }
    disconnectedCallback() {
        if (this.mo)
            this.mo.disconnect();
    }
    async componentWillLoad() {
        if (this.language === null)
            await awaitTopbar(this.hostElement);
    }
    componentDidLoad() {
        this.handleMaxWidth();
        if (this.open)
            this.openModal();
    }
    translate(prop) {
        return translations$9?.[prop]?.[this.language || en$2] || prop;
    }
    showImage() {
        return !!this.modalPicture?.innerHTML;
    }
    showHeader() {
        return !!(this.label || this.helpertext || this.hostElement.querySelector('[slot="header"]')?.textContent);
    }
    setOverflow() {
        this.removeOverflow = !this.hasOverflow();
    }
    hasOverflow() {
        const multiplyWith = isSmallScreen() ? 0.95 : 0.85;
        return this.modalContainer?.scrollHeight > innerHeight * multiplyWith;
    }
    isSameModal(target) {
        return this.modalElement.isSameNode(target);
    }
    handleKeyboard(event) {
        if (event.key !== 'Escape')
            return;
        event.preventDefault();
        event.stopImmediatePropagation();
        if (!this.persistent)
            this.setModalClose();
    }
    clickModalBackground(event) {
        const { clientY, clientX } = event;
        const notInsideAnyModal = event.target.localName !== this.modalElement.localName;
        const notThisModal = !this.isSameModal(event.target);
        if (notInsideAnyModal || notThisModal)
            return;
        const { top, left, height, width } = this.modalElement.getBoundingClientRect();
        const isInModal = top <= clientY && clientY <= top + height && left <= clientX && clientX <= left + width;
        if (!isInModal && !this.persistent)
            this.toggleOpen(false);
    }
    setModalClose() {
        this.toggleOpen(false);
    }
    closeModal() {
        this.modalElement.close();
    }
    openModal() {
        this.modalElement.showModal();
    }
    toggleOpen(state) {
        this.open = state ?? !this.open;
    }
    render() {
        return (hAsync(Host, { key: '5b50fca359ed20cebcbdead766d08c2439463b4c' }, hAsync("dialog", { key: '43eb7bb4f09c6ce9a665f7478f25b1ae4a253562', id: this.pnId, class: "pn-modal", "data-closing": this.isClosing, "data-sheet": this.sheet, "data-image": this.showImage(), "data-allow-overflow": this.removeOverflow, onClose: () => this.setModalClose(), onCancel: () => this.setModalClose(), onToggle: () => this.modalToggle.emit({ open: this.open }), onKeyDown: event => this.handleKeyboard(event), onClick: event => this.clickModalBackground(event), ref: el => (this.modalElement = el) }, !this.hideClose && (hAsync("pn-button", { key: '0bdc665fe32c8531edb073166fe8940d12360661', small: true, class: "pn-modal-close-button", icon: close, iconOnly: true, arialabel: this.translate('CLOSE_MODAL'), appearance: "light", variant: "borderless", type: "button", onPnClick: () => this.setModalClose() })), hAsync("div", { key: 'ce9529f76b572f6681e1b75528bcab67e3246dbd', class: "pn-modal-container", ref: el => (this.modalContainer = el) }, hAsync("div", { key: 'a2addec74c8af3fc9084a0d6faba9053a255bf86', class: "pn-modal-image", hidden: !this.showImage() }, hAsync("picture", { key: '4341ae13d01268cc0f9df74bf417522116bed2d9', class: "pn-modal-picture", ref: el => (this.modalPicture = el) }, hAsync("slot", { key: '99a643af231cdcd76ad2dafbcdbaf4fbabac5390', name: "image" }))), hAsync("header", { key: '849eea60adcfb7c3bbba8687dc49edf752004617', class: "pn-modal-header", hidden: !this.showHeader() }, this.label && hAsync("h2", { key: 'e57185ebd04cd622ceca5acb81c6606747afa6f9', class: "pn-modal-label" }, this.label), this.helpertext && hAsync("p", { key: '2e0290387a2b96f3eb70db67dd7ac349c5c4fe9e', class: "pn-modal-text" }, this.helpertext), hAsync("slot", { key: 'e05316839bfc8883a2e8f4c5079054e9edcd3859', name: "header" })), hAsync("section", { key: 'd59b818c18159c106df1f6c3b2b3f747f1b6af29', class: "pn-modal-content" }, hAsync("slot", { key: 'c740eb0b7909c9fa5878caecb66887f5bb9b2b73' })), hAsync("nav", { key: '22971631737901988e27f4f01c311d2d76839c6a', class: "pn-modal-buttons", "data-divider": this.sheet }, hAsync("slot", { key: '3c0e8e66db96d8abc8f718270d94e09b2ad90320', name: "buttons" }))))));
    }
    static get watchers() { return {
        "open": [{
                "handleOpen": 0
            }],
        "maxWidth": [{
                "handleMaxWidth": 0
            }]
    }; }
    static get style() { return pnModalCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-modal",
        "$members$": {
            "label": [1],
            "helpertext": [1],
            "language": [1],
            "pnId": [1, "pn-id"],
            "open": [1540],
            "persistent": [4],
            "hideClose": [4, "hide-close"],
            "allowOverflow": [4, "allow-overflow"],
            "sheet": [4],
            "maxWidth": [1, "max-width"],
            "isClosing": [32],
            "isOpening": [32],
            "removeOverflow": [32]
        },
        "$listeners$": [[9, "resize", "handleOverflow"]],
        "$lazyBundleId$": "-",
        "$attrsToReflect$": [["open", "open"]]
    }; }
}

const translations$8 = {
    SELECT_AN_OPTION: {
        en: 'Select an option',
        sv: 'Välj ett alternativ',
        da: 'Vælg en mulighed',
        fi: 'Valitse vaihtoehto',
        no: 'Velg et alternativ',
    },
    SELECT_ALL_OPTIONS: {
        en: 'Select all options',
        sv: 'Välj alla alternativ',
        da: 'Vælg alle muligheder',
        fi: 'Valitse kaikki vaihtoehdot',
        no: 'Velg alle alternativer',
    },
    SELECT_FOUND_OPTIONS: {
        en: 'Select {number} options',
        sv: 'Välj {number} alternativ',
        da: 'Vælg {number} muligheder',
        fi: 'Valitse {number} vaihtoehtoa',
        no: 'Velg {number} alternativer',
    },
    SELECTED_OPTIONS: {
        en: 'Selected options.',
        sv: 'Valda alternativ.',
        da: 'Valgte muligheder.',
        fi: 'Valitut vaihtoehdot.',
        no: 'Valgte alternativer.',
    },
    BUTTON_OPEN: {
        en: 'Open list',
        sv: 'Öppna listan',
        da: 'Open list',
        fi: 'Open list',
        no: 'Open list',
    },
    BUTTON_CLOSE: {
        en: 'Close list',
        sv: 'Stäng listan',
        da: 'Close list',
        fi: 'Close list',
        no: 'Close list',
    },
    REMOVE: {
        en: 'Remove',
        sv: 'Ta bort',
        da: 'Remove',
        fi: 'Remove',
        no: 'Remove',
    },
    REMOVED: {
        en: 'Removed',
        sv: 'Tog bort',
        da: 'Fjernet',
        fi: 'Poistettu',
        no: 'Fjernet',
    },
    MORE_OPTION: {
        en: 'more option.',
        sv: 'alternativ till.',
        da: 'mulighed mere.',
        fi: 'vaihtoehto lisää.',
        no: 'alternativ til.',
    },
    MORE_OPTIONS: {
        en: 'more options.',
        sv: 'fler alternativ.',
        da: 'more options.',
        fi: 'more options.',
        no: 'more options.',
    },
    SEARCH: {
        en: 'Search',
        sv: 'Sök',
        da: 'Søg',
        fi: 'Hae',
        no: 'Søk',
    },
    RESULTS_FOUND: {
        en: 'options found',
        sv: 'alternativ hittades',
        da: 'muligheder fundet',
        fi: 'vaihtoehtoja löytyi',
        no: 'alternativer funnet',
    },
    NO_SEARCH_RESULTS: {
        en: 'No options found',
        sv: 'Inga alternativ hittades',
        da: 'Ingen muligheder fundet',
        fi: 'Vaihtoehtoja ei löytynyt',
        no: 'Finner ingen alternativer',
    },
    NO_OPTIONS: {
        en: 'No options available',
        sv: 'Inga alternativ tillgängliga',
        da: 'Ingen tilgængelige muligheder',
        fi: 'Ei vaihtoehtoja',
        no: 'Ingen tilgjengelige alternativer',
    },
};

const pnMultiselectCss = () => `${transformTag("pn-multiselect")}{display:inline-block}${transformTag("pn-multiselect")} .pn-multiselect{position:relative;border:0;margin:0;padding:0}${transformTag("pn-multiselect")} .pn-multiselect[data-icon]{--pn-input-offset-left:2em}${transformTag("pn-multiselect")} .pn-multiselect[data-icon] .pn-multiselect-element{padding-left:2.75em}${transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-label{color:#a70707}${transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-label[data-compact]{color:#2d2013}${transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-element{padding-right:5.5em;border-color:#a70707}${transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-element:hover{border-color:#500715}${transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-element:focus-visible{background-color:#ffffff;border-color:#a70707;outline-color:#a70707}${transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-element:-webkit-autofill,${transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-element:-webkit-autofill:hover,${transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-element:-webkit-autofill:focus,${transformTag("pn-multiselect")} .pn-multiselect[data-error] .pn-multiselect-element:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #fef7f6 inset;-webkit-text-fill-color:#2d2013}${transformTag("pn-multiselect")} .pn-multiselect-label{width:100%;cursor:pointer;display:flex;justify-content:space-between;align-items:flex-end;font-weight:400;color:#2d2013;margin:0 0 0.25em 0;gap:0.5em;-webkit-tap-highlight-color:transparent;transition-property:color, transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-multiselect")} .pn-multiselect-label{transition-duration:0s;transition-delay:0s}}${transformTag("pn-multiselect")} .pn-multiselect-label[data-compact]{position:absolute;top:1.5625em;left:calc(var(--pn-input-offset-left, 0px) + 0.75em + 0.0625em);margin:0;pointer-events:none;align-items:center;height:1.5em;max-width:calc(100% - (var(--pn-input-offset-left, 0px) + 0.75em) - (var(--pn-input-offset-right, 0px) + 0.75em));transform:translateY(-50%) scale(1) translateZ(0);transform-origin:0 0;transition-delay:0.2s}${transformTag("pn-multiselect")} .pn-multiselect-label[data-compact]>span{font-size:1em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;line-height:1.5em}${transformTag("pn-multiselect")} .pn-multiselect-label>span{font-size:0.875em}${transformTag("pn-multiselect")} .pn-multiselect-label[data-compact]{justify-content:start}${transformTag("pn-multiselect")} .pn-multiselect-sr-only{position:absolute;height:1px;width:1px;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);margin:-1px;white-space:nowrap}${transformTag("pn-multiselect")} .pn-multiselect-group{position:relative;padding:0;margin:0}${transformTag("pn-multiselect")} .pn-multiselect-input{position:relative}${transformTag("pn-multiselect")} .pn-multiselect-input>${transformTag("pn-icon")}{pointer-events:none;position:absolute;top:0.75em;right:3.5em}${transformTag("pn-multiselect")} .pn-multiselect-input>${transformTag("pn-icon")}[data-custom]{left:0.75em;right:unset}${transformTag("pn-multiselect")} .pn-multiselect-button{cursor:pointer;position:absolute;right:0.75em;top:50%;transform:translateY(-50%);padding:0;margin:0;border:0;width:2em;height:2em;font-size:1em;border-radius:50%;background-color:transparent;-webkit-tap-highlight-color:transparent;transition-property:background-color, outline-color, border-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-multiselect")} .pn-multiselect-button{transition-duration:0s;transition-delay:0s}}${transformTag("pn-multiselect")} .pn-multiselect-button{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-multiselect")} .pn-multiselect-button:focus-visible{outline-color:#005d92;background-color:#ffffff;border-color:#005d92}${transformTag("pn-multiselect")} .pn-multiselect-button>${transformTag("pn-icon")} svg>path{transition-delay:0.2s;transform-origin:center;transform:rotate(0deg)}${transformTag("pn-multiselect")} .pn-multiselect-button:hover{background-color:#effbff}${transformTag("pn-multiselect")} .pn-multiselect-button[aria-expanded=true]{background-color:#effbff}${transformTag("pn-multiselect")} .pn-multiselect-button[aria-expanded=true]>${transformTag("pn-icon")} svg>path{transform:rotate(180deg);transition-delay:0s}${transformTag("pn-multiselect")} .pn-multiselect-element{cursor:text;text-align:left;transition-delay:0.1s, 0.1s, 0s;width:100%;display:flex;align-items:center;justify-content:space-between;gap:0.5em;overflow:hidden;text-overflow:ellipsis;color:#2d2013;background-color:#ffffff;border:0.0625em solid #969087;border-radius:0.5em;padding:0.75em 3.5em 0.75em 0.75em;font-family:inherit;font-size:1em;font-weight:500;line-height:1.5em;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent}${transformTag("pn-multiselect")} .pn-multiselect-element:-webkit-autofill,${transformTag("pn-multiselect")} .pn-multiselect-element:-webkit-autofill:hover,${transformTag("pn-multiselect")} .pn-multiselect-element:-webkit-autofill:focus,${transformTag("pn-multiselect")} .pn-multiselect-element:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #e0f8ff inset;-webkit-text-fill-color:#2d2013}${transformTag("pn-multiselect")} .pn-multiselect-element{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-multiselect")} .pn-multiselect-element:focus-visible{outline-color:#005d92;background-color:#ffffff;border-color:#005d92}${transformTag("pn-multiselect")} .pn-multiselect-element{transition-property:outline-color, background-color, border-color, color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-multiselect")} .pn-multiselect-element{transition-duration:0s;transition-delay:0s}}${transformTag("pn-multiselect")} .pn-multiselect-element[data-compact]{text-align:left;padding-top:1.125em;padding-bottom:0.375em;max-width:unset}${transformTag("pn-multiselect")} .pn-multiselect-element[data-compact]::placeholder{color:transparent}${transformTag("pn-multiselect")} .pn-multiselect-element[data-compact]:focus+.pn-multiselect-label,${transformTag("pn-multiselect")} .pn-multiselect-element[data-compact]:not(:placeholder-shown)+.pn-multiselect-label{transform:translateY(-85%) scale(0.75);transition-delay:0s}${transformTag("pn-multiselect")} .pn-multiselect-element::placeholder{color:#5e554a;font-weight:normal}${transformTag("pn-multiselect")} .pn-multiselect-element:hover{border-color:#005d92}${transformTag("pn-multiselect")} .pn-multiselect-element:disabled{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2}${transformTag("pn-multiselect")} .pn-multiselect-element:disabled{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2;pointer-events:none}${transformTag("pn-multiselect")} .pn-multiselect-element:disabled+.pn-multiselect-button{pointer-events:none}${transformTag("pn-multiselect")} .pn-multiselect-element:disabled+.pn-multiselect-button path{fill:#5e554a}${transformTag("pn-multiselect")} .pn-multiselect-element:placeholder{color:#5e554a;font-weight:normal}${transformTag("pn-multiselect")} .pn-multiselect-element[type=input]:hover{cursor:pointer;color:#2d2013;background-color:#effbff;transition-delay:0s}${transformTag("pn-multiselect")} .pn-multiselect-element[type=input]:hover[aria-invalid=true]{background-color:#fdefee}${transformTag("pn-multiselect")} .pn-multiselect-element:focus-visible{transition-delay:0s}${transformTag("pn-multiselect")} .pn-multiselect-element::-webkit-search-cancel-button,${transformTag("pn-multiselect")} .pn-multiselect-element::-webkit-search-decoration{-webkit-appearance:none;-moz-appearance:none;appearance:none}${transformTag("pn-multiselect")} .pn-multiselect-options{scroll-behavior:smooth;position:absolute;z-index:10;top:calc(100% + 0.5em);left:0;right:0;background-color:#ffffff;box-shadow:0em 0.075em 0.225em 0em rgba(0, 0, 0, 0.1), 0em 0.4em 0.9em 0em rgba(0, 0, 0, 0.13);border-radius:0.5em;list-style:none;margin:0;padding:0;width:clamp(100%, 95vw, 20em);max-height:var(--pn-select-max-height);overflow-y:auto;overflow-x:hidden;display:flex;flex-direction:column;visibility:hidden;transform-origin:top left;transform:translateX(var(--pn-select-options-offset, 0))}${transformTag("pn-multiselect")} .pn-multiselect-options[data-open]{visibility:visible}${transformTag("pn-multiselect")} .pn-multiselect-options[data-upwards]{top:unset;bottom:calc(100% + 0.5em);transform-origin:bottom left;box-shadow:0 -0.0625em 0.125em rgba(0, 0, 0, 0.2)}${transformTag("pn-multiselect")} .pn-multiselect-options[data-moving]{overflow:hidden;visibility:visible}${transformTag("pn-multiselect")} .pn-multiselect-options::-webkit-scrollbar{background-color:#ffffff;width:0.875em;border-radius:0.5em}${transformTag("pn-multiselect")} .pn-multiselect-options::-webkit-scrollbar-track{background-color:#ffffff;border-radius:0.5em}${transformTag("pn-multiselect")} .pn-multiselect-options::-webkit-scrollbar-thumb{cursor:pointer;background-color:#969087;border-radius:1em;border:0.25em solid #ffffff}${transformTag("pn-multiselect")} .pn-multiselect-options::-webkit-scrollbar-thumb:hover{background-color:#5e554a}${transformTag("pn-multiselect")} .pn-multiselect-options::-webkit-scrollbar-corner,${transformTag("pn-multiselect")} .pn-multiselect-options::-webkit-scrollbar-button{display:none}${transformTag("pn-multiselect")} .pn-multiselect-options>${transformTag("pn-input")}{padding:0.5em}${transformTag("pn-multiselect")} .pn-multiselect-optgroup{list-style:none;padding:0}${transformTag("pn-multiselect")} .pn-multiselect-optgroup>.pn-multiselect-option>.pn-multiselect-option-content{padding-left:2em}${transformTag("pn-multiselect")} .pn-multiselect-chips{list-style:none;display:flex;flex-wrap:wrap;gap:0.5em;padding:0;margin:0.5em 0 0 0;color:#5e554a;font-weight:400}${transformTag("pn-multiselect")} .pn-multiselect-chips:empty{display:none}${transformTag("pn-multiselect")} .pn-multiselect-chip{margin:0;display:inline-flex;align-items:center;gap:0.25em;background-color:#ffffff;border-radius:0.5em;padding:0.125em 0.25em 0.125em 0.5em;line-height:1.5em;border:0.0625em solid #5e554a;outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:background-color, outline-color, border-color, color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-multiselect")} .pn-multiselect-chip{transition-duration:0s;transition-delay:0s}}${transformTag("pn-multiselect")} .pn-multiselect-chip:focus-within{color:#005d92;outline-color:#005d92;background-color:#effbff;border-color:#005d92}${transformTag("pn-multiselect")} .pn-multiselect-chip[data-count]{pointer-events:none;border:0;padding-left:0;padding-right:0;background-color:unset}${transformTag("pn-multiselect")} .pn-multiselect-chip-label{font-size:0.875em;white-space:nowrap}${transformTag("pn-multiselect")} .pn-multiselect-chip-button{cursor:pointer;font-size:1em;padding:0.25em;height:1.5em;width:1.5em;border:0;background-color:unset;border-radius:50%;-webkit-tap-highlight-color:transparent;transition-property:background-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-multiselect")} .pn-multiselect-chip-button{transition-duration:0s;transition-delay:0s}}${transformTag("pn-multiselect")} .pn-multiselect-chip-button:hover{background-color:#8eddf9}${transformTag("pn-multiselect")} .pn-multiselect-chip-button:focus{outline:0}${transformTag("pn-multiselect")} .pn-multiselect-no-results{margin:0;padding:0.75em}${transformTag("pn-multiselect")} .pn-multiselect-text{color:#5e554a;font-size:0.875em;font-weight:400;margin:0.25em 0 0 0;display:flex;flex-direction:column;gap:0.25em}${transformTag("pn-multiselect")} .pn-multiselect-text[hidden]{display:none}${transformTag("pn-multiselect")} .pn-multiselect-text[role=alert]{color:#a70707}${transformTag("pn-multiselect")} .pn-multiselect-option{position:relative;margin:0;padding:0}${transformTag("pn-multiselect")} .pn-multiselect-option .pn-ripple{animation:ripple 0.4s cubic-bezier(0.7, 0, 0.3, 1);position:absolute;border-radius:50%;background-color:#005d92;transform:translate(-50%, -50%) scale(0);opacity:0.1;pointer-events:none;z-index:3}@keyframes ripple{to{transform:translate(-50%, -50%) scale(1);opacity:0}}${transformTag("pn-multiselect")} .pn-multiselect-option-input{cursor:pointer;position:absolute;opacity:0;left:0;top:0;height:100%;width:100%;margin:0;-webkit-tap-highlight-color:transparent}${transformTag("pn-multiselect")} .pn-multiselect-option-input:disabled{pointer-events:none}${transformTag("pn-multiselect")} .pn-multiselect-option-input:disabled+.pn-multiselect-option-content{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2;pointer-events:none}${transformTag("pn-multiselect")} .pn-multiselect-option-input:disabled+.pn-multiselect-option-content .pn-multiselect-option-checkbox{background-color:#f3f2f2;border-color:#969087}${transformTag("pn-multiselect")} .pn-multiselect-option-input:disabled+.pn-multiselect-option-content .pn-icon-svg path{fill:#5e554a}${transformTag("pn-multiselect")} .pn-multiselect-option-input:disabled:checked+.pn-multiselect-option-content{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2}${transformTag("pn-multiselect")} .pn-multiselect-option-input:disabled:checked+.pn-multiselect-option-content .pn-multiselect-option-checkbox{background-color:#969087;border-color:#969087}${transformTag("pn-multiselect")} .pn-multiselect-option-input:disabled:checked+.pn-multiselect-option-content .pn-icon-svg path{fill:#5e554a}${transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]+.pn-multiselect-option-content .pn-multiselect-option-checkbox{border-color:#a70707}${transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]+.pn-multiselect-option-content .pn-ripple{background-color:#a70707}${transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:checked+.pn-multiselect-option-content{background-color:#fdefee}${transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:checked+.pn-multiselect-option-content .pn-multiselect-option-checkbox{background-color:#a70707;border-color:#a70707}${transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:checked:focus-visible+.pn-multiselect-option-content{background-color:#fdefee}${transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:checked:focus-visible+.pn-multiselect-option-content .pn-multiselect-option-checkbox{background-color:#500715;border-color:#500715}${transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:checked:hover+.pn-multiselect-option-content{background-color:#fef7f6}${transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:checked:hover+.pn-multiselect-option-content .pn-multiselect-option-checkbox{background-color:#500715;border-color:#500715}${transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:hover+.pn-multiselect-option-content{background-color:#fef7f6}${transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:hover+.pn-multiselect-option-content .pn-multiselect-option-checkbox{background-color:#fdefee;border-color:#a70707}${transformTag("pn-multiselect")} .pn-multiselect-option-input[aria-invalid=true]:focus-visible+.pn-multiselect-option-content .pn-multiselect-option-checkbox{outline-color:#a70707;background-color:#fdefee;border-color:#a70707}${transformTag("pn-multiselect")} .pn-multiselect-option-input:hover+.pn-multiselect-option-content{background-color:#effbff}${transformTag("pn-multiselect")} .pn-multiselect-option-input:hover+.pn-multiselect-option-content .pn-multiselect-option-checkbox{border-color:#005d92;background-color:#e0f8ff}${transformTag("pn-multiselect")} .pn-multiselect-option-input:focus-visible+.pn-multiselect-option-content .pn-multiselect-option-checkbox{outline-color:#005d92;background-color:#e0f8ff;border-color:#005d92}${transformTag("pn-multiselect")} .pn-multiselect-option-input:checked+.pn-multiselect-option-content{background-color:#e0f8ff}${transformTag("pn-multiselect")} .pn-multiselect-option-input:checked+.pn-multiselect-option-content .pn-multiselect-option-checkbox{border-color:#005d92;background-color:#005d92}${transformTag("pn-multiselect")} .pn-multiselect-option-input:checked+.pn-multiselect-option-content .pn-multiselect-option-checkbox svg polyline.pn-multiselect-option-checkbox-checkmark-path{transition-delay:0.2s;stroke-dashoffset:0}${transformTag("pn-multiselect")} .pn-multiselect-option-input:checked:hover+.pn-multiselect-option-content{background-color:#effbff}${transformTag("pn-multiselect")} .pn-multiselect-option-input:checked:hover+.pn-multiselect-option-content .pn-multiselect-option-checkbox{border-color:#0d234b;background-color:#0d234b}${transformTag("pn-multiselect")} .pn-multiselect-option-input:checked:focus-visible+.pn-multiselect-option-content{background-color:#e0f8ff}${transformTag("pn-multiselect")} .pn-multiselect-option-input:checked:focus-visible+.pn-multiselect-option-content .pn-multiselect-option-checkbox{border-color:#0d234b;background-color:#0d234b}${transformTag("pn-multiselect")} .pn-multiselect-option-input:indeterminate+.pn-multiselect-option-content .pn-multiselect-option-checkbox{background-color:#005d92;border-color:#005d92}${transformTag("pn-multiselect")} .pn-multiselect-option-input:indeterminate+.pn-multiselect-option-content svg .pn-multiselect-option-checkbox-checkmark-path{stroke-dashoffset:23}${transformTag("pn-multiselect")} .pn-multiselect-option-input:indeterminate+.pn-multiselect-option-content svg .pn-multiselect-option-checkbox-indeterminate-path{stroke-dashoffset:0}${transformTag("pn-multiselect")} .pn-multiselect-option-input:indeterminate:hover+.pn-multiselect-option-content .pn-multiselect-option-checkbox{background-color:#0d234b;border-color:#0d234b}${transformTag("pn-multiselect")} .pn-multiselect-option-content{position:relative;overflow:hidden;z-index:-1;display:flex;align-items:center;padding:0.75em 1em;gap:0.5em;background-color:#ffffff;transition-property:background-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-multiselect")} .pn-multiselect-option-content{transition-duration:0s;transition-delay:0s}}${transformTag("pn-multiselect")} .pn-multiselect-option-text{flex:1;text-overflow:ellipsis;overflow:hidden}${transformTag("pn-multiselect")} .pn-multiselect-option-helper{color:#5e554a;margin:0}${transformTag("pn-multiselect")} .pn-multiselect-option-checkbox{background-color:#ffffff;flex:0 0 1.5em;width:1.5em;height:1.5em;border:0.0625em solid #969087;border-radius:0.25em;outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:background-color, border-color, outline-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-multiselect")} .pn-multiselect-option-checkbox{transition-duration:0s;transition-delay:0s}}${transformTag("pn-multiselect")} .pn-multiselect-option-checkbox svg polyline{stroke:#ffffff;stroke-linecap:round;stroke-dasharray:23;transition-delay:0s;transition-property:stroke-dashoffset;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-multiselect")} .pn-multiselect-option-checkbox svg polyline{transition-duration:0s;transition-delay:0s}}${transformTag("pn-multiselect")} .pn-multiselect-option-checkbox svg polyline.pn-multiselect-option-checkbox-checkmark-path{stroke-dashoffset:23}${transformTag("pn-multiselect")} .pn-multiselect-option-checkbox svg polyline.pn-multiselect-option-checkbox-indeterminate-path{stroke-dashoffset:23}`;

/**
 * The `pn-multiselect` gets its options via javascript.
 *
 * Native HTML does not accept arrays of objects. Most frameworks solves this automatically (Vue, react, etc...),
 * but keep this in mind if you use this component outside of a framework environment.
 *
 * @nativeChange The `pn-multiselect` is built with `input[type=checkbox]` elements, so the `change` event works. However, we recommend the customEvents described above.
 *
 * @slot helpertext - You can use this slot instead of the prop `helpertext`. Recommended, only if you need to include additional HTML markup. Such as a `pn-text-link`. Use a `span` element to wrap the text and link. {@since v7.25.0}
 * @slot error - You can use this slot instead of the prop `error`. Recommended, only if you need to include additional HTML markup. Such as a `pn-text-link`. Use a `span` element to wrap the text and link. {@since v7.25.0}
 *
 * @see {@link https://portal.postnord.com/web-components/?path=/docs/components-input-multiselect--docs#pn-multiselect%20(options) Options documentation}
 */
class PnMultiselect extends Mixin(animateHeightFactory) {
    constructor(hostRef) {
        super();
        registerInstance(this, hostRef);
        this.toggleSelect = createEvent(this, "toggleSelect", 7);
        this.allOptions = createEvent(this, "allOptions", 7);
        this.selectedOption = createEvent(this, "selectedOption", 7);
        this.selectedAllOptions = createEvent(this, "selectedAllOptions", 7);
        this.searchInput = createEvent(this, "searchInput", 7);
    }
    id = `pn-multiselect-${uuidv4()}`;
    idLegend = `${this.id}-legend`;
    idButton = `${this.id}-button`;
    idOptions = `${this.id}-options`;
    idHelper = `${this.id}-text`;
    idError = `${this.id}-error`;
    idChips = `${this.id}-chips`;
    idSr = `${this.id}-sr`;
    elGroup;
    elButton;
    elInput;
    elList;
    elChips;
    srTimer;
    get hostElement() { return getElement(this); }
    isSearching = false;
    /** Layout state. */
    open = false;
    upwards = false;
    srMessage;
    /** Label placed above the select */
    label;
    /** Display a helper text underneath the select */
    helpertext;
    /** Manually set the language, not needed if you have the pnTopbar available */
    language = undefined;
    /** HTML name of the checkbox elements. Used for each checkbox inside the multiselect. @category Native attributes */
    name;
    /** HTML name of the input element. @category Native attributes*/
    selectName;
    /**
     * This is what will be shown on load if no value is used.
     * The `placeholder` will override the default text used if you have the `search` prop active.
     * @category Native attributes
     */
    placeholder;
    /** Set the select as required. @category Native attributes */
    required = false;
    /** Disable the select. @category Native attributes */
    disabled = false;
    /**
     * The array of `PnMultiselectOption` objects.
     * @see {@link PnMultiselectOption} for the option object properties.
     * @category Features
     **/
    options;
    /** Set the date picker label as compact. If used, the `placeholder` will no longer be displayed. @since v7.21.0 @category Features */
    compact = false;
    /** Display an icon to the left of the select input @category Features */
    icon;
    /**
     * Adds a "Select all" option into the list.
     * If you use the search feature at the same time, clicking this option will only toggle the options found.
     * @see {@link search}
     * @category Features
     **/
    selectAll = false;
    /**
     * Set a custom value for the "Select all value" option.
     * @see {@link selectAll}
     * @category Features
     */
    allValue = 'pn_multiselect_all';
    /**
     * Allow the user to search among the options.
     * The selected options will now display underneath the multiselect element.
     *
     * @category Features
     **/
    search = false;
    /** Set the search query of the multiselect.
     *
     * @see {@link search}
     * @category Features
     */
    searchQuery = '';
    /**
     * Decide how many items should be shown before ellipsis. Requires the `search` prop to work.
     *
     * @see {@link search}
     * @category Features
     **/
    itemCount = 5;
    /**
     * The component will automatically set the max height of the dropdown list on its own.
     * It takes the `pn-topbar` into account and will open in the direction that fits best.
     * Use this prop to override this behaviour and use a custom max-height.
     * @category Features
     **/
    maxHeight;
    /**
     * Force the dropdown to always open upwards.
     * @category Features
     **/
    top = false;
    /**
     * Force the dropdown to always open downwards.
     * @category Features
     **/
    bottom = false;
    /** Trigger the invalid state. @category Features */
    invalid = false;
    /** Display an error message and trigger the invalid state. @category Features */
    error;
    /** Set a custom ID for the select. @since v7.25.0 @category HTML attributes */
    pnId;
    /**
     * Provide the label via an aria attribute.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabel;
    /**
     * Provide the label from another element via its ID.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabelledby;
    /** Select HTML id @deprecated Use `pn-id` instead. @category HTML attributes */
    selectId;
    handleOpen() {
        if (this.open) {
            this.addGlobalEventListeners();
            this.handleDirection();
            this.handleMaxHeight();
            this.handleOffset();
        }
        else {
            this.removeGlobalEventListeners();
        }
        this.dropdownHandler();
    }
    handleSearch() {
        if (!this.search)
            this.options = [
                ...this.options.map(option => {
                    const item = {
                        ...option,
                        hide: false,
                    };
                    if (item?.group?.length)
                        item.group.map(opt => ({ ...opt, hide: false }));
                    return item;
                }),
            ];
    }
    handleSearchQuery() {
        if (this.search && typeof this.searchQuery === 'string')
            this.handleInputSearch();
    }
    handleSelectId() {
        const id = this.getId();
        this.idLegend = `${id}-legend`;
        this.idButton = `${id}-button`;
        this.idOptions = `${id}-options`;
        this.idHelper = `${id}-text`;
        this.idError = `${id}-error`;
        this.idChips = `${id}-chips`;
        this.idSr = `${id}-sr`;
    }
    /**
     * If the select is open and you resize the window.
     * Remove all css props and disable the animations entierly.
     **/
    handleResize() {
        if (!this.open)
            return;
        this.toggleOpen(false);
        this.elGroup.style.removeProperty('--pn-select-max-height');
        this.elGroup.style.removeProperty('--pn-select-options-offset');
    }
    /** Dispatched everytime the multiselect is opened or closed. */
    toggleSelect;
    /** This event contains the entire options array with the new props. Dispatched everytime you make changes to any option. */
    allOptions;
    /** Dispatched when you toggle an option. Includes all the props of the option. */
    selectedOption;
    /**
     * This event is dispatched when the user toggles the "Choose all options" box.
     * Also triggers when you click the "Select {number} options" if you are performing a search at the same time.
     **/
    selectedAllOptions;
    /**
     * Contains the search text and the options found for that query.
     * Dispacthed everytime you change the search query.
     **/
    searchInput;
    async componentWillLoad() {
        if (this.language === undefined)
            await awaitTopbar(this.hostElement);
    }
    componentDidLoad() {
        if (!!this.searchQuery?.length)
            this.handleSearchQuery();
    }
    getId() {
        return this.pnId || this.selectId || this.id;
    }
    hasHelperText() {
        return this.helpertext?.length > 0 || this.checkSlottedHelper();
    }
    /** If any `error` text is present, either via prop/slot. */
    hasErrorMessage() {
        return this.error?.length > 0 || this.checkSlottedError();
    }
    /** If any `error` is active, either via the prop `invalid` or `error` prop/slot. */
    hasError() {
        return this.hasErrorMessage() || this.invalid;
    }
    checkSlottedHelper() {
        return !!this.hostElement.querySelector('[slot=helpertext]');
    }
    checkSlottedError() {
        return !!this.hostElement.querySelector('[slot=error]');
    }
    hideHelpertext() {
        return this.hasErrorMessage() || !this.hasHelperText();
    }
    hideError() {
        return !this.hasErrorMessage();
    }
    globalEvents = (event) => {
        const target = event.target;
        if (!this.hostElement.contains(target) || event?.key === 'Escape') {
            this.toggleOpen(false);
        }
    };
    addGlobalEventListeners() {
        const root = this.hostElement.getRootNode();
        root.addEventListener('click', this.globalEvents);
    }
    removeGlobalEventListeners() {
        const root = this.hostElement.getRootNode();
        root.removeEventListener('click', this.globalEvents);
    }
    dropdownHandler() {
        if (this.open)
            this.openDropdown(this.elList);
        else
            this.closeDropdown(this.elList);
    }
    emitEvents(option, all) {
        this.allOptions.emit(this.options);
        if (option)
            return this.selectedOption.emit(option);
        const data = {
            checked: all,
            searching: this.isSearching,
        };
        if (this.search && this.optionsTotal() !== this.optionsSearch().length) {
            data.query = this.searchQuery;
            data.found = this.optionsSearch();
        }
        this.selectedAllOptions.emit(data);
    }
    optionsChecked() {
        const list = this.options?.reduce((sum, item) => {
            const subgroup = item.group ? [...item.group.filter(({ checked }) => checked)] : [];
            if (item.checked)
                sum.push(item);
            if (subgroup?.length)
                sum.push(...subgroup);
            return sum;
        }, []);
        return list;
    }
    optionsTotal() {
        return this.options?.reduce((sum, item) => sum + (item?.group?.length ? item.group.length + 1 : 1), 0);
    }
    optionsIndex(val) {
        const findNested = ({ group = [] }) => group?.findIndex(({ value }) => value === val);
        const indexGroup = this.options.findIndex(option => option.value === val || findNested(option) !== -1);
        const indexNested = findNested(this.options?.[indexGroup]);
        return {
            indexGroup,
            indexNested,
        };
    }
    optionsCheckedTotal() {
        return this.optionsChecked()?.length;
    }
    optionsCheckedPreview() {
        return this.optionsChecked()?.slice(0, this.itemCount);
    }
    optionsCheckedLabels() {
        return this.optionsChecked()
            ?.map(({ label }) => label)
            ?.join(', ')
            ?.trim();
    }
    optionsSearch() {
        const list = this.options?.reduce((sum, item) => {
            const subgroup = item.group ? [...item.group.filter(({ hide }) => !hide)] : [];
            if (!item.hide)
                sum.push(item);
            if (subgroup?.length)
                sum.push(...subgroup);
            return sum;
        }, []);
        return list;
    }
    noResults() {
        return this.optionsSearch()?.length === 0;
    }
    isIndeterminate(groupIndex) {
        const option = this.options?.[groupIndex];
        if (option?.group?.length) {
            const all = option.group.every(({ checked }) => checked);
            const none = option.group.every(({ checked }) => !checked);
            return !(all || none);
        }
        return false;
    }
    optionSelect({ val, checked, chip }) {
        if (val === this.allValue)
            return this.optionSelectAll(checked);
        const options = this.options;
        const { indexGroup, indexNested } = this.optionsIndex(val);
        const group = options[indexGroup]?.group;
        const nested = group?.[indexNested];
        if (nested?.value) {
            options[indexGroup].group[indexNested].checked = checked;
            const allSiblingsChecked = group?.every(({ checked }) => checked);
            if (allSiblingsChecked)
                options[indexGroup].checked = true;
            else
                options[indexGroup].checked = false;
        }
        else {
            options[indexGroup].checked = checked;
            if (group?.length)
                options[indexGroup].group = group?.map(opt => ({ ...opt, checked: checked }));
        }
        const option = indexNested === -1 ? options[indexGroup] : options[indexGroup].group[indexNested];
        this.emitEvents(option);
        this.options = [...options];
        if (typeof chip === 'number') {
            this.handleSrMesssage(`${this.translate('REMOVED')} ${option.label}`);
            requestAnimationFrame(() => {
                const index = chip === this.optionsCheckedTotal() ? chip - 1 : chip;
                const btn = Array.from(this.elChips.children)?.[index];
                btn?.querySelector('button').focus({ preventScroll: true });
            });
        }
    }
    optionSelectAll(checked) {
        this.options = [
            ...this.options.map(option => {
                const opt = {
                    ...option,
                    checked: this.isSearching ? (option.hide ? option.checked : checked) : checked,
                };
                if (opt.group)
                    opt.group = [
                        ...opt.group.map(item => ({
                            ...item,
                            checked: this.isSearching ? (item.hide ? item.checked : checked) : checked,
                        })),
                    ];
                const allChecked = opt?.group?.every(({ checked }) => checked);
                if (opt?.group?.length)
                    opt.checked = allChecked;
                return opt;
            }),
        ];
        this.emitEvents(null, checked);
    }
    optionSelected(val) {
        return !!this.optionsChecked()?.find(({ value, checked }) => value === val && checked);
    }
    translate(prop) {
        const text = translations$8?.[prop]?.[this.language || en$2];
        if (text.includes('{number}'))
            return text.replace('{number}', this.optionsSearch().length);
        return text;
    }
    getRect(element) {
        return element?.getBoundingClientRect();
    }
    ripple({ clientX, clientY, target }) {
        const isKeyboard = clientX === 0 && clientY === 0;
        const element = target.nextElementSibling;
        const { x, width, y, top } = this.getRect(element);
        const clientCor = isKeyboard ? { clientX: x + width - 24, clientY: y - top } : { clientX, clientY };
        ripple(clientCor, element);
    }
    handleSrMesssage(text) {
        this.srMessage = text;
        clearTimeout(this.srTimer);
        this.srTimer = setTimeout(() => (this.srMessage = null), 2000);
    }
    handleDirection() {
        if (this.top)
            return (this.upwards = true);
        if (this.bottom)
            return (this.upwards = false);
        const { bottom, top } = this.getRect(this.elInput);
        const oneEm = 16;
        /*
         * Take the inner window height and subtract the elements bottom and 1em (16px)
         * If the max height of this calculation is less than the space above the element, open it upwards.
         * Do another calculation with the top value - 1em.
         */
        const offsetTop = window.innerHeight - bottom - oneEm;
        const offsetBottom = top - oneEm;
        /** Always point downwards, unless the space to the bottom is less than half of the top offset space. */
        this.upwards = offsetBottom / 2 > offsetTop;
    }
    handleMaxHeight() {
        if (this.maxHeight)
            return this.elGroup.style.setProperty('--pn-select-max-height', this.maxHeight);
        const { bottom, top } = this.getRect(this.elInput);
        const inputHeight = this.upwards ? top : bottom;
        const offsetTop = getTotalHeightOffset();
        const offset = this.upwards ? offsetTop + 16 : 16;
        const maxHeight = this.upwards ? inputHeight - offset : window.innerHeight - inputHeight - offset;
        this.elGroup.style.setProperty('--pn-select-max-height', `${Math.ceil(maxHeight)}px`);
    }
    handleOffset() {
        this.elGroup.style.removeProperty('--pn-select-options-offset');
        requestAnimationFrame(() => {
            const { left, right } = this.getRect(this.elList);
            const menuWidth = getMenuWidth();
            const leftBoundary = menuWidth + 8;
            const rightBoundary = window.innerWidth - 8;
            let offset = 0;
            if (left < leftBoundary)
                offset = leftBoundary - left;
            else if (right > rightBoundary)
                offset = rightBoundary - right;
            if (offset !== 0)
                this.elGroup.style.setProperty('--pn-select-options-offset', `${Math.floor(offset)}px`);
        });
    }
    setFocus() {
        if (this.search)
            this.elInput.focus({ preventScroll: true });
        else
            this.elButton.focus({ preventScroll: true });
    }
    toggleOpen(state) {
        if (typeof state === 'boolean' && state === this.open)
            return;
        this.open = state ?? !this.open;
        this.toggleSelect.emit({ open: this.open });
    }
    handleInputKeyboard(event) {
        event.stopImmediatePropagation();
        const { code } = event;
        if (code === 'Escape')
            return this.toggleOpen(false);
        if (!this.open && code.match(/^(Space|Enter)$|Arrow|^Key.*$/))
            this.toggleOpen();
    }
    setSearchQuery(value) {
        if (!this.open)
            this.toggleOpen(true);
        this.searchQuery = value;
    }
    handleInputSearch() {
        if (this.isEmpty())
            return;
        const term = this.searchQuery;
        const performSearch = ({ label, helpertext, value }) => {
            return `${label} ${helpertext} ${value}`.trim().toLowerCase().includes(term.toLowerCase());
        };
        const options = this.options.map(option => {
            const foundNested = option?.group?.map(item => ({ ...item, hide: !performSearch(item) })) || [];
            const found = performSearch(option) || foundNested?.some(({ hide }) => !hide);
            option.hide = !found;
            if (option?.group?.length)
                option.group = [...foundNested];
            return option;
        });
        this.isSearching = term !== '';
        this.options = [...options];
        this.searchInput.emit({ query: term, found: this.optionsSearch() });
    }
    getListItem(index) {
        const { value } = this.options[index];
        return this.elList.querySelector(`.pn-multiselect-option-input[value='${value}']`);
    }
    getOptionIndex(val, triggers, code) {
        const total = this.optionsTotal() - 1;
        if (code === 'End')
            return total;
        if (code === 'Home')
            return 0;
        const valIndex = this.options.findIndex(({ value }) => value === val);
        const count = triggers.find(item => typeof item === 'number');
        const index = valIndex + count;
        if (index >= total)
            return total;
        if (index <= 0)
            return 0;
        return index;
    }
    checkboxNav(e, val) {
        const { code } = e;
        const arrowUp = code === 'ArrowUp' && -1;
        const arrowDown = code === 'ArrowDown' && 1;
        const pageUp = code === 'PageUp' && -10;
        const pageDown = code === 'PageDown' && 10;
        const home = code === 'Home' && 0;
        const end = code === 'End' && this.optionsTotal() - 1;
        const tab = code === 'Tab';
        const space = code === 'Space';
        const enter = code === 'Enter';
        const escape = code === 'Escape';
        const triggers = [arrowUp, arrowDown, pageUp, pageDown, home, end, tab, space, enter, escape];
        if (!triggers.some(item => typeof item === 'number' || item))
            return;
        if (tab || space || enter)
            return;
        e.stopImmediatePropagation();
        e.preventDefault();
        if (escape) {
            this.setFocus();
            return this.toggleOpen(false);
        }
        const item = this.getOptionIndex(val, triggers, code);
        return this.getListItem(item)?.focus();
    }
    handleBlur(event) {
        const target = event.target;
        const related = event.relatedTarget;
        const jumpingToChips = (related || target)?.className === 'pn-multiselect-chip-button';
        if (jumpingToChips)
            this.toggleOpen(false);
    }
    handleLabel() {
        if (this.disabled)
            return;
        this.setFocus();
    }
    /** Check if there are no options in the list. */
    isEmpty() {
        return (this.options?.length || 0) === 0;
    }
    showSelectAll() {
        return this.selectAll && !this.isEmpty() && !this.noResults();
    }
    /** Check if the empty/nothing found should be visible. */
    showEmptyOption() {
        return (this.isSearching && this.noResults()) || this.isEmpty();
    }
    getPlaceholder() {
        const autoTranslation = this.search ? 'SEARCH' : 'SELECT_AN_OPTION';
        return this.placeholder || this.translate(autoTranslation);
    }
    handleChange({ target }) {
        const { value, checked } = target;
        this.optionSelect({ val: value, checked });
    }
    /** Display the "X more selected options" text. */
    additonalOptions() {
        const count = this.optionsCheckedTotal() - this.itemCount;
        const single = `MORE_OPTION${count === 1 ? '' : 'S'}`;
        return `${count} ${this.translate(single)}`;
    }
    displayLabel() {
        return !!this.label;
    }
    getAriaLabel() {
        return !this.displayLabel() && !this.pnAriaLabelledby ? this.pnAriaLabel : null;
    }
    /**
     * If you use a label (technically a legend), use the `idLegend` to point to it.
     * If not, make sure there is no pnAriaLabel and use pnAriaLabelledby.
     * This is to make sure there are no double label/labelledby.
     */
    getAriaLabelledby() {
        return this.displayLabel() ? this.idLegend : !this.pnAriaLabel ? this.pnAriaLabelledby : null;
    }
    describedBy() {
        const list = [];
        if (this.search)
            list.push(this.idChips);
        if (this.srMessage)
            list.push(this.idSr);
        if (this.hasHelperText() && !this.hasErrorMessage())
            list.push(this.idHelper);
        if (this.hasErrorMessage())
            list.push(this.idError);
        if (list.length)
            return list.join(' ');
        return null;
    }
    /**
     * This is to prevent a rare issue with rendering flag icons.
     * Flags use a set ID to identify gradient colors. If the icon is rendered while the dropdown is closed,
     * the ID is not unique and the icon will not be rendered for other pn-icons using it.
     * This is a temp fix to address the root issue which is how the flags SVG styling is built.
     */
    renderItemIcon(icon, hide) {
        return (this.open || this.isMoving()) && !!icon && !hide;
    }
    renderOption({ label, value, checked, helpertext, icon, id = `${this.getId()}-${value || label}`, invalid, disabled, hide, group, }, indexGroup, indexNested) {
        return (hAsync("li", { class: "pn-multiselect-option", key: id, hidden: hide }, hAsync("input", { type: "checkbox", id: id, class: "pn-multiselect-option-input", checked: checked ?? this.optionSelected(value), indeterminate: indexNested === undefined && this.isIndeterminate(indexGroup), name: this.name, value: value, disabled: this.disabled || disabled, required: this.required, "aria-invalid": invalid ? 'true' : null, "aria-describedby": helpertext ? `${id}-helper` : null, onClick: (event) => this.ripple(event), onKeyDown: (event) => this.checkboxNav(event, value), onBlur: (event) => this.handleBlur(event) }), hAsync("div", { class: "pn-multiselect-option-content" }, this.renderItemIcon(icon, hide) && hAsync("pn-icon", { icon: icon, color: "blue900" }), hAsync("div", { class: "pn-multiselect-option-text" }, hAsync("label", { class: "pn-multiselect-option-label", htmlFor: id }, hAsync("span", null, label)), helpertext && (hAsync("p", { class: "pn-multiselect-option-helper", id: `${id}-helper` }, helpertext))), hAsync("div", { class: "pn-multiselect-option-checkbox" }, hAsync("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none" }, hAsync("polyline", { class: "pn-multiselect-option-checkbox-checkmark-path", points: "4,12 9,17 20,6", "stroke-width": "3" }), hAsync("polyline", { class: "pn-multiselect-option-checkbox-indeterminate-path", points: "4,12 20,12", "stroke-width": "3" })))), group?.length && (hAsync("ul", { class: "pn-multiselect-optgroup" }, group?.map((option, i) => this.renderOption(option, indexGroup, i))))));
    }
    renderOptions() {
        return (hAsync("ul", { id: this.idOptions, class: "pn-multiselect-options", "data-open": this.open, "data-upwards": this.upwards, onChange: (event) => this.handleChange(event), style: { height: '0px' }, ref: el => (this.elList = el) }, this.showSelectAll() &&
            this.renderOption({
                label: this.translate(`SELECT_${this.isSearching ? 'FOUND' : 'ALL'}_OPTIONS`),
                value: this.allValue,
                checked: this.optionsTotal() === this.optionsCheckedTotal(),
            }), this.options?.map((option, index) => this.renderOption(option, index)), this.showEmptyOption() && (hAsync("li", { class: "pn-multiselect-option" }, hAsync("div", { class: "pn-multiselect-option-content", role: "alert" }, hAsync("div", { class: "pn-multiselect-option-text" }, hAsync("span", { class: "pn-multiselect-option-label" }, this.translate(this.isEmpty() ? 'NO_OPTIONS' : 'NO_SEARCH_RESULTS'))))))));
    }
    renderChips() {
        return (hAsync("ul", { id: this.idChips, class: "pn-multiselect-chips", "aria-label": this.translate('SELECTED_OPTIONS'), ref: el => (this.elChips = el) }, this.optionsCheckedPreview()?.map(({ label, value, icon }, index) => (hAsync("li", { class: "pn-multiselect-chip", "aria-setsize": this.optionsCheckedTotal(), "aria-posinset": index + 1, key: `${label}-${value}` }, !!icon && hAsync("pn-icon", { icon: icon, small: true }), hAsync("span", { class: "pn-multiselect-chip-label" }, label), hAsync("button", { type: "button", class: "pn-multiselect-chip-button", "aria-label": `${this.translate('REMOVE')} ${label}`, onClick: () => this.optionSelect({ val: value, checked: false, chip: index }) }, hAsync("pn-icon", { icon: close, small: true, color: "blue700" }))))), this.optionsCheckedTotal() > this.itemCount && (hAsync("li", { class: "pn-multiselect-chip", "data-count": true }, hAsync("span", { class: "pn-multiselect-chip-label" }, "+ ", this.additonalOptions())))));
    }
    renderLabel(compactLabel = false) {
        if (!this.label)
            return null;
        const Tag = compactLabel ? 'div' : 'legend';
        const id = compactLabel ? null : this.idLegend;
        const attrs = compactLabel ? { inert: true } : { onClick: () => this.handleLabel() };
        return (hAsync(Tag, { id: id, class: { 'pn-multiselect-label': true, 'pn-multiselect-sr-only': this.compact && !compactLabel }, "data-compact": this.compact, ...attrs }, hAsync("span", null, this.label), !!this.optionsChecked()?.length && (hAsync("span", null, this.optionsCheckedTotal(), "/", this.optionsTotal()))));
    }
    render() {
        return (hAsync(Host, { key: 'a0ecbc763c7fe2e742a2737a13ccb25049ca5d2c' }, hAsync("fieldset", { key: 'e34a6c4a098b8509985300c6101f28810a2624e5', class: "pn-multiselect", "data-icon": !!this.icon, "data-error": this.hasError(), disabled: this.disabled }, this.renderLabel(), hAsync("div", { key: '4af7e657d83cd4eb9d1f7aef7c41e91c204e8b49', class: "pn-multiselect-group", ref: el => (this.elGroup = el) }, hAsync("div", { key: 'f5d0ab6e61dfac0c19a3ba86230c3da6e14efde5', class: "pn-multiselect-input" }, !!this.icon && hAsync("pn-icon", { key: '2bb3a5906b9624c14b912dae42ab0f266be28708', class: "pn-multiselect-icon", "data-custom": true, icon: this.icon }), hAsync("input", { key: '40bf05bdcdfc7d20d11c7d463863727e5d6aff2e', tabindex: this.search ? null : '-1', type: this.search ? 'search' : 'input', id: this.getId(), class: "pn-multiselect-element", value: this.search ? this.searchQuery : this.optionsCheckedLabels(), name: this.selectName, placeholder: this.getPlaceholder(), required: this.search ? null : this.required, "aria-label": this.getAriaLabel(), "aria-labelledby": this.getAriaLabelledby(), "aria-describedby": this.describedBy(), "aria-controls": `${this.idOptions} ${this.search ? this.idChips : ''}`, "aria-invalid": this.hasError()?.toString(), disabled: this.disabled, readonly: !this.search, "data-compact": this.compact, onClick: () => (this.search && this.open ? null : this.toggleOpen()), onKeyDown: e => this.handleInputKeyboard(e), onBlur: e => this.handleBlur(e), onInput: e => this.search && this.setSearchQuery(e.target.value), ref: el => (this.elInput = el) }), this.compact && this.renderLabel(true), this.hasError() && (hAsync("pn-icon", { key: 'cb667952d2f8c5d2d651781f15ff74b6b775e042', class: "pn-multiselect-icon", "data-error": true, icon: alert_exclamation_circle, color: "warning" })), hAsync("button", { key: '94b05fea39ded60eab60763fdb84a9b711ae8162', id: this.idButton, type: "button", class: "pn-multiselect-button", "aria-label": this.translate(`BUTTON_${this.open ? 'CLOSE' : 'OPEN'}`), "aria-describedby": this.search ? null : this.getId(), "aria-controls": this.idOptions, "aria-expanded": this.open.toString(), onClick: () => this.toggleOpen(), ref: el => (this.elButton = el) }, hAsync("pn-icon", { key: 'eeaafee94ca176871092ceeb80d963fccc31dcec', class: "pn-multiselect-icon", icon: chevron_down, color: "blue700" }))), this.renderOptions()), hAsync("p", { key: '2b769d32ed6692b99a19c125c5177eb375095e68', id: this.idHelper, class: "pn-multiselect-text", hidden: this.hideHelpertext() }, hAsync("span", { key: 'dc43a1985211d85923e3085d44cb2b368e2582a4' }, this.helpertext), hAsync("slot", { key: 'f0f4cd86c528644a133f7c9db51251a77265e15f', name: "helpertext" })), hAsync("p", { key: '718171d4d2c510d70c562a188ef25eacf60ea039', id: this.idError, class: "pn-multiselect-text", role: "alert", hidden: this.hideError() }, hAsync("span", { key: '2b0cfd1042189fb60d96e3d43001f3ff6794cb4e' }, this.error), hAsync("slot", { key: 'e381d819a3de5c550816309f097ae37c713b604e', name: "error" })), this.search && this.renderChips(), hAsync("slot", { key: '6f7731063585b04cc851a5790ec77fff209baa03' }), this.search && (hAsync("p", { key: 'f4df41d21ebc5219a86fbc90947285635df86d13', id: this.idSr, class: "pn-multiselect-sr-only", role: "alert", "aria-live": "assertive" }, this.srMessage && hAsync("span", { key: '6d24d915b81ef53a1eb210d3c7d0a85184ea1e88' }, this.srMessage))))));
    }
    static get watchers() { return {
        "open": [{
                "handleOpen": 0
            }],
        "search": [{
                "handleSearch": 0
            }],
        "searchQuery": [{
                "handleSearchQuery": 0
            }],
        "selectId": [{
                "handleSelectId": 0
            }],
        "pnId": [{
                "handleSelectId": 1
            }]
    }; }
    static get style() { return pnMultiselectCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-multiselect",
        "$members$": {
            "label": [1],
            "helpertext": [1],
            "language": [1],
            "name": [1],
            "selectName": [1, "select-name"],
            "placeholder": [1],
            "required": [4],
            "disabled": [4],
            "options": [1040],
            "compact": [4],
            "icon": [1],
            "selectAll": [4, "select-all"],
            "allValue": [1, "all-value"],
            "search": [4],
            "searchQuery": [1025, "search-query"],
            "itemCount": [2, "item-count"],
            "maxHeight": [1, "max-height"],
            "top": [4],
            "bottom": [4],
            "invalid": [4],
            "error": [1],
            "pnId": [1, "pn-id"],
            "pnAriaLabel": [1, "pn-aria-label"],
            "pnAriaLabelledby": [1, "pn-aria-labelledby"],
            "selectId": [1, "select-id"],
            "isClosing": [32],
            "isExpanding": [32],
            "isSearching": [32],
            "open": [32],
            "upwards": [32],
            "srMessage": [32]
        },
        "$listeners$": [[9, "resize", "handleResize"]],
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const translations$7 = {
    SEARCH_BUTTON: {
        da: 'Search',
        en: 'Search',
        fi: 'Search',
        no: 'Search',
        sv: 'Sök',
    },
    SEARCH_SUCCESS: {
        da: 'Your OCR number is',
        en: 'Your OCR number is',
        fi: 'Your OCR number is',
        no: 'Your OCR number is',
        sv: 'Ditt OCR-nummer är',
    },
    ERROR_INVALID_LICENSE_NUMBER: {
        da: 'Invalid license number',
        en: 'Invalid license number',
        fi: 'Invalid license number',
        no: 'Invalid license number',
        sv: 'Ogiltligt licensnummer',
    },
    ERROR_NO_RESULTS: {
        da: 'The search did not generate any results',
        en: 'The search did not generate any results',
        fi: 'The search did not generate any results',
        no: 'The search did not generate any results',
        sv: 'Sökningen genererade inga träffar',
    },
    ERROR_REASON_HEADER: {
        da: 'It may be due to:',
        en: 'It may be due to:',
        fi: 'It may be due to:',
        no: 'It may be due to:',
        sv: 'Det kan bero på:',
    },
    ERROR_REASON_ONE: {
        da: 'We could not find that license number',
        en: 'We could not find that license number',
        fi: 'We could not find that license number',
        no: 'We could not find that license number',
        sv: 'Vi hittar inget sådant licensnummer',
    },
    ERROR_REASON_TWO: {
        da: 'Check the information and try again.',
        en: 'Check the information and try again.',
        fi: 'Check the information and try again.',
        no: 'Check the information and try again.',
        sv: 'Kontrollera uppgifterna och försök igen.',
    },
    PLACEHOLDER_TEXT: {
        da: 'License number 6 digits',
        en: 'License number 6 digits',
        fi: 'License number 6 digits',
        no: 'License number 6 digits',
        sv: 'Licensnummer 6 tecken',
    },
};

const pnOcrSearchCss = () => `${transformTag("pn-ocr-search")} .bold{font-weight:700}${transformTag("pn-ocr-search")} .search-results,${transformTag("pn-ocr-search")} .error-text-container{padding:1em 0.5em}${transformTag("pn-ocr-search")} .invalid-text-container{padding:0.5em 1em}${transformTag("pn-ocr-search")} .invalid-text-container .invalid-ocr{color:#a70707}`;

class PnOcrSearch {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    get hostElement() { return getElement(this); }
    loading = false;
    error = false;
    ocrNumber;
    searchSuccess = false;
    invalidOcrNumber = false;
    /** The `language` property will be prioritized before the pnTopbar language. */
    language = null;
    async componentWillLoad() {
        if (this.language === null)
            await awaitTopbar(this.hostElement);
    }
    getTranslation(key) {
        return translations$7[key][this.language || sv$2];
    }
    handleSearch(e) {
        // reset states
        this.invalidOcrNumber = false;
        this.searchSuccess = false;
        this.error = false;
        const validationResult = this.validateOcrNumber(e.detail);
        if (validationResult.error) {
            this.invalidOcrNumber = true;
            return;
        }
        this.ocrNumberSearch(validationResult.value);
    }
    async ocrNumberSearch(ocrNumber) {
        this.loading = true;
        await fetch(`https://portal.postnord.com/public-service/api/ocr?key=${ocrNumber}`)
            .then(response => response.json())
            .then(data => {
            this.ocrNumber = data.newOcr;
            this.searchSuccess = true;
        })
            .catch(() => {
            this.error = true;
            this.searchSuccess = false;
        })
            .finally(() => {
            this.loading = false;
        });
    }
    validateOcrNumber(value) {
        // Removes spaces and dashes
        const formatValue = value ? value.replace(/[ -]/gi, '') : '';
        // Looks for non-digits
        const ocrRegex = new RegExp(/\D+/);
        // Needs to be atleast 6 numbers
        const error = ocrRegex.test(formatValue) || formatValue.length !== 6;
        return { error, value: formatValue };
    }
    renderSearchResult() {
        if (!this.loading && !this.error && this.searchSuccess) {
            return (hAsync("div", { class: "search-results" }, this.getTranslation('SEARCH_SUCCESS'), ": ", hAsync("b", null, this.ocrNumber)));
        }
    }
    renderErrorMessage() {
        if (this.invalidOcrNumber && !this.loading) {
            return (hAsync("div", { class: "invalid-text-container" }, hAsync("p", { class: "invalid-ocr" }, this.getTranslation('ERROR_INVALID_LICENSE_NUMBER'))));
        }
        if (this.error && !this.loading) {
            return (hAsync("div", { class: "error-text-container" }, hAsync("p", { class: "bold" }, this.getTranslation('ERROR_NO_RESULTS')), hAsync("p", { class: "bold" }, this.getTranslation('ERROR_REASON_HEADER')), hAsync("p", null, this.getTranslation('ERROR_REASON_ONE')), hAsync("p", null, this.getTranslation('ERROR_REASON_TWO'))));
        }
    }
    render() {
        return (hAsync(Host, { key: 'c6f418483d78065a3a95f94f18613f76088ae279' }, hAsync("pn-search-field", { key: 'c28bff48bc802958b6c8c05f54ad9093c3b1708e', loading: this.loading, label: this.getTranslation('SEARCH_BUTTON'), button: "icon", buttonLabel: this.getTranslation('SEARCH_BUTTON'), placeholder: this.getTranslation('PLACEHOLDER_TEXT'), onSearch: e => this.handleSearch(e) }), this.renderSearchResult(), this.renderErrorMessage()));
    }
    static get style() { return pnOcrSearchCss(); }
    static get cmpMeta() { return {
        "$flags$": 512,
        "$tagName$": "pn-ocr-search",
        "$members$": {
            "language": [1],
            "loading": [32],
            "error": [32],
            "ocrNumber": [32],
            "searchSuccess": [32],
            "invalidOcrNumber": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnPageNavCss = () => `${transformTag("pn-page-nav")}{display:block;position:relative;font-size:clamp(0.8em, 2vw, 1em);z-index:5}.pn-page-nav-wrapper{transform:translateZ(0);font-size:inherit;max-width:100%;overflow:hidden;position:relative;display:inline-flex;border-radius:3em}.pn-page-nav{display:flex;align-items:center;border-radius:3em;min-height:3em;background:#0d234b;border:0.0625em solid #d3cecb;position:relative;overflow-x:auto;scroll-snap-type:x mandatory}.pn-page-nav::-webkit-scrollbar{display:none}.pn-page-nav ul.pn-page-nav-items{display:flex;list-style-type:none;padding:0.25em;margin:0;position:relative}.pn-page-nav-items>.pn-pn-bg{position:absolute;top:50%;transform:translateY(-50%);will-change:transform;left:0;border-radius:3em;transition:width 0.25s cubic-bezier(0.29, 0.15, 0.24, 0.97), transform 0.25s cubic-bezier(0.29, 0.15, 0.24, 0.97), background 0.15s, opacity 0.15s, box-shadow 0.15s}.pn-page-nav-items>.pn-pn-bg.pn-pn-active{box-shadow:0px 0.3px 0.9px rgba(0, 0, 0, 0.1), 0px 1.6px 3.6px rgba(0, 0, 0, 0.13);background:#005d92;z-index:1}.pn-page-nav-items>.pn-pn-bg.pn-pn-hover{background:#ffffff;opacity:0;border:0.0625em solid transparent;z-index:0}.pn-page-nav-items>.pn-pn-bg.hidden{opacity:0}@media (hover: hover){ul.pn-page-nav-items:focus-within .pn-pn-hover,ul.pn-page-nav-items:hover .pn-pn-hover{opacity:0.12}}${transformTag("pn-page-nav")} .pn-pn-arrows{position:absolute;top:50%;transform:translateY(-50%);left:0;height:100%;width:100%;z-index:3;display:flex;justify-content:space-between;align-items:center;pointer-events:none;padding:0.125em 0.1em}${transformTag("pn-page-nav")} .pn-pn-arrows svg{width:1.5em}${transformTag("pn-page-nav")} .pn-pn-arrows svg.pn-icon-svg path{fill:#005d92}${transformTag("pn-page-nav")} .pn-pn-arrows>*{transition:transform 0.2s, opacity 0.2s, background 0.1s, box-shadow 0.1s;pointer-events:all;height:100%;aspect-ratio:1;background:#ffffff;display:flex;align-items:center;justify-content:center;outline:none;cursor:pointer;opacity:0;will-change:transform;-webkit-tap-highlight-color:transparent;border-radius:50%;border:0.0625em solid #0d234b}${transformTag("pn-page-nav")} .pn-pn-arrows>*.pn-pn-arrow-left{transform:translateX(-100%)}${transformTag("pn-page-nav")} .pn-pn-arrows>*.pn-pn-arrow-right{transform:translateX(100%)}@media screen and (max-width: 30em){${transformTag("pn-page-nav")} .pn-pn-arrows>*{border:none}${transformTag("pn-page-nav")} .pn-pn-arrows>* ${transformTag("pn-icon")} .pn-icon-svg{width:100%;height:2em;animation:arrow 0.6s ease-in-out alternate infinite}${transformTag("pn-page-nav")} .pn-pn-arrows>* ${transformTag("pn-icon")} .pn-icon-svg path{fill:#ffffff}${transformTag("pn-page-nav")} .pn-pn-arrows>*.pn-pn-arrow-left{background:linear-gradient(to left, transparent, #0d234b 60%);border-radius:50% 0 0 50%}${transformTag("pn-page-nav")} .pn-pn-arrows>*.pn-pn-arrow-right{background:linear-gradient(to right, transparent, #0d234b 40%);border-radius:0 50% 50% 0}}${transformTag("pn-page-nav")} .pn-pn-arrows.pn-pn-left-visible .pn-pn-arrow-left,${transformTag("pn-page-nav")} .pn-pn-arrows.pn-pn-right-visible .pn-pn-arrow-right{opacity:1;transform:translateX(0)}@keyframes arrow{to{transform:translateX(10%)}}button.pn-page-nav-dropdown-button{font-size:1em;border-radius:3em 0 0 3em;background:#0d234b;color:#ffffff;padding:0.5em 1em 0.5em 1.5em;cursor:pointer;display:flex;align-items:center;border:none;transition:background 0.15s;outline:none;height:100%;position:relative;margin:0 0.5em 0 0;font-weight:500}button.pn-page-nav-dropdown-button ${transformTag("pn-icon")}{margin-left:0.5em}button.pn-page-nav-dropdown-button:hover,button.pn-page-nav-dropdown-button:focus{background:#263655}button.pn-page-nav-dropdown-button:focus{box-shadow:inset 0 0 0 0.1em #005d92, inset 0 0 0 0.2em #d3cecb}button.pn-page-nav-dropdown-button.pn-page-nav-dropdown-active{background:#005d92}button.pn-page-nav-dropdown-button.pn-page-nav-dropdown-active:hover,button.pn-page-nav-dropdown-button.pn-page-nav-dropdown-active:focus{background:#005d92}.pn-page-nav-divider{height:60%;background:#d3cecb;width:0.1em;position:absolute;right:0;transform:translateX(50%)}ul.pn-page-nav-dropdown{position:absolute;left:0;top:110%;background:#0d234b;border-radius:0.5em;margin:0;padding:0;list-style-type:none;box-shadow:0px 6.4000000954px 14.3999996185px 0px rgba(0, 0, 0, 0.1294117647), 0px 1.2000000477px 3.5999999046px 0px rgba(0, 0, 0, 0.1019607843);font-size:inherit;display:none}ul.pn-page-nav-dropdown.pn-page-nav-dropdown-open{display:block}`;

/**
 * @deprecated This component will be removed in v8. Please use the `pn-tablist` instead.
 * @see {@link https://portal.postnord.com/web-components/?path=/docs/components-navigation-tablist--docs Use `pn-tablist` instead.}
 *
 * @slot dropdown-item - Place your `pn-page-nav-dropdown-item` components here.
 */
class PnPageNav {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.navchange = createEvent(this, "navchange", 7);
    }
    mo;
    navContainer;
    navWrapper;
    navItems = [];
    dropdownButton;
    dropdownEl;
    dropdownItems;
    dropdownEls;
    eventHandler = this.keyboardEvents.bind(this);
    globalEventHandler = this.globalEvents.bind(this);
    activeBg;
    hoverBg;
    scrollRegistered = false;
    get hostElement() { return getElement(this); }
    currentSelection;
    showScrollArrows = false;
    showLeftArrow = false;
    showRightArrow = false;
    dropdownOpen = false;
    dropdownLinks = [];
    dropdownActive = false;
    /** Currently active menu item value */
    value;
    /** Pass a string which will be the text on the dropdown button. */
    dropdown = false;
    /** Set a unique HTML ID. */
    navid = `pn-page-nav-${uuidv4()}`;
    /** Emits the value of the selected item. */
    navchange;
    changeHandler({ target }) {
        this.currentSelection = target.closest(`${transformTag("pn-page-nav-item")}`);
        if (target.value)
            this.value = target.value;
        if (this.dropdownOpen)
            this.dropdownOpen = false;
    }
    handleResize() {
        this.rerender();
    }
    valueHandler() {
        if (!this.value)
            this.currentSelection = null;
        this.calcHighlight(this.currentSelection, this.activeBg);
        this.navchange.emit(this.value);
        if (!this.dropdownActive)
            return;
        this.isDropdownItemActive();
    }
    dropdownHandler() {
        if (this.dropdownOpen) {
            requestAnimationFrame(() => {
                this.addGlobalEventListeners();
            });
            return;
        }
        this.removeGlobalEventListeners();
    }
    /* ---------------------------------------LIFECYCLE--------------------------------------- */
    componentWillLoad() {
        if (!this.dropdown)
            return;
        this.dropdownEls = Array.from(this.hostElement.querySelectorAll(`${transformTag("pn-page-nav-dropdown-item")}`));
        if (this.dropdownEls.length) {
            this.dropdownActive = true;
            this.initiateDropdown();
        }
    }
    componentDidLoad() {
        if (this.mo)
            this.mo.disconnect();
        this.mo = new MutationObserver(() => {
            this.setActiveNavItem();
            this.rerender();
        });
        this.mo.observe(this.hostElement, { childList: true, subtree: true });
        this.navWrapper = this.hostElement.querySelector('.pn-page-nav');
        this.navContainer = this.hostElement.querySelector('.pn-page-nav-items');
        this.activeBg = this.hostElement.querySelector('.pn-pn-active');
        this.hoverBg = this.hostElement.querySelector('.pn-pn-hover');
        this.hostElement.addEventListener('mouseover', ({ target }) => this.calcHighlight(target, this.hoverBg));
        this.setActiveNavItem();
        this.rerender();
    }
    /* ---------------------------------------/LIFECYCLE--------------------------------------- */
    setActiveNavItem() {
        this.navItems = Array.from(this.hostElement.querySelectorAll(`${transformTag("pn-page-nav-item")}`));
        this.navItems.forEach(navItemEl => {
            if (this.value === navItemEl.value) {
                /** @ts-ignore This component will be removed soon, no need to deal with this. */
                this.currentSelection = navItemEl;
            }
            else {
                navItemEl.removeAttribute('selected');
            }
            navItemEl
                .querySelector('a')
                .addEventListener('focus', ({ target }) => this.calcHighlight(target, this.hoverBg));
        });
        /* -----------------dropdown------------------ */
        if (!this.dropdownActive)
            return;
        this.dropdownItems = Array.from(this.hostElement.querySelectorAll('.pn-page-nav-dropdown-item'));
        //Check active state on each item
        this.isDropdownItemActive();
        //Store all values to check if dropdown button should be active
        this.dropdownLinks = this.dropdownItems.map((el, i) => {
            el.setAttribute('data-index', `${i}`);
            return el.closest(`${transformTag("pn-page-nav-dropdown-item")}`).value;
        });
        /* -----------------/dropdown------------------ */
    }
    rerender() {
        requestAnimationFrame(() => {
            this.calcHighlight(this.currentSelection, this.activeBg);
            this.scrollArrowRender();
        });
    }
    /*---------------------------------------HIGHLIGHT LOGIC-------------------------------------------*/
    calcHighlight(el, bgEl) {
        if (!el?.closest(`${transformTag("pn-page-nav-item")}`)) {
            bgEl?.classList.add('hidden');
            return;
        }
        if (bgEl)
            bgEl.classList.remove('hidden');
        const elRect = el.closest(`${transformTag("pn-page-nav-item")}`).getBoundingClientRect();
        const { left: hostLeft } = this.navContainer.getBoundingClientRect();
        const { left: navLeft, height: navHeight, width: navWidth } = elRect;
        const offset = navLeft - hostLeft + this.navContainer.scrollLeft;
        bgEl.style.setProperty('transform', `translate(${offset}px, -50%`);
        bgEl.style.setProperty('width', `${navWidth}px`);
        bgEl.style.setProperty('height', `${navHeight}px`);
    }
    /*---------------------------------------/HIGHLIGHT LOGIC-------------------------------------------*/
    /*---------------------------------------SCROLL ARROW LOGIC-------------------------------------------*/
    scrollArrowRender() {
        if (!this.navWrapper)
            return;
        if (this.navWrapper.scrollWidth > this.navWrapper.clientWidth) {
            this.showScrollArrows = true;
            if (!this.scrollRegistered) {
                this.navWrapper.addEventListener('scroll', this.scrollArrowRender.bind(this));
                this.scrollRegistered = true;
            }
            const amountScrolled = Math.round(this.navWrapper.scrollWidth - this.navWrapper.scrollLeft);
            const distanceToEnd = amountScrolled - this.navWrapper.clientWidth;
            const distanceToStart = this.navWrapper.scrollLeft;
            this.showLeftArrow = distanceToStart > 0;
            this.showRightArrow = distanceToEnd > 0;
            return;
        }
        this.showLeftArrow = false;
        this.showRightArrow = false;
        this.showScrollArrows = false;
    }
    scroll(val) {
        let amount = this.navWrapper.scrollLeft + val;
        this.navWrapper.scroll({
            left: amount,
            behavior: 'smooth',
        });
    }
    scrollArrowClasses() {
        let classNames = 'pn-pn-arrows ';
        if (this.showLeftArrow)
            classNames += 'pn-pn-left-visible ';
        if (this.showRightArrow)
            classNames += 'pn-pn-right-visible ';
        return classNames;
    }
    /*---------------------------------------/SCROLL ARROW LOGIC-------------------------------------------*/
    /* ---------------------------------------DROPDOWN LOGIC--------------------------------------- */
    initiateDropdown() {
        requestAnimationFrame(() => {
            this.dropdownButton = this.hostElement.querySelector('.pn-page-nav-dropdown-button');
            this.dropdownEl = this.hostElement.querySelector('.pn-page-nav-dropdown');
            this.addDropdownEventListeners();
        });
    }
    toggleDropdown() {
        this.dropdownOpen = !this.dropdownOpen;
    }
    isDropdownItemActive() {
        this.dropdownEls.forEach(el => {
            if (el.value && this.value === el.value) {
                el.setAttribute('active', 'true');
                return;
            }
            el.removeAttribute('active');
        });
    }
    /* -----------------events------------------ */
    /* -----------------temporary events------------------ */
    addDropdownEventListeners() {
        this.hostElement.addEventListener('keydown', this.eventHandler);
        this.hostElement.addEventListener('click', this.eventHandler);
    }
    addGlobalEventListeners() {
        const root = this.hostElement.getRootNode();
        root.addEventListener('focusin', this.globalEventHandler);
        root.addEventListener('keydown', this.globalEventHandler);
        root.addEventListener('click', this.globalEventHandler);
    }
    removeGlobalEventListeners() {
        const root = this.hostElement.getRootNode();
        root.removeEventListener('focusin', this.globalEventHandler);
        root.removeEventListener('keydown', this.globalEventHandler);
        root.removeEventListener('click', this.globalEventHandler);
    }
    /* -----------------/temporary events------------------ */
    /* -----------------Open dropdown with keyboard------------------ */
    keyboardEvents(e) {
        const target = e.composedPath()[0];
        // As long as the dropdown is closed, we only want it to react to keyboard input
        // is the user has focus on the button
        if (e.type === 'keydown') {
            if (!this.dropdownOpen && target === this.dropdownButton && ['ArrowUp', 'ArrowDown'].includes(e.code)) {
                this.dropdownOpen = true;
                requestAnimationFrame(() => {
                    this.focusNextDropdownItem();
                });
            }
        }
    }
    /* -----------------/Open dropdown with keyboard------------------ */
    globalEvents(e) {
        const target = e.composedPath()[0];
        if (e.type === 'keydown' && e.code === 'Escape') {
            this.dropdownOpen = false;
            this.dropdownButton.focus();
        }
        if (e.code === 'ArrowDown')
            this.focusNextDropdownItem();
        if (e.code === 'ArrowUp')
            this.focusPrevDropdownItem();
        if ((e.type === 'click' || e.type === 'focusin') && !this.dropdownEl.contains(target)) {
            this.dropdownOpen = false;
        }
    }
    /* -----------------/events------------------ */
    /* -----------------focusing------------------ */
    focusNextDropdownItem() {
        const { activeElement } = this.hostElement.getRootNode();
        if (!activeElement.classList.contains('pn-page-nav-dropdown-item')) {
            this.dropdownItems[0].focus();
            return;
        }
        // focus next item
        const index = parseInt(activeElement.getAttribute('data-index'));
        if (index < this.dropdownItems.length - 1) {
            this.dropdownItems[index + 1].focus();
        }
    }
    focusPrevDropdownItem() {
        const { activeElement } = this.hostElement.getRootNode();
        if (!activeElement.classList.contains('dropdown-item')) {
            this.dropdownItems[this.dropdownItems.length - 1].focus();
        }
        // focus previous item
        const index = parseInt(activeElement.getAttribute('data-index'));
        if (index > 0) {
            this.dropdownItems[index - 1].focus();
            return;
        }
        this.dropdownButton.focus();
    }
    /* -----------------/focusing------------------ */
    dropdownButtonClasses() {
        let classList = 'pn-page-nav-dropdown-button ';
        if (this.dropdownLinks.includes(this.value))
            classList += 'pn-page-nav-dropdown-active ';
        return classList;
    }
    dropdownClasses() {
        let classList = 'pn-page-nav-dropdown ';
        if (this.dropdownOpen)
            classList += 'pn-page-nav-dropdown-open ';
        return classList;
    }
    /* ---------------------------------------/DROPDOWN LOGIC--------------------------------------- */
    render() {
        return (hAsync(Host, { key: '57c1d7248ca2704b6acf675cfd9648d5d2afcf60' }, hAsync("div", { key: 'b02d7389cb66d185ff1d72674a3ce2d2c3a81e76', class: "pn-page-nav-wrapper" }, hAsync("nav", { key: '60d1d6974945dd5971a967d92886c4c4a3a5b4ff', class: "pn-page-nav" }, this.dropdownActive && (hAsync("button", { key: '6ce020ca42332cd760c410b6144f2317fa95f239', type: "button", class: this.dropdownButtonClasses(), onClick: () => this.toggleDropdown(), "aria-controls": "page-nav-dropdown", "aria-expanded": `${this.dropdownOpen}` }, this.dropdown, hAsync("pn-icon", { key: 'd2b750dc24022e5b1b5425b4b2a76dcba0c26c69', icon: chevron_down, color: "white", small: true }), hAsync("div", { key: '1257070fcbcfcbe08142b379466f7fd7dc3d37ee', class: "pn-page-nav-divider" }))), hAsync("ul", { key: 'd72c186854c5a679bb9395c7aa9f0dfe469b8f14', class: "pn-page-nav-items" }, hAsync("slot", { key: 'ba7a508c841b594466bdadf1bf904cadef5b2bc9' }), hAsync("li", { key: 'c50294022952d8168886d816509a0297c262071c', class: "pn-pn-bg pn-pn-active", role: "presentation" }), hAsync("li", { key: 'a2dfc8bb63575feabb0a58caae1e8ae76e873943', class: "pn-pn-bg pn-pn-hover", role: "presentation" }))), this.showScrollArrows && (hAsync("div", { key: '5e99c2cc1d1122091b2286e4fd9c54cb0734fb59', class: this.scrollArrowClasses() }, hAsync("button", { key: 'a92f375c45a6705154b58dd5ca8df03cf6010a6f', class: "pn-pn-arrow-left", onClick: () => this.scroll(-120), tabindex: "-1" }, hAsync("pn-icon", { key: '58413aff678f1b3a4d17a3693261fc9f3110d8cc', icon: arrow_left, color: "white" })), hAsync("button", { key: '2a83e1480087752eacebdf5c35fcfbea3fa3cb8d', class: "pn-pn-arrow-right", onClick: () => this.scroll(120), tabindex: "-1" }, hAsync("pn-icon", { key: 'fde8949b978be59ae2d9c5ab44ce286b72c35790', icon: arrow_right, color: "blue700" }))))), this.dropdownActive && (hAsync("ul", { key: '802117bef707c98683b3ed30449897ac13d6af05', id: this.navid, class: this.dropdownClasses() }, hAsync("slot", { key: '414852b90620a09a11f9a4c3b1d7d4809b6f8487', name: "dropdown-item" })))));
    }
    static get watchers() { return {
        "value": [{
                "valueHandler": 0
            }],
        "dropdownOpen": [{
                "dropdownHandler": 0
            }]
    }; }
    static get style() { return pnPageNavCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-page-nav",
        "$members$": {
            "value": [1025],
            "dropdown": [8],
            "navid": [1],
            "currentSelection": [32],
            "showScrollArrows": [32],
            "showLeftArrow": [32],
            "showRightArrow": [32],
            "dropdownOpen": [32],
            "dropdownLinks": [32],
            "dropdownActive": [32]
        },
        "$listeners$": [[0, "itemselection", "changeHandler"], [9, "resize", "handleResize"]],
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnPageNavDropdownItemCss = () => `${transformTag("pn-page-nav-dropdown-item")}:first-of-type li>a,${transformTag("pn-page-nav-dropdown-item")}:first-of-type li>button{border-radius:0.5em 0.5em 0 0}${transformTag("pn-page-nav-dropdown-item")}:last-of-type li>a,${transformTag("pn-page-nav-dropdown-item")}:last-of-type li>button{border-radius:0 0 0.5em 0.5em}${transformTag("pn-page-nav-dropdown-item")}:last-of-type li>hr{display:none}${transformTag("pn-page-nav-dropdown-item")} li{font-size:inherit}${transformTag("pn-page-nav-dropdown-item")} li>*{color:#ffffff;font-size:inherit;border:none;padding:1em;margin:0;display:flex;justify-content:space-between;align-items:center;cursor:pointer;transition:background 0.15s;outline:none;width:100%;font-weight:500}${transformTag("pn-page-nav-dropdown-item")} li>*>${transformTag("pn-icon")}{margin-left:1em}${transformTag("pn-page-nav-dropdown-item")} li>*.pn-page-nav-dropdown-item-active{background:#005d92}${transformTag("pn-page-nav-dropdown-item")} li>*.pn-page-nav-dropdown-item-active:hover,${transformTag("pn-page-nav-dropdown-item")} li>*.pn-page-nav-dropdown-item-active:focus{background:#005d92}${transformTag("pn-page-nav-dropdown-item")} li>*:hover,${transformTag("pn-page-nav-dropdown-item")} li>*:focus{background:#0d234b}${transformTag("pn-page-nav-dropdown-item")} li>*:focus{box-shadow:inset 0 0 0 0.1em #005d92, inset 0 0 0 0.2em #d3cecb}${transformTag("pn-page-nav-dropdown-item")} li>a{text-decoration:none}${transformTag("pn-page-nav-dropdown-item")} li>button{background:none}${transformTag("pn-page-nav-dropdown-item")} li>hr{bottom:0;padding:0;margin:0 auto;border-top:0.0625em solid #d3cecb;opacity:0.6;width:85%}`;

/**
 * @deprecated This component will be removed in v8. Please use the `pn-tablist` instead.
 * @see {@link https://portal.postnord.com/web-components/?path=/docs/components-navigation-tablist--docs Use `pn-tablist` instead.}
 */
class PnPageNavDropdownItem {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.itemselection = createEvent(this, "itemselection", 7);
    }
    get hostElement() { return getElement(this); }
    /**
     * The value that will be emitted upon selection, only pass this if the item
     * is a link, if you want a button (for quick actions), omit this prop.
     */
    value;
    /** Pass an href to the items if you want to have links that lead outside of your app */
    href;
    /** Ignore this, it's internal communication with parent. @hide true */
    active = false;
    /** Ignore this, it's internal communication with parent */
    itemselection;
    select(e) {
        if (this.value && !this.href)
            e.preventDefault();
        this.itemselection.emit(this.value);
    }
    setClassnames() {
        let classes = 'pn-page-nav-dropdown-item ';
        if (this.active)
            classes += 'pn-page-nav-dropdown-item-active ';
        return classes;
    }
    getType() {
        return this.value ? null : 'button';
    }
    getTagName() {
        return this.value ? 'a' : 'button';
    }
    render() {
        const TagName = this.getTagName();
        return (hAsync("li", { key: 'a092dbd0ea2bead9b2d974cadf80f74190a0d14e' }, hAsync(TagName, { key: 'd0d9542e100b59c39ced2612c9b279d7d07bd876', href: this.href || '#', class: this.setClassnames(), type: this.getType(), onClick: e => this.select(e), tabindex: "-1" }, hAsync("slot", { key: '96f8721e300c4b32e72df20079030986d5ffee6b' }), hAsync("pn-icon", { key: 'd835de522cec9ec9f686bb9c0d30d842d4feeb80', icon: arrow_right, color: "white" })), hAsync("hr", { key: 'db691728876fa378a714eb13202922a99bd8ca46' })));
    }
    static get style() { return pnPageNavDropdownItemCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-page-nav-dropdown-item",
        "$members$": {
            "value": [1],
            "href": [1],
            "active": [4]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnPageNavItemCss = () => `${transformTag("pn-page-nav-item")}{position:relative;color:#ffffff;margin-right:0.5em;z-index:2;white-space:nowrap;scroll-snap-align:center;outline:none;-webkit-tap-highlight-color:transparent;transform:translateZ(0)}${transformTag("pn-page-nav-item")} a{text-decoration:none;color:#ffffff;height:100%;width:100%;padding:0.5em;font-weight:500;border-radius:3em;border:0.0625em solid transparent;display:inline-flex;align-items:center;cursor:pointer;outline:none;transition:box-shadow 0.15s}${transformTag("pn-page-nav-item")} a:focus{box-shadow:0 0 0 0.1em #d3cecb}${transformTag("pn-page-nav-item")} a>${transformTag("pn-icon")}{margin-right:0.5em}${transformTag("pn-page-nav-item")}:last-of-type{margin-right:0}`;

/**
 * @deprecated This component will be removed in v8. Please use the `pn-tablist` instead.
 * @see {@link https://portal.postnord.com/web-components/?path=/docs/components-navigation-tablist--docs Use `pn-tablist` instead.}
 */
class PnPageNavItem {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.itemselection = createEvent(this, "itemselection", 7);
    }
    get hostElement() { return getElement(this); }
    /** The item value. Used by `pn-page-nav` to determine pre-selected item. */
    value;
    /** Pass an href to the items if you want to have links that lead outside of your app. */
    href;
    /** The SVG content of the icon you want. */
    icon;
    /** Event is emitted when you select an item. */
    itemselection;
    select(e) {
        if (this.value && !this.href)
            e.preventDefault();
        this.itemselection.emit(this.value);
    }
    render() {
        return (hAsync(Host, { key: '3bceeadfd2b66e184d7c287e0d720d8093e571fa' }, hAsync("li", { key: '58eb5671306d42c653113838c1a1ba9c96312c2d' }, hAsync("a", { key: '438609540a2a64ac3aabf8030b68056574e68551', href: this.href || '#', class: "pn-page-nav-item", onClick: e => this.select(e) }, this.icon && hAsync("pn-icon", { key: '945dd1e63943e2854290b010f088caa08f684cc4', icon: this.icon, color: "white" }), hAsync("slot", { key: 'f3a9032f5373651349135b101a23ef2dc52a52a9' })))));
    }
    static get style() { return pnPageNavItemCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-page-nav-item",
        "$members$": {
            "value": [1],
            "href": [1],
            "icon": [1]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const translations$6 = {
    PAGINATION: {
        sv: 'Paginering',
        en: 'Pagination',
        da: 'Paginering',
        fi: 'Sivunumerointi',
        no: 'Paginering',
    },
    PAGE: {
        sv: 'Sida',
        en: 'Page',
        da: 'Side',
        fi: 'Sivu',
        no: 'Side',
    },
    PREVIOUS_PAGE: {
        sv: 'Föregående sida',
        en: 'Previous page',
        da: 'Forrige side',
        fi: 'Edellinen sivu',
        no: 'Forrige side',
    },
    NEXT_PAGE: {
        sv: 'Nästa sida',
        en: 'Next page',
        da: 'Næste side',
        fi: 'Seuraava sivu',
        no: 'Neste side',
    },
    ROWS_PAGE: {
        sv: 'Object per sida',
        en: 'Items per page',
        da: 'Varer pr. side',
        fi: 'Kohteita per sivu',
        no: 'Elementer per side',
    },
};

const pnPaginationCss = () => `${transformTag("pn-pagination")}{display:block;margin-top:1.5em}${transformTag("pn-pagination")} .pn-pagination{display:flex;gap:1em;flex-wrap:wrap;padding-top:1em;border-top:0.0625em solid #e9e6e5}${transformTag("pn-pagination")} .pn-pagination-container{display:flex;align-items:center;flex-wrap:wrap;gap:0.5em;margin:0 auto}${transformTag("pn-pagination")} .pn-pagination-container[data-right]{margin-right:0}${transformTag("pn-pagination")} .pn-pagination-container>[data-arrow]{display:none}${transformTag("pn-pagination")} .pn-pagination-container>[data-arrow][data-show]{display:inline-block}${transformTag("pn-pagination")} .pn-pagination-rows{flex:0 0 auto;margin-right:auto}${transformTag("pn-pagination")} .pn-pagination-pages{flex:0 0 auto;margin-left:auto}${transformTag("pn-pagination")} .pn-pagination-list{list-style:none;padding:0;margin:0;display:flex;flex-wrap:wrap;justify-content:center;gap:0.5em}${transformTag("pn-pagination")} .pn-pagination-list ${transformTag("pn-button")}>.pn-button{padding:0.375em 0.75em}${transformTag("pn-pagination")} .pn-pagination-dot{display:none;padding:0.375em 0.5em;height:2em;width:2.5em;text-align:center}${transformTag("pn-pagination")} .pn-pagination-dot[data-show]{display:inline-block}`;

/**
 * Accessible pagination needs each item to link to a different part of the document.
 * This means that you must `preventDefault` on the `MouseEvent` emitted from the `pageSelected` event if you have a SPA.
 *
 * If you set a `page` value that is higher than `pages`, the component will automatically lower it to the `pages` value.
 *
 * @since v7.9.0
 */
class PnPagination {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.pageSelected = createEvent(this, "pageSelected", 7);
        this.rowsSelected = createEvent(this, "rowsSelected", 7);
    }
    listElement;
    get hostElement() { return getElement(this); }
    list;
    /** Set a label for the pagination element for screen readers. It defaults to `Pagination`. */
    label;
    /** Set a custom URL template. Use `{page}` within the string to position where the dynamic page number should be. */
    urlTemplate = '?page={page}';
    /** Set a HTML id on the pagination element. */
    paginationId = null;
    /** Manually set the language. */
    language = null;
    /**
     * Set which page the user is currently viewing.
     * Use this to set an inital page or if the selected page is changed from outside this component.
     *
     * @category Pages
     **/
    page = 1;
    /** Set how many pages are available. @category Pages */
    pages;
    /** Set how many pages should be visible at one time. Use an odd number. Minimum is `5`. @category Pages */
    pagesVisible = 5;
    /**
     * Allow the user to decide how many items should be shown per page.
     * Make sure this value exists in the `rowsList` string.
     *
     * @see {@link rowsList}
     * @category Rows per page
     * */
    rows = null;
    /**
     * Set available items per page options the user can select. Use a comma separated string.
     *
     * @see {@link rows}
     * @category Rows per page
     * */
    rowsList = '10,25,50';
    /**
     * Default label is "Items per page".
     * @see {@link rows}
     * @category Rows per page
     * */
    rowsLabel = null;
    handlePage() {
        if (this.page > this.pages)
            this.page = this.pages;
        else if (this.page < 1)
            this.page = 1;
    }
    handlePages() {
        const list = [];
        if (this.pages > 10000) {
            console.error(`${this.hostElement.localName}: Invalid page count ${this.pages}. Maximum is 10000.`);
            this.pages = 10000;
        }
        for (let index = 0; this.pages > index; index++) {
            const page = index + 1;
            list.push({ index, page });
        }
        this.list = list;
        this.handlePage();
    }
    handlePagesVisible() {
        if (5 > this.pagesVisible)
            this.pagesVisible = 5;
        if (this.pagesVisible % 2 === 0)
            this.pagesVisible = Math.round(this.pagesVisible) - 1;
    }
    /** Emitted when the page is changed. Either via clicking a link or selecting a page in the select. */
    pageSelected;
    /** This event fires when the user changes how many items should be shown per page. */
    rowsSelected;
    async componentWillLoad() {
        this.handlePagesVisible();
        this.handlePages();
        if (this.language === null)
            await awaitTopbar(this.hostElement);
    }
    translate(prop) {
        return translations$6[prop][this.language || en$2];
    }
    isActivePage(page) {
        return page === this.page;
    }
    navigate({ page, event, focus }) {
        if (typeof page === 'number' && page >= 1 && this.pages >= page)
            this.page = page;
        this.pageSelected.emit({ page: this.page, mouse: event });
        if (focus)
            requestAnimationFrame(() => {
                const element = this.listElement.querySelector('a[aria-current="page"]');
                element?.focus({ preventScroll: true });
            });
    }
    useRowList() {
        return !!this.rows && !!this.rowsList;
    }
    setRows(event) {
        const target = event.target;
        this.rows = Number(target.value);
        this.rowsSelected.emit({ rows: this.rows, change: event });
    }
    getRowList() {
        return this.rowsList.split(',').map(item => Number(item.trim()));
    }
    /** Get the page numbers of the lowest and highest visible page. */
    getPaginationIndex() {
        const current = this.page;
        let low = current - Math.ceil(this.pagesVisible / 2);
        let high = current + Math.floor(this.pagesVisible / 2);
        for (let i = 0; this.pagesVisible > i; i++) {
            if (low < 0) {
                high++;
                low++;
            }
            else if (high > this.pages) {
                high--;
                low--;
            }
        }
        const lowest = 0 > low ? 0 : low;
        const leftIndent = lowest >= 1;
        const rightIndent = this.pages > high;
        return {
            low: rightIndent && leftIndent ? lowest + 1 : lowest,
            high: rightIndent && leftIndent ? high - 1 : high,
            leftIndent,
            rightIndent,
        };
    }
    getPagination() {
        const { low, high } = this.getPaginationIndex();
        return this.list.slice(low, high);
    }
    getUrl(page) {
        return this.setPageText(this.urlTemplate, page);
    }
    setPageText(text, page) {
        return text.replace('{page}', page.toString());
    }
    getPrevPage() {
        let page = this.page;
        return page > 1 ? (page -= 1) : 1;
    }
    getNextPage() {
        let page = this.page;
        return this.pages > page ? (page += 1) : this.pages;
    }
    showIntendation(last = false) {
        const { leftIndent, rightIndent } = this.getPaginationIndex();
        return last ? rightIndent : leftIndent;
    }
    renderDivider(last = false) {
        return (hAsync("span", { class: "pn-pagination-dot", "data-show": this.showIntendation(last) }, "..."));
    }
    renderButton({ page, dataAttr }) {
        const active = this.isActivePage(page);
        return (hAsync("pn-button", { label: page.toString(), arialabel: `${this.translate('PAGE')} ${page}`, ariacurrent: active ? 'page' : null, href: this.getUrl(page), variant: active ? 'outlined' : '', appearance: "light", small: true, "data-arrow": dataAttr, "data-show": dataAttr && this.showIntendation(dataAttr === 'last'), onPnClick: ({ detail }) => this.navigate({ page, event: detail, focus: true }) }));
    }
    renderItem({ page }) {
        return (hAsync("li", { class: "pn-pagination-list-item", "aria-setsize": this.pages, "aria-posinset": page }, this.renderButton({ page })));
    }
    renderJumpButton(last = false) {
        const rel = last ? 'next' : 'prev';
        const icon = last ? arrow_right : arrow_left;
        const page = last ? this.getNextPage() : this.getPrevPage();
        const current = last ? this.pages === this.page : 1 === this.page;
        const text = last ? 'NEXT_PAGE' : 'PREVIOUS_PAGE';
        const showPageNumber = current ? '' : ` (${page})`;
        const label = `${this.translate(text)}${showPageNumber}`;
        return (hAsync("pn-button", { arialabel: label, ariacurrent: current ? 'page' : null, href: this.getUrl(page), rel: current ? null : rel, appearance: "light", small: true, icon: icon, iconOnly: true, onPnClick: ({ detail }) => this.navigate({ page, event: detail }) }));
    }
    render() {
        return (hAsync(Host, { key: '5c36be3d032fa0769af32e78f76ef7681b87b5b0' }, hAsync("nav", { key: '1e63a84c6f9e0b43bffd675d24d8b11e1a2e6abb', id: this.paginationId, class: "pn-pagination", "aria-label": this.label || this.translate('PAGINATION') }, this.useRowList() && (hAsync("pn-select", { key: '07e4af8aab83392cedff2587e72abab3045ccdaf', class: "pn-pagination-rows", label: this.rowsLabel || this.translate('ROWS_PAGE'), onChange: event => this.setRows(event) }, this.getRowList().map(item => (hAsync("option", { value: item, selected: this.rows === Number(item), innerHTML: `${item}` }))))), hAsync("div", { key: '6ece9af08f44edde18795c16b03b476de6682be9', class: "pn-pagination-container", "data-right": this.useRowList() }, this.renderJumpButton(), this.renderButton({ page: 1, dataAttr: 'first' }), this.renderDivider(), hAsync("ol", { key: '6c87dbecfad6aecc50c10158e17a903581902c45', class: "pn-pagination-list", ref: el => (this.listElement = el) }, this.getPagination().map(item => this.renderItem(item))), this.renderDivider(true), this.renderButton({ page: this.pages, dataAttr: 'last' }), this.renderJumpButton(true)))));
    }
    static get watchers() { return {
        "page": [{
                "handlePage": 0
            }],
        "pages": [{
                "handlePages": 0
            }],
        "pagesVisible": [{
                "handlePagesVisible": 0
            }]
    }; }
    static get style() { return pnPaginationCss(); }
    static get cmpMeta() { return {
        "$flags$": 512,
        "$tagName$": "pn-pagination",
        "$members$": {
            "label": [1],
            "urlTemplate": [1, "url-template"],
            "paginationId": [1, "pagination-id"],
            "language": [1],
            "page": [1538],
            "pages": [1026],
            "pagesVisible": [1026, "pages-visible"],
            "rows": [1026],
            "rowsList": [1, "rows-list"],
            "rowsLabel": [1, "rows-label"],
            "list": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": [["page", "page"]]
    }; }
}

const pnProgressBarCss = () => `${transformTag("pn-progress-bar")} .pn-progress-bar-label{margin-bottom:0.5em;color:#2d2013;font-weight:500;display:flex;justify-content:space-between;align-items:center;gap:0.5em}${transformTag("pn-progress-bar")} .pn-progress-bar-subtext{margin-top:0.5em;color:#5e554a;font-weight:400}${transformTag("pn-progress-bar")} .pn-progress-bar-container{overflow:hidden;padding:0.0625em;height:0.75em;border-radius:0.5em}${transformTag("pn-progress-bar")} .pn-progress-bar-meter{position:relative;width:100%;background:#f3f2f2;height:0.625em;border-radius:0.5em;box-shadow:0 0 0 0.0625em #969087}${transformTag("pn-progress-bar")} .pn-progress-bar-value{position:absolute;top:-0.0625em;left:-0.0625em;height:0.75em;background-color:#005d92;width:var(--progress-value);border-radius:0.5em 0 0 0.5em;transition-property:width, border-radius, background-color;transition-duration:0.2s, 0.2s, 0.5s;transition-timing-function:linear}@media (prefers-reduced-motion: reduce){${transformTag("pn-progress-bar")} .pn-progress-bar-value{transition-duration:0s}}${transformTag("pn-progress-bar")} .pn-progress-bar-value[data-valid]{width:calc(var(--progress-value) + 0.125em);background-color:#0aa85c;border-top-right-radius:0.5em;border-bottom-right-radius:0.5em}${transformTag("pn-progress-bar")} .pn-progress-bar-value[data-error]{background-color:#a70707}`;

class PnProgressBar {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    uniqueId = uuidv4();
    idProgress = `pn-progress-bar-${this.uniqueId}`;
    idLabel = `${this.idProgress}-label`;
    idText = `${this.idProgress}-text`;
    get hostElement() { return getElement(this); }
    progressPercentage;
    /** Set a label for the progress bar */
    label;
    /** Progress value, 0-100 */
    progress = 0;
    /** Replaces the default progress percentage text */
    progressText;
    /** Text shown on success (100%)  */
    successText;
    /** Trigger an error and display a message */
    error;
    /** A unique HTML id fror the progress bar */
    progressId = this.idProgress;
    setProgress() {
        if (!Number.isInteger(this.progress))
            return;
        const progressWidth = this.progress < 100 ? Math.ceil(this.progress) : 100;
        this.progressPercentage = `${progressWidth.toString()}%`;
        this.hostElement.style.setProperty('--progress-value', this.progressPercentage);
    }
    componentWillLoad() {
        this.setProgress();
    }
    hasLabel() {
        return !!this.label?.length;
    }
    hasText() {
        return !!this.successText?.length;
    }
    hasError() {
        return !!this.error?.length;
    }
    isValid() {
        return this.progress === 100;
    }
    hasIcon() {
        return this.isValid() || this.hasError();
    }
    getSubtext() {
        if (this.hasError())
            return this.error;
        if (this.isValid() && this.hasText())
            return this.successText;
        return this.progressText ? this.progressText : this.progressPercentage;
    }
    getIconSvg() {
        if (this.hasError())
            return alert_exclamation_circle;
        return check_circle;
    }
    getIconColor() {
        if (this.hasError())
            return 'warning';
        return 'green500';
    }
    render() {
        return (hAsync(Host, { key: '09b5b426ac2b3b5ac6da052516f02a37e86a5ae6' }, this.hasLabel() && (hAsync("p", { key: 'f63e4d6fcf21e46e809866fa9f25e92975665c60', id: this.idLabel, class: "pn-progress-bar-label" }, hAsync("span", { key: '731610df6161f9d7724f85e1fc849983dd2c9e30' }, this.label), this.hasIcon() && hAsync("pn-icon", { key: 'a9a823e21c9a6192ecd476fa7f993e2dc508f292', icon: this.getIconSvg(), color: this.getIconColor() }))), hAsync("div", { key: 'b38c51cbc3bf30d73cc169053a97fd62acd95972', id: this.progressId, class: "pn-progress-bar-container", role: "progressbar", "aria-labelledby": this.idLabel, "aria-describedby": this.hasIcon() ? this.idText : null, "aria-valuenow": this.progress, "aria-valuetext": this.progressPercentage }, hAsync("div", { key: '91f89839bf307d1b32f3735690ae6894b845fcc2', class: "pn-progress-bar-meter" }, hAsync("div", { key: '01dd3151497db0d7a4bfaa401fb132e015708ca6', class: "pn-progress-bar-value", "data-error": this.hasError(), "data-valid": this.isValid() }))), hAsync("p", { key: 'fe4122adfd2d4e1ea043f161bc217b59f3164cf0', id: this.idText, class: "pn-progress-bar-subtext", role: this.hasError() ? 'alert' : null }, hAsync("span", { key: '7094b7dd7cf15e29cec6f710927a3b62151d8709' }, this.getSubtext()))));
    }
    static get watchers() { return {
        "progress": [{
                "setProgress": 0
            }]
    }; }
    static get style() { return pnProgressBarCss(); }
    static get cmpMeta() { return {
        "$flags$": 512,
        "$tagName$": "pn-progress-bar",
        "$members$": {
            "label": [1],
            "progress": [2],
            "progressText": [1, "progress-text"],
            "successText": [1, "success-text"],
            "error": [1],
            "progressId": [1, "progress-id"],
            "progressPercentage": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnProgressIndicatorCss = () => `.pn-progress-indicator{display:flex;padding:2.8em 1em 0}`;

/**
 * @deprecated This component will be removed in v8. Please use the `pn-progress-stepper` instead.
 * @see {@link https://portal.postnord.com/web-components/?path=/docs/components-feedback-progress-stepper--docs Use `pn-progress-stepper` instead.}
 */
class PnProgressIndicator {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.progresschange = createEvent(this, "progresschange", 7);
    }
    get hostElement() { return getElement(this); }
    /** Takes the index of the active step */
    activeStep = 0;
    /** This will emit when progress is changed and is the value you want to bind to your VM state */
    progresschange;
    setActiveStepHandler({ detail }) {
        this.activeStep = detail;
        this.progresschange.emit(this.activeStep);
    }
    componentWillLoad() {
        this.passPropsToChildren();
    }
    componentDidUpdate() {
        this.passPropsToChildren();
    }
    passPropsToChildren() {
        const children = Array.from(this.hostElement.querySelectorAll(`${transformTag("pn-progress-indicator-step")}`));
        children.forEach((child, i) => {
            child.activeStep = this.activeStep;
            child.index = i;
        });
    }
    render() {
        return (hAsync("div", { key: '55eb279175a09345ebcb087ac6b0f819d5032a1e', class: "pn-progress-indicator" }, hAsync("slot", { key: '70f0273b605df274663752dadde8585411a74bd7' })));
    }
    static get style() { return pnProgressIndicatorCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-progress-indicator",
        "$members$": {
            "activeStep": [1026, "active-step"]
        },
        "$listeners$": [[0, "setactivestep", "setActiveStepHandler"]],
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnProgressIndicatorStepCss = () => `${transformTag("pn-progress-indicator-step")}{display:flex;flex:1 0 4em}${transformTag("pn-progress-indicator-step")}:first-child{flex:0 0 auto}${transformTag("pn-progress-indicator-step")}:first-child .progress-line{display:none}${transformTag("pn-progress-indicator-step")}:first-child .info-container{transform:translateX(-50%);left:50%}.pn-progress-indicator-step{position:relative;display:flex;flex:1 0 4em;-webkit-tap-highlight-color:rgba(0, 0, 0, 0);-webkit-tap-highlight-color:transparent}.pn-progress-indicator-step .circle{width:1.5em;height:1.5em;padding:0.3rem;border-radius:50%;background-color:#f3f2f2;transition-property:background-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){.pn-progress-indicator-step .circle{transition-duration:0s;transition-delay:0s}}.pn-progress-indicator-step .info-container{position:absolute;bottom:-2.5em;right:0;transform:translateX(50%) translateX(-1.2rem);white-space:nowrap;color:#f3f2f2;display:flex;align-items:center;flex-direction:column;font-size:1em;font-weight:normal;transition-property:color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){.pn-progress-indicator-step .info-container{transition-duration:0s;transition-delay:0s}}.pn-progress-indicator-step .info-container .pn-icon-svg{height:1.7em;width:1.7em;margin-bottom:0.1em}.pn-progress-indicator-step .info-container .pn-icon-svg path,.pn-progress-indicator-step .info-container .pn-icon-svg polygon{fill:#f3f2f2}.pn-progress-indicator-step .progress-line{flex:1 1 auto;margin:auto 4px;height:0.8rem;background-color:#f3f2f2;position:relative;overflow:hidden;pointer-events:none;border-radius:10rem}.pn-progress-indicator-step .progress-line:after{content:"";position:absolute;top:0;left:0;height:0.8rem;width:100%;background-color:#005d92;transform:translateX(-100%);transition-property:transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){.pn-progress-indicator-step .progress-line:after{transition-duration:0s;transition-delay:0s}}.pn-progress-indicator-step .progress-line:after{transition-delay:0.2s}.pn-progress-indicator-step.active .info-container{color:#000000}.pn-progress-indicator-step.active .info-container .pn-icon-svg path{fill:#000000}.pn-progress-indicator-step.active .info-container .pn-icon-svg polygon{fill:#000000}.pn-progress-indicator-step.activated{cursor:pointer}.pn-progress-indicator-step.done .progress-line:after,.pn-progress-indicator-step.active .progress-line:after{transform:translateX(0)}.pn-progress-indicator-step.done .circle,.pn-progress-indicator-step.active .circle{background-color:#005d92}.pn-progress-indicator-step.done .checkmark-path{stroke-linecap:round;stroke-dasharray:27;stroke-dashoffset:-23;animation:dash 0.2s cubic-bezier(0.55, 0, 0.1, 1) both}@keyframes dash{to{stroke-dashoffset:0}}`;

/**
 * @deprecated This component will be removed in v8. Please use the `pn-progress-stepper` instead.
 * @see {@link https://portal.postnord.com/web-components/?path=/docs/components-feedback-progress-stepper--docs Use `pn-progress-stepper` instead.}
 */
class PnProgressIndicatorStep {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.setactivestep = createEvent(this, "setactivestep", 7);
    }
    activated;
    done;
    /** Set by the parent component. Do not use manually. @hide true */
    activeStep;
    /** Set by the parent component. Do not use manually. @hide true */
    index;
    /** The step name. */
    name;
    /** Set the step as checked, meaning a white check mark will appear. */
    checked = false;
    /** Set by the parent component. Do not use manually. @hide true */
    active;
    setactivestep;
    setActiveStepHandler() {
        if (this.done || this.activated) {
            this.setactivestep.emit(this.index);
        }
    }
    componentWillLoad() {
        this.checkStatus();
    }
    componentDidUpdate() {
        this.checkStatus();
    }
    checkStatus() {
        if (!this.done) {
            this.done = this.checked || this.activeStep > this.index;
        }
        if (this.active === 'yes') {
            this.activated = true;
        }
        else if (this.active === 'no') {
            this.activated = false;
            this.done = false;
        }
        else if (!this.activated) {
            this.activated = this.activeStep >= this.index;
        }
    }
    getClassNames() {
        let className = 'pn-progress-indicator-step';
        if (this.done || this.checked)
            className += ' done';
        if (this.activated)
            className += ' activated';
        if (this.activeStep === this.index)
            className += ' active';
        return className;
    }
    render() {
        return (hAsync(Host, { key: '8e3e6d57379a0e7fbc4fa481ed58f320b0a7e270', class: this.getClassNames(), onClick: () => this.setActiveStepHandler() }, hAsync("div", { key: 'f07ace31e400c93a84043d4402bff452b2f3a5ea', class: "progress-line" }), hAsync("div", { key: '1b7b7fcdbcf11091b66a29f936cb144cb8d7b948', class: "info-container" }, hAsync("slot", { key: '9e075b50e5c16f7313d0442c889cd7ccbc2cbac9' }), this.name), hAsync("div", { key: '8240501b137f38915d3a42139e340593a1975977', class: "circle" }, this.done || this.checked ? (hAsync("svg", { xmlns: "http://www.w3.org/2000/svg", "enable-background": "new 0 0 24 24", id: "checkmark", version: "1.0", viewBox: "0 0 24 24" }, hAsync("polyline", { class: "checkmark-path", fill: "none", points: "20,6 9,17 4,12", stroke: white, "stroke-miterlimit": "10", "stroke-width": "3" }))) : (''))));
    }
    static get style() { return pnProgressIndicatorStepCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-progress-indicator-step",
        "$members$": {
            "activeStep": [2, "active-step"],
            "index": [2],
            "name": [1],
            "checked": [4],
            "active": [1],
            "activated": [32],
            "done": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const translations$5 = {
    STEP: {
        da: 'Trin',
        en: 'Step',
        fi: 'Vaihe',
        no: 'Trinn',
        sv: 'Steg',
    },
};

const pnProgressStepperCss = () => `${transformTag("pn-progress-stepper")}{display:block}${transformTag("pn-progress-stepper")} .pn-progress{position:relative;width:100%;background:#f3f2f2;height:0.5em;border-radius:0.5em;box-shadow:0 0 0 0.0625em #969087}${transformTag("pn-progress-stepper")} .pn-progress-label{display:block;color:#2d2013;font-size:1em;margin-bottom:0.5em}${transformTag("pn-progress-stepper")} .pn-progress-value{position:absolute;top:-0.0625em;left:-0.0625em;height:0.625em;background-color:#005d92;width:calc(var(--pn-progress-value) + 0.125em);border-radius:0.5em 0 0 0.5em;transition-property:width, border-radius;transition-duration:0.4s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-progress-stepper")} .pn-progress-value{transition-duration:0s;transition-delay:0s}}${transformTag("pn-progress-stepper")} .pn-progress-value[data-full]{border-top-right-radius:0.5em;border-bottom-right-radius:0.5em}${transformTag("pn-progress-stepper")} .pn-progress-dots{display:flex;align-items:center;justify-content:center;gap:1em}${transformTag("pn-progress-stepper")} .pn-progress-dot{width:0.875em;height:0.875em;background-color:#f3f2f2;border:0.0625em solid #d3cecb;border-radius:50%;transform:scale(1) translateY(0%);transition-property:background-color, border-color;transition-duration:0.4s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-progress-stepper")} .pn-progress-dot{transition-duration:0s;transition-delay:0s}}${transformTag("pn-progress-stepper")} .pn-progress-dot{animation:pnBackwards 0.2s cubic-bezier(0.7, 0, 0.3, 1);animation-fill-mode:forwards}${transformTag("pn-progress-stepper")} .pn-progress-dot[data-active]{background-color:#005d92;border-color:#005d92;animation:pnForward 0.2s cubic-bezier(0.7, 0, 0.3, 1);animation-fill-mode:forwards}${transformTag("pn-progress-stepper")} .pn-progress-sr-only{position:absolute;height:1px;width:1px;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);margin:-1px;white-space:nowrap}@keyframes pnForward{0%{transform:scale(1) translateY(0%)}50%{transform:scale(1) translateY(20%)}75%{transform:scale(1.1) translateY(10%)}100%{transform:scale(1) translateY(0%)}}@keyframes pnBackwards{0%{transform:scale(1) translateY(0%)}50%{transform:scale(1) translateY(-20%)}75%{transform:scale(0.9) translateY(-10%)}100%{transform:scale(1) translateY(0%)}}`;

/**
 * The `pn-progress-stepper` is used to visualize the users progress through a flow (checkout/survey, etc...).
 **/
class PnProgressStepper {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    id = `pn-progress-stepper-${uuidv4()}`;
    minStep = 1;
    maxStep = 7;
    get hostElement() { return getElement(this); }
    builtInLabel;
    /** Percentage calculated with currentStep / totalSteps. */
    progressValue = 0;
    /** Set custom label for the stepper, default label is "Step". */
    label = '';
    /** Set a custom HTML id on the progress stepper element to associate progress bar with label. */
    progressStepperId = '';
    /**
     * Set the language manually, only use this prop if the pnTopbar is not loaded.
     * Will not overwrite the custom `label` prop if used.
     **/
    language = null;
    /** Set total amount of steps, maximum allowed is `7`. @category Steps */
    totalSteps = this.maxStep;
    /** The current step of the progress stepper. @category Steps */
    currentStep = this.minStep;
    /** You can add a custom optional string to the label if you need a name for the current step. @category Steps */
    stepName;
    /**
     * Use the dots visual, instead of the bar.
     *
     * This will hide the label from view, but is still accessible to screenreaders.
     *
     * @since v7.16.0
     * @category Visual
     */
    dots = false;
    stepWatchers(a, b, c) {
        if (c === 'currentStep')
            this.validate(a, 'currentStep');
        if (c === 'totalSteps')
            this.validate(b, 'totalSteps');
        this.calculateProgress();
    }
    watchLanguage() {
        this.builtInLabel = translations$5.STEP[this.language || en$2];
    }
    async componentWillLoad() {
        this.watchLanguage();
        this.validate(this.currentStep, 'currentStep');
        this.validate(this.totalSteps, 'totalSteps');
        this.calculateProgress();
        if (this.language === null)
            await awaitTopbar(this.hostElement);
    }
    validate(step, prop) {
        const componentName = this.hostElement.localName;
        if (step < this.minStep) {
            console.warn(`${componentName}: The ${prop} ${step} is below the minimum allowed steps of ${this.minStep}. ${prop} will default to ${this.minStep}.`);
            this[prop] = this.minStep;
        }
        if (prop === 'currentStep' && step > this.totalSteps) {
            console.warn(`${componentName}: The ${prop} ${step} is above totalSteps ${this.totalSteps}, ${prop} will default to ${this.totalSteps}.`);
            this[prop] = this.totalSteps;
        }
        if (step > this.maxStep) {
            console.warn(`${componentName}: The ${prop} ${step} is above the maximum allowed steps of ${this.maxStep}. ${prop} will default to ${this.maxStep}.`);
            this[prop] = this.maxStep;
        }
    }
    calculateProgress() {
        try {
            this.progressValue = Math.floor((this.currentStep / this.totalSteps) * 100);
            this.hostElement.style.setProperty('--pn-progress-value', `${this.progressValue}%`);
        }
        catch (error) {
            console.error(`${this.hostElement.localName}:`, error.message);
        }
    }
    getLabel() {
        return this.label || this.builtInLabel;
    }
    getId() {
        return this.progressStepperId || this.id;
    }
    render() {
        return (hAsync(Host, { key: 'eae49d6f5d3085e714bff2e668694523185c6fb6' }, hAsync("label", { key: 'd5ec64934b8e8eab33b771d20aa34cdfb595f600', htmlFor: this.getId(), class: 'pn-progress-label' + (this.dots ? ' pn-progress-sr-only' : '') }, hAsync("span", { key: 'a30465882d45cdc3ee6513c79a9b9a0cacb68a88' }, this.getLabel(), " ", this.currentStep, "/", this.totalSteps), this.stepName && hAsync("span", { key: 'fb4f2eb25ccd60c648c7a2d077dfce35b6888f52' }, " - ", this.stepName)), hAsync("progress", { key: '6822b750b6d86644f5a77115d449c050b7be418d', id: this.getId(), class: "pn-progress-sr-only", max: "100", value: this.progressValue }), this.dots ? (hAsync("div", { class: "pn-progress-dots", "aria-hidden": "true" }, [...Array(this.totalSteps)].map((_, i) => (hAsync("div", { class: "pn-progress-dot", "data-active": i + 1 <= this.currentStep, key: i }))))) : (hAsync("div", { "aria-hidden": "true", class: "pn-progress" }, hAsync("div", { class: "pn-progress-value", "data-full": this.currentStep === this.totalSteps })))));
    }
    static get watchers() { return {
        "currentStep": [{
                "stepWatchers": 0
            }],
        "totalSteps": [{
                "stepWatchers": 0
            }],
        "language": [{
                "watchLanguage": 0
            }]
    }; }
    static get style() { return pnProgressStepperCss(); }
    static get cmpMeta() { return {
        "$flags$": 512,
        "$tagName$": "pn-progress-stepper",
        "$members$": {
            "label": [1],
            "progressStepperId": [1, "progress-stepper-id"],
            "language": [1],
            "totalSteps": [1026, "total-steps"],
            "currentStep": [1026, "current-step"],
            "stepName": [1, "step-name"],
            "dots": [4],
            "builtInLabel": [32],
            "progressValue": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnRadioButtonCss = () => `${transformTag("pn-radio-button")}{position:relative;display:inline-block}${transformTag("pn-radio-button")} .pn-radio{position:relative;display:flex;flex-wrap:wrap;flex-direction:row}${transformTag("pn-radio-button")} .pn-radio-label{cursor:pointer;color:#2d2013;-webkit-tap-highlight-color:transparent}${transformTag("pn-radio-button")} .pn-radio-helpertext{color:#5e554a;margin:0 0 0.5em 0;display:flex;flex-direction:column}${transformTag("pn-radio-button")} .pn-radio-helpertext:last-child{margin:0}${transformTag("pn-radio-button")} .pn-radio-content{display:flex;flex-direction:column;align-items:flex-start;font-weight:400;line-height:1.5;flex:1;margin:0 0 0 0.75em}${transformTag("pn-radio-button")} .pn-radio-button{display:flex;gap:0.75em;padding:0}${transformTag("pn-radio-button")} .pn-radio-outer{background-color:#ffffff;border:0.0625em solid #969087;border-radius:50%;height:1.5em;width:1.5em;display:flex;justify-content:center;align-items:center;outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:border-color, background-color, outline-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-radio-button")} .pn-radio-outer{transition-duration:0s;transition-delay:0s}}${transformTag("pn-radio-button")} .pn-radio-inner{height:0.75em;width:0.75em;background-color:#005d92;border-radius:50%;transform:scale(0);transform-origin:center center;transition-property:background-color, transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-radio-button")} .pn-radio-inner{transition-duration:0s;transition-delay:0s}}${transformTag("pn-radio-button")} .pn-radio[data-tile]{padding:1em;border:0.0625em solid #969087;border-radius:0.5em;background-color:#ffffff;outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:border-color, background-color, outline-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-radio-button")} .pn-radio[data-tile]{transition-duration:0s;transition-delay:0s}}${transformTag("pn-radio-button")} .pn-radio[data-tile] .pn-radio-outer{outline:none}${transformTag("pn-radio-button")} .pn-radio[data-invalid]{border-color:#a70707}${transformTag("pn-radio-button")} .pn-radio[data-invalid] .pn-radio-outer{border-color:#a70707}${transformTag("pn-radio-button")} .pn-radio[data-invalid] .pn-radio-inner{background-color:#a70707}${transformTag("pn-radio-button")} .pn-radio-container{flex:1 1 100%;overflow:hidden;visibility:hidden}${transformTag("pn-radio-button")} .pn-radio-container[data-open]{visibility:visible;overflow:unset}${transformTag("pn-radio-button")} .pn-radio-container[data-moving]{visibility:visible;overflow:hidden}${transformTag("pn-radio-button")} .pn-radio-area{padding:0.75em 0 0 2.25em;display:flex;flex-direction:column;flex-wrap:nowrap;gap:1em}${transformTag("pn-radio-button")} .pn-radio>${transformTag("pn-icon")}{margin-left:0.75em}${transformTag("pn-radio-button")}>input[type=radio]{cursor:pointer;opacity:0;position:absolute;margin:0;z-index:1;top:0;left:0;font-size:1em;width:1.5em;height:1.5em;-webkit-tap-highlight-color:transparent}${transformTag("pn-radio-button")}>input[type=radio][data-tile]:not([data-expand]){width:100%;height:100%}${transformTag("pn-radio-button")}>input[type=radio][data-expand]{top:1em;left:1em}${transformTag("pn-radio-button")}>input[type=radio][aria-describedby]+.pn-radio[data-tile] .pn-radio-label{font-weight:500}${transformTag("pn-radio-button")}>input[type=radio]:hover+.pn-radio[data-tile]{border-color:#005d92;background-color:#e0f8ff}${transformTag("pn-radio-button")}>input[type=radio]:hover+.pn-radio[data-tile] .pn-radio-outer{background-color:#e0f8ff}${transformTag("pn-radio-button")}>input[type=radio]:hover+.pn-radio[data-tile][data-invalid]{border-color:#a70707;background-color:#fdefee}${transformTag("pn-radio-button")}>input[type=radio]:hover+.pn-radio[data-tile][data-invalid] .pn-radio-outer{background-color:#fdefee}${transformTag("pn-radio-button")}>input[type=radio]:hover+.pn-radio[data-invalid] .pn-radio-outer{border-color:#a70707;background-color:#fdefee}${transformTag("pn-radio-button")}>input[type=radio]:hover+.pn-radio .pn-radio-outer{border-color:#005d92;background-color:#e0f8ff}${transformTag("pn-radio-button")}>input[type=radio]:checked:hover+.pn-radio[data-tile][data-invalid]{border-color:#500715}${transformTag("pn-radio-button")}>input[type=radio]:checked:hover+.pn-radio[data-invalid]>.pn-radio-button>.pn-radio-outer{border-color:#500715}${transformTag("pn-radio-button")}>input[type=radio]:focus-visible+.pn-radio .pn-radio-outer{outline-color:#005d92}${transformTag("pn-radio-button")}>input[type=radio]:focus-visible+.pn-radio[data-invalid] .pn-radio-outer{outline-color:#a70707}${transformTag("pn-radio-button")}>input[type=radio]:focus-visible+.pn-radio[data-tile]{outline-color:#005d92;border-color:#005d92}${transformTag("pn-radio-button")}>input[type=radio]:focus-visible+.pn-radio[data-tile][data-invalid]{outline-color:#a70707;border-color:#a70707}${transformTag("pn-radio-button")}>input[type=radio]:focus-visible+.pn-radio[data-tile]>.pn-radio-button>.pn-radio-outer{outline:none}${transformTag("pn-radio-button")}>input[type=radio]:checked+.pn-radio[data-tile]{border-color:#005d92;background-color:#e0f8ff}${transformTag("pn-radio-button")}>input[type=radio]:checked+.pn-radio[data-tile][data-invalid]{border-color:#a70707;background-color:#fdefee}${transformTag("pn-radio-button")}>input[type=radio]:checked+.pn-radio>.pn-radio-button>.pn-radio-outer{border-color:#005d92}${transformTag("pn-radio-button")}>input[type=radio]:checked+.pn-radio>.pn-radio-button>.pn-radio-outer>.pn-radio-inner{transform:scale(1);background-color:#005d92}${transformTag("pn-radio-button")}>input[type=radio]:checked+.pn-radio[data-invalid]>.pn-radio-button>.pn-radio-outer{border-color:#a70707}${transformTag("pn-radio-button")}>input[type=radio]:checked+.pn-radio[data-invalid]>.pn-radio-button>.pn-radio-outer>.pn-radio-inner{background-color:#a70707}${transformTag("pn-radio-button")}>input[type=radio]:disabled{pointer-events:none}${transformTag("pn-radio-button")}>input[type=radio]:disabled+.pn-radio .pn-radio-label{pointer-events:none}${transformTag("pn-radio-button")}>input[type=radio]:disabled+.pn-radio[data-tile]{background-color:#f3f2f2;border-color:#f3f2f2}${transformTag("pn-radio-button")}>input[type=radio]:disabled+.pn-radio[data-tile]>${transformTag("pn-icon")} .pn-icon-svg path{fill:#5e554a}${transformTag("pn-radio-button")}>input[type=radio]:disabled+.pn-radio[data-tile]>.pn-radio-content>.pn-radio-label{color:#5e554a}${transformTag("pn-radio-button")}>input[type=radio]:disabled+.pn-radio>.pn-radio-button>.pn-radio-outer{background-color:#f3f2f2;border-color:#969087;outline:none}${transformTag("pn-radio-button")}>input[type=radio]:disabled+.pn-radio>.pn-radio-button>.pn-radio-outer>.pn-radio-inner{background-color:#969087}`;

/**
 * The `pn-radio-button` is built with a native `input[type="radio"]` in the background.
 * This means you can use native events to listen to the changes.
 *
 * @nativeChange Use the `change` event to listen when the radio state is being changed.
 *
 * @slot - The default slot for adding custom HTML under the label/helpertext. {@since v7.17.0}
 * @slot helpertext - Use this slot to add custom HTML inside of the helpertext element.
 * Only recommended if you need a link without the `tile` prop. {@since v7.17.0}
 * @slot content - When using the `tile` and `expand` props, this slot will be revealed when the input is checked. {@since v7.17.0}
 */
class PnRadioButton extends Mixin(animateHeightFactory) {
    constructor(hostRef) {
        super();
        registerInstance(this, hostRef);
        this.pnRadioChange = createEvent(this, "pnRadioChange", 3);
    }
    id = `pn-radio-${uuidv4()}`;
    idHelpertext = `${this.id}-helpertext`;
    contentArea;
    radioInput;
    get hostElement() { return getElement(this); }
    /** The radio label */
    label;
    /** This adds an optional helpertext under the label. */
    helpertext;
    /** This will be emitted on change and input events. @category Native attributes */
    value;
    /** The name of the radio group. @category Native attributes */
    name;
    /** Programmatically check the input. @category Native attributes */
    checked = false;
    /** Set the radio as required. @category Native attributes */
    required = false;
    /** Disable the radio. @category Native attributes */
    disabled = false;
    /**
     * Turn the radio into a clickable tile. A border and padding is added.
     *
     * **Do not** use interactive elements (links/buttons) inside of the slots when using this prop.
     * An exception is made when using the `tile` + `expand` props together,
     * which allows you to use interactive elements.
     *
     * @category Features
     */
    tile = false;
    /**
     * Allow the radio to control the slot area "content".
     * When checked, the area is visible, when unchecked, the area is hidden.
     *
     * The prop `tile` must be used at the same time.
     * @see {@link tile}
     * @since v7.17.0
     * @category Features
     */
    expand = false;
    /**
     * Add an icon on the right of your radio tile. The `tile` prop must be `true` for the icon to work.
     * @see {@link tile}
     * @category Features
     */
    icon = null;
    /**
     * If set to true, color scheme will turn red, indicating that there is an issue or incorrect input related the radio.
     * @category Features
     */
    invalid = false;
    /** A unique HTML ID for the radio. @since v7.25.0 @category HTML attributes */
    pnId;
    /**
     * Provide the label via an aria attribute.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabel;
    /**
     * Provide the label from another element via its ID.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabelledby;
    /**
     * A unique HTML ID for the radio.
     * @deprecated Use `pn-id` instead.
     * @category HTML attributes
     */
    radioid;
    handleId() {
        this.idHelpertext = `${this.getId()}-helpertext`;
    }
    handleChecked(checked) {
        this.checked = checked ?? this.radioInput.checked;
        if (!this.displayContent())
            return;
        if (this.checked) {
            this.openDropdown(this.contentArea);
            this.uncheckOtherRadios();
        }
        else {
            this.closeDropdown(this.contentArea);
        }
    }
    handleChange(e) {
        const target = e.target;
        const { name } = target;
        const isSameRadioGroup = name === this.name;
        const isSameRadio = target === this.radioInput && target.checked;
        /**
         * Since content can be nested inside of this component,
         * double check that the event is coming from this specific radio.
         */
        if (isSameRadioGroup)
            this.checked = isSameRadio;
    }
    /**
     * This is the same as the native `change` event, but without bubbling.
     * This is useful when you want to listen to the event directly on the `pn-radio-button` element without
     * having to worry about catching events from nested pn-radio-buttons.
     *
     * @since v7.25.0
     **/
    pnRadioChange;
    componentDidLoad() {
        requestAnimationFrame(() => this.displayContent() && this.checked && this.openDropdown(this.contentArea));
    }
    getId() {
        return this.pnId || this.radioid || this.id;
    }
    uncheckOtherRadios() {
        if (!this.name)
            return;
        const selector = `pn-radio-button[name="${this.name}"]`;
        const list = document.querySelectorAll(selector);
        const radios = Array.from(list);
        radios.forEach(radio => radio !== this.hostElement && (radio.checked = false));
    }
    isInvalid() {
        return this.invalid && !this.disabled;
    }
    displayText() {
        return this.displayLabel() || this.displayHelpertext();
    }
    displayLabel() {
        return !!this.label;
    }
    displayHelpertext() {
        return !!(this.helpertext || this.hostElement.querySelector('[slot="helpertext"]')?.textContent);
    }
    displayIcon() {
        return this.tile && !!this.icon;
    }
    displayContent() {
        return this.tile && this.expand;
    }
    getAriaLabel() {
        return !this.displayLabel() && !this.pnAriaLabelledby ? this.pnAriaLabel : null;
    }
    getAriaLabelledby() {
        return !this.displayLabel() && !this.pnAriaLabel ? this.pnAriaLabelledby : null;
    }
    render() {
        return (hAsync(Host, { key: '52305f6cf3826500739510f0cf1fd0ab2abc7dc2' }, hAsync("input", { key: 'cc4f799fb58073ca59af798601d70baf88263aca', type: "radio", id: this.getId(), class: "pn-radio-input", value: this.value, name: this.name, disabled: this.disabled, checked: this.checked, required: this.required, "aria-label": this.getAriaLabel(), "aria-labelledby": this.getAriaLabelledby(), "aria-invalid": this.isInvalid()?.toString(), "aria-describedby": this.displayHelpertext() ? this.idHelpertext : null, "data-tile": this.tile, "data-expand": this.expand, onChange: event => this.pnRadioChange.emit(event), ref: el => (this.radioInput = el) }), hAsync("div", { key: '05e2a10face9b2ca1b0ced1f6f38f1173f15d1c0', class: "pn-radio", "data-tile": this.tile, "data-expand": this.expand, "data-invalid": this.isInvalid() }, hAsync("div", { key: 'b5274e03c47ac3d53103af945b3e8ce211eec827', class: "pn-radio-button" }, hAsync("div", { key: '1f4a592f7d243312e00259f67ce60836a449f42d', class: "pn-radio-outer" }, hAsync("div", { key: '05cb629b8c45724c6831271a40620ba5ec6e66ef', class: "pn-radio-inner" }))), hAsync("div", { key: 'a91835bcaa01888fd2a2b1b768def02203b58038', class: "pn-radio-content", hidden: !this.displayText() }, hAsync("label", { key: 'c11016410fd25dbb3288640ef5f239553991f0f8', htmlFor: this.getId(), class: "pn-radio-label", hidden: !this.displayLabel() }, this.label), hAsync("p", { key: '6d4d46978e2a4f326af1558c4c6dd04c3c29956b', id: this.idHelpertext, class: "pn-radio-helpertext", hidden: !this.displayHelpertext() }, this.helpertext, hAsync("slot", { key: '3167af1f4d47e1a9c8010bc9316b32c5499f66ee', name: "helpertext" })), hAsync("slot", { key: '1a4b466d8a8ba4e06ae96977e33fad1c502d5ea2' })), this.displayIcon() && hAsync("pn-icon", { key: '67f80f5c1db91e7310cf5baefdf6f3c346c83397', icon: this.icon, color: "gray900" }), hAsync("div", { key: 'e296239a734c33c40035b489d79b1edf44f1a2b7', class: "pn-radio-container", "data-open": this.checked, hidden: !this.displayContent(), style: { height: '0px' }, ref: el => (this.contentArea = el) }, hAsync("div", { key: 'f6245b5b2c9611da4b59a3fdb3047fe8365f1678', class: "pn-radio-area" }, hAsync("slot", { key: 'b985712da1ea4504025d17cc507588f14d9ebfff', name: "content" }))))));
    }
    static get watchers() { return {
        "radioid": [{
                "handleId": 0
            }],
        "pnId": [{
                "handleId": 1
            }],
        "checked": [{
                "handleChecked": 0
            }]
    }; }
    static get style() { return pnRadioButtonCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-radio-button",
        "$members$": {
            "label": [1],
            "helpertext": [1],
            "value": [513],
            "name": [1],
            "checked": [1028],
            "required": [4],
            "disabled": [4],
            "tile": [4],
            "expand": [4],
            "icon": [1],
            "invalid": [4],
            "pnId": [1, "pn-id"],
            "pnAriaLabel": [1, "pn-aria-label"],
            "pnAriaLabelledby": [1, "pn-aria-labelledby"],
            "radioid": [1],
            "isClosing": [32],
            "isExpanding": [32]
        },
        "$listeners$": [[8, "change", "handleChange"]],
        "$lazyBundleId$": "-",
        "$attrsToReflect$": [["value", "value"]]
    }; }
}

const pnRangeCss = () => `${transformTag("pn-range")}{display:block}${transformTag("pn-range")} .pn-range{color:#2d2013;display:flex;flex-direction:row;flex-wrap:wrap;gap:clamp(0.25em, 5vw, 0.75em);align-items:center;container-type:inline-size}@container (max-width: 24em){${transformTag("pn-range")} .pn-range .pn-range-header[data-input]{position:absolute;height:1px;width:1px;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);margin:-1px;white-space:nowrap}${transformTag("pn-range")} .pn-range>${transformTag("pn-input")}{flex:1 1 100%}${transformTag("pn-range")} .pn-range>${transformTag("pn-input")} .pn-input-label{position:unset;height:unset;width:unset;overflow:unset;clip:unset;margin:0 0 0.25em 0;white-space:unset}}${transformTag("pn-range")} .pn-range[data-markers]{margin-bottom:1em}${transformTag("pn-range")} .pn-range[data-markers][data-input]{margin-bottom:0.5em}${transformTag("pn-range")} .pn-range-header{display:flex;justify-content:space-between;flex:1 1 100%;width:100%}${transformTag("pn-range")} .pn-range-header:empty{display:none}${transformTag("pn-range")} .pn-range-label{cursor:pointer;display:flex;justify-content:space-between;align-items:flex-end;font-weight:400;color:#2d2013;margin:0 0 0.25em 0;gap:0.5em;-webkit-tap-highlight-color:transparent;transition-property:color, transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-range")} .pn-range-label{transition-duration:0s;transition-delay:0s}}${transformTag("pn-range")} .pn-range-label>span{font-size:0.875em}${transformTag("pn-range")} .pn-range-message{color:#5e554a;font-size:0.875em;font-weight:400;margin:0.25em 0 0 0;display:flex;flex-direction:column;gap:0.25em;text-align:left;flex:1 1 100%;width:100%}${transformTag("pn-range")} .pn-range-message[hidden],${transformTag("pn-range")} .pn-range-message>span[hidden]{display:none}${transformTag("pn-range")} .pn-range-error{color:#a70707}${transformTag("pn-range")} .pn-range-field{flex:0 0 auto}${transformTag("pn-range")} .pn-range-field .pn-input-label{position:absolute;height:1px;width:1px;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);margin:-1px;white-space:nowrap}${transformTag("pn-range")} .pn-range-group{position:relative;min-height:0.75em;padding:0.75em 0;flex:1 1 auto}${transformTag("pn-range")} .pn-range-group[data-pressing] *,${transformTag("pn-range")} .pn-range-group[data-pressing] *:before,${transformTag("pn-range")} .pn-range-group[data-pressing] *:after{transition-duration:0s}${transformTag("pn-range")} .pn-range-text{font-weight:400;font-size:0.875em;color:#2d2013}${transformTag("pn-range")} .pn-range-input{z-index:1;position:absolute;top:0;left:0;height:100%;width:100%;margin:0;opacity:0;cursor:pointer;-webkit-tap-highlight-color:transparent}${transformTag("pn-range")} .pn-range-input:focus~.pn-range-thumb:before,${transformTag("pn-range")} .pn-range-input:hover~.pn-range-thumb:before{background-color:#0d234b}${transformTag("pn-range")} .pn-range-input:focus~.pn-range-thumb .pn-range-tooltip,${transformTag("pn-range")} .pn-range-input:hover~.pn-range-thumb .pn-range-tooltip{opacity:1;transform:translateX(50%) translateY(0%);transition-delay:0s}${transformTag("pn-range")} .pn-range-input:focus-visible[data-single]~.pn-range-thumb:before{outline-color:#005d92}${transformTag("pn-range")} .pn-range-input:focus-visible[data-start]~.pn-range-thumb[data-start]:before,${transformTag("pn-range")} .pn-range-input:focus-visible[data-end]~.pn-range-thumb[data-end]:before{outline-color:#005d92}${transformTag("pn-range")} .pn-range-input[aria-invalid=true]~.pn-range-thumb:before{background-color:#a70707}${transformTag("pn-range")} .pn-range-input[aria-invalid=true]~.pn-range-thumb .pn-range-tooltip{background-color:#500715}${transformTag("pn-range")} .pn-range-input[aria-invalid=true]~.pn-range-track:before{background-color:#a70707}${transformTag("pn-range")} .pn-range-input[aria-invalid=true]:focus-visible[data-start]~.pn-range-thumb[data-start]:before,${transformTag("pn-range")} .pn-range-input[aria-invalid=true]:focus-visible[data-end]~.pn-range-thumb[data-end]:before{outline-color:#a70707}${transformTag("pn-range")} .pn-range-input[aria-invalid=true]:hover~.pn-range-thumb:before{background-color:#500715}${transformTag("pn-range")} .pn-range-input:disabled{cursor:not-allowed}${transformTag("pn-range")} .pn-range-input:disabled+.pn-range-track:before{background-color:#969087}${transformTag("pn-range")} .pn-range-input:disabled~.pn-range-thumb:before{background-color:#5e554a}${transformTag("pn-range")} .pn-range-input:disabled~.pn-range-thumb .pn-range-tooltip{background-color:#2d2013}${transformTag("pn-range")} .pn-range-overlay-input{z-index:5;cursor:pointer;position:absolute;appearance:none;top:0;left:0;height:100%;width:100%;margin:0;padding:0;border:0;outline:0;opacity:0;display:block;-webkit-tap-highlight-color:transparent}${transformTag("pn-range")} .pn-range-overlay-input:focus~.pn-range-thumb:before,${transformTag("pn-range")} .pn-range-overlay-input:focus-visible~.pn-range-thumb:before,${transformTag("pn-range")} .pn-range-overlay-input:hover~.pn-range-thumb:before{background-color:#0d234b}${transformTag("pn-range")} .pn-range-overlay-input:focus~.pn-range-thumb[data-align=right] .pn-range-tooltip,${transformTag("pn-range")} .pn-range-overlay-input:focus-visible~.pn-range-thumb[data-align=right] .pn-range-tooltip,${transformTag("pn-range")} .pn-range-overlay-input:hover~.pn-range-thumb[data-align=right] .pn-range-tooltip{transform:translateX(0%) translateY(0%);border-bottom-right-radius:0em}${transformTag("pn-range")} .pn-range-overlay-input:focus~.pn-range-thumb[data-align=left] .pn-range-tooltip,${transformTag("pn-range")} .pn-range-overlay-input:focus-visible~.pn-range-thumb[data-align=left] .pn-range-tooltip,${transformTag("pn-range")} .pn-range-overlay-input:hover~.pn-range-thumb[data-align=left] .pn-range-tooltip{transform:translateX(100%) translateY(0%);border-bottom-left-radius:0em}${transformTag("pn-range")} .pn-range-overlay-input:focus~.pn-range-thumb .pn-range-tooltip,${transformTag("pn-range")} .pn-range-overlay-input:focus-visible~.pn-range-thumb .pn-range-tooltip,${transformTag("pn-range")} .pn-range-overlay-input:hover~.pn-range-thumb .pn-range-tooltip{opacity:1;transform:translateX(50%) translateY(0%);transition-delay:0s}${transformTag("pn-range")} .pn-range-overlay-input[aria-invalid=true]:focus~.pn-range-thumb:before,${transformTag("pn-range")} .pn-range-overlay-input[aria-invalid=true]:focus-visible~.pn-range-thumb:before,${transformTag("pn-range")} .pn-range-overlay-input[aria-invalid=true]:hover~.pn-range-thumb:before{background-color:#500715}${transformTag("pn-range")} .pn-range-track{pointer-events:none;position:relative;min-height:inherit;display:block;background-color:#d3cecb;border-radius:2em;overflow:hidden}${transformTag("pn-range")} .pn-range-track:before,${transformTag("pn-range")} .pn-range-track:after{content:"";z-index:0;position:absolute;right:100%;pointer-events:none;height:100%;width:100%;background-color:#005d92;transform:translateX(var(--pn-range-progress));transition-property:transform, background-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-range")} .pn-range-track:before,${transformTag("pn-range")} .pn-range-track:after{transition-duration:0s;transition-delay:0s}}${transformTag("pn-range")} .pn-range-track:after{display:none}${transformTag("pn-range")} .pn-range-track:before{background-color:#005d92;transform:translateX(var(--pn-range-progress))}${transformTag("pn-range")} .pn-range-track[data-multiple]:before{transform:translateX(var(--pn-range-progress-end))}${transformTag("pn-range")} .pn-range-track[data-multiple]:after{display:unset;background-color:#d3cecb;transform:translateX(var(--pn-range-progress))}${transformTag("pn-range")} .pn-range-thumb{pointer-events:none;position:absolute;height:100%;width:calc(100% - 1em);top:0;right:calc(100% - 0.5em);transform:translateX(var(--pn-range-progress));transition-property:transform, border-radius;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-range")} .pn-range-thumb{transition-duration:0s;transition-delay:0s}}${transformTag("pn-range")} .pn-range-thumb[data-end]{transform:translateX(var(--pn-range-progress-end))}${transformTag("pn-range")} .pn-range-thumb[data-align=right] .pn-range-tooltip{transform:translateX(0%) translateY(10%)}${transformTag("pn-range")} .pn-range-thumb[data-align=right] .pn-range-tooltip:before{transform:translateX(50%) translateY(-50%) rotate(0deg)}${transformTag("pn-range")} .pn-range-thumb[data-align=left] .pn-range-tooltip{transform:translateX(100%) translateY(10%)}${transformTag("pn-range")} .pn-range-thumb[data-align=left] .pn-range-tooltip:before{transform:translateX(50%) translateY(-50%) rotate(0deg)}${transformTag("pn-range")} .pn-range-thumb:before{content:"";position:absolute;top:0.5em;right:-0.65625em;height:1.3125em;width:1.3125em;background-color:#005d92;border-radius:5em;outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:background-color, outline-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-range")} .pn-range-thumb:before{transition-duration:0s;transition-delay:0s}}${transformTag("pn-range")} .pn-range-tooltip{position:absolute;z-index:10;top:-85%;right:0;text-align:center;line-height:1.25em;white-space:nowrap;height:1.75em;min-width:2em;padding:0.25em 0.5em;border-radius:0.5em;background-color:#0d234b;color:#ffffff;transform:translateX(50%) translateY(10%);opacity:0;transition-property:opacity, transform, border-radius, background-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-range")} .pn-range-tooltip{transition-duration:0s;transition-delay:0s}}${transformTag("pn-range")} .pn-range-tooltip{transition-delay:0.4s}${transformTag("pn-range")} .pn-range-tooltip-label{font-size:0.875em;font-weight:400}${transformTag("pn-range")} .pn-range-tooltip:before{content:"";z-index:-1;position:absolute;left:50%;bottom:-0.25em;height:0.5em;width:0.5em;background-color:inherit;transform:translateX(-50%) translateY(0%) rotate(45deg);transition-property:left, transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-range")} .pn-range-tooltip:before{transition-duration:0s;transition-delay:0s}}${transformTag("pn-range")} .pn-range-markers{position:absolute;top:100%;left:0.5em;min-height:1em;width:calc(100% - 1em);padding:0;margin:0;list-style:none;display:flex;flex-direction:row;flex-wrap:nowrap}${transformTag("pn-range")} .pn-range-markers-item{position:relative;left:var(--pn-range-marker-position)}${transformTag("pn-range")} .pn-range-markers-item[data-min] .pn-range-markers-label{left:-0.0625em;transform:translateX(0%)}${transformTag("pn-range")} .pn-range-markers-item[data-max] .pn-range-markers-label{left:unset;right:0;transform:translateX(0%)}${transformTag("pn-range")} .pn-range-markers-item:before{content:"";position:absolute;left:0;top:-100%;border-left:0.0625em solid #d3cecb;height:1em;z-index:-1}${transformTag("pn-range")} .pn-range-markers-label{position:absolute;top:0;left:50%;transform:translateX(-50%);font-weight:400;font-size:0.875em;color:#5e554a;transition-property:color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-range")} .pn-range-markers-label{transition-duration:0s;transition-delay:0s}}${transformTag("pn-range")} .pn-range-markers-label[data-active]{color:#2d2013}`;

/**
 * Allow the user to use the slider to set a number value. Its built on the native `input[type=range]` element and
 * has support for most attributes.
 *
 * @slot helpertext - Set the helpertext via a slot instead of prop. Wrap the content like this: `<span slot="helpertext" />`.
 * @slot error - Set the error message via a slot instead of prop. Wrap the content like this: `<span slot="error" />`.
 *
 * @nativeInput Use the `input` event to listen to the range / input value being modified by the user. It is emitted everytime the user changes the value.
 * @nativeChange The `change` event is emitted when the user makes a final selection (letting go of the range/input).
 *
 * @since v7.20.0
 */
class PnRange {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.rangeSelected = createEvent(this, "rangeSelected", 7);
    }
    id = `pn-range-${uuidv4()}`;
    idEnd = `${this.id}-end`;
    idInput = `${this.id}-input`;
    idInputEnd = `${this.idEnd}-input`;
    idInputHidden = `${this.id}-hidden`;
    idHelpertext = `${this.id}-helpertext`;
    idError = `${this.id}-error`;
    idDatalist = `${this.id}-data`;
    mo;
    rangeTimeout;
    tooltipDefault = '{value}';
    get hostElement() { return getElement(this); }
    showHelperSlot = false;
    showErrorSlot = false;
    /** If true, remove transition times. */
    isPressing = false;
    /** When using `multiple`, decide which control is being pressed. */
    pressControl = null;
    /** Label for the range input. */
    label;
    /** Label for the range end input. */
    labelEnd;
    /** Set a helpertext for the range input. */
    helpertext = null;
    /** The range input value. @category Native attributes */
    value = 0;
    /** The range end input value. @category Native attributes */
    valueEnd = 0;
    /** The range input name. @category Native attributes */
    name;
    /** The range input name. @category Native attributes */
    nameEnd;
    /** The range input min value. @category Native attributes */
    min = 0;
    /** The range input max value. @category Native attributes */
    max = 100;
    /** Set a step value for the range input. @category Native attributes */
    step = '';
    /** Disable the range input. @category Native attributes */
    disabled = false;
    /**
     * Add markers. This will also render a `datalist` element with `options`.
     * Omitting the `label` for a marker will use the `value` as label instead.
     * Set `label` to `null` or `''` to hide it completely.
     * @category Features
     */
    markers = [];
    /**
     * Display an input for the range value.
     * Allowing the user to type or use the slider to set the value.
     * @category Features
     */
    input = false;
    /**
     * Range tooltip label template. Default is simply the value of the range input.
     * @example
     * // Show a suffixed '%' in the tooltip with '{value} %'.
     * <pn-range tooltip-template="{value} %" value="25" />
     * @category Features
     */
    tooltipTemplate = this.tooltipDefault;
    /** Hide the tooltip. @category Features */
    tooltipHide = false;
    /** Set a prefix for the range/input field. @category Features */
    textPrefix = null;
    /** Set a suffix for the range/input field. @category Features */
    textSuffix = null;
    /** Set an icon for the range/input field. @category Features */
    icon = null;
    /** Set an icon at the end of the range or for the second input field when using `multiple`. @category Features */
    iconEnd = null;
    /**
     * Allow multiple values to be selected
     * @category Features
     */
    multiple = false;
    /** Set the error visual for the range input, same as `error`, but without a message. @category Features */
    invalid = false;
    /** Set an error message for the range input. @category Features */
    error = null;
    /** Set a custom ID for the input. @category HTML attributes */
    pnId = this.id;
    /** Set a custom ID for the end input. @category HTML attributes */
    pnIdEnd = this.idEnd;
    /**
     * Provide the label via an aria attribute.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabel;
    /**
     * Provide the label for the end input via an aria attribute.
     * We strongly recommend you use the `label-end` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabelEnd;
    /**
     * Provide the label from another element via its ID.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabelledby;
    /**
     * Provide the label for the end input from another element via its ID.
     * We strongly recommend you use the `label-end` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabelledbyEnd;
    handleValue() {
        if (this.multiple && this.value > this.valueEnd) {
            this.valueEnd = this.value;
        }
        const percentage = this.calcPercentage(this.value);
        requestAnimationFrame(() => this.hostElement.style.setProperty('--pn-range-progress', `${percentage}%`));
    }
    handleValueEnd() {
        if (!this.multiple)
            return;
        if (this.value > this.valueEnd) {
            this.value = this.valueEnd;
        }
        const percentage = this.calcPercentage(this.valueEnd);
        requestAnimationFrame(() => this.hostElement.style.setProperty('--pn-range-progress-end', `${percentage}%`));
    }
    handleId() {
        this.idInput = `${this.pnId}-input`;
        this.idInputEnd = `${this.pnIdEnd}-input`;
        this.idHelpertext = `${this.pnId}-helpertext`;
        this.idError = `${this.pnId}-error`;
        this.idDatalist = `${this.pnId}-data`;
    }
    handleMessage() {
        this.checkSlottedHelper();
        this.checkSlottedError();
    }
    handleMultiple() {
        this.isPressing = true;
        requestAnimationFrame(() => (this.isPressing = false));
    }
    /** Emitted as the user makes any changes to the range/input value. */
    rangeSelected;
    connectedCallback() {
        this.mo = new MutationObserver(() => forceUpdate());
        this.mo.observe(this.hostElement, { childList: true, subtree: true });
    }
    disconnectedCallback() {
        if (this.mo)
            this.mo.disconnect();
    }
    getAriaLabel(end) {
        if (end)
            return !this.labelEnd && !this.pnAriaLabelledbyEnd ? this.pnAriaLabelEnd : null;
        return !this.label && !this.pnAriaLabelledby ? this.pnAriaLabel : null;
    }
    getAriaLabelledby(end) {
        if (end)
            return !this.labelEnd && !this.pnAriaLabelEnd ? this.pnAriaLabelledbyEnd : null;
        return !this.label && !this.pnAriaLabel ? this.pnAriaLabelledby : null;
    }
    tooltipDirection(isEnd = false) {
        if (this.multiple) {
            const isSmall = this.hostElement.offsetWidth < 384;
            const percentageStart = this.calcPercentage(this.value);
            const percentageEnd = this.calcPercentage(this.valueEnd);
            const isClose = Math.abs(percentageEnd - percentageStart) < (isSmall ? 30 : 20);
            if (isClose)
                return isEnd ? 'left' : 'right';
            if (!isEnd && this.value <= this.min + (this.max - this.min) * (isSmall ? 0.3 : 0.2))
                return 'left';
            if (isEnd && this.valueEnd > this.max * (isSmall ? 0.75 : 0.8))
                return 'right';
        }
        return 'center';
    }
    isActiveMarker(value) {
        const isActive = this.value === value;
        if (this.multiple)
            return isActive || this.valueEnd === value;
        return isActive;
    }
    hasHelperText() {
        return this.helpertext?.length > 0 || this.showHelperSlot;
    }
    /** If any `error` text is present, either via prop/slot. */
    hasErrorMessage() {
        return this.error?.length > 0 || this.showErrorSlot;
    }
    /** If any `error` is active, either via the prop `invalid` or `error` prop/slot. */
    hasError() {
        return this.hasErrorMessage() || this.invalid;
    }
    checkSlottedHelper() {
        const slottedHelper = this.hostElement.querySelector('[slot=helpertext]')?.textContent;
        this.showHelperSlot = !!slottedHelper?.length;
    }
    checkSlottedError() {
        const slottedError = this.hostElement.querySelector('[slot=error]')?.textContent;
        this.showErrorSlot = !!slottedError?.length;
    }
    calcPercentage(value) {
        return ((value - this.min) / (this.max - this.min)) * 100;
    }
    setValue(value, isEnd = false) {
        const isWithinMinMax = value >= this.min && value <= this.max;
        if (!isWithinMinMax)
            return;
        if (isEnd)
            this.valueEnd = value;
        else
            this.value = value;
        const range = Number((this.valueEnd - this.value).toPrecision(4));
        const percentageStart = this.calcPercentage(this.value);
        const percentageEnd = this.calcPercentage(this.valueEnd);
        const percentage = Number((this.multiple ? percentageEnd - percentageStart : percentageStart).toPrecision(4));
        const rangeDetail = this.multiple
            ? {
                valueEnd: this.valueEnd,
                difference: range,
            }
            : {};
        this.rangeSelected.emit({
            value: this.value,
            percentage,
            ...rangeDetail,
        });
    }
    getTooltipLabel(isEnd = false) {
        return this.tooltipTemplate?.replace(this.tooltipDefault, (isEnd ? this.valueEnd : this.value)?.toString());
    }
    getMarkerLabel({ value, label }) {
        if (label === null || label === '')
            return '';
        return (label || value).toString();
    }
    ariaDescribedby() {
        const list = [];
        if (this.hasErrorMessage())
            list.push(this.idError);
        else if (this.hasHelperText())
            list.push(this.idHelpertext);
        return list.length ? list.join(' ') : null;
    }
    handleChange(event) {
        const target = event.target;
        const { id, valueAsNumber, type } = target;
        const numberValue = isNaN(valueAsNumber) ? 0 : valueAsNumber;
        const isEnd = type === 'range' ? id === this.pnIdEnd : id === this.idInputEnd;
        this.setValue(numberValue, isEnd);
    }
    setListeners(isOverlay = false) {
        const inputEvent = (event) => (isOverlay ? this.handleOverlayInput(event) : this.handleChange(event));
        return {
            onInput: inputEvent,
            onTouchStart: (e) => this.handlePress(e),
            onTouchEnd: () => this.handleRelease(),
            onMouseDown: (e) => this.handlePress(e),
            onMouseUp: () => this.handleRelease(),
        };
    }
    handlePress(event) {
        this.rangeTimeout = setTimeout(() => {
            this.isPressing = true;
        }, event.type === 'touchstart' ? 200 : 100);
    }
    handleRelease() {
        clearTimeout(this.rangeTimeout);
        this.isPressing = false;
        this.pressControl = null;
    }
    commonAttrs() {
        return {
            step: this.step,
            min: this.min,
            max: this.max,
            list: this.markers?.length ? this.idDatalist : null,
            disabled: this.disabled,
        };
    }
    renderPrefix() {
        if (this.input)
            return this.renderNumberInput();
        if (this.icon)
            return hAsync("pn-icon", { class: "pn-range-icon", icon: this.icon });
        if (this.textPrefix && !this.input)
            return hAsync("span", { class: "pn-range-text" }, this.textPrefix);
        return null;
    }
    renderSuffix() {
        if (this.input && this.multiple)
            return this.renderNumberInput(true);
        if (this.iconEnd)
            return hAsync("pn-icon", { class: "pn-range-icon", icon: this.iconEnd });
        if (this.textSuffix && !this.input)
            return hAsync("span", { class: "pn-range-text" }, this.textSuffix);
        return null;
    }
    renderNumberInput(isEnd = false) {
        const label = isEnd ? this.labelEnd : this.label;
        const value = isEnd ? this.valueEnd : this.value;
        const idInput = isEnd ? this.idInputEnd : this.idInput;
        const name = isEnd ? (this.nameEnd ? `${this.nameEnd}-input` : null) : this.name ? `${this.name}-input` : null;
        return (hAsync("pn-input", { class: "pn-range-field", label: label, type: "number", name: name, ...this.commonAttrs(), icon: isEnd ? this.iconEnd : this.icon, textPrefix: this.textPrefix, textSuffix: this.textSuffix, value: value?.toString(), inputid: idInput, invalid: this.hasError(), "pn-aria-label": this.getAriaLabel(isEnd), "pn-aria-labelledby": this.getAriaLabelledby(isEnd), "data-single": !this.multiple, ...this.setListeners() }));
    }
    renderRangeInput(isEnd = false) {
        const id = isEnd ? this.pnIdEnd : this.pnId;
        const value = isEnd ? this.valueEnd : this.value;
        const customTooltip = this.tooltipDefault !== this.tooltipTemplate;
        return (hAsync("input", { id: id, class: "pn-range-input", type: "range", name: isEnd ? this.nameEnd : this.name, ...this.commonAttrs(), value: value, "aria-label": this.getAriaLabel(isEnd), "aria-labelledby": this.getAriaLabelledby(isEnd), "aria-valuetext": customTooltip ? this.getTooltipLabel(isEnd) : null, "aria-describedby": this.ariaDescribedby(), "aria-invalid": this.hasError().toString(), "data-start": isEnd ? null : true, "data-end": isEnd ? true : null, ...this.setListeners() }));
    }
    renderTooltip(isEnd = false) {
        return (hAsync("div", { class: "pn-range-thumb", "data-start": isEnd ? null : true, "data-end": isEnd ? true : null, "data-align": this.tooltipDirection(isEnd), "aria-hidden": "true" }, !this.tooltipHide && (hAsync("div", { class: "pn-range-tooltip" }, hAsync("span", { class: "pn-range-tooltip-label" }, this.getTooltipLabel(isEnd))))));
    }
    handleOverlayInput(event) {
        const target = event.target;
        const { valueAsNumber } = target;
        const numberValue = isNaN(valueAsNumber) ? 0 : valueAsNumber;
        if (!this.pressControl) {
            this.pressControl = Math.abs(numberValue - this.value) <= Math.abs(numberValue - this.valueEnd) ? 'start' : 'end';
        }
        this.setValue(numberValue, this.pressControl === 'end');
    }
    render() {
        return (hAsync(Host, { key: '7b15d5fd890496496ef2056fe05d84726ca469fb' }, hAsync("div", { key: '61d8b45ca3ccf77cdafed4ba1b810c171ed7fc53', class: "pn-range", "data-markers": !!this.markers?.length, "data-input": this.input }, hAsync("div", { key: 'e7c83db6b00415406d2906b48d0e502b241419ba', class: "pn-range-header", "data-input": this.input }, this.label && (hAsync("label", { key: '11a45aa1c4559e8a067f3f795e6c471d1a208079', htmlFor: this.pnId, class: "pn-range-label" }, hAsync("span", { key: '70f0c5a768b9524c2b029d723dc8440396ab9e73' }, this.label))), this.multiple && this.labelEnd && (hAsync("label", { key: '87c879956b9c056e94e520160d2d5ce101156bdb', htmlFor: this.pnIdEnd, class: "pn-range-label" }, hAsync("span", { key: '19cef5a35f5af8d7572bd25b8c585142090e01eb' }, this.labelEnd)))), this.renderPrefix(), hAsync("div", { key: 'fa7fcce195c3ec0f59f68223235991c78b0cd1e5', class: "pn-range-group", "data-pressing": this.isPressing }, this.renderRangeInput(), this.multiple && (hAsync(Fragment, { key: 'b8cfb75f9e26ca87cfcea6c9ac86843b83dd7f65' }, this.renderRangeInput(true), hAsync("input", { key: '6ae36cdd478fa192f7c131e6b1dbdbe4423beb31', id: this.idInputHidden, type: "range", class: "pn-range-overlay-input", ...this.commonAttrs(), "aria-invalid": this.hasError().toString(), hidden: true, tabIndex: -1, ...this.setListeners(true) }))), hAsync("div", { key: '87fa2359de2cb4ad694a5637e86105ddeb001d83', class: "pn-range-track", "data-multiple": this.multiple, "aria-hidden": "true" }), this.renderTooltip(), this.multiple && this.renderTooltip(true), !!this.markers?.length && (hAsync("ul", { key: '7fba4903d152f1597916a6ca960d0ead94108705', "aria-hidden": "true", class: "pn-range-markers" }, this.markers.map(({ label, value }) => (hAsync("li", { class: "pn-range-markers-item", "data-min": this.calcPercentage(value) === this.min, "data-max": this.calcPercentage(value) === this.max, style: { '--pn-range-marker-position': `${this.calcPercentage(value)}%` } }, hAsync("span", { class: "pn-range-markers-label", "data-active": this.isActiveMarker(value) }, this.getMarkerLabel({ value, label })))))))), this.renderSuffix(), !!this.markers?.length && (hAsync("datalist", { key: 'b14372658a0fef24130fb285de78833828db1690', id: this.idDatalist }, this.markers.map(({ label, value }) => (hAsync("option", { value: value, label: label === null ? null : label }))))), hAsync("p", { key: 'b69de56bb0a97f7a60a7cf7d68e52feb21a5af1b', id: this.idHelpertext, class: "pn-range-message", hidden: !this.hasHelperText() || this.hasErrorMessage() }, hAsync("span", { key: 'd0a03b481006198b487144d0552b1719bf845f67' }, this.helpertext), hAsync("slot", { key: 'e4c4698135491e6af33df77a7d0108f8c0aa0840', name: "helpertext" })), hAsync("p", { key: '9f462d515aeedfa4c28d0214afa9dba5ec10225e', id: this.idError, class: "pn-range-message pn-range-error", role: "alert", hidden: !this.hasErrorMessage() }, hAsync("span", { key: 'cbf21fa15da09a99e7d6daf01e5b497dec7d437c' }, this.error), hAsync("slot", { key: '93f9afd84d778eebf53d73531084c18fa583ee84', name: "error" })))));
    }
    static get watchers() { return {
        "value": [{
                "handleValue": 1
            }],
        "valueEnd": [{
                "handleValueEnd": 1
            }],
        "pnId": [{
                "handleId": 0
            }],
        "pnIdEnd": [{
                "handleId": 1
            }],
        "helpertext": [{
                "handleMessage": 1
            }],
        "error": [{
                "handleMessage": 0
            }],
        "multiple": [{
                "handleMultiple": 0
            }]
    }; }
    static get style() { return pnRangeCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-range",
        "$members$": {
            "label": [1],
            "labelEnd": [1, "label-end"],
            "helpertext": [1],
            "value": [1538],
            "valueEnd": [1538, "value-end"],
            "name": [1],
            "nameEnd": [1, "name-end"],
            "min": [2],
            "max": [2],
            "step": [1],
            "disabled": [4],
            "markers": [16],
            "input": [4],
            "tooltipTemplate": [1, "tooltip-template"],
            "tooltipHide": [4, "tooltip-hide"],
            "textPrefix": [1, "text-prefix"],
            "textSuffix": [1, "text-suffix"],
            "icon": [1],
            "iconEnd": [1, "icon-end"],
            "multiple": [4],
            "invalid": [4],
            "error": [1],
            "pnId": [1, "pn-id"],
            "pnIdEnd": [1, "pn-id-end"],
            "pnAriaLabel": [1, "pn-aria-label"],
            "pnAriaLabelEnd": [1, "pn-aria-label-end"],
            "pnAriaLabelledby": [1, "pn-aria-labelledby"],
            "pnAriaLabelledbyEnd": [1, "pn-aria-labelledby-end"],
            "showHelperSlot": [32],
            "showErrorSlot": [32],
            "isPressing": [32],
            "pressControl": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": [["value", "value"], ["valueEnd", "value-end"]]
    }; }
}

const pnReadOnlyButtonCss = () => `${transformTag("pn-read-only-button")}{display:inline-block}${transformTag("pn-read-only-button")} button{cursor:not-allowed;color:#5e554a;background:#f3f2f2;padding:0.75em 1.2em;width:100%;border:none;border-radius:3em;outline:none;position:relative;font-size:1em;min-height:3em;min-width:5.5em;font-weight:500;display:flex;justify-content:center;align-items:center;-webkit-tap-highlight-color:transparent}${transformTag("pn-read-only-button")} button ${transformTag("pn-icon")}{flex-shrink:0;margin:0 0 0 0.5em}${transformTag("pn-read-only-button")} button .button-tooltip{position:absolute;bottom:calc(100% + 0.35em);left:50%;background:#a70707;color:#ffffff;padding:0.25em 0.75em;font-size:0.875em;font-weight:300;border-radius:1em;box-shadow:0 1.2px 3.6px rgba(0, 0, 0, 0.1), 0 6.4px 14.4px rgba(0, 0, 0, 0.13);z-index:5;max-width:min(95vw, 40em);transform:translateX(-50%);width:max-content;pointer-events:none;opacity:0;transition-property:opacity;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-read-only-button")} button .button-tooltip{transition-duration:0s;transition-delay:0s}}${transformTag("pn-read-only-button")} button[data-tooltip-open] .button-tooltip{opacity:1}${transformTag("pn-read-only-button")} button.pn-button-left-icon{flex-direction:row-reverse}${transformTag("pn-read-only-button")} button.pn-button-left-icon ${transformTag("pn-icon")}{margin:0 0.5em 0 0}${transformTag("pn-read-only-button")} button.icon-only{width:3em;min-width:0}${transformTag("pn-read-only-button")} button.icon-only ${transformTag("pn-icon")}{margin:0}${transformTag("pn-read-only-button")} button.icon-only.pn-button-small{width:2.286em;min-width:0;padding:0}${transformTag("pn-read-only-button")} button.icon-only span.read-only-icon-only{display:none}${transformTag("pn-read-only-button")} button.pn-button-small{font-size:0.875em;padding:0.5em 1em;font-weight:normal;min-height:2.286em;min-width:none}${transformTag("pn-read-only-button")} button.pn-button-small ${transformTag("pn-icon")} .pn-icon-svg{height:1.28em;width:1.28em}`;

/**
 * There are no events or features other than the `icon`, `small` and `language` prop.
 *
 * Our rule is to not have disabled buttons.
 * However, this component is an exception for a very specific use case regarding portal users.
 */
class PnReadOnlyButton {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    get hostElement() { return getElement(this); }
    readOnlyModeText = '';
    tooltipOpen = false;
    tooltipEl;
    tooltipDx;
    /** The SVG content of the icon you want. */
    icon;
    /** Icon on the left side instead of on the right. */
    leftIcon = false;
    /** If you're using a button with only an icon, button text is still REQUIRED for the tooltip. */
    iconOnly = false;
    /** Smaller button. */
    small = false;
    /** Set the language manually. */
    language = null;
    setReadOnlyModeText() {
        const translations = {
            en: 'You cannot complete this action while in read only mode',
            sv: 'Du kan inte utföra denna handling i skrivskyddat läge',
            da: 'Du kan ikke gennemføre denne handling i skrivebeskyttet tilstand',
            fi: 'Et voi suorittaa tätä toimintoa vain luku -tilassa',
            no: 'Du kan ikke utføre denne handlingen i skrivebeskyttet modus',
        };
        this.readOnlyModeText = translations[this.language];
    }
    async componentWillLoad() {
        this.setReadOnlyModeText();
        if (this.language)
            return;
        await awaitTopbar(this.hostElement);
    }
    componentDidLoad() {
        this.initTooltip();
    }
    /*---------------------------------------TOOLTIP LOGIC-------------------------------------------*/
    openHandler() {
        if (this.tooltipOpen) {
            this.checkTooltipPosition();
            return;
        }
        this.setTooltipOffset();
    }
    initTooltip() {
        this.tooltipEl = this.hostElement.querySelector('.button-tooltip');
        const tooltipAnchor = this.hostElement;
        const openEvents = ['mouseenter', 'focus'];
        const closeEvents = ['mouseleave', 'blur'];
        const eventListeners = [...openEvents, ...closeEvents];
        eventListeners.forEach(e => {
            tooltipAnchor.addEventListener(e, event => {
                // Should open?
                if (openEvents.includes(event.type)) {
                    this.tooltipOpen = true;
                    return;
                }
                // Should close?
                if (closeEvents.includes(event.type)) {
                    this.tooltipOpen = false;
                }
            });
        });
    }
    setTooltipOffset() {
        this.tooltipEl.style.transform = `translateX(-50%) translateX(${this.tooltipDx}px)`;
    }
    checkTooltipPosition() {
        this.tooltipEl.style.transform = 'translateX(-50%)';
        requestAnimationFrame(() => {
            const { x, right } = this.tooltipEl.getBoundingClientRect();
            const extraMargin = 8;
            this.tooltipDx = '0';
            this.tooltipEl.style.transform = '';
            if (x < 0)
                this.tooltipDx = `${x * -1 + extraMargin}`;
            if (right > window.innerWidth)
                this.tooltipDx = `${window.innerWidth - right - extraMargin}`;
            requestAnimationFrame(() => {
                this.setTooltipOffset();
            });
        });
    }
    /* ---------------------------------------/TOOLTIP--------------------------------------- */
    getClassNames() {
        let classNames = 'pn-button ';
        if (this.small)
            classNames += 'pn-button-small ';
        if (this.leftIcon)
            classNames += 'pn-button-left-icon ';
        if (this.iconOnly)
            classNames += 'icon-only ';
        return classNames;
    }
    render() {
        return (hAsync(Host, { key: '050c438370b6d5c86e327be03d206880f2f572e5', class: "pn-read-only-button" }, hAsync("button", { key: 'a6cd36bc8f112d3ff7cb6ea65768339dd789813c', class: this.getClassNames(), "data-tooltip-open": this.tooltipOpen, disabled: true }, !this.iconOnly && hAsync("slot", { key: '94979edec979712e7ecc1f683dcf2f32a7889f48' }), this.icon && hAsync("pn-icon", { key: '14012e9a320767c993fab05c614c659f188783e3', icon: this.icon, color: "gray700" }), this.iconOnly && (hAsync("span", { key: '4f75372bf50ec504504ecbd808d3bf1e746c1418', class: "read-only-icon-only" }, hAsync("slot", { key: 'a12bca58ae471729cbb2442b1791bb4ee16c7db5' }))), hAsync("div", { key: '3ec03d46dc7c44229112a90b0df8ea4737a09e79', class: "button-tooltip" }, this.readOnlyModeText))));
    }
    static get watchers() { return {
        "language": [{
                "setReadOnlyModeText": 0
            }],
        "tooltipOpen": [{
                "openHandler": 0
            }]
    }; }
    static get style() { return pnReadOnlyButtonCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-read-only-button",
        "$members$": {
            "icon": [1],
            "leftIcon": [4, "left-icon"],
            "iconOnly": [4, "icon-only"],
            "small": [4],
            "language": [1],
            "readOnlyModeText": [32],
            "tooltipOpen": [32],
            "tooltipEl": [32],
            "tooltipDx": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const translations$4 = {
    SEARCH: {
        en: 'Search',
        sv: 'Sök',
        da: 'Søg',
        fi: 'Hae',
        no: 'Søk',
    },
    CLEAR: {
        en: 'Clear search field',
        sv: 'Rensa sökfältet',
        da: 'Ryd søgefeltet',
        fi: 'Tyhjennä hakukenttä',
        no: 'Tøm søkefeltet',
    },
};

const pnSearchFieldCss = () => `${transformTag("pn-search-field")}{display:inline-block}${transformTag("pn-search-field")} .pn-search-field{display:flex;gap:0.5em}${transformTag("pn-search-field")} .pn-search-field-container{width:100%;flex:1 1 100%;position:relative}${transformTag("pn-search-field")} .pn-search-field-input{min-height:3em;height:100%;width:100%;color:#2d2013;background-color:#ffffff;border:0.0625em solid #969087;border-radius:3em;padding:0.75em;font-family:inherit;font-size:1em;font-weight:500;line-height:1.5em;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent}${transformTag("pn-search-field")} .pn-search-field-input:-webkit-autofill,${transformTag("pn-search-field")} .pn-search-field-input:-webkit-autofill:hover,${transformTag("pn-search-field")} .pn-search-field-input:-webkit-autofill:focus,${transformTag("pn-search-field")} .pn-search-field-input:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #e0f8ff inset;-webkit-text-fill-color:#2d2013}${transformTag("pn-search-field")} .pn-search-field-input{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-search-field")} .pn-search-field-input:focus-visible{outline-color:#005d92;background-color:#ffffff;border-color:#005d92}${transformTag("pn-search-field")} .pn-search-field-input{transition-property:outline-color, background-color, border-color, color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-search-field")} .pn-search-field-input{transition-duration:0s;transition-delay:0s}}${transformTag("pn-search-field")} .pn-search-field-input::placeholder{color:#5e554a;font-weight:normal}${transformTag("pn-search-field")} .pn-search-field-input:hover{border-color:#005d92}${transformTag("pn-search-field")} .pn-search-field-input:disabled{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2}${transformTag("pn-search-field")} .pn-search-field-input::-webkit-calendar-picker-indicator,${transformTag("pn-search-field")} .pn-search-field-input::-webkit-search-cancel-button,${transformTag("pn-search-field")} .pn-search-field-input::-webkit-search-decoration{display:none !important}${transformTag("pn-search-field")} .pn-search-field-inline{pointer-events:none;position:absolute;top:0;right:0;background:transparent;width:3em;height:100%;overflow:hidden;display:flex;align-items:center;justify-content:center}${transformTag("pn-search-field")} .pn-search-field-inline ${transformTag("pn-button")}{position:absolute;left:50%;top:50%;transition-property:transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-search-field")} .pn-search-field-inline ${transformTag("pn-button")}{transition-duration:0s;transition-delay:0s}}${transformTag("pn-search-field")} .pn-search-field-inline ${transformTag("pn-button")}{transition-delay:0.2s;transform:translate(100%, -50%)}${transformTag("pn-search-field")} .pn-search-field-submit{white-space:nowrap}${transformTag("pn-search-field")} .pn-search-field-spinner{position:absolute;left:50%;top:50%;transition:transform cubic-bezier(0.7, 0, 0.3, 1) 0.2s;transform:translate(100%, -50%)}${transformTag("pn-search-field")} .pn-search-field[data-inline] .pn-search-field-inline{pointer-events:unset}${transformTag("pn-search-field")} .pn-search-field[data-inline] .pn-search-field-button{transform:translate(-50%, -50%)}${transformTag("pn-search-field")} .pn-search-field[data-inline][data-loading] ${transformTag("pn-button")}{transform:translate(100%, -50%)}${transformTag("pn-search-field")} .pn-search-field[data-inline][data-loading] .pn-search-field-spinner{transform:translate(-50%, -50%)}${transformTag("pn-search-field")} .pn-search-field[data-inline][data-searching] .pn-search-field-button{transform:translate(150%, -50%)}${transformTag("pn-search-field")} .pn-search-field[data-jumbo] .pn-search-field-input{min-height:4em;padding-left:1.25em}${transformTag("pn-search-field")} .pn-search-field[data-jumbo] .pn-search-field-submit .pn-button[data-icon-only]{width:4em;height:4em}${transformTag("pn-search-field")} .pn-search-field[data-jumbo] .pn-search-field-submit .pn-button[data-icon-only][data-loading] .pn-button-bg{width:4em;height:4em}${transformTag("pn-search-field")} .pn-search-field[data-searching] .pn-search-field-inline{pointer-events:unset}${transformTag("pn-search-field")} .pn-search-field[data-searching] .pn-search-field-clear{transform:translate(-50%, -50%)}`;

/**
 * The search field has multiple button variants that changes the visual appearance.
 *
 * @nativeInput Use the `input` event to listen to content being modified by the user. It is emitted everytime a user writes or removes content in the input.
 * @nativeChange The `change` event is emitted when the input loses focus, the user clicks `Enter` or makes a selection (such as auto complete or suggestions).
 */
class PnSearchField {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.search = createEvent(this, "search", 7);
        this.update = createEvent(this, "update", 7);
    }
    id = `pn-search-field-${uuidv4()}`;
    get hostElement() { return getElement(this); }
    /** Provide an aria-label for the search field. */
    label;
    /** Override the pntopbar language. */
    language = undefined;
    /** Set the value of the search field. @category Native attributes */
    value = '';
    /** Set HTML name of the search input. @category Native attributes */
    name;
    /** Set a search field placeholder. @category Native attributes */
    placeholder;
    /** Allow the browser to autocomplete the search field. @category Native attributes */
    autocomplete;
    /** Point to a datalist element with this id. @category Native attributes */
    list;
    /** Set the search field as required. @category Native attributes */
    required = false;
    /** Disable the search field. @category Native attributes */
    disabled = false;
    /** Display loading animation. @category Features */
    loading = false;
    /**
     * Button variant changes the visual of the search field:
     * - `''` Standard with a blue button.
     * - `simple` | ~~`icon`~~ with simple white icon only button.
     * - `auto` | ~~`icon-inline`~~ | ~~`none`~~ with a white inline search button.
     * - `jumbo` with a larger blue icon only button.
     *
     * @since v7.18.0: Use `''`, `simple`, `auto` or `jumbo`.
     *
     * @category Features
     */
    button = '';
    /** Label for the button element. @category Features */
    buttonLabel;
    /** Add a tooltip to the search button. @category Features */
    buttonTooltip;
    /**
     * Light instead of dark search button.
     *
     * @deprecated The color is now set automatically based on the button prop.
     * @category Features
     */
    buttonLight = false;
    /** Set a custom ID for the search input. @since v7.25.0 @category HTML attributes */
    pnId;
    /**
     * Provide the label from another element via its ID.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabelledby;
    /** Set a unique ID for the search input. @deprecated Use `pn-id` instead. @category HTML attributes  */
    searchid;
    /** This is emitted on search submission both with keyboard and mouse. */
    search;
    /** Custom event that handles both clearing and input to have the option of just binding listeners to one event instead of two. */
    update;
    inputHandler() {
        this.update.emit(this.value);
    }
    async componentWillLoad() {
        if (this.language === undefined)
            await awaitTopbar(this.hostElement);
    }
    getId() {
        return this.pnId || this.searchid || this.id;
    }
    translate(prop) {
        return translations$4?.[prop]?.[this.language || en$2];
    }
    emitSearch({ click, button }) {
        if (click?.type === 'click' || (button?.type === 'keydown' && button?.key === 'Enter')) {
            // We prevent the native search event since it's not supported in IE and FF, then we emit our own instead
            const event = click || button;
            event.preventDefault();
            this.search.emit(this.value);
        }
    }
    setVal(e) {
        this.value = e.target.value;
    }
    clearInput() {
        this.value = '';
        this.update.emit(this.value);
        this.hostElement.querySelector('input').focus();
    }
    displayLabel() {
        return !!this.label;
    }
    getAriaLabelledby() {
        return !this.displayLabel() ? this.pnAriaLabelledby : null;
    }
    getButtonLabel() {
        return this.buttonLabel || this.translate('SEARCH');
    }
    /** icon === simple-search */
    searchSimple() {
        return this.button === 'icon' || this.button === 'simple';
    }
    /** none | icon-inline  === auto-search */
    searchAuto() {
        return this.button === 'icon-inline' || this.button === 'none' || this.button === 'auto';
    }
    searchJumbo() {
        return this.button === 'jumbo';
    }
    searchButtonAppearance() {
        return this.searchSimple() ? 'light' : null;
    }
    searchButtonVariant() {
        return this.searchSimple() ? 'outlined' : null;
    }
    render() {
        return (hAsync(Host, { key: 'aa01f135ec98eed061d33617a5d21fb75407a917' }, hAsync("div", { key: '17161eac733e7f46c26524baf0508292b1575712', class: "pn-search-field", "data-inline": this.searchAuto(), "data-loading": this.loading, "data-searching": !!this.value, "data-jumbo": this.searchJumbo() }, hAsync("div", { key: '12a771d29c021a6c83fe9aa152f8367c7f20f2e3', class: "pn-search-field-container" }, hAsync("input", { key: 'b5ce3770f1ef6d53ee904ef40894eb91c76c96b4', class: "pn-search-field-input", id: this.getId(), type: "search", value: this.value, name: this.name, placeholder: this.placeholder, autocomplete: this.autocomplete, list: this.list, required: this.required, disabled: this.disabled, "aria-label": this.label, "aria-labelledby": this.getAriaLabelledby(), onKeyDown: e => this.emitSearch({ button: e }), onInput: e => this.setVal(e) }), hAsync("div", { key: 'f1922be073a70bbf54f67b7adc793c240b212769', class: "pn-search-field-inline" }, this.searchAuto() && (hAsync("pn-button", { key: '497b71cf5c3a1403789a4746b92da1b6f72f6341', class: "pn-search-field-button", type: "button", appearance: "light", small: true, icon: search, iconOnly: true, arialabel: this.getButtonLabel(), noTab: this.loading, onPnClick: e => this.emitSearch({ click: e.detail }) })), !this.disabled && (hAsync("pn-button", { key: 'd1591b1d364e9da38129099a7f2841282c0d224e', small: true, class: "pn-search-field-clear", type: "button", appearance: "light", icon: close_small, iconOnly: true, arialabel: this.translate('CLEAR'), noTab: !this.value || this.loading, onPnClick: () => this.clearInput() })), this.searchAuto() && hAsync("pn-spinner", { key: '205a3761b7637381f9ea50c4e28c6734f27558f3', class: "pn-search-field-spinner" }))), !this.searchAuto() && (hAsync("pn-button", { key: '0b41069b9d9554c196e32289e82192137cd8059e', class: "pn-search-field-submit", label: this.getButtonLabel(), tooltip: this.buttonTooltip, appearance: this.searchButtonAppearance(), variant: this.searchButtonVariant(), icon: search, iconOnly: this.searchSimple() || this.searchJumbo(), arialabel: this.searchSimple() || this.searchJumbo() ? this.getButtonLabel() : null, loading: this.loading, onPnClick: e => this.emitSearch({ click: e.detail }) })))));
    }
    static get style() { return pnSearchFieldCss(); }
    static get cmpMeta() { return {
        "$flags$": 512,
        "$tagName$": "pn-search-field",
        "$members$": {
            "label": [1],
            "language": [1],
            "value": [1025],
            "name": [1],
            "placeholder": [1],
            "autocomplete": [1],
            "list": [1],
            "required": [4],
            "disabled": [4],
            "loading": [4],
            "button": [1],
            "buttonLabel": [1, "button-label"],
            "buttonTooltip": [1, "button-tooltip"],
            "buttonLight": [4, "button-light"],
            "pnId": [1, "pn-id"],
            "pnAriaLabelledby": [1, "pn-aria-labelledby"],
            "searchid": [1]
        },
        "$listeners$": [[0, "input", "inputHandler"]],
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnSegmentCss = () => `${transformTag("pn-segment")}{position:relative;color:#005d92;margin-right:0.5em;z-index:2;white-space:nowrap;scroll-snap-align:center;outline:none;-webkit-tap-highlight-color:transparent;transform:translateZ(0)}${transformTag("pn-segment")}:last-of-type{margin-right:0}${transformTag("pn-segment")} .pn-segment{cursor:pointer;margin:0;padding:0;opacity:0;position:absolute;top:0;left:0;width:100%;height:100%;-webkit-tap-highlight-color:transparent}${transformTag("pn-segment")} .pn-segment:disabled{cursor:not-allowed}${transformTag("pn-segment")} .pn-segment:disabled~.pn-segment-label{color:#5e554a}${transformTag("pn-segment")} .pn-segment:disabled~.pn-segment-label ${transformTag("pn-icon")} .pn-icon-svg path{fill:#5e554a}${transformTag("pn-segment")} .pn-segment-label{height:100%;width:100%;padding:0.5em;border-radius:3em;font-weight:500;border:0.0625em solid transparent;display:inline-flex;gap:0.5em;align-items:center;-webkit-tap-highlight-color:transparent}`;

/**
 * The `pn-segment` is built with a native `input[type="radio"]` in the background.
 * Do not listen to events on the `pn-segment`, but on the `pn-segmented-control` instead.
 */
class PnSegment {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.segmentHover = createEvent(this, "segmentHover", 7);
    }
    id = `pn-segment-${uuidv4()}`;
    get hostElement() { return getElement(this); }
    /** The segment label, same as the slot. @since v7.7.0 */
    label;
    /** The segment value. @category Native attributes */
    value;
    /** The segment controller name. @category Native attributes */
    name;
    /** Disable the segment. @since v7.7.0 @category Native attributes */
    disabled = false;
    /** Set the segment as selected. Used by the `pn-segmented-control`. **Do not use manually**. @hide true */
    selected = false;
    /** The SVG content of the icon you want. @category Features */
    icon;
    /** Set a custom ID for the segment. @since v7.25.0 @category HTML attributes */
    pnId;
    /** Set a custom ID for the segment. @deprecated Use `pn-id` instead. @category HTML attributes */
    segmentid;
    /** This event is used by the `pn-segmented-control` component. Do not use manually. */
    segmentHover;
    handleHover(mouse) {
        this.segmentHover.emit(mouse);
    }
    getId() {
        return this.pnId || this.segmentid || this.id;
    }
    render() {
        return (hAsync(Host, { key: '035a10616c69c6c25f0edcff2a31532138684e99', onMouseEnter: (event) => this.handleHover(event) }, hAsync("input", { key: 'd256c8e01319f349339beafe2257ff2b2ebfbf08', class: "pn-segment", id: this.getId(), name: this.name, checked: this.selected, type: "radio", value: this.value, disabled: this.disabled }), hAsync("label", { key: '1bd57da75f8c9de454777d4bdcc22f23703c9d7e', htmlFor: this.getId(), class: "pn-segment-label" }, this.icon && hAsync("pn-icon", { key: 'f5c399f939fcad384b18c1de782fa542f3cf0ee9', icon: this.icon, color: "blue700" }), hAsync("span", { key: 'e0484e6a5357c24a2fa61bdb63245703a8db9cda', class: "pn-segment-text" }, this.label, hAsync("slot", { key: '1c2e2d941fefd272ea58fdcd0b98c0909eccfd5f' })))));
    }
    static get style() { return pnSegmentCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-segment",
        "$members$": {
            "label": [1],
            "value": [1],
            "name": [1],
            "disabled": [4],
            "selected": [4],
            "icon": [1],
            "pnId": [1, "pn-id"],
            "segmentid": [1]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnSegmentedControlCss = () => `${transformTag("pn-segmented-control")}{position:relative;display:inline-block;max-width:100%;overflow:hidden;border-radius:3em;transform:translateZ(0);transition-property:outline-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-segmented-control")}{transition-duration:0s;transition-delay:0s}}${transformTag("pn-segmented-control")}{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-segmented-control")}:focus-within,${transformTag("pn-segmented-control")}:active{outline-color:#005d92}${transformTag("pn-segmented-control")} .pn-segmented-control{display:flex;align-items:center;border-radius:3em;min-height:3em;padding:0.25em;background:#f3f2f2;position:relative;overflow-x:auto;scroll-snap-type:x mandatory}${transformTag("pn-segmented-control")} .pn-segmented-control:hover .pn-sc-bg[data-hover]{opacity:1}${transformTag("pn-segmented-control")} .pn-segmented-control::-webkit-scrollbar{display:none}${transformTag("pn-segmented-control")} .pn-segmented-control .pn-sc-bg{position:absolute;top:50%;transform:translateY(-50%);will-change:transform;left:0;border-radius:inherit;transition-property:width, transform, background-color, opacity, box-shadow;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-segmented-control")} .pn-segmented-control .pn-sc-bg{transition-duration:0s;transition-delay:0s}}${transformTag("pn-segmented-control")} .pn-segmented-control .pn-sc-bg[data-active]{box-shadow:0px 0.3px 0.9px rgba(0, 0, 0, 0.1), 0px 1.6px 3.6px rgba(0, 0, 0, 0.13);border:0.0625em solid #005d92;background-color:#ffffff;z-index:1}${transformTag("pn-segmented-control")} .pn-segmented-control .pn-sc-bg[data-hover]{background-color:#e0f8ff;opacity:0;border:0.25em solid transparent;z-index:0}${transformTag("pn-segmented-control")} .pn-segmented-control .pn-sc-bg[data-hover][data-disabled]{border-color:#e9e6e5;background-color:#e9e6e5}${transformTag("pn-segmented-control")} .pn-segmented-control .pn-sc-bg[data-disabled]{border-color:#e9e6e5;background-color:#e9e6e5}${transformTag("pn-segmented-control")} .pn-sc-arrows{position:absolute;top:50%;transform:translateY(-50%);left:0;height:100%;width:100%;z-index:3;display:flex;justify-content:space-between;align-items:center;pointer-events:none}${transformTag("pn-segmented-control")} .pn-sc-arrows svg{width:1.5em}${transformTag("pn-segmented-control")} .pn-sc-arrows svg.pn-icon-svg path{fill:#005d92}${transformTag("pn-segmented-control")} .pn-sc-arrows>.pn-sc-arrow{cursor:pointer;pointer-events:all;width:2.5em;height:2.5em;background:#ffffff;border:none;outline:none;display:flex;align-items:center;justify-content:center;opacity:0;will-change:transform;-webkit-tap-highlight-color:transparent;transition-property:transform, opacity, background-color, box-shadow;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-segmented-control")} .pn-sc-arrows>.pn-sc-arrow{transition-duration:0s;transition-delay:0s}}${transformTag("pn-segmented-control")} .pn-sc-arrows>.pn-sc-arrow.pn-sc-arrow-left{transform:translateX(-100%);border-radius:0 50% 50% 0;padding:0 0.3em 0 0;box-shadow:0.2rem 0.3rem 0.2rem rgba(0, 0, 0, 0.4)}${transformTag("pn-segmented-control")} .pn-sc-arrows>.pn-sc-arrow.pn-sc-arrow-right{transform:translateX(100%);border-radius:50% 0 0 50%;box-shadow:-0.2rem 0.3rem 0.2rem rgba(0, 0, 0, 0.4)}${transformTag("pn-segmented-control")} .pn-sc-arrows[data-left] .pn-sc-arrow-left,${transformTag("pn-segmented-control")} .pn-sc-arrows[data-right] .pn-sc-arrow-right{opacity:1;transform:translateX(0)}`;

/**
 * The `pn-segmented-control` and `pn-segmented` is built with native `input[type="radio"]` in the background.
 * This means you can use native events to listen to the changes.
 *
 * @nativeChange Use the `change` event to listen when the segment state is being changed.
 */
class PnSegmentedControl {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    mo;
    segmentContainer;
    segments = [];
    activeBg;
    hoverBg;
    scrollRegistered = false;
    get hostElement() { return getElement(this); }
    showScrollArrows = false;
    showLeftArrow = false;
    showRightArrow = false;
    /** This is the name of the radio buttons inside the controller. @deprecated Set the name in the nested `pn-segment` components. */
    name;
    /** Currently active segment value. */
    value;
    valueHandler() {
        this.setActiveSegment();
    }
    changeHandler(event) {
        const target = event.target;
        this.value = target.value;
        this.setActiveSegment();
    }
    handleResize() {
        this.rerender();
    }
    handleHover(event) {
        const { target } = event.detail;
        this.calcHighlight(target, true);
    }
    connectedCallback() {
        this.mo = new MutationObserver(() => {
            this.setSegments();
        });
        this.mo.observe(this.hostElement, { childList: true, subtree: true });
    }
    disconnectedCallback() {
        if (this.mo)
            this.mo.disconnect();
    }
    componentDidLoad() {
        this.setSegments();
    }
    setSegments() {
        const segmentTag = transformTag('pn-segment');
        const list = this.hostElement.querySelectorAll(segmentTag);
        this.segments = Array.from(list);
        this.setActiveSegment();
    }
    setActiveSegment() {
        this.segments.forEach(segmentEl => {
            if (this.value === segmentEl.value)
                segmentEl.setAttribute('selected', 'true');
            else
                segmentEl.removeAttribute('selected');
        });
        this.rerender();
    }
    rerender() {
        requestAnimationFrame(() => {
            this.calcHighlight();
            this.scrollArrowRender();
        });
    }
    /*---------------------------------------HIGHLIGHT LOGIC-------------------------------------------*/
    calcHighlight(element, hover) {
        const chip = hover ? this.hoverBg : this.activeBg;
        requestAnimationFrame(() => {
            const el = element || this.segments.find(({ value }) => value === this.value);
            const segmentTag = transformTag('pn-segment');
            const elSegment = el?.closest(segmentTag);
            if (!elSegment)
                return;
            const elRect = elSegment.getBoundingClientRect();
            const { left: hostLeft } = this.segmentContainer.getBoundingClientRect();
            const { left: segmentLeft, height: segmentHeight, width: segmentWidth } = elRect;
            const offset = segmentLeft - hostLeft + this.segmentContainer.scrollLeft;
            chip.style.setProperty('transform', `translate(${offset}px, -50%`);
            chip.style.setProperty('width', `${segmentWidth}px`);
            chip.style.setProperty('height', `${segmentHeight}px`);
            el.disabled ? (chip.dataset.disabled = '') : delete chip.dataset.disabled;
        });
    }
    /*---------------------------------------/HIGHLIGHT LOGIC-------------------------------------------*/
    /*---------------------------------------SCROLL ARROW LOGIC-------------------------------------------*/
    scrollArrowRender() {
        if (this.segmentContainer.scrollWidth > this.segmentContainer.clientWidth) {
            this.showScrollArrows = true;
            if (!this.scrollRegistered) {
                this.segmentContainer.addEventListener('scroll', this.scrollArrowRender.bind(this));
                this.scrollRegistered = true;
            }
            const amountScrolled = Math.round(this.segmentContainer.scrollWidth - this.segmentContainer.scrollLeft);
            const distanceToEnd = amountScrolled - this.segmentContainer.clientWidth;
            const distanceToStart = this.segmentContainer.scrollLeft;
            this.showLeftArrow = distanceToStart > 0;
            this.showRightArrow = distanceToEnd > 0;
        }
        else {
            this.showLeftArrow = false;
            this.showRightArrow = false;
            this.showScrollArrows = false;
        }
    }
    scroll(val) {
        let amount = this.segmentContainer.scrollLeft + val;
        this.segmentContainer.scroll({
            left: amount,
            behavior: 'smooth',
        });
    }
    /*---------------------------------------/SCROLL ARROW LOGIC-------------------------------------------*/
    render() {
        return (hAsync(Host, { key: '314c016bb1daea417c741babc236f8de14b9ab21' }, hAsync("div", { key: '10af3eb77723a2f99d6e665e6340caf9aaf03d27', class: "pn-segmented-control", ref: el => (this.segmentContainer = el) }, hAsync("slot", { key: '516890ccb71a58628d1f527272424b295c8959ab' }), hAsync("div", { key: 'f0f162d91a3c14a93b60195492978f03b41a0ecf', class: "pn-sc-bg", "data-active": true, ref: el => (this.activeBg = el) }), hAsync("div", { key: '9ca1016209402986a1702db3f50f9d52d913d249', class: "pn-sc-bg", "data-hover": true, ref: el => (this.hoverBg = el) })), hAsync("div", { key: '61d56ebba096df1a0cfab0aea8aa52059c62d13e', class: "pn-sc-arrows", "data-left": this.showLeftArrow, "data-right": this.showRightArrow, hidden: !this.showScrollArrows }, hAsync("button", { key: '1da8665af3d990175b92e50cf83e01adca082909', "aria-label": "Left", class: "pn-sc-arrow pn-sc-arrow-left", onClick: () => this.scroll(-120), tabindex: "-1" }, hAsync("pn-icon", { key: '3e78658670b082a938a5f976ea34b51449d669af', icon: arrow_left })), hAsync("button", { key: '03fad3f5c772b282850098e31d8ea717f5efb054', "aria-label": "Right", class: "pn-sc-arrow pn-sc-arrow-right", onClick: () => this.scroll(120), tabindex: "-1" }, hAsync("pn-icon", { key: '659dfab232a3256a9819cdf4ec34445f9bbfa875', icon: arrow_right })))));
    }
    static get watchers() { return {
        "value": [{
                "valueHandler": 0
            }]
    }; }
    static get style() { return pnSegmentedControlCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-segmented-control",
        "$members$": {
            "name": [1],
            "value": [1537],
            "showScrollArrows": [32],
            "showLeftArrow": [32],
            "showRightArrow": [32]
        },
        "$listeners$": [[0, "change", "changeHandler"], [9, "resize", "handleResize"], [0, "segmentHover", "handleHover"]],
        "$lazyBundleId$": "-",
        "$attrsToReflect$": [["value", "value"]]
    }; }
}

const pnSelectCss = () => `${transformTag("pn-select")}{display:inline-block}${transformTag("pn-select")} .pn-select-label{cursor:pointer;display:flex;justify-content:space-between;align-items:flex-end;font-weight:400;color:#2d2013;margin:0 0 0.25em 0;gap:0.5em;-webkit-tap-highlight-color:transparent;transition-property:color, transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-select")} .pn-select-label{transition-duration:0s;transition-delay:0s}}${transformTag("pn-select")} .pn-select-label[data-compact]{position:absolute;top:1.5625em;left:calc(var(--pn-input-offset-left, 0px) + 0.75em + 0.0625em);margin:0;pointer-events:none;align-items:center;height:1.5em;max-width:calc(100% - (var(--pn-input-offset-left, 0px) + 0.75em) - (var(--pn-input-offset-right, 0px) + 0.75em));transform:translateY(-50%) scale(1) translateZ(0);transform-origin:0 0;transition-delay:0.2s}${transformTag("pn-select")} .pn-select-label[data-compact]>span{font-size:1em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;line-height:1.5em}${transformTag("pn-select")} .pn-select-label>span{font-size:0.875em}${transformTag("pn-select")} .pn-select-label[data-compact][data-icon]{--pn-input-offset-left:calc(2em)}${transformTag("pn-select")} .pn-select-input{position:relative}${transformTag("pn-select")} .pn-select-icon{pointer-events:none;position:absolute;top:50%;transform:translateY(-50%);width:1.5em;height:1.5em;border-radius:50%;background-color:transparent}${transformTag("pn-select")} .pn-select-icon .pn-icon-svg{transition-property:transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-select")} .pn-select-icon .pn-icon-svg{transition-duration:0s;transition-delay:0s}}${transformTag("pn-select")} .pn-select-icon[data-default]{right:1em}${transformTag("pn-select")} .pn-select-icon[data-custom]{left:0.75em}${transformTag("pn-select")} .pn-select-icon[data-custom]~.pn-select-element{padding-left:2.75em}${transformTag("pn-select")} .pn-select-icon[data-error]{right:3.5em}${transformTag("pn-select")} .pn-select-icon[data-error]~.pn-select-element{padding-right:5.5em}${transformTag("pn-select")} .pn-select-element{cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100%;text-overflow:ellipsis;white-space:nowrap;color:#2d2013;background-color:#ffffff;border:0.0625em solid #969087;border-radius:0.5em;padding:0.75em 3em 0.75em 0.75em;font-family:inherit;font-size:1em;font-weight:500;line-height:1.5em;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent}${transformTag("pn-select")} .pn-select-element:-webkit-autofill,${transformTag("pn-select")} .pn-select-element:-webkit-autofill:hover,${transformTag("pn-select")} .pn-select-element:-webkit-autofill:focus,${transformTag("pn-select")} .pn-select-element:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #e0f8ff inset;-webkit-text-fill-color:#2d2013}${transformTag("pn-select")} .pn-select-element{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-select")} .pn-select-element:focus-visible{outline-color:#005d92;background-color:#ffffff;border-color:#005d92}${transformTag("pn-select")} .pn-select-element{transition-property:outline-color, background-color, border-color, color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-select")} .pn-select-element{transition-duration:0s;transition-delay:0s}}${transformTag("pn-select")} .pn-select-element[data-compact]{text-align:left;padding-top:1.125em;padding-bottom:0.375em;max-width:unset}${transformTag("pn-select")} .pn-select-element[data-compact]::placeholder{color:transparent}${transformTag("pn-select")} .pn-select-element[data-compact]:focus+.pn-select-label,${transformTag("pn-select")} .pn-select-element[data-compact]:not(:placeholder-shown)+.pn-select-label{transform:translateY(-85%) scale(0.75);transition-delay:0s}${transformTag("pn-select")} .pn-select-element::placeholder{color:#5e554a;font-weight:normal}${transformTag("pn-select")} .pn-select-element:hover{border-color:#005d92}${transformTag("pn-select")} .pn-select-element:disabled{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2}${transformTag("pn-select")} .pn-select-element:open~.pn-select-icon .pn-icon-svg{transform:rotate(180deg)}${transformTag("pn-select")} .pn-select-element:disabled{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2;pointer-events:none}${transformTag("pn-select")} .pn-select-element:disabled:hover{background-color:#f3f2f2}${transformTag("pn-select")} .pn-select-element:has(option[value=""]:checked){color:#5e554a;font-weight:normal}${transformTag("pn-select")} .pn-select-element:hover{color:#2d2013;background-color:#effbff}${transformTag("pn-select")} .pn-select-no-results{margin:0;padding:0.75em}${transformTag("pn-select")} .pn-select-text{color:#5e554a;font-size:0.875em;font-weight:400;margin:0.25em 0 0 0;display:flex;flex-direction:column;gap:0.25em}${transformTag("pn-select")} .pn-select-text[role=alert]{color:#a70707}${transformTag("pn-select")} .pn-select[data-error]>.pn-select-label{color:#a70707}${transformTag("pn-select")} .pn-select[data-error]>.pn-select-input>.pn-select-element{border-color:#a70707}${transformTag("pn-select")} .pn-select[data-error]>.pn-select-input>.pn-select-element:hover{border-color:#500715}${transformTag("pn-select")} .pn-select[data-error]>.pn-select-input>.pn-select-element:focus-visible{background-color:#ffffff;border-color:#a70707;outline-color:#a70707}${transformTag("pn-select")} .pn-select[data-error]>.pn-select-input>.pn-select-element:-webkit-autofill,${transformTag("pn-select")} .pn-select[data-error]>.pn-select-input>.pn-select-element:-webkit-autofill:hover,${transformTag("pn-select")} .pn-select[data-error]>.pn-select-input>.pn-select-element:-webkit-autofill:focus,${transformTag("pn-select")} .pn-select[data-error]>.pn-select-input>.pn-select-element:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #fef7f6 inset;-webkit-text-fill-color:#2d2013}${transformTag("pn-select")} .pn-select[data-error]>.pn-select-input>.pn-select-element:hover{background-color:#fdefee}`;

/**
 * The `pn-select` uses a native `select` element under the hood.
 * Use the slot to include `option` elements.
 *
 * Just like a regular `select`, you can use the `selected` prop on the nested option elements to preselect an option.
 *
 * @slot - This is the default slot, where the `option` elements go.
 * @slot helpertext - You can use this slot instead of the prop `helpertext`. Recommended, only if you need to include additional HTML markup. Such as a `pn-text-link`. Use a `span` element to wrap the text and link. {@since v7.25.0}
 * @slot error - You can use this slot instead of the prop `error`. Recommended, only if you need to include additional HTML markup. Such as a `pn-text-link`. Use a `span` element to wrap the text and link. {@since v7.25.0}
 *
 * @nativeChange Use the `change` event to listen to changes on the select element.
 */
class PnSelect {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    id = `pn-select-${uuidv4()}`;
    idHelper = `${this.id}-text`;
    idError = `${this.id}-error`;
    mo;
    get hostElement() { return getElement(this); }
    /** Label placed above the select. */
    label;
    /** Display a helper text underneath the select. */
    helpertext;
    /** HTML select name. @category Native attributes */
    name;
    /** HTML form name. @category Native attributes */
    form;
    /** HTML autocomplete. @category Native attributes */
    autocomplete;
    /** Set the select as required. @category Native attributes */
    required = false;
    /** Disable the select. @category Native attributes */
    disabled = false;
    /** Use the compact label variant. @since v7.21.0 @category Features */
    compact = false;
    /** Display an icon to the left of the select input. @category Features */
    icon;
    /** Trigger the invalid state. @category Features */
    invalid = false;
    /** Display an error message and trigger the invalid state. @category Features */
    error;
    /** Set a custom ID for the select. @since v7.25.0 @category HTML attributes */
    pnId;
    /**
     * Provide the label via an aria attribute.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabel;
    /**
     * Provide the label from another element via its ID.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabelledby;
    /** Set a custom ID for the select. @deprecated Use `pn-id` instead. @category HTML attributes */
    selectId;
    handleId() {
        this.idHelper = `${this.getId()}-text`;
        this.idError = `${this.getId()}-error`;
    }
    connectedCallback() {
        this.mo = new MutationObserver(() => forceUpdate());
        this.mo.observe(this.hostElement, { childList: true, subtree: true });
    }
    disconnectedCallback() {
        if (this.mo)
            this.mo.disconnect();
    }
    hasHelperText() {
        return this.helpertext?.length > 0 || this.checkSlottedHelper();
    }
    /** If any `error` text is present, either via prop/slot. */
    hasErrorMessage() {
        return this.error?.length > 0 || this.checkSlottedError();
    }
    /** If any `error` is active, either via the prop `invalid` or `error` prop/slot. */
    hasError() {
        return this.hasErrorMessage() || this.invalid || this.checkSlottedError();
    }
    checkSlottedHelper() {
        return !!this.hostElement.querySelector('[slot=helpertext]');
    }
    checkSlottedError() {
        return !!this.hostElement.querySelector('[slot=error]');
    }
    hideHelpertext() {
        return this.hasErrorMessage() || !this.hasHelperText();
    }
    hideError() {
        return !this.hasErrorMessage();
    }
    getId() {
        return this.pnId || this.selectId || this.id;
    }
    displayLabel() {
        return !!this.label;
    }
    getAriaLabel() {
        return !this.displayLabel() && !this.pnAriaLabelledby ? this.pnAriaLabel : null;
    }
    getAriaLabelledby() {
        return !this.displayLabel() && !this.pnAriaLabel ? this.pnAriaLabelledby : null;
    }
    getAriaDescribedby() {
        const list = [];
        if (this.hasErrorMessage())
            list.push(this.idError);
        else if (this.hasHelperText())
            list.push(this.idHelper);
        return list.length ? list.join(' ') : null;
    }
    renderLabel() {
        if (!this.label)
            return null;
        return (hAsync("label", { htmlFor: this.getId(), class: "pn-select-label", "data-compact": this.compact, "data-icon": !!this.icon }, hAsync("span", null, this.label)));
    }
    render() {
        return (hAsync(Host, { key: 'c00c913a1786719ef71800ed15adaf0dd47577ff' }, hAsync("div", { key: 'c2ee0553f2c130e12e7bc5bcfb611d457071cdec', class: "pn-select", "data-error": this.hasError() }, !this.compact && this.renderLabel(), hAsync("div", { key: '7e8d7a1ab89e30b870883ff50bec31dd2a38690d', class: "pn-select-input" }, this.icon && hAsync("pn-icon", { key: '772eb356db3cdf4fd04a67e1666ddb98799d40c0', class: "pn-select-icon", icon: this.icon, "data-custom": true, "aria-hidden": "true" }), this.hasError() && (hAsync("pn-icon", { key: '03ccbd0952abb83cc4828ad6bfca777e1544f7a6', class: "pn-select-icon", icon: alert_exclamation_circle, color: "warning", "data-error": true, "aria-hidden": "true" })), hAsync("select", { key: '46db113874c38b6f2ae6a42fbc63d9a9654a9dc1', id: this.getId(), class: "pn-select-element", name: this.name, form: this.form, autocomplete: this.autocomplete, "aria-label": this.getAriaLabel(), "aria-labelledby": this.getAriaLabelledby(), "aria-describedby": this.getAriaDescribedby(), "aria-invalid": this.hasError().toString(), disabled: this.disabled, "data-compact": this.compact }, hAsync("slot", { key: '8253ace83c8f6454d8bae7550895768d4e53f809' })), this.compact && this.renderLabel(), hAsync("pn-icon", { key: '88b094bd13b0d9cf912103427722e8be9ea2b687', class: "pn-select-icon", icon: chevron_down, color: "blue700", "data-default": true, "aria-hidden": "true" })), hAsync("p", { key: '03009e2b484ade6fadb9e20f161cfc50964db43a', id: this.idHelper, class: "pn-select-text", hidden: this.hideHelpertext() }, hAsync("span", { key: '2620e53c70c4ab95efc9924faa1a3ea298ec741b' }, this.helpertext), hAsync("slot", { key: 'bd9798ba17632021ce177292cc022f57ae52193f', name: "helpertext" })), hAsync("p", { key: '6ba88b6a3884430e7c263803ece5000adb08abe7', id: this.idError, class: "pn-select-text", role: "alert", hidden: this.hideError() }, hAsync("span", { key: 'dcc53f692bce2eaa5460075b9a1e191f29a777ad' }, this.error), hAsync("slot", { key: '0cf932dadffd1df3958e400a08c090483fc7c397', name: "error" })))));
    }
    static get watchers() { return {
        "selectId": [{
                "handleId": 0
            }],
        "pnId": [{
                "handleId": 1
            }]
    }; }
    static get style() { return pnSelectCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-select",
        "$members$": {
            "label": [1],
            "helpertext": [1],
            "name": [1],
            "form": [1],
            "autocomplete": [1],
            "required": [4],
            "disabled": [4],
            "compact": [4],
            "icon": [1],
            "invalid": [4],
            "error": [1],
            "pnId": [1, "pn-id"],
            "pnAriaLabel": [1, "pn-aria-label"],
            "pnAriaLabelledby": [1, "pn-aria-labelledby"],
            "selectId": [1, "select-id"]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnSkeletonLoaderCss = () => `@keyframes pn-shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}${transformTag("pn-skeleton-loader")}{display:block;background:transparent}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader{background:linear-gradient(90deg, #f3f2f2 25%, #f9f8f8 50%, #f3f2f2 75%);background-size:200% 100%;animation:pn-shimmer 1.5s infinite ease-in-out}@media (prefers-reduced-motion: reduce){${transformTag("pn-skeleton-loader")} .pn-skeleton-loader{animation:none}}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--box{width:100%;height:100%;min-height:3em;min-width:10em;border-radius:0.5em}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--card{width:100%;min-width:10em;border-radius:0.5em;box-shadow:0em 0.0625em 0.125em 0em rgba(20, 20, 20, 0.11), 0em 0.1875em 0.4375em 0em rgba(0, 0, 0, 0.13);background:#ffffff;animation:none;overflow:hidden;display:flex;flex-direction:column}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-card-image{width:100%;height:10em;clip-path:ellipse(175% 100% at top center);background:linear-gradient(90deg, #f3f2f2 25%, #f9f8f8 50%, #f3f2f2 75%);background-size:200% 100%;animation:pn-shimmer 1.5s infinite ease-in-out}@media (prefers-reduced-motion: reduce){${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-card-image{animation:none}}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-card-content{display:flex;flex-direction:column;gap:0.5em;padding:clamp(0.75em, 5vw, 1.5em)}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--tile{width:100%;border-radius:0.5em;box-shadow:0em 0.0625em 0.125em 0em rgba(20, 20, 20, 0.11), 0em 0.1875em 0.4375em 0em rgba(0, 0, 0, 0.13);background:#ffffff;animation:none;display:flex;flex-direction:column;align-items:center;padding:clamp(0.75em, 3vw, 1.5em);gap:clamp(1em, 5vw, 1.5em);text-align:center}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-tile-circle{width:7em;height:7em;border-radius:50%;background:linear-gradient(90deg, #f3f2f2 25%, #f9f8f8 50%, #f3f2f2 75%);background-size:200% 100%;animation:pn-shimmer 1.5s infinite ease-in-out}@media (prefers-reduced-motion: reduce){${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-tile-circle{animation:none}}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-tile-content{display:flex;flex-direction:column;gap:0.5em;width:100%}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--header{width:100%;background:none;animation:none;display:flex;flex-direction:column;gap:1em;padding:clamp(1em, 3vw, 2em) clamp(0.5em, 3vw, 2em)}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-header-back{width:5em;height:1em;border-radius:0.25em;background:linear-gradient(90deg, #f3f2f2 25%, #f9f8f8 50%, #f3f2f2 75%);background-size:200% 100%;animation:pn-shimmer 1.5s infinite ease-in-out}@media (prefers-reduced-motion: reduce){${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-header-back{animation:none}}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-header-heading{width:40%;height:2em;border-radius:0.25em;background:linear-gradient(90deg, #f3f2f2 25%, #f9f8f8 50%, #f3f2f2 75%);background-size:200% 100%;animation:pn-shimmer 1.5s infinite ease-in-out}@media (prefers-reduced-motion: reduce){${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-header-heading{animation:none}}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-header-subheading{width:30%;height:1em;border-radius:0.25em;background:linear-gradient(90deg, #f3f2f2 25%, #f9f8f8 50%, #f3f2f2 75%);background-size:200% 100%;animation:pn-shimmer 1.5s infinite ease-in-out}@media (prefers-reduced-motion: reduce){${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-header-subheading{animation:none}}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--chip{display:inline-block;width:6em;height:2.5em;border-radius:0.5em}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--chip.pn-skeleton-loader--small{height:2em;width:5em}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--chip.pn-skeleton-loader--large{height:2.875em;width:7em}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--input{width:100%;min-width:10em;height:3em;border-radius:0.5em}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--avatar{width:3em;height:3em;border-radius:50%}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--button{display:inline-block;min-width:5.5em;height:3em;border-radius:3em}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic{position:relative;background:none;animation:none;pointer-events:none}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic *{color:transparent !important;text-shadow:none !important}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic img,${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic svg,${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic ${transformTag("pn-icon")},${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic ${transformTag("pn-illustration")}{visibility:hidden}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic [data-skeleton]{position:relative;overflow:hidden}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic [data-skeleton]::after{content:"";position:absolute;inset:0;border-radius:inherit;background:linear-gradient(90deg, #f3f2f2 25%, #f9f8f8 50%, #f3f2f2 75%);background-size:200% 100%;animation:pn-shimmer 1.5s infinite ease-in-out}@media (prefers-reduced-motion: reduce){${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic [data-skeleton]::after{animation:none}}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic [data-skeleton=avatar]{border-radius:50%;overflow:hidden}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic [data-skeleton=button]{border-radius:3em;min-height:3em;min-width:5.5em}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic [data-skeleton=button] *{visibility:hidden}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic [data-skeleton=chip]{border-radius:0.5em;min-height:2.5em;min-width:4em}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic [data-skeleton=chip] *{visibility:hidden}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic [data-skeleton=text]::after{display:none}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic [data-skeleton=text]>*{position:relative;overflow:hidden;border-radius:0.25em}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic [data-skeleton=text]>*::after{content:"";position:absolute;inset:0;border-radius:0.25em;background:linear-gradient(90deg, #f3f2f2 25%, #f9f8f8 50%, #f3f2f2 75%);background-size:200% 100%;animation:pn-shimmer 1.5s infinite ease-in-out}@media (prefers-reduced-motion: reduce){${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--automatic [data-skeleton=text]>*::after{animation:none}}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--text{width:100%;min-width:10em;height:1em;border-radius:0.25em}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--paragraph{display:flex;flex-direction:column;gap:0.5em;min-width:10em;background:none;animation:none}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader--table{display:flex;flex-direction:column;gap:0.5em;min-width:10em;background:none;animation:none;border-radius:0.5em}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-table-header{width:100%;height:4em;border-radius:0.5em 0.5em 0 0;background:linear-gradient(90deg, #f3f2f2 25%, #f9f8f8 50%, #f3f2f2 75%);background-size:200% 100%;animation:pn-shimmer 1.5s infinite ease-in-out}@media (prefers-reduced-motion: reduce){${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-table-header{animation:none}}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-table-row{width:100%;height:3em;background:linear-gradient(90deg, #f3f2f2 25%, #f9f8f8 50%, #f3f2f2 75%);background-size:200% 100%;animation:pn-shimmer 1.5s infinite ease-in-out}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-table-row:last-child{border-radius:0 0 0.5em 0.5em}@media (prefers-reduced-motion: reduce){${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-table-row{animation:none}}${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-line{width:100%;height:1em;border-radius:0.25em;background:linear-gradient(90deg, #f3f2f2 25%, #f9f8f8 50%, #f3f2f2 75%);background-size:200% 100%;animation:pn-shimmer 1.5s infinite ease-in-out}@media (prefers-reduced-motion: reduce){${transformTag("pn-skeleton-loader")} .pn-skeleton-loader-line{animation:none}}`;

/** Display a skeleton loader placeholder to indicate content is loading. */
class PnSkeletonLoader {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    /** The skeleton shape to render.
     */
    type = 'box';
    /** Custom width (CSS value). Overrides type default.
     */
    width;
    /** Custom height (CSS value). Overrides type default.
     */
    height;
    /** Custom border-radius (CSS value). Overrides type default.
     */
    borderRadius;
    /** Small size variant for type="chip".
     */
    small = false;
    /** Large size variant for type="chip".
     */
    large = false;
    /** Number of lines for type="paragraph" or body rows for type="table". Does not do anything for other types. Default is 3.
     */
    lines = 3;
    /** When true, masks slotted content with shimmer instead of rendering a skeleton shape. The slotted content keeps its layout but text and images are hidden behind the shimmer effect.
     */
    automatic = false;
    /** When true, hides the skeleton. For automatic mode, the slotted content is shown without masking.
     */
    hide = false;
    getStyle() {
        const style = {};
        if (this.width)
            style['width'] = this.width;
        if (this.height)
            style['height'] = this.height;
        if (this.borderRadius)
            style['border-radius'] = this.borderRadius;
        return style;
    }
    renderParagraph() {
        const rows = [];
        for (let i = 0; i < this.lines; i++) {
            const isLast = i === this.lines - 1;
            rows.push(hAsync("div", { class: "pn-skeleton-loader-line", style: isLast ? { width: '75%' } : undefined }));
        }
        return rows;
    }
    renderTable() {
        const rows = [];
        for (let i = 0; i < this.lines; i++) {
            rows.push(hAsync("div", { class: "pn-skeleton-loader-table-row" }));
        }
        return rows;
    }
    render() {
        const style = this.getStyle();
        if (this.automatic) {
            return (hAsync(Host, null, hAsync("div", { class: {
                    'pn-skeleton-loader--automatic': !this.hide,
                }, role: !this.hide ? 'status' : undefined, "aria-busy": !this.hide ? 'true' : undefined, "aria-label": !this.hide ? 'Loading' : undefined }, hAsync("slot", null))));
        }
        if (this.hide) {
            return hAsync(Host, { style: { display: 'none' } });
        }
        if (this.type === 'paragraph') {
            return (hAsync(Host, null, hAsync("div", { class: "pn-skeleton-loader pn-skeleton-loader--paragraph", style: style, role: "status", "aria-busy": "true", "aria-label": "Loading" }, this.renderParagraph())));
        }
        if (this.type === 'table') {
            return (hAsync(Host, null, hAsync("div", { class: "pn-skeleton-loader pn-skeleton-loader--table", style: style, role: "status", "aria-busy": "true", "aria-label": "Loading" }, hAsync("div", { class: "pn-skeleton-loader-table-header" }), this.renderTable())));
        }
        if (this.type === 'card') {
            return (hAsync(Host, null, hAsync("div", { class: "pn-skeleton-loader pn-skeleton-loader--card", style: style, role: "status", "aria-busy": "true", "aria-label": "Loading" }, hAsync("div", { class: "pn-skeleton-loader-card-image" }), hAsync("div", { class: "pn-skeleton-loader-card-content" }, this.renderParagraph()))));
        }
        if (this.type === 'tile') {
            return (hAsync(Host, null, hAsync("div", { class: "pn-skeleton-loader pn-skeleton-loader--tile", style: style, role: "status", "aria-busy": "true", "aria-label": "Loading" }, hAsync("div", { class: "pn-skeleton-loader-tile-circle" }), hAsync("div", { class: "pn-skeleton-loader-tile-content" }, hAsync("div", { class: "pn-skeleton-loader-line" }), hAsync("div", { class: "pn-skeleton-loader-line", style: { width: '75%' } })))));
        }
        if (this.type === 'header') {
            return (hAsync(Host, null, hAsync("div", { class: "pn-skeleton-loader pn-skeleton-loader--header", style: style, role: "status", "aria-busy": "true", "aria-label": "Loading" }, hAsync("div", { class: "pn-skeleton-loader-header-back" }), hAsync("div", { class: "pn-skeleton-loader-header-heading" }), hAsync("div", { class: "pn-skeleton-loader-header-subheading" }))));
        }
        const classes = {
            'pn-skeleton-loader': true,
            [`pn-skeleton-loader--${this.type}`]: true,
            'pn-skeleton-loader--small': this.small,
            'pn-skeleton-loader--large': this.large,
        };
        return (hAsync(Host, null, hAsync("div", { class: classes, style: style, role: "status", "aria-busy": "true", "aria-label": "Loading" })));
    }
    static get style() { return pnSkeletonLoaderCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-skeleton-loader",
        "$members$": {
            "type": [1],
            "width": [1],
            "height": [1],
            "borderRadius": [1, "border-radius"],
            "small": [4],
            "large": [4],
            "lines": [2],
            "automatic": [4],
            "hide": [4]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnSpinnerCss = () => `${transformTag("pn-spinner")}{display:inline-block}${transformTag("pn-spinner")} .pn-spinner{--pn-spinner-size:1.5em;--pn-spinner-color:main.$blue700;height:var(--pn-spinner-size);width:var(--pn-spinner-size);display:block;animation:rotate 1s infinite;animation-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-spinner")} .pn-spinner{animation-duration:2s}}${transformTag("pn-spinner")} .pn-spinner-circle{stroke:var(--pn-spinner-color);transform-origin:center center;transform:rotate(-310deg);stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:64;animation:loading 2s infinite;animation-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-spinner")} .pn-spinner-circle{animation-duration:4s}}${transformTag("pn-spinner")} .pn-spinner-dot{fill:var(--pn-spinner-color)}@keyframes loading{0%{stroke-dashoffset:55}50%{stroke-dashoffset:12}100%{stroke-dashoffset:55}}@keyframes rotate{from{transform:rotate(-180deg) scaleX(-1)}to{transform:rotate(180deg) scaleX(-1)}}`;

/** Display a spinner to indicate a loading state. */
class PnSpinner {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    get hostElement() { return getElement(this); }
    /** Light version of the spinner. */
    light = false;
    /** Size in em. */
    size = 1.5;
    getColor() {
        if (this.light)
            return '#fff';
        return '#005d92';
    }
    getSize() {
        return `${this.size}em`;
    }
    render() {
        return (hAsync(Host, { key: 'a143e0f8959099811a49a4772809bea95ac7b3c5' }, hAsync("svg", { key: '14d49833b52a340b3b3d1a3c1dfdfb8e9c176858', class: "pn-spinner", style: { '--pn-spinner-size': this.getSize(), '--pn-spinner-color': this.getColor() }, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none" }, hAsync("circle", { key: 'b66d19a748cf83364f508956c9c3e1a487de96fc', class: "pn-spinner-circle", cx: "12", cy: "12", r: "10", "stroke-width": "3" }), hAsync("circle", { key: 'e576947e99cd98ead97e4a49327fcce9e5811af3', class: "pn-spinner-dot", cx: "21.3", cy: "16", r: "1.48" }))));
    }
    static get style() { return pnSpinnerCss(); }
    static get cmpMeta() { return {
        "$flags$": 512,
        "$tagName$": "pn-spinner",
        "$members$": {
            "light": [4],
            "size": [2]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnTabCss = () => `${transformTag("pn-tab")}{position:relative;overflow:hidden;flex-shrink:0;scroll-snap-align:center;display:inline-block;border-radius:0.5em}${transformTag("pn-tab")} .pn-tab{position:relative;cursor:pointer;margin:1em 0.25em;padding:0 0.25em;border:none;border-radius:0.5em;color:#2d2013;background-color:transparent;font-family:inherit;font-size:1em;font-weight:500;text-decoration:none;display:flex;gap:0.5em;align-items:center;justify-content:center;-webkit-tap-highlight-color:transparent}${transformTag("pn-tab")} .pn-tab .pn-ripple{animation:ripple 0.4s cubic-bezier(0.7, 0, 0.3, 1);position:absolute;border-radius:50%;background-color:#005d92;transform:translate(-50%, -50%) scale(0);opacity:0.1;pointer-events:none;z-index:3}@keyframes ripple{to{transform:translate(-50%, -50%) scale(1);opacity:0}}${transformTag("pn-tab")} .pn-tab{transition-property:color, outline-color, background-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-tab")} .pn-tab{transition-duration:0s;transition-delay:0s}}${transformTag("pn-tab")} .pn-tab{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-tab")} .pn-tab-label{line-height:1.5em}${transformTag("pn-tab")} .pn-tab:focus-visible{overflow:hidden;outline-color:#005d92;background-color:#ffffff}${transformTag("pn-tab")} .pn-tab[aria-selected=true],${transformTag("pn-tab")} .pn-tab[aria-current=page]{color:#005d92}${transformTag("pn-tab")} .pn-tab[aria-selected=true]:focus,${transformTag("pn-tab")} .pn-tab[aria-current=page]:focus{color:#0d234b}${transformTag("pn-tab")} .pn-tab[aria-selected=true]:focus ${transformTag("pn-icon")} .pn-icon-svg path,${transformTag("pn-tab")} .pn-tab[aria-selected=true]:focus ${transformTag("pn-icon")} .pn-icon-svg polygon,${transformTag("pn-tab")} .pn-tab[aria-current=page]:focus ${transformTag("pn-icon")} .pn-icon-svg path,${transformTag("pn-tab")} .pn-tab[aria-current=page]:focus ${transformTag("pn-icon")} .pn-icon-svg polygon{fill:#0d234b}`;

/**
 * This tab should control a tab panel.
 * Use the `ariacontrols` and `tabid` props to connect the tab with the tab panel.
 * The tab panel should in turn have `aria-labelledby` set to the `tabid` of the tab.
 *
 * If you use the `href` prop, the tab will turn into an anchor element instead of a button.
 * This does not required the ariacontrols and tabid props.
 */
class PnTab {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.setActiveTab = createEvent(this, "setActiveTab", 7);
        this.tabEnter = createEvent(this, "tabEnter", 7);
        this.tabLeave = createEvent(this, "tabLeave", 7);
    }
    mo;
    tag = 'button';
    get hostElement() { return getElement(this); }
    /** Set a label for the tab. */
    label;
    /** This is the value that will be matched with `pn-tablist` value. (required) */
    value;
    /** Turns the tab from a `button` to an `a` element, but only if the `pn-tablist` is inside a `pn-header`. */
    href;
    /** The SVG content of the icon you want to display */
    icon;
    /** Use the ID of the container that this tab controls.  */
    ariacontrols;
    /** Tab ID, use if you want to have the tab container be `aria-labelledby` by this tab. */
    tabid;
    /** Is set by `pn-tablist`, don't use this prop. @hide true */
    activeTab;
    /** Used by `pn-tab` to communicate with `pn-tablist`. Emits the selected tab value and element. */
    setActiveTab;
    setActiveTabHandler({ click = false, element } = {}) {
        if (click || this.isActive()) {
            const val = element?.value || this.value;
            const el = ((element?.value && element) || this.hostElement);
            this.setActiveTab.emit({
                val,
                el,
            });
        }
    }
    /** Used by `pn-tab` to communicate with `pn-tablist`. Emits when the tab gets focus. */
    tabEnter;
    triggerEnter(event) {
        this.tabEnter.emit(event);
    }
    /** Used by `pn-tab` to communicate with `pn-tablist`. Emits when the tab is blured.  */
    tabLeave;
    triggerLeave(event) {
        this.tabLeave.emit(event);
    }
    connectedCallback() {
        this.mo = new MutationObserver(() => forceUpdate());
        this.mo.observe(this.hostElement, { subtree: true, childList: true });
    }
    disconnectedCallback() {
        this.mo?.disconnect();
    }
    componentWillLoad() {
        this.tabTag();
    }
    componentDidUpdate() {
        this.setActiveTabHandler();
    }
    componentDidLoad() {
        this.setActiveTabHandler();
    }
    arrowKeyNav(event) {
        if (!/^(ArrowRight|ArrowLeft|Home|End)$/.test(event.key))
            return;
        const tabName = transformTag('pn-tab');
        const tablistName = transformTag('pn-tablist');
        event.preventDefault();
        // Get tablist parent
        const parent = event.target.closest(tablistName);
        if (!parent)
            return;
        const list = Array.from(parent.querySelectorAll(tabName));
        const first = list[0];
        const last = list[list.length - 1];
        const nextElement = this.hostElement.nextElementSibling;
        const previousElement = this.hostElement.previousElementSibling;
        if (event.key === 'Home')
            this.setActiveTabHandler({ element: first });
        if (event.key === 'End')
            this.setActiveTabHandler({ element: last });
        if (event.key === 'ArrowRight') {
            // Check the next element value. We do this because the last element i a DIV element. If no value, go to the first element.
            this.setActiveTabHandler({ element: nextElement?.value ? nextElement : first });
        }
        if (event.key === 'ArrowLeft') {
            // Go to the last element if there is no element to your left.
            this.setActiveTabHandler({ element: previousElement?.value ? previousElement : last });
        }
    }
    isActive() {
        return this.activeTab === this.value;
    }
    tabTag() {
        const tablistName = transformTag('pn-tablist');
        const isMenu = this.hostElement.closest(tablistName);
        this.tag = isMenu?.slot === 'menu' ? 'a' : 'button';
    }
    renderProperties() {
        return this.tag === 'a'
            ? {
                'href': this.href,
                'aria-current': this.isActive() ? 'page' : 'false',
            }
            : {
                'tabindex': this.isActive() ? 0 : -1,
                'type': 'button',
                'role': 'tab',
                'aria-selected': this.isActive().toString(),
                'aria-controls': this.ariacontrols,
            };
    }
    iconColor() {
        return this.isActive() ? 'blue700' : 'gray900';
    }
    handleClick(e) {
        this.setActiveTabHandler({ click: true });
        ripple(e, this.hostElement, '.pn-tab');
    }
    render() {
        const Tag = this.tag;
        return (hAsync(Host, { key: '55537e72d57486887ce53f76414c3cf2f6cf8d5d' }, hAsync(Tag, { key: 'a6b04fbff9c34f49e3ef93b4d34dc7dc08fcdbc9', id: this.tabid, class: "pn-tab", ...this.renderProperties(), onClick: (e) => this.handleClick(e), onMouseEnter: (e) => this.triggerEnter(e), onFocus: (e) => this.triggerEnter(e), onMouseLeave: (e) => this.triggerLeave(e), onBlur: (e) => this.triggerLeave(e), onKeyDown: (e) => this.arrowKeyNav(e) }, !!this.icon && hAsync("pn-icon", { key: '9d7fc111d42a22dbed2f9bc3a67644d6de632e61', icon: this.icon, color: this.iconColor() }), hAsync("slot", { key: '09d51a66dada9af7263e01ea08b0717cba6f4722' }), hAsync("span", { key: '23ae59bf1b5fbb25fe3a936758402c67e47eee3a', class: "pn-tab-label" }, this.label))));
    }
    static get style() { return pnTabCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-tab",
        "$members$": {
            "label": [1],
            "value": [1],
            "href": [1],
            "icon": [1],
            "ariacontrols": [1],
            "tabid": [1],
            "activeTab": [1, "active-tab"]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnTableCss = () => `${transformTag("pn-table")}{display:block;margin-bottom:1em}${transformTag("pn-table")} .pn-table-container table{width:100%}${transformTag("pn-table")} .pn-table-container table .column-wrapper{display:flex;gap:0.5em;width:100%;align-items:center}${transformTag("pn-table")} .pn-table-container table,${transformTag("pn-table")} .pn-table-container table th,${transformTag("pn-table")} .pn-table-container table td{padding:0;margin:0;border:0;outline:0;border-collapse:collapse;max-width:100%}${transformTag("pn-table")} .pn-table-container table th,${transformTag("pn-table")} .pn-table-container table td{text-align:left;line-height:2;vertical-align:middle;padding:1em 1.15em}${transformTag("pn-table")} .pn-table-container table th:first-child,${transformTag("pn-table")} .pn-table-container table td:first-child{border-radius:0.5em 0 0 0.5em}${transformTag("pn-table")} .pn-table-container table th:last-child,${transformTag("pn-table")} .pn-table-container table td:last-child{border-radius:0 0.5em 0.5em 0}${transformTag("pn-table")} .pn-table-container table th ${transformTag("pn-icon")},${transformTag("pn-table")} .pn-table-container table td ${transformTag("pn-icon")}{vertical-align:middle}${transformTag("pn-table")} .pn-table-container table thead tr th,${transformTag("pn-table")} .pn-table-container table thead tr td{color:#005d92;font-weight:500}${transformTag("pn-table")} .pn-table-container table tbody tr th,${transformTag("pn-table")} .pn-table-container table tbody tr td{color:#2d2013;font-weight:400}${transformTag("pn-table")}.bordered .pn-table-container table{border-collapse:separate;border-spacing:0}${transformTag("pn-table")}.bordered .pn-table-container table thead tr:last-child th,${transformTag("pn-table")}.bordered .pn-table-container table thead tr:last-child td{border-bottom-width:0.0625em}${transformTag("pn-table")}.bordered .pn-table-container table thead tr:first-child th,${transformTag("pn-table")}.bordered .pn-table-container table thead tr:first-child td{border-top:0.0625em solid #005d92}${transformTag("pn-table")}.bordered .pn-table-container table thead tr th,${transformTag("pn-table")}.bordered .pn-table-container table thead tr td{border-bottom:0.0625em solid #005d92}${transformTag("pn-table")}.bordered .pn-table-container table thead tr th:first-child,${transformTag("pn-table")}.bordered .pn-table-container table thead tr td:first-child{border-left:0.0625em solid #005d92;border-radius:0.5em 0 0}${transformTag("pn-table")}.bordered .pn-table-container table thead tr th:last-child,${transformTag("pn-table")}.bordered .pn-table-container table thead tr td:last-child{border-radius:0 0.5em 0 0;border-right:0.0625em solid #005d92}${transformTag("pn-table")}.bordered .pn-table-container table tbody tr th,${transformTag("pn-table")}.bordered .pn-table-container table tbody tr td{border-bottom:0.0625em solid #d3cecb}${transformTag("pn-table")}.bordered .pn-table-container table tbody tr th:first-child,${transformTag("pn-table")}.bordered .pn-table-container table tbody tr td:first-child{border-left:0.0625em solid #005d92;border-radius:0}${transformTag("pn-table")}.bordered .pn-table-container table tbody tr th:last-child,${transformTag("pn-table")}.bordered .pn-table-container table tbody tr td:last-child{border-right:0.0625em solid #005d92;border-radius:0}${transformTag("pn-table")}.bordered .pn-table-container table tbody tr:last-of-type th,${transformTag("pn-table")}.bordered .pn-table-container table tbody tr:last-of-type td{border-bottom:0.0625em solid #005d92}${transformTag("pn-table")}.bordered .pn-table-container table tbody tr:last-of-type th:last-child,${transformTag("pn-table")}.bordered .pn-table-container table tbody tr:last-of-type td:last-child{border-radius:0 0 0.5em 0}${transformTag("pn-table")}.bordered .pn-table-container table tbody tr:last-of-type th:first-child,${transformTag("pn-table")}.bordered .pn-table-container table tbody tr:last-of-type td:first-child{border-radius:0 0 0 0.5em}${transformTag("pn-table")}.bordered.striped .pn-table-container table tbody tr th,${transformTag("pn-table")}.bordered.striped .pn-table-container table tbody tr td{border-bottom-width:0}${transformTag("pn-table")}.bordered.striped .pn-table-container table tbody tr:last-child th,${transformTag("pn-table")}.bordered.striped .pn-table-container table tbody tr:last-child td{border-bottom-width:0.0625em}${transformTag("pn-table")}.striped .pn-table-container table tbody tr:nth-child(odd) th,${transformTag("pn-table")}.striped .pn-table-container table tbody tr:nth-child(odd) td{background-color:#effbff}${transformTag("pn-table")}.color-gray .pn-table-container table tbody tr:nth-child(odd) th,${transformTag("pn-table")}.color-gray .pn-table-container table tbody tr:nth-child(odd) td{background-color:#f9f8f8}`;

/**
 * The `pn-table` component is just a wrapper for your HTML table element.
 * You need to create the markup, but the component will deal with the styling.
 *
 * We have a built in class for divs inside table colums called `column-wrapper`.
 * This will line up your content and provide a grid gap.
 **/
class PnTable {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    get hostElement() { return getElement(this); }
    /** Use the gray variant instead of blue. */
    gray = false;
    /** Add border to table. */
    bordered = false;
    /** Make the table striped. */
    striped = false;
    getClassNames() {
        const classes = [this.striped && 'striped', this.bordered && 'bordered', this.gray ? 'color-gray' : 'color-blue'];
        return classes.filter(Boolean).join(' ');
    }
    render() {
        return (hAsync(Host, { key: 'c46bc77bf7e40631d6229457a7d764cf356f1b3d', class: this.getClassNames() }, hAsync("div", { key: 'e547b118837d48715f62cad80d0bfd31f10954d6', class: "pn-table-container" }, hAsync("slot", { key: '6c750540cac0e6fbdb9b9857f7eb309c27566d53' }))));
    }
    static get style() { return pnTableCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-table",
        "$members$": {
            "gray": [4],
            "bordered": [4],
            "striped": [4]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

var translations$3 = {
    LEFT: {
        sv: 'Bläddra åt vänster',
        en: 'Scroll to the left',
        da: 'Rul til venstre',
        fi: 'Vieritä vasemmalle',
        no: 'Rull til venstre',
    },
    RIGHT: {
        sv: 'Bläddra åt höger',
        en: 'Scroll to the right',
        da: 'Rul til højre',
        fi: 'Vieritä oikealle',
        no: 'Rull til høyre',
    },
};

const pnTablistCss = () => `${transformTag("pn-tablist")}{width:100%;min-width:0;position:relative;border-bottom:0.0625em solid #d3cecb;display:block}${transformTag("pn-tablist")} .pn-tablist,${transformTag("pn-tablist")} ol,${transformTag("pn-tablist")} ul{display:flex;width:100%;flex-direction:row;gap:1em;position:relative;list-style:none;padding:0;margin:0}${transformTag("pn-tablist")} .pn-tablist[data-stacked] .pn-tab,${transformTag("pn-tablist")} ol[data-stacked] .pn-tab,${transformTag("pn-tablist")} ul[data-stacked] .pn-tab{margin:0.5em 0.25em 0.75em;gap:0.25em;flex-direction:column}${transformTag("pn-tablist")} .pn-tablist[data-small] .pn-tab,${transformTag("pn-tablist")} ol[data-small] .pn-tab,${transformTag("pn-tablist")} ul[data-small] .pn-tab{margin:0.25em 0.25em 0.75em}${transformTag("pn-tablist")} .pn-tablist[data-small] .pn-tab>*:not(${transformTag("pn-icon")}),${transformTag("pn-tablist")} ol[data-small] .pn-tab>*:not(${transformTag("pn-icon")}),${transformTag("pn-tablist")} ul[data-small] .pn-tab>*:not(${transformTag("pn-icon")}){font-size:0.875em}${transformTag("pn-tablist")} .pn-tablist[data-large] .pn-tab>*:not(${transformTag("pn-icon")}),${transformTag("pn-tablist")} ol[data-large] .pn-tab>*:not(${transformTag("pn-icon")}),${transformTag("pn-tablist")} ul[data-large] .pn-tab>*:not(${transformTag("pn-icon")}){font-size:1.25em}${transformTag("pn-tablist")} .pn-tablist[data-scroll],${transformTag("pn-tablist")} ol[data-scroll],${transformTag("pn-tablist")} ul[data-scroll]{overflow-y:hidden;overflow-x:auto;scroll-snap-type:x mandatory}${transformTag("pn-tablist")} .pn-tablist::-webkit-scrollbar,${transformTag("pn-tablist")} ol::-webkit-scrollbar,${transformTag("pn-tablist")} ul::-webkit-scrollbar{display:none}${transformTag("pn-tablist")} .pn-tablist-line{height:0.25em;position:absolute;bottom:0}${transformTag("pn-tablist")} .pn-tablist-line-item{position:absolute;width:100%;height:inherit;border-radius:0.25em 0.25em 0 0;transform-origin:left center;opacity:0;transition-property:transform, opacity, width;transition-duration:0.4s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-tablist")} .pn-tablist-line-item{transition-duration:0s;transition-delay:0s}}${transformTag("pn-tablist")} .pn-tablist-line-active{z-index:1;background-color:#005d92;width:var(--pn-active-width);transform:translateX(var(--pn-active-offset));opacity:var(--pn-active-opacity)}${transformTag("pn-tablist")} .pn-tablist-line-hovered{background-color:#00a0d6;width:var(--pn-hover-width);transform:translateX(var(--pn-hover-offset));opacity:var(--pn-hover-opacity)}${transformTag("pn-tablist")} .pn-tablist-scroll{position:absolute;top:50%;left:0;right:0;pointer-events:none;transform:translateY(-50%);display:flex;justify-content:space-between;align-items:center;z-index:1;height:100%}${transformTag("pn-tablist")} .pn-tablist-arrow{pointer-events:all;transform:scaleY(0);opacity:0;visibility:hidden;transition-property:transform, opacity, visibility;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-tablist")} .pn-tablist-arrow{transition-duration:0s;transition-delay:0s}}${transformTag("pn-tablist")} .pn-tablist-arrow[data-show]{opacity:1;visibility:visible;transform:scaleY(1)}`;

/**
 * The tablist allows you to create a list with nested `pn-tab` components.
 * These should control the visibility of panel elements on the page.
 *
 * If you use the slot name "menu" the tablist will adapt to be used inside of
 * a `pn-header` component. This also allows the pn-tabs to use the `href` prop.
 *
 * @slot menu - Can only be used inside of a `pn-header`. Allows the `href` attribute on the `pn-tab` when active.
 */
class PnTablist {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.tabchange = createEvent(this, "tabchange", 7);
    }
    mo;
    isMenu = false;
    isTabHovered = false;
    tabListEl;
    lineActive;
    lineHovered;
    tabElement;
    get hostElement() { return getElement(this); }
    /** Display the scrolling arrows */
    showScrollArrows = false;
    /** Display the scroll arrow to the left */
    arrowLeft = false;
    /** Display the scroll arrow to the right */
    arrowRight = false;
    /** Give the tablist a name for screenreaders. */
    label;
    /** The value of the tab that is currently active, each `<pn-tab value="example-value">` also expects a unique value */
    value;
    /** Make the tablist smaller */
    small;
    /** Icons are stacked vertically instead of the default rows */
    stackedicons = false;
    /** Manually set the language. */
    language = null;
    /**
     * This will emit when a tab is changed. The detail property of the event will contain the value of the selected tab.
     * This is the event and value you listen to when you toggle the visibility among your tabpanels.
     **/
    tabchange;
    setValue() {
        const tabName = transformTag('pn-tab');
        const tabs = Array.from(this.hostElement.querySelectorAll(tabName));
        tabs.forEach(tab => {
            tab.activeTab = this.value;
        });
    }
    scrollHandler() {
        if (this.showScrollArrows) {
            this.tabListEl.addEventListener('scroll', this.scrollIndicators.bind(this));
        }
        else {
            this.tabListEl.removeEventListener('scroll', this.scrollIndicators);
        }
    }
    setActiveTabHandler({ detail }) {
        this.tabElement = detail.el;
        requestAnimationFrame(() => this.activateTab(detail.el));
        if (this.value === detail.val)
            return;
        this.value = detail.val;
        this.tabchange.emit(this.value);
        this.tabElement.querySelector('.pn-tab').focus();
    }
    rerender() {
        requestAnimationFrame(() => {
            this.scrollIndicators();
            this.isTabHovered = false;
        });
    }
    handleEnter(e) {
        this.isTabHovered = true;
        this.styleLines(e.target);
    }
    handleLeave() {
        this.isTabHovered = false;
        setTimeout(() => {
            if (!this.isTabHovered)
                this.lineHovered.style.setProperty('--pn-hover-opacity', '0');
        }, 500);
    }
    connectedCallback() {
        this.mo = new MutationObserver(() => {
            this.setValue();
            this.rerender();
        });
        this.mo.observe(this.hostElement, { subtree: true, childList: true });
    }
    disconnectedCallback() {
        this.mo?.disconnect();
    }
    async componentWillLoad() {
        this.isMenu = this.hostElement.slot === 'menu';
        if (this.language === null)
            await awaitTopbar(this.hostElement);
    }
    componentDidRender() {
        this.setValue();
        this.rerender();
    }
    getRect(element) {
        return element.getBoundingClientRect();
    }
    activateTab(element) {
        this.styleLines(element, true);
        this.styleLines(element, false);
    }
    styleLines(element, active = false) {
        const tabListCoords = this.getRect(this.tabListEl);
        const scrollOffset = this.tabListEl.scrollLeft;
        const line = this.getRect(element);
        const width = line.width;
        const offset = line.left + scrollOffset - tabListCoords.left;
        const cssVar = active ? 'active' : 'hover';
        const prop = active ? 'lineActive' : 'lineHovered';
        this[prop].style.setProperty(`--pn-${cssVar}-width`, `${width}px`);
        this[prop].style.setProperty(`--pn-${cssVar}-offset`, `${offset}px`);
        this[prop].style.setProperty(`--pn-${cssVar}-opacity`, '1');
    }
    scrollIndicators() {
        const { scrollWidth, scrollLeft } = this.tabListEl;
        const { clientWidth } = this.hostElement;
        this.showScrollArrows = scrollWidth > clientWidth;
        this.arrowLeft = this.showScrollArrows && scrollLeft > 0;
        this.arrowRight = this.showScrollArrows && clientWidth + 16 + scrollLeft < scrollWidth;
    }
    scroll({ right = false } = {}) {
        const tabList = this.tabListEl;
        const { scrollLeft, clientWidth } = tabList;
        let left = scrollLeft;
        // The width of the scroll arrow is 32px, so we remove that from this calculation so the scroll
        const scrollAmount = clientWidth - 64;
        if (right)
            left += scrollAmount;
        else
            left -= scrollAmount;
        tabList.scrollTo({
            left,
            behavior: 'smooth',
        });
    }
    translate(prop) {
        return translations$3?.[prop]?.[this.language || en$2];
    }
    render() {
        return (hAsync(Host, { key: '5e8d5b627e77c77e6de6bc560695f1acd5b1630d' }, hAsync("nav", { key: 'a33459d6510b75b5fc72674ab18606c4806a4058', class: "pn-tablist", role: this.isMenu ? null : 'tablist', "aria-label": this.label, "data-stacked": this.stackedicons, "data-small": !this.isMenu && this.small, "data-large": this.isMenu, "data-scroll": this.showScrollArrows, ref: el => (this.tabListEl = el) }, hAsync("slot", { key: '7bc0071b838903823c0c687385cd7d3311e83111' }), hAsync("div", { key: '50a05b5c23f05341728a941f3285e33c0b4dea0b', class: "pn-tablist-line" }, hAsync("div", { key: '9f838979792831b3283e35e60328ef406a52115e', ref: el => (this.lineActive = el), class: "pn-tablist-line-item pn-tablist-line-active" }), hAsync("div", { key: '06c6f200d2aa9eab372bcf5eee3b903864b2b7ff', ref: el => (this.lineHovered = el), class: "pn-tablist-line-item pn-tablist-line-hovered" }))), hAsync("div", { key: 'a43537577c3442186c66418cbaa26d48547c0828', class: "pn-tablist-scroll" }, hAsync("pn-button", { key: '7881274a4cffa56529a8c1684d38d7bc3af7ac66', class: "pn-tablist-arrow", "data-show": this.arrowLeft, onClick: () => this.scroll(), noTab: true, appearance: "light", variant: "outlined", icon: chevron_left, iconOnly: true, arialabel: this.translate('LEFT'), small: true }), hAsync("pn-button", { key: '0f38bf167cf2c8784242439c43950e5608699bed', class: "pn-tablist-arrow", "data-show": this.arrowRight, onClick: () => this.scroll({ right: true }), noTab: true, appearance: "light", variant: "outlined", icon: chevron_right, iconOnly: true, arialabel: this.translate('RIGHT'), small: true }))));
    }
    static get watchers() { return {
        "value": [{
                "setValue": 0
            }],
        "showScrollArrows": [{
                "scrollHandler": 0
            }]
    }; }
    static get style() { return pnTablistCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-tablist",
        "$members$": {
            "label": [1],
            "value": [1537],
            "small": [4],
            "stackedicons": [4],
            "language": [1],
            "showScrollArrows": [32],
            "arrowLeft": [32],
            "arrowRight": [32]
        },
        "$listeners$": [[0, "setActiveTab", "setActiveTabHandler"], [9, "resize", "rerender"], [0, "tabEnter", "handleEnter"], [0, "tabLeave", "handleLeave"]],
        "$lazyBundleId$": "-",
        "$attrsToReflect$": [["value", "value"]]
    }; }
}

const pnTagCss = () => `${transformTag("pn-tag")}{display:inline-block}${transformTag("pn-tag")} .pn-tag{display:inline-flex;flex-direction:row;gap:0.5em;justify-content:center;align-items:center;border-radius:0.5em;padding:0.5em 1em}${transformTag("pn-tag")} .pn-tag[data-icon]{padding-left:0.75em}${transformTag("pn-tag")} .pn-tag{background-color:rgba(142, 221, 249, 0.3);color:#0d234b}${transformTag("pn-tag")} .pn-tag[data-dark]{background-color:#8eddf9}${transformTag("pn-tag")} .pn-tag ${transformTag("pn-icon")} .pn-icon-svg path{fill:#0d234b}${transformTag("pn-tag")} .pn-tag-label{line-height:1.5em;font-weight:400}${transformTag("pn-tag")} .pn-tag{}${transformTag("pn-tag")} .pn-tag[data-xsmall]{padding:0 0.5em}${transformTag("pn-tag")} .pn-tag[data-xsmall] .pn-tag-label{font-size:0.875em;line-height:1.715em}${transformTag("pn-tag")} .pn-tag{}${transformTag("pn-tag")} .pn-tag[data-small]{padding:0.125em 0.5em}${transformTag("pn-tag")} .pn-tag[data-small] .pn-tag-label{font-size:0.875em;line-height:1.715em}${transformTag("pn-tag")} .pn-tag[data-small][data-icon]{padding-left:0.5em}${transformTag("pn-tag")} .pn-tag{}${transformTag("pn-tag")} .pn-tag[data-large]{padding:0.75em 1.25em}${transformTag("pn-tag")} .pn-tag{}${transformTag("pn-tag")} .pn-tag[data-appearance=discrete]{background-color:rgba(211, 206, 203, 0.3);color:#2d2013}${transformTag("pn-tag")} .pn-tag[data-appearance=discrete][data-dark]{background-color:#d3cecb}${transformTag("pn-tag")} .pn-tag[data-appearance=discrete] ${transformTag("pn-icon")} .pn-icon-svg path{fill:#2d2013}${transformTag("pn-tag")} .pn-tag[data-appearance=positive]{background-color:rgba(171, 227, 187, 0.3);color:#002f24}${transformTag("pn-tag")} .pn-tag[data-appearance=positive][data-dark]{background-color:#abe3bb}${transformTag("pn-tag")} .pn-tag[data-appearance=positive] ${transformTag("pn-icon")} .pn-icon-svg path{fill:#002f24}${transformTag("pn-tag")} .pn-tag[data-appearance=warning]{background-color:rgba(255, 200, 163, 0.3);color:#99290a}${transformTag("pn-tag")} .pn-tag[data-appearance=warning][data-dark]{background-color:#ffc8a3}${transformTag("pn-tag")} .pn-tag[data-appearance=warning] ${transformTag("pn-icon")} .pn-icon-svg path{fill:#99290a}${transformTag("pn-tag")} .pn-tag[data-appearance=error]{background-color:rgba(251, 194, 193, 0.3);color:#a70707}${transformTag("pn-tag")} .pn-tag[data-appearance=error][data-dark]{background-color:#fbc2c1}${transformTag("pn-tag")} .pn-tag[data-appearance=error] ${transformTag("pn-icon")} .pn-icon-svg path{fill:#a70707}${transformTag("pn-tag")} .pn-tag{}`;

/** The `pn-tag` is a non-interactive visual marker designed to emphasize important aspects of an item, such as its status. */
class PnTag {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    /** The label of the tag. */
    label;
    /**
     * Select icon from out `pn-design-assets` list. Works with any SVG content.
     *
     * **Please note**: Can not be used with the `xsmall` prop due to the small size.
     *
     * @see {@link https://portal.postnord.com/web-components/?path=/docs/docs-assets--docs Get started with PostNord assets.}
     */
    icon;
    /** Set tag appearance: `discrete`, `positive`, `warning` & `error`. @category Visual */
    appearance = '';
    /**
     * Set darker background-color on the tag.
     *
     * This is intended for better tag visibility on colored background.
     *
     * @category Visual
     * @deprecated Will be removed in v8.0.0
     */
    dark = false;
    /** Set larger tag. @category Size */
    large = false;
    /** Set smaller tag. @category Size */
    small = false;
    /** Set extra small tag. @since v7.11.0 @category Size */
    xsmall = false;
    componentWillRender() {
        if (!!this.icon && this.xsmall)
            console.warn(`pn-tag: Icon was not rendered because tag size is set to xsmall`);
    }
    showIcon() {
        return !!this.icon && !this.xsmall;
    }
    render() {
        return (hAsync(Host, { key: '25baf496ed00dccf72f5eb7cb8f8623814c67452' }, hAsync("div", { key: 'beee7ac3dc693e1c8cb5653e2fce3af01566c4e9', class: "pn-tag", "data-appearance": this.appearance, "data-icon": !!this.icon, "data-dark": this.dark, "data-small": this.small, "data-xsmall": this.xsmall, "data-large": this.large }, this.showIcon() && hAsync("pn-icon", { key: '64f9df4e0906c8897045a08edce51f8015a1be56', icon: this.icon }), hAsync("span", { key: 'a43a26db7b5e7b28eb49f8ac76eab9ebd8b7ee25', class: "pn-tag-label" }, this.label))));
    }
    static get style() { return pnTagCss(); }
    static get cmpMeta() { return {
        "$flags$": 512,
        "$tagName$": "pn-tag",
        "$members$": {
            "label": [1],
            "icon": [1],
            "appearance": [1],
            "dark": [4],
            "large": [4],
            "small": [4],
            "xsmall": [4]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnTextLinkCss = () => `${transformTag("pn-text-link")}{display:inline}${transformTag("pn-text-link")} .pn-text-link{border-radius:0.25em;color:#005d92;font-weight:500;text-decoration:underline;font-size:1em;transition-property:color, outline-color, text-decoration-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-text-link")} .pn-text-link{transition-duration:0s;transition-delay:0s}}${transformTag("pn-text-link")} .pn-text-link{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-text-link")} .pn-text-link:focus-visible{outline-color:#005d92}${transformTag("pn-text-link")} .pn-text-link:hover{color:#0d234b;text-decoration-color:#0d234b}${transformTag("pn-text-link")} .pn-text-link[data-icon]{display:inline-flex;gap:0.25em;align-items:center;text-decoration-color:transparent;padding:0.1em;border-radius:0.5em}${transformTag("pn-text-link")} .pn-text-link[data-icon] .pn-icon-svg path{fill:#005d92}${transformTag("pn-text-link")} .pn-text-link[data-icon]:hover{text-decoration-color:#0d234b}${transformTag("pn-text-link")} .pn-text-link[data-icon]:hover .pn-icon-svg path,${transformTag("pn-text-link")} .pn-text-link[data-icon]:focus-visible .pn-icon-svg path{fill:#0d234b}${transformTag("pn-text-link")} .pn-text-link[data-icon][data-icon-left]{flex-direction:row-reverse}${transformTag("pn-text-link")} .pn-text-link[data-light]{color:#ffffff}${transformTag("pn-text-link")} .pn-text-link[data-light]:focus-visible{outline-color:#ffffff}${transformTag("pn-text-link")} .pn-text-link[data-light]:hover{text-decoration-color:#ffffff}${transformTag("pn-text-link")} .pn-text-link[data-light][data-icon] ${transformTag("pn-icon")} .pn-icon-svg path{fill:#ffffff}`;

/** The `pn-text-link` is a styled `a` element with some extra functionality built in. Such as `icon` and `light` support.  */
class PnTextLink {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    get hostElement() { return getElement(this); }
    /** The link text. @since v7.5.0 */
    label;
    /** The URL string. */
    href;
    /** Use the light version of the link. @category Visual */
    light = false;
    /** SVG content of the icon. @category Visual */
    icon;
    /** Align the icon on the left. @category Visual */
    leftIcon = false;
    /** Treat the link as a download link. @category Link attributes */
    download;
    /** Set the hreflang of the URL destination. @category Link attributes */
    hreflang;
    /** Link media. @category Link attributes */
    media;
    /** Set referrerpolicy on the link. @category Link attributes */
    referrerpolicy;
    /** Set the rel of the link. @category Link attributes */
    rel = 'noopener noreferrer';
    /** Set the target of the link. @category Link attributes */
    target;
    /** Set a unique html ID of the a element. @category Link attributes */
    linkid;
    render() {
        return (hAsync("a", { key: 'c6ea5bb512bf4ea09b6003358805533d2230ec67', id: this.linkid, class: "pn-text-link", href: this.href, rel: this.rel, target: this.target, download: this.download, hreflang: this.hreflang, media: this.media, referrerPolicy: this.referrerpolicy, "data-icon": !!this.icon, "data-icon-left": this.leftIcon, "data-light": this.light }, this.label, hAsync("slot", { key: '17fa00f7ca96e51f512713cd344d9c8bfb160af1' }), this.icon && hAsync("pn-icon", { key: '99a0150b6b9be360f911c2afb66c728ae54d739b', icon: this.icon })));
    }
    static get style() { return pnTextLinkCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-text-link",
        "$members$": {
            "label": [1],
            "href": [1],
            "light": [4],
            "icon": [1],
            "leftIcon": [4, "left-icon"],
            "download": [1],
            "hreflang": [1],
            "media": [1],
            "referrerpolicy": [1],
            "rel": [1],
            "target": [1],
            "linkid": [1]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnTextareaCss = () => `${transformTag("pn-textarea")}{display:inline-flex;flex-direction:column}${transformTag("pn-textarea")} .pn-textarea{position:relative}${transformTag("pn-textarea")} .pn-textarea-label{cursor:pointer;display:flex;justify-content:space-between;align-items:flex-end;font-weight:400;color:#2d2013;margin:0 0 0.25em 0;gap:0.5em;-webkit-tap-highlight-color:transparent;transition-property:color, transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-textarea")} .pn-textarea-label{transition-duration:0s;transition-delay:0s}}${transformTag("pn-textarea")} .pn-textarea-label[data-compact]{position:absolute;top:1.5625em;left:calc(var(--pn-input-offset-left, 0px) + 0.75em + 0.0625em);margin:0;pointer-events:none;align-items:center;height:1.5em;max-width:calc(100% - (var(--pn-input-offset-left, 0px) + 0.75em) - (var(--pn-input-offset-right, 0px) + 0.75em));transform:translateY(-50%) scale(1) translateZ(0);transform-origin:0 0;transition-delay:0.2s}${transformTag("pn-textarea")} .pn-textarea-label[data-compact]>span{font-size:1em;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;line-height:1.5em}${transformTag("pn-textarea")} .pn-textarea-label>span{font-size:0.875em}${transformTag("pn-textarea")} .pn-textarea-label[data-compact]>span{background-color:#ffffff;color:#2d2013}${transformTag("pn-textarea")} .pn-textarea-text{color:#5e554a;font-size:0.875em;font-weight:400;margin:0.25em 0 0 0;display:flex;flex-direction:column;gap:0.25em;text-align:left}${transformTag("pn-textarea")} .pn-textarea-text[role=alert]{color:#a70707}${transformTag("pn-textarea")} .pn-textarea-text[hidden]{display:none}${transformTag("pn-textarea")} .pn-textarea-element{width:100%;resize:none;color:#2d2013;background-color:#ffffff;border:0.0625em solid #969087;border-radius:0.5em;padding:0.75em;font-family:inherit;font-size:1em;font-weight:500;line-height:1.5em;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent}${transformTag("pn-textarea")} .pn-textarea-element:-webkit-autofill,${transformTag("pn-textarea")} .pn-textarea-element:-webkit-autofill:hover,${transformTag("pn-textarea")} .pn-textarea-element:-webkit-autofill:focus,${transformTag("pn-textarea")} .pn-textarea-element:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #e0f8ff inset;-webkit-text-fill-color:#2d2013}${transformTag("pn-textarea")} .pn-textarea-element{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-textarea")} .pn-textarea-element:focus-visible{outline-color:#005d92;background-color:#ffffff;border-color:#005d92}${transformTag("pn-textarea")} .pn-textarea-element{transition-property:outline-color, background-color, border-color, color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-textarea")} .pn-textarea-element{transition-duration:0s;transition-delay:0s}}${transformTag("pn-textarea")} .pn-textarea-element[data-compact]{text-align:left;padding-top:1.125em;padding-bottom:0.375em;max-width:unset}${transformTag("pn-textarea")} .pn-textarea-element[data-compact]::placeholder{color:transparent}${transformTag("pn-textarea")} .pn-textarea-element[data-compact]:focus+.pn-textarea-label,${transformTag("pn-textarea")} .pn-textarea-element[data-compact]:not(:placeholder-shown)+.pn-textarea-label{transform:translateY(-85%) scale(0.75);transition-delay:0s}${transformTag("pn-textarea")} .pn-textarea-element::placeholder{color:#5e554a;font-weight:normal}${transformTag("pn-textarea")} .pn-textarea-element:hover{border-color:#005d92}${transformTag("pn-textarea")} .pn-textarea-element:disabled{color:#5e554a;background-color:#f3f2f2;border-color:#f3f2f2}${transformTag("pn-textarea")} .pn-textarea-element::-webkit-scrollbar{background-color:#ffffff;width:0.875em;border-radius:0.5em}${transformTag("pn-textarea")} .pn-textarea-element::-webkit-scrollbar-track{background-color:#ffffff;border-radius:0.5em}${transformTag("pn-textarea")} .pn-textarea-element::-webkit-scrollbar-thumb{cursor:pointer;background-color:#969087;border-radius:1em;border:0.25em solid #ffffff}${transformTag("pn-textarea")} .pn-textarea-element::-webkit-scrollbar-thumb:hover{background-color:#5e554a}${transformTag("pn-textarea")} .pn-textarea-element::-webkit-scrollbar-corner,${transformTag("pn-textarea")} .pn-textarea-element::-webkit-scrollbar-button{display:none}${transformTag("pn-textarea")} .pn-textarea-element:read-only{border-color:#ffffff}${transformTag("pn-textarea")} .pn-textarea-element:disabled+.pn-textarea-label>span{background-color:#f3f2f2}${transformTag("pn-textarea")} .pn-textarea-element::-webkit-resizer{background-image:url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%3E%0A%20%20%3Cpath%20d%3D%22M7%2017L17%207M12%2017L17%2012%22%20stroke%3D%22%23005D92%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%2F%3E%0A%3C%2Fsvg%3E");background-repeat:no-repeat;background-position:center}${transformTag("pn-textarea")} .pn-textarea[data-valid]>.pn-textarea-label{color:#005e41}${transformTag("pn-textarea")} .pn-textarea[data-valid]>.pn-textarea-element{border-color:#005e41}${transformTag("pn-textarea")} .pn-textarea[data-valid]>.pn-textarea-element:hover{border-color:#002f24}${transformTag("pn-textarea")} .pn-textarea[data-valid]>.pn-textarea-element:focus-visible{background-color:#ffffff;border-color:#005e41;outline-color:#005e41}${transformTag("pn-textarea")} .pn-textarea[data-valid]>.pn-textarea-element:-webkit-autofill,${transformTag("pn-textarea")} .pn-textarea[data-valid]>.pn-textarea-element:-webkit-autofill:hover,${transformTag("pn-textarea")} .pn-textarea[data-valid]>.pn-textarea-element:-webkit-autofill:focus,${transformTag("pn-textarea")} .pn-textarea[data-valid]>.pn-textarea-element:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #edfbf3 inset;-webkit-text-fill-color:#2d2013}${transformTag("pn-textarea")} .pn-textarea[data-error]>.pn-textarea-label{color:#a70707}${transformTag("pn-textarea")} .pn-textarea[data-error]>.pn-textarea-element{border-color:#a70707}${transformTag("pn-textarea")} .pn-textarea[data-error]>.pn-textarea-element:hover{border-color:#500715}${transformTag("pn-textarea")} .pn-textarea[data-error]>.pn-textarea-element:focus-visible{background-color:#ffffff;border-color:#a70707;outline-color:#a70707}${transformTag("pn-textarea")} .pn-textarea[data-error]>.pn-textarea-element:-webkit-autofill,${transformTag("pn-textarea")} .pn-textarea[data-error]>.pn-textarea-element:-webkit-autofill:hover,${transformTag("pn-textarea")} .pn-textarea[data-error]>.pn-textarea-element:-webkit-autofill:focus,${transformTag("pn-textarea")} .pn-textarea[data-error]>.pn-textarea-element:-webkit-autofill:active{-webkit-box-shadow:0 0 0 10em #fef7f6 inset;-webkit-text-fill-color:#2d2013}${transformTag("pn-textarea")} .pn-textarea[data-resize]>.pn-textarea-element{resize:vertical}`;

/**
 * The `pn-textarea` is built with a native `textarea`.
 * This means you can use native events to listen to the input.
 *
 * @nativeInput Use the `input` event to listen to content being modified by the user.
 *
 * @slot helpertext - You can use this slot instead of the prop `helpertext`. Recommended, only if you need to include additional HTML markup. Such as a `pn-text-link`. Use a `span` element to wrap the text and link. {@since v7.25.0}
 * @slot error - You can use this slot instead of the prop `error`. Recommended, only if you need to include additional HTML markup. Such as a `pn-text-link`. Use a `span` element to wrap the text and link. {@since v7.25.0}
 */
class PnTextarea {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    id = `pn-textarea-${uuidv4()}`;
    idHelper = `${this.id}-text`;
    idError = `${this.id}-error`;
    get hostElement() { return getElement(this); }
    /** The label describing the textarea. */
    label;
    /** Helper text that will appear underneath the textarea. Will be overwritten if you set an `error` string */
    helpertext;
    /** The textarea content, do not provide slotted content. @category Native attributes */
    value = '';
    /** HTML name. @category Native attributes */
    name;
    /** Placeholder for the textarea. @category Native attributes */
    placeholder;
    /** Set the associated form. @category Native attributes */
    form;
    /** Set the row count for the textarea. @category Native attributes */
    rows = 2;
    /** Set the col count for the textarea. @category Native attributes */
    cols = 20;
    /** Set the wrap control. @category Native attributes */
    wrap = 'soft';
    /** The maximum number of characters the user should be able to add, also adds a visible counter. @category Native attributes */
    maxlength;
    /** Allow the browser to autocomplete the textarea. @category Native attributes */
    autocomplete = 'off';
    /** Allow the browser to spellcheck the textarea. @category Native attributes */
    spellcheck = false;
    /** Allow the user to resize the textarea vertically. Handle width in your own layout. @category Native attributes */
    resize = false;
    /** Make the textarea required. @category Native attributes */
    required = false;
    /** Disable the textarea. @category Native attributes */
    disabled = false;
    /** Make the textarea readonly. @category Native attributes */
    readonly = false;
    /** Use the compact label variant. @since v7.21.0 @category Features */
    compact = false;
    /** Set the textarea as `valid`, will make the Label and focus rings green. @category Features */
    valid = false;
    /** Set the textarea as `invalid`, will make the Label and focus rings red. @category Features */
    invalid = false;
    /** Same as `invalid`, but will display the string as an error message under the textarea. @category Features */
    error;
    /** Set a custom ID for the textarea. @since v7.25.0 @category HTML attributes */
    pnId;
    /**
     * Provide the label via an aria attribute.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabel;
    /**
     * Provide the label from another element via its ID.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabelledby;
    /** Set a custom ID for the textarea. @deprecated Use `pn-id` instead. @category HTML attributes */
    textareaid;
    handleId() {
        this.idHelper = `${this.getId()}-helpertext`;
        this.idError = `${this.getId()}-error`;
    }
    setVal(event) {
        const value = event.target.value;
        this.value = value;
    }
    hasHelperText() {
        return this.helpertext?.length > 0 || this.checkSlottedHelper();
    }
    /** If any `error` text is present, either via prop/slot. */
    hasErrorMessage() {
        return this.error?.length > 0 || this.checkSlottedError();
    }
    /** If any `error` is active, either via the prop `invalid` or `error` prop/slot. */
    hasError() {
        return this.hasErrorMessage() || this.invalid || this.checkSlottedError();
    }
    checkSlottedHelper() {
        return !!this.hostElement.querySelector('[slot=helpertext]');
    }
    checkSlottedError() {
        return !!this.hostElement.querySelector('[slot=error]');
    }
    hideHelpertext() {
        return this.hasErrorMessage() || !this.hasHelperText();
    }
    hideError() {
        return !this.hasErrorMessage();
    }
    getId() {
        return this.pnId || this.textareaid || this.id;
    }
    displayLabel() {
        return !!this.label;
    }
    getAriaLabel() {
        return !this.displayLabel() && !this.pnAriaLabelledby ? this.pnAriaLabel : null;
    }
    getAriaLabelledby() {
        return !this.displayLabel() && !this.pnAriaLabel ? this.pnAriaLabelledby : null;
    }
    getAriaDescribedby() {
        const list = [];
        if (this.hasErrorMessage())
            list.push(this.idError);
        else if (this.hasHelperText())
            list.push(this.idHelper);
        return list.length ? list.join(' ') : null;
    }
    renderLabel() {
        return (hAsync("label", { class: "pn-textarea-label", htmlFor: this.getId(), "data-compact": this.compact }, hAsync("span", null, this.label), this.maxlength >= 1 && hAsync("span", null, `${this.value?.length || 0}/${this.maxlength}`)));
    }
    render() {
        return (hAsync(Host, { key: '046f1fdb7dd6f834116a0488a90da361d7b91b1c' }, hAsync("div", { key: 'f0ffbb17ac4dfe2074deba72fbc26e7988dafeb6', class: "pn-textarea", "data-valid": this.valid, "data-error": this.hasError(), "data-resize": this.resize }, !this.compact && this.renderLabel(), hAsync("textarea", { key: 'aa82eb1bbe99f801941cb155fe1ee6af1f55b805', class: "pn-textarea-element", id: this.getId(), value: this.value, name: this.name, placeholder: this.compact ? this.placeholder || ' ' : this.placeholder, rows: this.rows, cols: this.cols, wrap: this.wrap, autocomplete: this.autocomplete, spellcheck: this.spellcheck, maxlength: this.maxlength, required: this.required, disabled: this.disabled, readonly: this.readonly, "aria-label": this.getAriaLabel(), "aria-labelledby": this.getAriaLabelledby(), "aria-describedby": this.getAriaDescribedby(), "aria-invalid": this.hasError().toString(), "data-compact": this.compact, onInput: e => this.setVal(e) }), this.compact && this.renderLabel(), hAsync("p", { key: '3b258a6423b92fb8fdc411db861be42c17f0b0d1', id: this.idHelper, class: "pn-textarea-text", hidden: this.hideHelpertext() }, hAsync("span", { key: 'be839a0794224ee1766e56b09858df2050d7199a' }, this.helpertext), hAsync("slot", { key: '631642b2a335fb0009cc110f177cbe4851d5a0fb', name: "helpertext" })), hAsync("p", { key: '7f91ffb2a81e5dd9a78187d86aa71aca6e2b43d7', id: this.idError, class: "pn-textarea-text", role: "alert", hidden: this.hideError() }, hAsync("span", { key: '4d8d749e257bb292c8e0b982354e9a7add06b50b' }, this.error), hAsync("slot", { key: '7178418c4bf5cbe7b2bc8de6f586766e3cbc73c9', name: "error" })))));
    }
    static get watchers() { return {
        "textareaid": [{
                "handleId": 0
            }],
        "pnId": [{
                "handleId": 1
            }]
    }; }
    static get style() { return pnTextareaCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-textarea",
        "$members$": {
            "label": [1],
            "helpertext": [1],
            "value": [1025],
            "name": [1],
            "placeholder": [1],
            "form": [1],
            "rows": [2],
            "cols": [2],
            "wrap": [1],
            "maxlength": [2],
            "autocomplete": [1],
            "spellcheck": [4],
            "resize": [4],
            "required": [4],
            "disabled": [4],
            "readonly": [4],
            "compact": [4],
            "valid": [4],
            "invalid": [4],
            "error": [1],
            "pnId": [1, "pn-id"],
            "pnAriaLabel": [1, "pn-aria-label"],
            "pnAriaLabelledby": [1, "pn-aria-labelledby"],
            "textareaid": [1]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnTileCss = () => `${transformTag("pn-tile")}{position:relative;display:block}${transformTag("pn-tile")} .pn-tile{position:relative;overflow:hidden;word-break:break-word;text-align:center;border-radius:0.5em;padding:clamp(0.75em, 3vw, 1.5em);height:100%;color:#2d2013;background-color:#ffffff;box-shadow:0em 0.0625em 0.125em 0em rgba(20, 20, 20, 0.11), 0em 0.1875em 0.4375em 0em rgba(0, 0, 0, 0.13);display:flex;flex-wrap:wrap;flex-direction:column;align-items:center;justify-content:flex-start;gap:clamp(1em, 5vw, 1.5em);outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:box-shadow, background-color, outline-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-tile")} .pn-tile{transition-duration:0s;transition-delay:0s}}${transformTag("pn-tile")} .pn-tile .pn-ripple{animation:ripple 0.4s cubic-bezier(0.7, 0, 0.3, 1);position:absolute;border-radius:50%;background-color:#005d92;transform:translate(-50%, -50%) scale(0);opacity:0.1;pointer-events:none;z-index:3}@keyframes ripple{to{transform:translate(-50%, -50%) scale(1);opacity:0}}${transformTag("pn-tile")} .pn-tile[data-horizontal]{text-align:left;flex-direction:row;flex-wrap:nowrap;gap:clamp(1em, 5vw, 1.5em)}${transformTag("pn-tile")} .pn-tile[data-horizontal] .pn-tile-illustration[data-circle]:before{clip-path:ellipse(0% 100% at 0% 50%)}${transformTag("pn-tile")} .pn-tile[data-horizontal] .pn-tile-text{flex-grow:2}${transformTag("pn-tile")} .pn-tile[data-href][data-focus]{outline-color:#005d92;box-shadow:0em 0em 0em 0em rgba(20, 20, 20, 0.11), 0em 0em 0em 0em rgba(0, 0, 0, 0.13)}${transformTag("pn-tile")} .pn-tile[data-href]:hover{background-color:rgba(183, 235, 252, 0.3)}${transformTag("pn-tile")} .pn-tile[data-href]:hover .pn-tile-illustration[data-circle]:before,${transformTag("pn-tile")} .pn-tile[data-href]:focus-within .pn-tile-illustration[data-circle]:before{clip-path:ellipse(100% 50% at 50% -25%)}${transformTag("pn-tile")} .pn-tile[data-href]:hover[data-horizontal] .pn-tile-illustration[data-circle]:before,${transformTag("pn-tile")} .pn-tile[data-href]:focus-within[data-horizontal] .pn-tile-illustration[data-circle]:before{clip-path:ellipse(50% 100% at -25% 50%)}${transformTag("pn-tile")} .pn-tile[data-href]:hover .pn-tile-link,${transformTag("pn-tile")} .pn-tile[data-href]:focus-within .pn-tile-link{color:#0d234b;text-decoration-color:#0d234b}${transformTag("pn-tile")} .pn-tile[data-href]:hover ${transformTag("pn-icon")} .pn-icon-svg path,${transformTag("pn-tile")} .pn-tile[data-href]:focus-within ${transformTag("pn-icon")} .pn-icon-svg path{fill:#0d234b}${transformTag("pn-tile")} .pn-tile-illustration{z-index:2;flex:1 1;max-width:7.5em;max-height:7.5em}${transformTag("pn-tile")} .pn-tile-illustration[data-icon]{flex:0 0}${transformTag("pn-tile")} .pn-tile-illustration[data-icon] ${transformTag("pn-icon")}{padding:1em;border-radius:50%;background-color:#e0f8ff}${transformTag("pn-tile")} .pn-tile-illustration[data-icon] ${transformTag("pn-icon")}>svg{font-size:2em}${transformTag("pn-tile")} .pn-tile-illustration-slot{display:block;height:100%;width:100%}${transformTag("pn-tile")} .pn-tile-illustration[data-circle]:before{content:"";position:absolute;z-index:-1;top:0;left:0;width:100%;height:100%;background-color:rgba(183, 235, 252, 0.7);background-color:rgba(183, 235, 252, 0.7);clip-path:ellipse(100% 0% at 50% 0%);transition-property:clip-path;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-tile")} .pn-tile-illustration[data-circle]:before{transition-duration:0s;transition-delay:0s}}${transformTag("pn-tile")} .pn-tile-text{z-index:3;flex:1 1;display:flex;flex-direction:column;gap:0.5em}${transformTag("pn-tile")} .pn-tile-link{cursor:pointer;color:#005d92;text-decoration:underline;text-decoration-color:transparent;-webkit-tap-highlight-color:transparent;transition-property:color, text-decoration-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-tile")} .pn-tile-link{transition-duration:0s;transition-delay:0s}}${transformTag("pn-tile")} .pn-tile-link:focus{outline:0;text-decoration-color:#0d234b;color:#0d234b}${transformTag("pn-tile")} .pn-tile-link:after{content:"";position:absolute;top:0;left:0;height:100%;width:100%;opacity:0}${transformTag("pn-tile")} .pn-tile-title{font-family:inherit;font-weight:700;font-size:clamp(1.25em, 3vw, 1.5em);margin:0em}${transformTag("pn-tile")} .pn-tile-title ${transformTag("pn-icon")}{margin-left:0.25em;vertical-align:middle}${transformTag("pn-tile")} .pn-tile-slot{font-weight:400;color:#5e554a;display:flex;flex-direction:column;gap:0.25em}${transformTag("pn-tile")} .pn-tile-paragraph,${transformTag("pn-tile")} .pn-tile p{font-size:0.875em}${transformTag("pn-tile")} .pn-tile-paragraph:last-child,${transformTag("pn-tile")} .pn-tile p:last-child{margin:0em}`;

/**
 * The `pn-tile` is a navigational element that is intended to be accompanied by an illustration.
 *
 * It is very important that you use the `label` and `url`. This component renders an `a` element if the URL prop is set,
 * so you do not need to wrap or nest the tile in another `a` element. Doing so makes the component inaccessible.
 *
 * @slot illustration - Set a custom SVG. We recommend you use the `pn-illustration` component.
 * This is the same as the `illustration` prop.
 */
class PnTile {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.pnTile = createEvent(this, "pnTile", 7);
    }
    mo;
    tile;
    illustrationSlot;
    visibleOutline = false;
    get hostElement() { return getElement(this); }
    /** Label of the link. This is required for the component to be accessible. */
    label;
    /** Set a string of text for the tile. Same as the default slot. @since v7.12.0 */
    text;
    /** The link of the tile. This is required for the component to be accessible. @category href */
    url;
    /** The target attribute of the link. @category href */
    target;
    /** The rel attribute of the link. @category href */
    rel = 'noopener noreferrer';
    /** The SVG content of an illustration. @category Image */
    illustration;
    /** The SVG content of a decorative icon. @since v7.12.0 @category Image */
    icon;
    /** Use the horizontal tile. @category Layout */
    horizontal = false;
    /**
     * Emitted when the link is clicked. Use the `click` property to `preventDefault`
     * if you wish to perform the navigation programmatically.
     * @since v7.12.0
     **/
    pnTile;
    connectedCallback() {
        this.mo = new MutationObserver(() => forceUpdate());
        this.mo.observe(this.hostElement, { subtree: true, childList: true });
    }
    disconnectedCallback() {
        this.mo?.disconnect();
    }
    isExternal() {
        return this.target === '_blank';
    }
    showIcon() {
        return !!this.icon && !this.showSlotIllustration();
    }
    showPropIllustration() {
        return !!this.illustration && !this.showSlotIllustration();
    }
    showSlotIllustration() {
        return !!this.illustrationSlot?.querySelector('[slot="illustration"]');
    }
    showImage() {
        return this.showIcon() || this.showPropIllustration() || this.showSlotIllustration();
    }
    handleFocus({ type, target }) {
        this.visibleOutline = type === 'focus' && target.matches(':focus-visible');
    }
    clickHandler(event) {
        ripple(event, this.tile);
        this.pnTile.emit({ click: event });
    }
    render() {
        return (hAsync(Host, { key: '127727acb1596f91d84fce39bb15da17557ab760' }, hAsync("div", { key: 'afc40764a1e45b51127f4622758678351d6c6c4e', class: "pn-tile", "data-horizontal": this.horizontal, "data-href": !!this.url, "data-focus": this.visibleOutline, ref: el => (this.tile = el) }, hAsync("div", { key: '32546ad6c86dd3ca850b4161c5672fdfc612ccf4', class: "pn-tile-illustration", "data-circle": !!this.url, "data-icon": this.showIcon(), role: "presentation", hidden: !this.showImage() }, this.showPropIllustration() ? (hAsync("pn-illustration", { illustration: this.illustration })) : (this.showIcon() && hAsync("pn-icon", { color: "blue700", icon: this.icon })), hAsync("div", { key: '4bc8653775913c7c3f5437b724905833136d6305', class: "pn-tile-illustration-slot", hidden: !this.showSlotIllustration(), ref: el => (this.illustrationSlot = el) }, hAsync("slot", { key: '4d1658c813db7e2b4b6f2c32ce081384a576cf2d', name: "illustration" }))), hAsync("div", { key: 'f51d689d6d72a039d83adbdc28d6b6de2953e610', class: "pn-tile-text" }, hAsync("h3", { key: '904c4fb3f4578842cebef57f810314fc41e47ab5', class: "pn-tile-title" }, this.url ? (hAsync("a", { class: "pn-tile-link", href: this.url, target: this.target, rel: !this.rel && this.isExternal() ? 'noopener noreferrer' : this.rel, onClick: e => this.clickHandler(e), onFocus: event => this.handleFocus(event), onBlur: event => this.handleFocus(event) }, this.label)) : (this.label), this.isExternal() && hAsync("pn-icon", { key: '1bbebd1324580d07ef646a272b0f73396a6ff7db', icon: open_in_new, small: true, color: "blue700" })), hAsync("div", { key: 'b223d1cda348abe5dc4c07e4d52d33580b6fdf67', class: "pn-tile-slot" }, !!this.text && hAsync("p", { key: '6e79f2654198dfe5d1f3dab7cd0527174393b00e', class: "pn-tile-paragraph" }, this.text), hAsync("slot", { key: '33a4dfe4e18147785372a56c19b78e8961ad1ccb' }))))));
    }
    static get style() { return pnTileCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-tile",
        "$members$": {
            "label": [1],
            "text": [1],
            "url": [1],
            "target": [1],
            "rel": [1],
            "illustration": [1],
            "icon": [1],
            "horizontal": [4],
            "visibleOutline": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const translations$2 = {
    HIDE: {
        sv: 'Stäng meddelande',
        en: 'Dismiss message',
        da: 'Afvis besked',
        fi: 'Hylkää viesti',
        no: 'Avvis meldingen',
    },
};

const pnToastCss = () => `${transformTag("pn-toast")}{position:relative;display:block}${transformTag("pn-toast")} .pn-toast{position:relative;color:#2d2013;padding:1em;border-radius:0.5em;outline:none;font-size:1em;font-weight:400;background-color:#e0f8ff;border-color:#005d92;display:flex;align-items:center;gap:0.75em;visibility:visible;transition-property:visibility;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-toast")} .pn-toast{transition-duration:0s;transition-delay:0s}}${transformTag("pn-toast")} .pn-toast .pn-ripple{animation:ripple 0.4s cubic-bezier(0.7, 0, 0.3, 1);position:absolute;border-radius:50%;background-color:#005d92;transform:translate(-50%, -50%) scale(0);opacity:0.1;pointer-events:none;z-index:3}@keyframes ripple{to{transform:translate(-50%, -50%) scale(1);opacity:0}}${transformTag("pn-toast")} .pn-toast[data-hide]{visibility:hidden;transition-delay:0.2s}${transformTag("pn-toast")} .pn-toast-heading{font-size:1em;font-style:normal;font-weight:500;margin:0}${transformTag("pn-toast")} .pn-toast-text{font-size:1em;font-style:normal;font-weight:400;margin:0 0 0.25em 0}${transformTag("pn-toast")} .pn-toast-text:last-child{margin-bottom:0}${transformTag("pn-toast")} .pn-toast-icon .pn-icon-svg path{fill:#2d2013}${transformTag("pn-toast")} .pn-toast-content{display:flex;flex-direction:column;align-self:center;align-items:flex-start;gap:0.25em;margin:0 auto 0 0}${transformTag("pn-toast")} .pn-toast-button{cursor:pointer;border-radius:50%;border:none;background:none;padding:0.25em;font-size:1em;display:flex;align-items:center;justify-content:center;transition-property:background-color, outline-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-toast")} .pn-toast-button{transition-duration:0s;transition-delay:0s}}${transformTag("pn-toast")} .pn-toast-button{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-toast")} .pn-toast-button:focus-visible{outline-color:#005d92;background-color:#8eddf9}${transformTag("pn-toast")} .pn-toast-button:hover{background-color:#8eddf9}${transformTag("pn-toast")} .pn-toast[data-appearance=success]{background-color:#dcf6e7}${transformTag("pn-toast")} .pn-toast[data-appearance=success] .pn-toast-button{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-toast")} .pn-toast[data-appearance=success] .pn-toast-button:focus-visible{outline-color:#005e41;background-color:#abe3bb}${transformTag("pn-toast")} .pn-toast[data-appearance=success] .pn-toast-button:hover{background-color:#abe3bb}${transformTag("pn-toast")} .pn-toast[data-appearance=success] .pn-ripple{background-color:#005e41}${transformTag("pn-toast")} .pn-toast[data-appearance=success] .pn-toast-icon .pn-icon-svg path{fill:#005e41}${transformTag("pn-toast")} .pn-toast[data-appearance=success][data-temporary]{border-color:#005e41}${transformTag("pn-toast")} .pn-toast[data-appearance=warning]{background-color:#fff1e3}${transformTag("pn-toast")} .pn-toast[data-appearance=warning] .pn-toast-button{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-toast")} .pn-toast[data-appearance=warning] .pn-toast-button:focus-visible{outline-color:#99290a;background-color:#ffc8a3}${transformTag("pn-toast")} .pn-toast[data-appearance=warning] .pn-toast-button:hover{background-color:#ffc8a3}${transformTag("pn-toast")} .pn-toast[data-appearance=warning] .pn-ripple{background-color:#99290a}${transformTag("pn-toast")} .pn-toast[data-appearance=warning] .pn-toast-icon .pn-icon-svg path{fill:#99290a}${transformTag("pn-toast")} .pn-toast[data-appearance=warning][data-temporary]{border-color:#ed7123}${transformTag("pn-toast")} .pn-toast[data-appearance=error]{background-color:#fdefee}${transformTag("pn-toast")} .pn-toast[data-appearance=error] .pn-toast-button{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-toast")} .pn-toast[data-appearance=error] .pn-toast-button:focus-visible{outline-color:#a70707;background-color:#fbc2c1}${transformTag("pn-toast")} .pn-toast[data-appearance=error] .pn-toast-button:hover{background-color:#fbc2c1}${transformTag("pn-toast")} .pn-toast[data-appearance=error] .pn-ripple{background-color:#a70707}${transformTag("pn-toast")} .pn-toast[data-appearance=error] .pn-toast-icon .pn-icon-svg path{fill:#a70707}${transformTag("pn-toast")} .pn-toast[data-appearance=error][data-temporary]{border-color:#a70707}${transformTag("pn-toast")} .pn-toast[data-temporary]{border-style:solid;border-width:0.0625em;box-shadow:0 0.125em 0.25em rgba(0, 0, 0, 0.2)}`;

/**
 * This component is able to fill many roles of a classic toast.
 * It has 4 different colors, a temporary state, hide button, icon and illustration support.
 *
 * The `pn-toast` will expand to its parent containers full width.
 * Either limit the parent width or set a CSS rule to your specific width if needed.
 */
class PnToast extends Mixin(animateHeightFactory) {
    constructor(hostRef) {
        super();
        registerInstance(this, hostRef);
        this.close = createEvent(this, "close", 7);
        this.hidden = createEvent(this, "hidden", 7);
    }
    toast;
    button;
    get hostElement() { return getElement(this); }
    hasSlottedContent = false;
    /**
     * Set a title for the toast. Requires the `text` prop in order to work.
     * @description Can be used together with slotted content.
     */
    heading = '';
    /**
     * Set a paragraph of text for the toast.
     * @description Can be used together with slotted content.
     */
    text = '';
    /** Give the toast a HTML ID. */
    toastId;
    /**
     * Default color is blue, you also have the option of success (green), warning (orange) and error (red).
     * @category Visual
     */
    appearance;
    /**
     * This will apply a shadow and border to the toast.
     * @category Visual
     */
    temporary = false;
    /**
     * Set an SVG icon.
     * @category Visual
     */
    icon;
    /**
     * Set an SVG illustration.
     * @category Visual
     */
    illustration;
    /**
     * Control the visibility of the toast. If the `closable` prop is active, the toast will set the `hide` prop on its own.
     * @see {@link closable}
     * @category Features
     */
    hide = false;
    /**
     * Show close button.
     * @category Features
     */
    closable = false;
    /**
     * Manually set the language, only needed if the `closable` prop is enabled.
     * @see {@link closable}
     * @category Features
     */
    language = null;
    handleHide() {
        this.hostElement.style.overflow = 'hidden';
        requestAnimationFrame(() => this.toggleToastVisibility());
    }
    /** Event fired when the close button is pressed. */
    close;
    /**
     * This event is fired when the toast is fully hidden after the animation is finished.
     * Triggers from the close button or if the prop `hide` is set to true.
     * @since v7.6.0
     **/
    hidden;
    async componentWillLoad() {
        if (this.hide) {
            this.hostElement.style.height = '0';
            this.hostElement.style.overflow = 'hidden';
        }
        // Any text content at this stage means there is slotted content present.
        this.hasSlottedContent = !!this.hostElement.textContent;
        if (this.language === null)
            await awaitTopbar(this.hostElement);
    }
    componentDidLoad() {
        if (!!this.heading && !this.text && !this.hasSlottedContent)
            console.warn('The %s prop is only available if you use the %s prop or slotted content.', 'heading', 'text');
    }
    toggleToastVisibility() {
        if (this.hide)
            this.closeDropdown(this.hostElement, this.toast.clientHeight);
        else
            this.openDropdown(this.hostElement, this.toast.clientHeight);
    }
    handleClick(event) {
        this.hide = true;
        this.close.emit(this.hide);
        ripple(event, this.toast);
    }
    getIcon() {
        if (this.illustration)
            return '';
        if (this.icon)
            return this.icon;
        if (this.appearance === 'success')
            return check_circle;
        if (this.appearance === 'warning')
            return alert_exclamation_triangle;
        if (this.appearance === 'error')
            return alert_exclamation_circle;
        return alert_info_circle;
    }
    getRole() {
        return this.appearance === 'error' ? 'alert' : 'status';
    }
    showIcon() {
        return !this.illustration;
    }
    showIllustration() {
        return !this.showIcon();
    }
    showTitle() {
        return (this.hasSlottedContent || !!this.text) && !!this.heading;
    }
    translate(prop) {
        return translations$2?.[prop]?.[this.language || en$2] || prop;
    }
    hideToast() {
        return this.hide && !this.isMoving();
    }
    render() {
        return (hAsync(Host, { key: '8fc8af6de122bae90d2909840a3d2c412cc3181d' }, hAsync("div", { key: 'ad45d0c295ea660c6e03f1b98e91294519003886', id: this.toastId, class: "pn-toast", role: this.getRole(), "data-appearance": this.appearance, "data-temporary": this.temporary, "data-hide": this.hideToast(), ref: el => (this.toast = el) }, this.showIcon() && hAsync("pn-icon", { key: '7e856fb052f535e72b15044347eb2a20dc141297', class: "pn-toast-icon", icon: this.getIcon() }), hAsync("div", { key: 'b8549738d389bb4b3269192c9a6fa606e6500e25', class: "pn-toast-content" }, this.showTitle() && hAsync("h4", { key: 'ef243b8a4d842c8583308bd8cd75a3c640ba811a', class: "pn-toast-heading" }, this.heading), this.text && hAsync("p", { key: '7d4a03a243567f881ddaa826959c36cebd84ad00', class: "pn-toast-text" }, this.text), hAsync("slot", { key: '1cf28e44d6f37c053b33634529ee0a2d1d7dc58d' })), this.showIllustration() && hAsync("pn-illustration", { key: 'f219657a26c48361d1f31cccf947a13f749f6e7b', illustration: this.illustration, width: "5.5em", height: "5.5em" }), this.closable && (hAsync("button", { key: '1bebf8881b20963d9a611cdcf8e293fb6f035cc7', class: "pn-toast-button", type: "button", "aria-label": this.translate('HIDE'), onClick: (event) => this.handleClick(event), ref: el => (this.button = el) }, hAsync("pn-icon", { key: '14b4fee29de5810bd9d04476500e6d806fe3a2eb', icon: close }))))));
    }
    static get watchers() { return {
        "hide": [{
                "handleHide": 0
            }]
    }; }
    static get style() { return pnToastCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-toast",
        "$members$": {
            "heading": [1],
            "text": [1],
            "toastId": [1, "toast-id"],
            "appearance": [1],
            "temporary": [4],
            "icon": [1],
            "illustration": [1],
            "hide": [1540],
            "closable": [4],
            "language": [1025],
            "isClosing": [32],
            "isExpanding": [32],
            "hasSlottedContent": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": [["hide", "hide"]]
    }; }
}

const pnToggleSwitchCss = () => `${transformTag("pn-toggle-switch")}{display:inline-block;position:relative}${transformTag("pn-toggle-switch")} .pn-toggle{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:1em}${transformTag("pn-toggle-switch")} .pn-toggle-label{cursor:pointer;display:flex;justify-content:space-between;align-items:flex-end;font-weight:500;color:#2d2013;margin:0;gap:0.5em;-webkit-tap-highlight-color:transparent;transition-property:color, transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-toggle-switch")} .pn-toggle-label{transition-duration:0s;transition-delay:0s}}${transformTag("pn-toggle-switch")} .pn-toggle-label>span{font-size:1em}${transformTag("pn-toggle-switch")} .pn-toggle-helper{color:#5e554a;font-size:0.875em;font-weight:400;margin:0.25em 0 0 0;display:flex;flex-direction:column;gap:0.25em}${transformTag("pn-toggle-switch")} .pn-toggle-content{flex:1 0}${transformTag("pn-toggle-switch")} .pn-toggle-button{position:relative;font-size:1em;width:3.625em;height:2em;padding:0.1875em;transition-property:transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-toggle-switch")} .pn-toggle-button{transition-duration:0s;transition-delay:0s}}${transformTag("pn-toggle-switch")} .pn-toggle-button{-webkit-tap-highlight-color:transparent}${transformTag("pn-toggle-switch")} .pn-toggle-button[data-small]{width:2.625em;height:1.5em}${transformTag("pn-toggle-switch")} .pn-toggle-button[data-small] .pn-toggle-circle{width:1.125em;height:1.125em}${transformTag("pn-toggle-switch")} .pn-toggle-button[data-small][data-loading]>.pn-toggle-bg{width:1.5em}${transformTag("pn-toggle-switch")} .pn-toggle-button[data-large]{width:4.625em;height:2.5em}${transformTag("pn-toggle-switch")} .pn-toggle-button[data-large] .pn-toggle-circle{width:2.125em;height:2.125em}${transformTag("pn-toggle-switch")} .pn-toggle-button[data-large][data-loading]>.pn-toggle-bg{width:2.5em}${transformTag("pn-toggle-switch")} .pn-toggle-button[data-loading] .pn-toggle-bg{width:2em}${transformTag("pn-toggle-switch")} .pn-toggle-button[data-loading] .pn-toggle-circle,${transformTag("pn-toggle-switch")} .pn-toggle-button[data-loading] .pn-toggle-element:checked~.pn-toggle-circle{transform:translateX(50%)}${transformTag("pn-toggle-switch")} .pn-toggle-button[data-loading] .pn-toggle-element:checked~.pn-toggle-circle .pn-toggle-check{opacity:0}${transformTag("pn-toggle-switch")} .pn-toggle-button[data-loading] .pn-toggle-element:checked~.pn-toggle-circle .pn-toggle-check polyline{stroke-dashoffset:23;transition-delay:0s}${transformTag("pn-toggle-switch")} .pn-toggle-button[data-loading] ${transformTag("pn-spinner")}{opacity:1;transform:translate(-50%, -50%);position:absolute;top:50%;left:50%}${transformTag("pn-toggle-switch")} .pn-toggle-bg{position:absolute;top:0;left:50%;width:100%;height:100%;z-index:0;border-radius:2em;background-color:#969087;transform:translateX(-50%);outline:0.2rem solid transparent;outline-offset:0.2rem;transition-property:width, background-color, outline-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-toggle-switch")} .pn-toggle-bg{transition-duration:0s;transition-delay:0s}}${transformTag("pn-toggle-switch")} .pn-toggle-circle{position:relative;z-index:1;width:1.625em;height:1.625em;background-color:#ffffff;box-shadow:0 0.25em 0.5em rgba(0, 0, 0, 0.1);border-radius:50%;padding:0.25em;transform:translateX(0%);transition-property:transform, background-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-toggle-switch")} .pn-toggle-circle{transition-duration:0s;transition-delay:0s}}${transformTag("pn-toggle-switch")} .pn-toggle-element{position:absolute;z-index:3;top:0;left:0;cursor:pointer;width:100%;height:100%;opacity:0;margin:0;}${transformTag("pn-toggle-switch")} .pn-toggle-element:focus-visible+.pn-toggle-bg{outline-color:#005d92}${transformTag("pn-toggle-switch")} .pn-toggle-element:hover+.pn-toggle-bg{background-color:#5e554a}${transformTag("pn-toggle-switch")} .pn-toggle-element:hover:checked+.pn-toggle-bg{background-color:#0d234b}${transformTag("pn-toggle-switch")} .pn-toggle-element:hover:checked~.pn-toggle-circle .pn-toggle-check polyline{stroke:#0d234b}${transformTag("pn-toggle-switch")} .pn-toggle-element:checked~.pn-toggle-bg{background-color:#005d92}${transformTag("pn-toggle-switch")} .pn-toggle-element:checked~.pn-toggle-circle{transform:translateX(100%)}${transformTag("pn-toggle-switch")} .pn-toggle-element:checked~.pn-toggle-circle .pn-toggle-check{opacity:1}${transformTag("pn-toggle-switch")} .pn-toggle-element:checked~.pn-toggle-circle .pn-toggle-check polyline{transition-delay:0.2s, 0s;stroke-dashoffset:0}${transformTag("pn-toggle-switch")} .pn-toggle-element:disabled{cursor:not-allowed}${transformTag("pn-toggle-switch")} .pn-toggle-element:disabled+.pn-toggle-bg{background-color:#d3cecb;box-shadow:none}${transformTag("pn-toggle-switch")} .pn-toggle-element:disabled~.pn-toggle-circle{background-color:#f3f2f2}${transformTag("pn-toggle-switch")} .pn-toggle-element:disabled~.pn-toggle-circle .pn-toggle-check polyline{stroke:#969087}${transformTag("pn-toggle-switch")} .pn-toggle-element:disabled~.pn-toggle-circle ${transformTag("pn-spinner")} .pn-spinner-circle{stroke:#969087}${transformTag("pn-toggle-switch")} .pn-toggle-element:disabled~.pn-toggle-circle ${transformTag("pn-spinner")} .pn-spinner-dot{fill:#969087}${transformTag("pn-toggle-switch")} .pn-toggle-element:disabled:hover+.pn-toggle-bg,${transformTag("pn-toggle-switch")} .pn-toggle-element:disabled:hover:checked+.pn-toggle-bg{background-color:#d3cecb}${transformTag("pn-toggle-switch")} .pn-toggle-element:disabled:hover~.pn-toggle-circle .pn-toggle-check polyline,${transformTag("pn-toggle-switch")} .pn-toggle-element:disabled:hover:checked~.pn-toggle-circle .pn-toggle-check polyline{stroke:#969087}${transformTag("pn-toggle-switch")} .pn-toggle-check{position:absolute;left:50%;top:50%;height:1.5em;width:1.5em;padding:0.25em;transform:translate(-50%, -50%);opacity:0;transition-property:opacity;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-toggle-switch")} .pn-toggle-check{transition-duration:0s;transition-delay:0s}}${transformTag("pn-toggle-switch")} .pn-toggle-check polyline{stroke:#005d92;stroke-linecap:round;stroke-dasharray:23;stroke-dashoffset:23;transition-property:stroke-dashoffset, stroke;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-toggle-switch")} .pn-toggle-check polyline{transition-duration:0s;transition-delay:0s}}${transformTag("pn-toggle-switch")} .pn-toggle ${transformTag("pn-spinner")}{opacity:0;transition-property:opacity;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-toggle-switch")} .pn-toggle ${transformTag("pn-spinner")}{transition-duration:0s;transition-delay:0s}}${transformTag("pn-toggle-switch")} .pn-toggle ${transformTag("pn-spinner")} .pn-spinner-circle{transition-property:stroke;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-toggle-switch")} .pn-toggle ${transformTag("pn-spinner")} .pn-spinner-circle{transition-duration:0s;transition-delay:0s}}${transformTag("pn-toggle-switch")} .pn-toggle ${transformTag("pn-spinner")} .pn-spinner-dot{transition-property:fill;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-toggle-switch")} .pn-toggle ${transformTag("pn-spinner")} .pn-spinner-dot{transition-duration:0s;transition-delay:0s}}`;

/**
 * The `pn-toggle-switch` is built with a native `input[type="checkbox"]` in the background.
 * This means you can use native events to listen to the changes.
 *
 * @nativeChange Use the `change` event to listen when the switch state is being toggled.
 *
 * @slot helpertext - Set the helpertext with a slot instead of prop. Use a `span` element as wrapper.
 * Only use if you need HTML content, such as a link. {@since v7.12.0}
 */
class PnToggleSwitch {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    id = `pn-toggle-${uuidv4()}`;
    idHelper = `${this.id}-helper`;
    get hostElement() { return getElement(this); }
    /** A label for the toggle switch. */
    label;
    /** Provide a helpertext for the toggle switch. */
    helpertext;
    /** HTML toggle value. @category Native attributes  */
    value = null;
    /** HTML toggle name. @category Native attributes  */
    name = null;
    /** Precheck the toggle. @category Native attributes  */
    checked = false;
    /** Set the switch as required. @since v7.25.0 @category Native attributes */
    required = false;
    /** Disable the toggle. @category Native attributes */
    disabled = false;
    /** Make the toggle smaller. @category Features */
    small = false;
    /** Make the toggle larger. @category Features */
    large = false;
    /** Set the loading state. @category Features */
    loading = false;
    /** Set a custom ID for the switch. @since v7.25.0 @category HTML attributes */
    pnId;
    /**
     * Provide the label via an aria attribute.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabel;
    /**
     * Provide the label from another element via its ID.
     * We strongly recommend you use the `label` prop instead.
     * @since v7.25.0
     * @category HTML attributes
     */
    pnAriaLabelledby;
    /** Set a custom ID for the switch. @deprecated Use `pn-id` instead. @category HTML attributes */
    toggleid;
    handleHelperId() {
        this.idHelper = `${this.getId()}-helper`;
    }
    getId() {
        return this.pnId || this.toggleid || this.id;
    }
    getSpinnerSize() {
        if (this.small)
            return 1;
        if (this.large)
            return 1.25;
        return 1.125;
    }
    hasHelpertextProp() {
        return !!this.helpertext;
    }
    hasHelpertextSlot() {
        return !!this.hostElement.querySelector('[slot="helpertext"]');
    }
    showHelpertext() {
        return this.hasHelpertextProp() || this.hasHelpertextSlot();
    }
    describedBy() {
        return this.showHelpertext() ? this.idHelper : null;
    }
    displayLabel() {
        return !!this.label;
    }
    getAriaLabel() {
        return !this.displayLabel() && !this.pnAriaLabelledby ? this.pnAriaLabel : null;
    }
    getAriaLabelledby() {
        return !this.displayLabel() && !this.pnAriaLabel ? this.pnAriaLabelledby : null;
    }
    render() {
        return (hAsync(Host, { key: 'a3363d23f18ca6fd7e9240dcaa46946cda07dd7b' }, hAsync("div", { key: '203140db6d9953527ba4f15e7289bffb2e69a2a1', class: "pn-toggle" }, hAsync("div", { key: 'dac906f74e8aa9899bcb1c99ee53e82695f5a280', class: "pn-toggle-content" }, this.label && (hAsync("label", { key: 'fecf18137bbec21e45feb4380f6c0ebdd0dae01a', htmlFor: this.getId(), class: "pn-toggle-label" }, hAsync("span", { key: '176e29c2756be27e0975690fe0d5f555b382ef6f' }, this.label))), hAsync("p", { key: '865da739546b4f5214fdb63d22a1ea23f1029203', id: this.idHelper, class: "pn-toggle-helper", hidden: !this.showHelpertext() }, this.hasHelpertextProp() && hAsync("span", { key: 'c958031faa669b81215300bd4bc2b31fed018e1a' }, this.helpertext), hAsync("slot", { key: '01267d6e878a089a7174e2747cd232fd9a250f28', name: "helpertext" }))), hAsync("div", { key: 'e3f74dd8febd161788f7a9d197e4216cfa00513e', class: "pn-toggle-button", "data-small": this.small, "data-large": this.large, "data-loading": this.loading }, hAsync("input", { key: '2e9627c525e29bf561072b6d5578b379cba5f597', id: this.getId(), class: "pn-toggle-element", type: "checkbox", name: this.name, value: this.value, checked: this.checked, required: this.required, disabled: this.disabled, "aria-label": this.getAriaLabel(), "aria-labelledby": this.getAriaLabelledby(), "aria-describedby": this.describedBy() }), hAsync("div", { key: '45c2b0269215a6ffa48654541f81d70f33eb57d3', class: "pn-toggle-bg" }), hAsync("div", { key: '684e373a709db9877993c18f29eefc68e6f74585', class: "pn-toggle-circle" }, hAsync("svg", { key: 'e918edb5254603543bc20d639164c05f56db1c54', class: "pn-toggle-check", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none" }, hAsync("polyline", { key: '4f5441441932cd5e645686a8226ddd6a9744b47c', points: "4,12 9,17 20,6", "stroke-width": "3" })), hAsync("pn-spinner", { key: 'a0d94d932142f174c009bf0fb61d23714f9f700d', size: this.getSpinnerSize() }))))));
    }
    static get watchers() { return {
        "pnId": [{
                "handleHelperId": 0
            }],
        "toggleid": [{
                "handleHelperId": 1
            }]
    }; }
    static get style() { return pnToggleSwitchCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-toggle-switch",
        "$members$": {
            "label": [1],
            "helpertext": [1],
            "value": [1],
            "name": [1],
            "checked": [1028],
            "required": [4],
            "disabled": [4],
            "small": [4],
            "large": [4],
            "loading": [4],
            "pnId": [1, "pn-id"],
            "pnAriaLabel": [1, "pn-aria-label"],
            "pnAriaLabelledby": [1, "pn-aria-labelledby"],
            "toggleid": [1]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const pnTooltipCss = () => `${transformTag("pn-tooltip")}{display:inline-block;font-size:1em}${transformTag("pn-tooltip")} .pn-tooltip{background:none;background-color:transparent;border:none;position:relative;padding:0;border-radius:50%;transition-property:outline-color, background-color;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-tooltip")} .pn-tooltip{transition-duration:0s;transition-delay:0s}}${transformTag("pn-tooltip")} .pn-tooltip{cursor:pointer;font-size:inherit;outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-tooltip")} .pn-tooltip:focus-visible{outline-color:#005d92;background-color:#e0f8ff}${transformTag("pn-tooltip")} .pn-tooltip:hover{background-color:#e0f8ff}${transformTag("pn-tooltip")} .pn-tooltip[data-light] ${transformTag("pn-icon")} .pn-icon-svg path{fill:#ffffff}${transformTag("pn-tooltip")} .pn-tooltip[data-light]:focus,${transformTag("pn-tooltip")} .pn-tooltip[data-light]:hover{background-color:rgba(255, 255, 255, 0.2)}${transformTag("pn-tooltip")} .pn-tooltip[data-warning] ${transformTag("pn-icon")} .pn-icon-svg path{fill:#a70707}${transformTag("pn-tooltip")} .pn-tooltip[data-warning]{outline:0.2rem solid transparent;outline-offset:0.2rem}${transformTag("pn-tooltip")} .pn-tooltip[data-warning]:focus-visible{outline-color:#a70707;background-color:#fdefee}${transformTag("pn-tooltip")} .pn-tooltip[data-warning]:hover{background-color:#fdefee}${transformTag("pn-tooltip")} .pn-tooltip-content{position:absolute;text-align:left;bottom:calc(100% + 0.75em);left:50%;background:#ffffff;padding:1em;border-radius:0.8rem;box-shadow:0 1.2px 3.6px rgba(0, 0, 0, 0.1), 0 6.4px 14.4px rgba(0, 0, 0, 0.13);z-index:1;max-width:min(95vw, 40em);transition-property:transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-tooltip")} .pn-tooltip-content{transition-duration:0s;transition-delay:0s}}${transformTag("pn-tooltip")} .pn-tooltip-content{transition-delay:0.15s;transform:scale(0) translateX(-50%);transform-origin:bottom left;width:max-content;color:#2d2013}${transformTag("pn-tooltip")} .pn-tooltip-content[data-simple]{background:#0d234b;color:#ffffff;border-radius:10em;padding:0.5em 0.85em;bottom:100%;font-size:0.875em;font-weight:300;margin-bottom:0.1em;margin-top:0.1em}${transformTag("pn-tooltip")} .pn-tooltip>${transformTag("pn-icon")}{position:relative;pointer-events:none}${transformTag("pn-tooltip")} .pn-tooltip>${transformTag("pn-icon")}:before{content:"";pointer-events:none;width:0;height:0;border-left:0.75em solid transparent;border-right:0.75em solid transparent;border-top:0.75em solid #ffffff;filter:drop-shadow(0 0.3rem 0.1rem rgba(0, 0, 0, 0.075));bottom:102%;left:50%;position:absolute;z-index:2;transition-property:transform;transition-duration:0.2s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-tooltip")} .pn-tooltip>${transformTag("pn-icon")}:before{transition-duration:0s;transition-delay:0s}}${transformTag("pn-tooltip")} .pn-tooltip>${transformTag("pn-icon")}:before{transition-delay:0;transform:scale(0) translateX(-50%);transform-origin:top left}${transformTag("pn-tooltip")} .pn-tooltip>${transformTag("pn-icon")}[data-simple]:before{content:none}${transformTag("pn-tooltip")} .pn-tooltip[data-open] .pn-tooltip-content{transition-delay:0}${transformTag("pn-tooltip")} .pn-tooltip[data-open] ${transformTag("pn-icon")}:before{transform:scale(1) translateX(-50%);transition-delay:0.15s;pointer-events:auto}${transformTag("pn-tooltip")} .pn-tooltip[data-downwards] .pn-tooltip-content{bottom:unset;top:calc(100% + 0.75em);transform-origin:top left}${transformTag("pn-tooltip")} .pn-tooltip[data-downwards] ${transformTag("pn-icon")}:before{top:102%;transform-origin:bottom left;filter:drop-shadow(0 -0.3rem 0.1rem rgba(0, 0, 0, 0.02));border-top:none;border-bottom:0.75em solid #ffffff}`;

/**
 * The `pn-tooltip` can display slotted HTML content or a text `string` with the `tooltip` prop.
 *
 * Remember that the component is techincally a `button` element, don't put any HTML content that would be out of place in a regular button
 * (no headlines, other input elements, etc...).
 */
class PnTooltip {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    content;
    button;
    openEvents = ['mouseover', 'focus'];
    closeEvents = ['mouseleave', 'blur', 'touchcancel', 'touchleave'];
    eventListeners = [...this.openEvents, ...this.closeEvents];
    timeout;
    get hostElement() { return getElement(this); }
    downwards = false;
    open = false;
    deltaX = '0';
    /** Apply the warning color and change the icon to `!`. */
    warning = false;
    /** Apply the light color if you use a dark background. */
    light = false;
    /** Overrides the slotted content to create a small tooltip instead. @since v7.3.0 */
    tooltip;
    openHandler() {
        if (this.open)
            this.checkPosition();
        else
            this.setTransform();
    }
    componentDidLoad() {
        this.initTooltip();
    }
    setTransform() {
        this.content.style.transform = `scale(${Number(this.open)}) translateX(-50%) translateX(${this.deltaX}px)`;
    }
    getSymbol() {
        return this.warning ? alert_exclamation_circle : alert_question_circle;
    }
    checkPosition() {
        this.content.style.transition = 'none';
        this.content.style.transform = 'scale(1) translateX(-50%)';
        this.downwards = false;
        requestAnimationFrame(() => {
            const { x, y, right } = this.content.getBoundingClientRect();
            const extraMargin = 8;
            this.deltaX = '0';
            this.downwards = y < 0;
            this.content.style.transform = '';
            if (x < 0)
                this.deltaX = `${x * -1 + extraMargin}`; // left edge
            if (right > window.innerWidth)
                this.deltaX = `${window.innerWidth - right - extraMargin}`; // right edge
            requestAnimationFrame(() => {
                this.content.style.transition = '';
                this.setTransform();
            });
        });
    }
    initTooltip() {
        this.eventListeners.forEach(name => this.button.addEventListener(name, (event) => this.toggleTooltip(event)));
    }
    toggleTooltip(event) {
        const status = this.openEvents.includes(event.type);
        let time = 500;
        if (status)
            time = 0;
        clearTimeout(this.timeout);
        this.timeout = setTimeout(() => {
            this.open = status;
        }, time);
    }
    render() {
        return (hAsync("button", { key: 'b05404e6f5f07fd347bc701860e5653a9dbce3e8', class: "pn-tooltip", "data-light": this.light, "data-warning": this.warning, "data-downwards": this.downwards, "data-open": this.open, ref: el => (this.button = el) }, hAsync("pn-icon", { key: 'f2842073c6434c74b4edc312fde550f71fb46657', icon: this.getSymbol(), "data-simple": !!this.tooltip }), hAsync("div", { key: 'cd9a95132eb2bcacc999fbb2d3e31d5cdee64fed', class: "pn-tooltip-content", "data-simple": !!this.tooltip, ref: el => (this.content = el) }, this.tooltip, hAsync("div", { key: 'd10296fa39d348a197405296d62c5b11c4ccbd92', hidden: !!this.tooltip }, hAsync("slot", { key: 'a12512c517fd7aca30f5dadf6cd8b6fbd1f5da56' })))));
    }
    static get watchers() { return {
        "open": [{
                "openHandler": 0
            }]
    }; }
    static get style() { return pnTooltipCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-tooltip",
        "$members$": {
            "warning": [4],
            "light": [4],
            "tooltip": [1],
            "downwards": [32],
            "open": [32],
            "deltaX": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

const translations$1 = {
    NEXT: {
        sv: 'Nästa',
        en: 'Next',
        da: 'Næste',
        fi: 'Seuraava',
        no: 'Neste',
    },
    PREV: {
        sv: 'Föregående',
        en: 'Previous',
        da: 'Forrige',
        fi: 'Edellinen',
        no: 'Forrige',
    },
    FINISH: {
        sv: 'Slutför',
        en: 'Finish',
        da: 'Afslut',
        fi: 'Valmis',
        no: 'Fullfør',
    },
    CANCEL: {
        sv: 'Avbryt',
        en: 'Cancel',
        da: 'Annuller',
        fi: 'Peruuta',
        no: 'Avbryt',
    },
};

const pnWizardCss = () => `${transformTag("pn-wizard")} .pn-wizard{z-index:10000;position:absolute;top:0;border:none;margin:0;padding:0;background-color:transparent;outline:none;overflow:unset;height:100%;width:100%;max-width:unset;max-height:unset;display:none;opacity:0;transition-property:display, opacity;transition-duration:0.4s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-wizard")} .pn-wizard{transition-duration:0s;transition-delay:0s}}${transformTag("pn-wizard")} .pn-wizard{transition-behavior:allow-discrete}${transformTag("pn-wizard")} .pn-wizard[open]{display:block;opacity:1}@starting-style{${transformTag("pn-wizard")} .pn-wizard[open]{display:block;opacity:0}}${transformTag("pn-wizard")} .pn-wizard::backdrop{background-color:transparent}${transformTag("pn-wizard")} .pn-wizard-sr-only{position:absolute;height:1px;width:1px;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);margin:-1px;white-space:nowrap}${transformTag("pn-wizard")} .pn-wizard-overlay{z-index:0}${transformTag("pn-wizard")} .pn-wizard-highlight{position:absolute;left:0;top:0;width:var(--pn-spotlight-width, 0%);height:var(--pn-spotlight-height, 0%);border-radius:var(--pn-spotlight-radius, 0.25em);box-shadow:0 0 0 9999px rgba(0, 0, 0, 0.55);z-index:0;transform:translate(var(--pn-spotlight-x, 0%), var(--pn-spotlight-y, 0%));transition-property:transform, width, height, border-radius;transition-duration:0.4s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-wizard")} .pn-wizard-highlight{transition-duration:0s;transition-delay:0s}}${transformTag("pn-wizard")} .pn-wizard-content{position:absolute;z-index:1;background:#ffffff;border-radius:2em;max-width:20em;box-shadow:0 0 0.5em rgba(0, 0, 0, 0.3);left:0;top:0;transform:translate(var(--pn-wizard-content-x), var(--pn-wizard-content-y));transition-property:transform;transition-duration:0.4s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-wizard")} .pn-wizard-content{transition-duration:0s;transition-delay:0s}}@media (max-width: 55em){${transformTag("pn-wizard")} .pn-wizard-content{position:fixed;top:unset;bottom:0;left:0.5em;border-radius:2em 2em 0 0;width:calc(100vw - 1em);max-width:unset;transform:none}}${transformTag("pn-wizard")} .pn-wizard-cancel{position:absolute;top:1em;right:1em;z-index:10}${transformTag("pn-wizard")} .pn-wizard-text{padding:3em 1em 1em;text-align:center;display:flex;flex-direction:column;flex-wrap:nowrap;gap:clamp(0.5em, 5vw, 1em)}${transformTag("pn-wizard")} .pn-wizard-label{margin:0;font-size:clamp(1.25em, 5vw, 1.5em);font-weight:700;color:#2d2013}${transformTag("pn-wizard")} .pn-wizard-helpertext{margin:0;font-size:clamp(0.875em, 5vw, 1em);font-weight:400;color:#5e554a}${transformTag("pn-wizard")} .pn-wizard-controls{border-top:0.0625em solid #d3cecb;padding:1em;display:flex;justify-content:end;gap:0.5em;flex-wrap:wrap}${transformTag("pn-wizard")} .pn-wizard-indicator{margin-right:auto;align-self:center;font-size:1em;color:#5e554a;padding:0 0.625em}${transformTag("pn-wizard")} .pn-wizard-arrow{position:absolute;width:0;height:0;border:0.5em solid transparent;top:0;right:0;bottom:0;left:0;transition-property:top, right, bottom, left, border-color;transition-duration:0.4s;transition-timing-function:cubic-bezier(0.7, 0, 0.3, 1)}@media (prefers-reduced-motion: reduce){${transformTag("pn-wizard")} .pn-wizard-arrow{transition-duration:0s;transition-delay:0s}}${transformTag("pn-wizard")} .pn-wizard-arrow[data-arrow=bottom]{top:100%;bottom:-0.9375em;left:var(--pn-arrow-offset);border-top-color:#ffffff}${transformTag("pn-wizard")} .pn-wizard-arrow[data-arrow=top]{top:-0.9375em;left:var(--pn-arrow-offset);border-bottom-color:#ffffff}${transformTag("pn-wizard")} .pn-wizard-arrow[data-arrow=right]{right:-0.9375em;left:100%;top:var(--pn-arrow-offset);border-left-color:#ffffff}${transformTag("pn-wizard")} .pn-wizard-arrow[data-arrow=left]{left:-0.9375em;top:var(--pn-arrow-offset);border-right-color:#ffffff}${transformTag("pn-wizard")} .pn-wizard-arrow[data-arrow=none]{border-color:transparent}`;

/**
 * The wizard component lets you highlight areas on the page
 * that is accompanied with a modal for user guidance.
 *
 * Either use the label & helpertext props to set a title and description,
 * or use the default slot to add custom HTML content.
 *
 * The steps prop takes an array of querySelectors that the wizard will highlight in order.
 * Set the step prop to start the wizard at a specific step (0-indexed). -1 closes the wizard.
 *
 * @slot - The default slot can be used to add custom content to the wizard modal.
 * @slot buttons - Use this slot to add custom buttons to the wizard controls area.
 * Its a good idea to combine these with the `hide-back`, `hide-next` and `hide-finish` props.
 *
 * @since v7.19.0
 */
class PnWizard {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.wizardStep = createEvent(this, "wizardStep", 7);
        this.wizardHighlightClick = createEvent(this, "wizardHighlightClick", 7);
        this.wizardClose = createEvent(this, "wizardClose", 7);
    }
    id = `pn-wizard-${uuidv4()}`;
    wizardIdLabel;
    wizardIdHelpertext;
    wizardElement;
    wizardContent;
    wizardArrow;
    timeoutRerender;
    get hostElement() { return getElement(this); }
    /** Set a title for the wizard. */
    label = '';
    /** Set a helpertext for the wizard. */
    helpertext = '';
    /** Manually set the language. */
    language = null;
    /** Set a custom HTML id. */
    pnId = this.id;
    /**
     * Assign the current step.
     * Any value above -1 is valid and will start the wizard.
     * @category Wizard steps
     **/
    step = -1;
    /**
     * The list of querySelectors that the wizards will highlight.
     * If a selector is invalid or empty, the wizard will be centered on the screen.
     *
     * Recommended maximum of 7 steps.
     * @category Wizard steps
     **/
    steps = [];
    /**
     * Choose to display one of 2 built in progress steppers.
     * - `dots`: The pn-progress-stepper with the `dots` prop.
     * - `text`: simple text indicator "current/total"
     * @category Features
     */
    progress = '';
    /** Choose where the scrolling will focus on the highlighted elements. @category Features */
    scrollBlock = 'center';
    /**
     * By default, the component will hide the overflow on the body element when active.
     * You may wish to disable this if your HTML/CSS structure is not compatible with this behavior.
     * @category Features
     */
    displayOverflow = false;
    /** Hide the back button. @category Buttons */
    hideBack = false;
    /** Hide the next button. @category Buttons */
    hideNext = false;
    /** Hide the finish button. @category Buttons */
    hideFinish = false;
    /** Set a custom label for the back button. @category Buttons */
    labelBack = '';
    /** Set a custom label for the next button. @category Buttons */
    labelNext = '';
    /** Set a custom label for the finish button. @category Buttons */
    labelFinish = '';
    /** Emitted when the wizard step changes. */
    wizardStep;
    /** Emitted when the highlighted area is clicked. */
    wizardHighlightClick;
    /** Emitted when the wizard is canceled or finished. */
    wizardClose;
    handleStepChange(step, prevStep) {
        if (step === -1) {
            const finished = prevStep === this.steps.length;
            this.wizardClose.emit({ step: finished ? prevStep - 1 : prevStep, finished });
        }
        if (!this.isActive()) {
            this.wizardElement?.close();
            setTimeout(() => this.handleDisplayOverflow(), reduceMotion() ? 0 : 400);
            return;
        }
        if (!this.wizardElement.open) {
            this.runStepLogic();
            requestAnimationFrame(() => {
                this.handleDisplayOverflow();
                this.wizardElement?.showModal();
            });
        }
        this.wizardStep.emit({
            step,
            next: step > (prevStep ?? -1),
            prev: step < (prevStep ?? -1),
        });
    }
    handleIdChange() {
        this.wizardIdLabel = `${this.pnId || this.id}-label`;
        this.wizardIdHelpertext = `${this.pnId || this.id}-helpertext`;
    }
    handleOverflow() {
        if (!this.isActive())
            return;
        clearTimeout(this.timeoutRerender);
        this.timeoutRerender = setTimeout(() => this.runStepLogic(), 250);
    }
    async componentWillLoad() {
        if (this.language === null)
            await awaitTopbar(this.hostElement);
    }
    componentDidRender() {
        requestAnimationFrame(() => this.isActive() && this.runStepLogic());
    }
    getRect(element) {
        return element.getBoundingClientRect();
    }
    translate(prop) {
        return translations$1?.[prop]?.[this.language || en$2] || prop;
    }
    runStepLogic() {
        if (this.isOpen())
            this.scrollToElement();
        this.highlightElement();
        this.positionModal();
    }
    handleDisplayOverflow() {
        if (this.displayOverflow)
            return;
        const body = document.body;
        const scrollbarWidth = innerWidth - document.documentElement.clientWidth;
        if (this.isActive()) {
            body.style.setProperty('overflow', 'hidden');
            body.style.setProperty('margin-right', `${scrollbarWidth}px`);
        }
        else {
            body.style.removeProperty('overflow');
            body.style.removeProperty('margin-right');
        }
    }
    /** Is the step within the valid range of available {@link steps}. */
    isActive(step = this.step) {
        return step >= 0 && step < this.steps.length;
    }
    isOpen() {
        return this.isActive() && this.wizardElement?.open;
    }
    isClosed(step = this.step) {
        return step === -1;
    }
    isFirstStep() {
        return this.step === 0;
    }
    isLastStep(step = this.step) {
        if (this.steps.length === 1)
            return true;
        return step === this.steps.length - 1;
    }
    isProgressDots() {
        return this.progress === 'dots';
    }
    isProgressText() {
        return this.progress === 'text';
    }
    /**
     * By default, the `pn-progress-stepper` will always render,
     * but is hidden from view unless `dots` is assinged to {@link progress}.
     *
     * The only exception is when there are more than 7 steps. Something that the stepper does not allow.
     */
    renderProgress() {
        return 7 >= this.steps.length && (this.isProgressDots() || this.isProgressText());
    }
    showBackButton() {
        if (this.hideBack || this.isClosed() || this.isFirstStep())
            return false;
        return true;
    }
    showNextButton() {
        if (this.hideNext)
            return false;
        return !this.isLastStep() || this.showFinishButton();
    }
    showFinishButton() {
        return !this.hideFinish && this.isLastStep();
    }
    nextStep() {
        const next = this.step + 1;
        this.step = next;
    }
    prevStep() {
        const prev = this.step - 1;
        this.step = prev;
    }
    endWizard() {
        this.step = -1;
    }
    getNextLabel() {
        const finish = this.labelFinish || 'FINISH';
        const next = this.labelNext || 'NEXT';
        const prop = this.isLastStep() ? finish : next;
        return this.translate(prop);
    }
    getHighlightTarget() {
        const selector = this.steps[this.step];
        if (!selector)
            return null;
        const target = document.querySelector(selector);
        return target;
    }
    getHighlightRect() {
        const target = this.getHighlightTarget();
        if (!target) {
            this.resetToCenter();
            return;
        }
        const rect = this.getRect(target);
        const margin = parseFloat(getComputedStyle(target).margin) || 0;
        const top = rect.top + window.scrollY - margin;
        const left = rect.left + window.scrollX - margin;
        const width = rect.width + margin * 2;
        const height = rect.height + margin * 2;
        const radius = parseFloat(getComputedStyle(target).borderRadius) || 4;
        return { top, left, width, height, radius };
    }
    isInViewport(element) {
        const { top, left, bottom, right } = element.getBoundingClientRect();
        return (top >= 0 &&
            left >= 0 &&
            bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
            right <= (window.innerWidth || document.documentElement.clientWidth));
    }
    scrollToElement() {
        const target = this.getHighlightTarget();
        if (!target || this.isInViewport(target))
            return;
        target.scrollIntoView({ behavior: 'instant', block: this.scrollBlock });
    }
    highlightElement() {
        const target = this.getHighlightTarget();
        if (!target)
            return this.resetToCenter();
        this.setHighlightVars(this.getHighlightRect());
    }
    resetToCenter() {
        const { width, height } = this.getWizardContentRect();
        const top = window.scrollY + window.innerHeight / 2 - height / 2;
        const left = window.scrollX + window.innerWidth / 2 - width / 2;
        this.setHighlightVars({ top, left, width: 0, height: 0, radius: 0 });
        this.setModalVars({ top, left });
        this.setArrowVars('none', 0);
    }
    getWizardContentRect() {
        if (!this.wizardContent)
            return { width: 0, height: 0 };
        return this.getRect(this.wizardContent);
    }
    positionModal() {
        const target = this.getHighlightTarget();
        if (!target)
            return;
        /** The distance between the highlight and the modal */
        const gap = 16;
        /** The minimum offset from the edge of the viewport */
        const minOffset = gap / 2;
        /** Target = Highlighted element */
        const { top: targetTop, left: targetLeft, width: targetWidth, height: targetHeight } = this.getHighlightRect();
        const targetCenter = targetLeft + targetWidth / 2;
        /** Modal = Wizard content */
        const { width: modalWidth, height: modalHeight } = this.getWizardContentRect();
        /** The X position of the modal */
        let contentX = 0;
        /** The Y position of the modal */
        let contentY = 0;
        /** Get viewport dimensions and scroll position */
        const { scrollY, scrollX, innerWidth, innerHeight } = window;
        const scrollbarWidth = innerWidth - document.documentElement.clientWidth;
        // Where does the modal fit?
        const modalFitsDown = targetTop + targetHeight + gap + modalHeight < scrollY + innerHeight;
        const modalFitsUp = targetTop - scrollY > modalHeight + gap;
        const modalFitsLeft = targetLeft - gap - modalWidth > scrollX;
        const modalFitsRight = targetLeft + targetWidth + gap + modalWidth < scrollX + innerWidth;
        const modalFitsNone = !modalFitsDown && !modalFitsUp && !modalFitsLeft && !modalFitsRight;
        const fitsY = modalFitsDown || modalFitsUp;
        const fitsX = modalFitsLeft || modalFitsRight;
        let maxY = minOffset;
        let maxX = minOffset;
        maxY = modalFitsDown ? targetTop + targetHeight + gap : targetTop - modalHeight - gap;
        maxX = scrollX + innerWidth - modalWidth - scrollbarWidth - minOffset;
        // Arrow stuff
        let arrowOffset = 0;
        let arrowDirection = 'top';
        if (fitsY) {
            contentX = targetCenter - modalWidth / 2;
            contentY = modalFitsDown ? targetTop + targetHeight + gap : targetTop - modalHeight - gap;
            arrowDirection = modalFitsDown ? 'top' : 'bottom';
            arrowOffset = targetCenter - contentX;
        }
        else if (fitsX) {
            contentX = modalFitsRight ? targetLeft + targetWidth + gap : targetLeft - modalWidth - gap;
            contentY = targetTop + targetHeight / 2 - modalHeight / 2;
            maxY = scrollY + innerHeight - modalHeight - minOffset;
            arrowDirection = modalFitsRight ? 'left' : 'right';
            arrowOffset = modalHeight / 2;
        }
        else if (modalFitsNone) {
            contentX = targetCenter - modalWidth / 2;
            contentY = targetTop + targetHeight - modalHeight / 2;
            maxY = scrollY - modalHeight - minOffset;
            arrowDirection = 'top';
            arrowOffset = targetCenter - contentX;
        }
        // Clamp horizontally within viewport
        const minX = scrollX + scrollbarWidth || minOffset;
        contentX = Math.max(minX, Math.min(contentX, maxX));
        // Clamp vertically within viewport
        const minY = minOffset;
        contentY = Math.max(minY, Math.min(contentY, maxY));
        this.setModalVars({ top: contentY, left: contentX });
        if (isSmallScreen()) {
            arrowDirection = 'top';
        }
        // Adjust arrow offset based on final position
        if (arrowDirection === 'top' || arrowDirection === 'bottom') {
            arrowOffset = targetCenter - contentX;
        }
        else {
            arrowOffset = targetTop + targetHeight / 2 - contentY;
        }
        const modalSize = arrowDirection === 'top' || arrowDirection === 'bottom' ? modalWidth : modalHeight;
        arrowOffset = Math.max(32, // Minimum offset from edge of modal
        Math.min(arrowOffset - minOffset, modalSize - 32));
        this.setArrowVars(arrowDirection, arrowOffset);
    }
    setHighlightVars({ top, left, width, height, radius, }) {
        // Center and scale the highlight using transform
        this.hostElement.style.setProperty('--pn-spotlight-x', `${Math.round(left)}px`);
        this.hostElement.style.setProperty('--pn-spotlight-y', `${Math.round(top)}px`);
        this.hostElement.style.setProperty('--pn-spotlight-width', `${Math.round(width)}px`);
        this.hostElement.style.setProperty('--pn-spotlight-height', `${Math.round(height)}px`);
        this.hostElement.style.setProperty('--pn-spotlight-radius', `${Math.round(radius)}px`);
    }
    setModalVars({ top, left }) {
        this.hostElement.style.setProperty('--pn-wizard-content-x', `${Math.round(left)}px`);
        this.hostElement.style.setProperty('--pn-wizard-content-y', `${Math.round(top)}px`);
    }
    setArrowVars(direction, offset) {
        this.wizardArrow.setAttribute('data-arrow', direction);
        this.hostElement.style.setProperty('--pn-arrow-offset', `${Math.round(offset)}px`);
    }
    render() {
        return (hAsync(Host, { key: '3fbeaf58c3adc8ea380a81b93dc66fb8a6bece5c' }, hAsync("dialog", { key: 'f0f94968cba2e2dc8baba4752d80a7bea862c929', id: this.pnId, "aria-labelledby": this.label ? this.wizardIdLabel : null, "aria-describedby": this.helpertext ? this.wizardIdHelpertext : null, class: "pn-wizard", ref: el => (this.wizardElement = el), onCancel: () => this.endWizard(), onClose: () => this.endWizard() }, hAsync("div", { key: '737f8207c19876c82c6a3d2418305fc7268ee251', class: "pn-wizard-overlay" }, hAsync("div", { key: 'd420a48ad3b30828b4dd496f56073eea375bbe34', class: "pn-wizard-highlight", onClick: e => this.wizardHighlightClick.emit(e) })), hAsync("div", { key: '03d6e169d95b7fe7bdb65a31e839b5744db190d0', class: "pn-wizard-content", ref: el => (this.wizardContent = el) }, hAsync("pn-button", { key: '3534ecbbd28f9171b0ba1adfa07a91a4a20a1dd1', class: "pn-wizard-cancel", arialabel: this.translate('CANCEL'), icon: close, iconOnly: true, small: true, appearance: "light", variant: "borderless", onPnClick: () => this.endWizard() }), hAsync("div", { key: 'b1f3f3ddb93efe5201091d19df4ff22acde76391', class: "pn-wizard-text" }, this.label && (hAsync("h2", { key: 'b689ff85832dd65814d30ca85c00b59281aef1d1', class: "pn-wizard-label", id: this.wizardIdLabel }, this.label)), this.helpertext && (hAsync("p", { key: '6a978db802f3faa402435c84c233e84c3456f657', class: "pn-wizard-helpertext", id: this.wizardIdHelpertext }, this.helpertext)), hAsync("slot", { key: '52d0440d5b470fd06eb3a0c21921d540c79c0ac9' }), this.renderProgress() && (hAsync("pn-progress-stepper", { key: '63f08858ddef511b92d622a559fe3888b5a6508a', class: !this.isProgressDots() && 'pn-wizard-sr-only', totalSteps: this.steps.length, currentStep: this.step > 0 ? this.step + 1 : 1, dots: true }))), hAsync("div", { key: 'c5b266d5421f09bbc2ab199d6d71f5938dc8ae72', class: "pn-wizard-arrow", ref: el => (this.wizardArrow = el) }), hAsync("div", { key: '00aef3606f751ca56142fe2b0a6a08a36e4f92f3', class: "pn-wizard-controls" }, this.isProgressText() && (hAsync("span", { key: 'd6c0c85554253580d65aa42742cdabf55158bfe5', class: "pn-wizard-indicator", "aria-hidden": "true" }, this.step + 1, "/", this.steps.length)), hAsync("slot", { key: '76a1b7c69280ffbbc81f210acdfb8812b241329d', name: "buttons" }), this.showBackButton() && (hAsync("pn-button", { key: '560aa03d06aec0b32ae94ee2264b6bd059b5f305', label: this.labelBack || this.translate('PREV'), small: true, appearance: "light", variant: "outlined", onPnClick: () => this.prevStep() })), this.showNextButton() && (hAsync("pn-button", { key: '00d8a13c7ee3413aa2e3d751d101de41e228f866', label: this.getNextLabel(), small: true, icon: arrow_right, onPnClick: () => this.nextStep() })))))));
    }
    static get watchers() { return {
        "step": [{
                "handleStepChange": 0
            }],
        "pnId": [{
                "handleIdChange": 1
            }]
    }; }
    static get style() { return pnWizardCss(); }
    static get cmpMeta() { return {
        "$flags$": 772,
        "$tagName$": "pn-wizard",
        "$members$": {
            "label": [1],
            "helpertext": [1],
            "language": [1025],
            "pnId": [1025, "pn-id"],
            "step": [1538],
            "steps": [16],
            "progress": [1],
            "scrollBlock": [1, "scroll-block"],
            "displayOverflow": [4, "display-overflow"],
            "hideBack": [4, "hide-back"],
            "hideNext": [4, "hide-next"],
            "hideFinish": [4, "hide-finish"],
            "labelBack": [1, "label-back"],
            "labelNext": [1, "label-next"],
            "labelFinish": [1, "label-finish"]
        },
        "$listeners$": [[9, "resize", "handleOverflow"]],
        "$lazyBundleId$": "-",
        "$attrsToReflect$": [["step", "step"]]
    }; }
}

const translations = {
    CLOSEST_DELIVERY_DATE: {
        en: 'Closest delivery date:',
        sv: 'Nästa utdelningsdag:',
    },
    NEXT_DELIVERY_DATE: {
        en: 'Next delivery date:',
        sv: 'Kommande utdelningsdag:',
    },
    ZIP_CODE: {
        en: 'Zip code:',
        sv: 'Postnummer:',
    },
    VALIDATION_ERROR_MESSAGE: {
        en: 'Zip code not valid',
        sv: 'Postnumret är inte giltigt',
    },
    SERVER_ERROR_MESSAGE: {
        en: 'Could not find zip code',
        sv: 'Kan inte hitta postnumret',
    },
    PLACEHOLDER_TEXT: {
        en: 'Search for a zip code',
        sv: 'Sök på ett postnummer',
    },
    SEARCH: {
        en: 'Search',
        sv: 'Sök',
    },
};

const pnZipcodeSearchCss = () => `${transformTag("pn-zipcode-search")}{display:block;color:#5e554a}${transformTag("pn-zipcode-search")} .pn-search-results{display:flex;flex-direction:column;gap:1em;padding:0 0.75em}${transformTag("pn-zipcode-search")} .pn-search-results span{color:#5e554a}${transformTag("pn-zipcode-search")} .pn-search-results h3{color:#2d2013}${transformTag("pn-zipcode-search")} .pn-error-text{color:#a70707;padding:0 0.75em}${transformTag("pn-zipcode-search")}>${transformTag("pn-search-field")}{width:100%;margin-bottom:1em}`;

/** Check the delivery date for letters, newspapers and direct mail that are distributed every second day. */
class PnZipcodeSearch {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.searchsuccessful = createEvent(this, "searchsuccessful", 7);
    }
    /** This language property will update when pnTopbar loads */
    searchId = `pn-zipcode-${uuidv4()}`;
    get hostElement() { return getElement(this); }
    validZipCode;
    loading = false;
    showResult = false;
    zipCodeSearchResult = {
        delivery: '',
        upcoming: '',
        city: '',
        postalCode: '',
    };
    error = false;
    errorMessage;
    /** The `language` property will be prioritized before the pnTopbar language. */
    language = null;
    /** Set a pre initialized value. */
    value;
    /** Event fired when search has result */
    searchsuccessful;
    async componentWillLoad() {
        if (this.language === null)
            await awaitTopbar(this.hostElement);
        if (!!this.value)
            this.handleSearch(this.value);
    }
    translation(key) {
        return translations[key][this.language || sv$2];
    }
    handleSearch(value) {
        this.value = value;
        this.validateZipCode();
        if (this.error) {
            this.errorMessage = 'VALIDATION_ERROR_MESSAGE';
            return;
        }
        this.zipCodeSearch();
    }
    async zipCodeSearch() {
        this.loading = true;
        await fetch(`https://portal.postnord.com/api/sendoutarrival/closest?postalCode=${this.validZipCode}`)
            .then(response => response.json())
            .then(data => {
            this.showResult = true;
            this.zipCodeSearchResult = data;
            this.searchsuccessful.emit(true);
        })
            .catch(() => {
            this.error = true;
            this.errorMessage = 'SERVER_ERROR_MESSAGE';
            this.searchsuccessful.emit(false);
        })
            .finally(() => {
            this.loading = false;
        });
    }
    validateZipCode() {
        // Removes spaces and dashes
        const formatValue = this.value ? this.value.replace(/[ -]/gi, '') : '';
        const validRegex = /^\d{5}$/;
        const valid = validRegex.test(formatValue);
        this.error = !valid;
        if (valid) {
            this.validZipCode = formatValue;
        }
    }
    renderSearchResult() {
        if (!this.loading && !this.error && this.showResult) {
            return (hAsync("output", { class: "pn-search-results", htmlFor: this.searchId }, hAsync("p", { class: "text-row" }, hAsync("span", null, this.translation('CLOSEST_DELIVERY_DATE')), hAsync("h3", { class: "delivery-date" }, this.zipCodeSearchResult.delivery)), hAsync("p", { class: "text-row" }, hAsync("span", null, this.translation('NEXT_DELIVERY_DATE')), hAsync("h3", { class: "delivery-date" }, this.zipCodeSearchResult.upcoming)), hAsync("p", { class: "text-row" }, hAsync("span", null, this.translation('ZIP_CODE')), hAsync("h3", null, this.zipCodeSearchResult.postalCode, ", ", this.zipCodeSearchResult.city || 'N/A'))));
        }
    }
    renderErrorMessage() {
        if (this.error && !this.loading) {
            return (hAsync("p", { class: "pn-error-text", role: "alert" }, hAsync("small", null, this.translation(this.errorMessage))));
        }
    }
    render() {
        return (hAsync(Host, { key: '604fc6f9244f665ee3aec5411ed21c475e103755' }, hAsync("pn-search-field", { key: '80704adf3156c3ad8b0430cff195344ae2e31536', label: this.translation('PLACEHOLDER_TEXT'), value: this.value, searchid: this.searchId, loading: this.loading, button: "icon", buttonLabel: this.translation('SEARCH'), placeholder: this.translation('PLACEHOLDER_TEXT'), onSearch: e => this.handleSearch(e.detail) }), this.renderSearchResult(), this.renderErrorMessage()));
    }
    static get style() { return pnZipcodeSearchCss(); }
    static get cmpMeta() { return {
        "$flags$": 512,
        "$tagName$": "pn-zipcode-search",
        "$members$": {
            "language": [1],
            "value": [1025],
            "validZipCode": [32],
            "loading": [32],
            "showResult": [32],
            "zipCodeSearchResult": [32],
            "error": [32],
            "errorMessage": [32]
        },
        "$listeners$": undefined,
        "$lazyBundleId$": "-",
        "$attrsToReflect$": []
    }; }
}

registerComponents([
  PnAccordion,
  PnAccordionRow,
  PnActionMenu,
  PnButton,
  PnButtonDropdown,
  PnCard,
  PnCheckbox,
  PnChoiceChip,
  PnCounter,
  PnDatePicker,
  PnFieldset,
  PnFileUpload,
  PnFooter,
  PnHeader,
  PnIcon,
  PnIllustration,
  PnInput,
  PnInputChip,
  PnModal,
  PnMultiselect,
  PnOcrSearch,
  PnPageNav,
  PnPageNavDropdownItem,
  PnPageNavItem,
  PnPagination,
  PnProgressBar,
  PnProgressIndicator,
  PnProgressIndicatorStep,
  PnProgressStepper,
  PnRadioButton,
  PnRange,
  PnReadOnlyButton,
  PnSearchField,
  PnSegment,
  PnSegmentedControl,
  PnSelect,
  PnSkeletonLoader,
  PnSpinner,
  PnTab,
  PnTable,
  PnTablist,
  PnTag,
  PnTextLink,
  PnTextarea,
  PnTile,
  PnToast,
  PnToggleSwitch,
  PnTooltip,
  PnWizard,
  PnZipcodeSearch,
]);

exports.hydrateApp = hydrateApp;


    /*hydrateAppClosure end*/
    hydrateApp(window, $stencilHydrateOpts, $stencilHydrateResults, $stencilAfterHydrate, $stencilHydrateResolve);
  }

  hydrateAppClosure($stencilWindow);
}

// src/app-data/index.ts
var BUILD = {
  allRenderFn: false,
  element: true,
  event: true,
  hasRenderFn: true,
  hostListener: true,
  hostListenerTargetWindow: true,
  hostListenerTargetDocument: true,
  hostListenerTargetBody: true,
  hostListenerTargetParent: false,
  hostListenerTarget: true,
  member: true,
  method: true,
  mode: true,
  observeAttribute: true,
  prop: true,
  propMutable: true,
  reflect: true,
  scoped: true,
  shadowDom: true,
  slot: true,
  cssAnnotations: true,
  state: true,
  style: true,
  formAssociated: false,
  svg: true,
  updatable: true,
  vdomAttribute: true,
  vdomXlink: true,
  vdomClass: true,
  vdomFunctional: true,
  vdomKey: true,
  vdomListener: true,
  vdomRef: true,
  vdomPropOrAttr: true,
  vdomRender: true,
  vdomStyle: true,
  vdomText: true,
  propChangeCallback: true,
  taskQueue: true,
  hotModuleReplacement: false,
  isDebug: false,
  isDev: false,
  isTesting: false,
  hydrateServerSide: false,
  hydrateClientSide: false,
  lifecycleDOMEvents: false,
  lazyLoad: false,
  profile: false,
  slotRelocation: true,
  // TODO(STENCIL-914): remove this option when `experimentalSlotFixes` is the default behavior
  appendChildSlotFix: false,
  // TODO(STENCIL-914): remove this option when `experimentalSlotFixes` is the default behavior
  cloneNodeFix: false,
  hydratedAttribute: false,
  hydratedClass: true,
  // TODO(STENCIL-1305): remove this option
  scriptDataOpts: false,
  // TODO(STENCIL-914): remove this option when `experimentalSlotFixes` is the default behavior
  scopedSlotTextContentFix: false,
  // TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
  shadowDomShim: false,
  // TODO(STENCIL-914): remove this option when `experimentalSlotFixes` is the default behavior
  slotChildNodesFix: false,
  invisiblePrehydration: true,
  propBoolean: true,
  propNumber: true,
  propString: true,
  constructableCSS: true,
  devTools: false,
  shadowDelegatesFocus: true,
  shadowSlotAssignmentManual: false,
  initializeNextTick: false,
  asyncLoading: true,
  asyncQueue: false,
  // TODO: deprecated in favour of `setTagTransformer` and `transformTag`. Remove in 5.0
  transformTagName: false,
  attachStyles: true,
  // TODO(STENCIL-914): remove this option when `experimentalSlotFixes` is the default behavior
  experimentalSlotFixes: false
};
var Env = {};
var NAMESPACE = (
  /* default */
  "app"
);

/*
 Stencil Hydrate Runner v4.43.2 | MIT Licensed | https://stenciljs.com
 */
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 __typeError = (msg) => {
  throw TypeError(msg);
};
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __commonJS = (cb, mod) => function __require() {
  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
));
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);

// node_modules/balanced-match/index.js
var require_balanced_match = __commonJS({
  "node_modules/balanced-match/index.js"(exports, module) {
    "use strict";
    module.exports = balanced;
    function balanced(a, b, str) {
      if (a instanceof RegExp) a = maybeMatch(a, str);
      if (b instanceof RegExp) b = maybeMatch(b, str);
      var r = range(a, b, str);
      return r && {
        start: r[0],
        end: r[1],
        pre: str.slice(0, r[0]),
        body: str.slice(r[0] + a.length, r[1]),
        post: str.slice(r[1] + b.length)
      };
    }
    function maybeMatch(reg, str) {
      var m = str.match(reg);
      return m ? m[0] : null;
    }
    balanced.range = range;
    function range(a, b, str) {
      var begs, beg, left, right, result;
      var ai = str.indexOf(a);
      var bi = str.indexOf(b, ai + 1);
      var i = ai;
      if (ai >= 0 && bi > 0) {
        if (a === b) {
          return [ai, bi];
        }
        begs = [];
        left = str.length;
        while (i >= 0 && !result) {
          if (i == ai) {
            begs.push(i);
            ai = str.indexOf(a, i + 1);
          } else if (begs.length == 1) {
            result = [begs.pop(), bi];
          } else {
            beg = begs.pop();
            if (beg < left) {
              left = beg;
              right = bi;
            }
            bi = str.indexOf(b, i + 1);
          }
          i = ai < bi && ai >= 0 ? ai : bi;
        }
        if (begs.length) {
          result = [left, right];
        }
      }
      return result;
    }
  }
});

// node_modules/brace-expansion/index.js
var require_brace_expansion = __commonJS({
  "node_modules/brace-expansion/index.js"(exports, module) {
    var balanced = require_balanced_match();
    module.exports = expandTop;
    var escSlash = "\0SLASH" + Math.random() + "\0";
    var escOpen = "\0OPEN" + Math.random() + "\0";
    var escClose = "\0CLOSE" + Math.random() + "\0";
    var escComma = "\0COMMA" + Math.random() + "\0";
    var escPeriod = "\0PERIOD" + Math.random() + "\0";
    function numeric(str) {
      return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
    }
    function escapeBraces(str) {
      return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
    }
    function unescapeBraces(str) {
      return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
    }
    function parseCommaParts(str) {
      if (!str)
        return [""];
      var parts = [];
      var m = balanced("{", "}", str);
      if (!m)
        return str.split(",");
      var pre = m.pre;
      var body = m.body;
      var post = m.post;
      var p = pre.split(",");
      p[p.length - 1] += "{" + body + "}";
      var postParts = parseCommaParts(post);
      if (post.length) {
        p[p.length - 1] += postParts.shift();
        p.push.apply(p, postParts);
      }
      parts.push.apply(parts, p);
      return parts;
    }
    function expandTop(str) {
      if (!str)
        return [];
      if (str.substr(0, 2) === "{}") {
        str = "\\{\\}" + str.substr(2);
      }
      return expand2(escapeBraces(str), true).map(unescapeBraces);
    }
    function embrace(str) {
      return "{" + str + "}";
    }
    function isPadded(el) {
      return /^-?0\d/.test(el);
    }
    function lte(i, y) {
      return i <= y;
    }
    function gte(i, y) {
      return i >= y;
    }
    function expand2(str, isTop) {
      var expansions = [];
      var m = balanced("{", "}", str);
      if (!m) return [str];
      var pre = m.pre;
      var post = m.post.length ? expand2(m.post, false) : [""];
      if (/\$$/.test(m.pre)) {
        for (var k = 0; k < post.length; k++) {
          var expansion = pre + "{" + m.body + "}" + post[k];
          expansions.push(expansion);
        }
      } else {
        var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
        var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
        var isSequence = isNumericSequence || isAlphaSequence;
        var isOptions = m.body.indexOf(",") >= 0;
        if (!isSequence && !isOptions) {
          if (m.post.match(/,(?!,).*\}/)) {
            str = m.pre + "{" + m.body + escClose + m.post;
            return expand2(str);
          }
          return [str];
        }
        var n;
        if (isSequence) {
          n = m.body.split(/\.\./);
        } else {
          n = parseCommaParts(m.body);
          if (n.length === 1) {
            n = expand2(n[0], false).map(embrace);
            if (n.length === 1) {
              return post.map(function(p) {
                return m.pre + n[0] + p;
              });
            }
          }
        }
        var N;
        if (isSequence) {
          var x = numeric(n[0]);
          var y = numeric(n[1]);
          var width = Math.max(n[0].length, n[1].length);
          var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
          var test = lte;
          var reverse = y < x;
          if (reverse) {
            incr *= -1;
            test = gte;
          }
          var pad = n.some(isPadded);
          N = [];
          for (var i = x; test(i, y); i += incr) {
            var c;
            if (isAlphaSequence) {
              c = String.fromCharCode(i);
              if (c === "\\")
                c = "";
            } else {
              c = String(i);
              if (pad) {
                var need = width - c.length;
                if (need > 0) {
                  var z = new Array(need + 1).join("0");
                  if (i < 0)
                    c = "-" + z + c.slice(1);
                  else
                    c = z + c;
                }
              }
            }
            N.push(c);
          }
        } else {
          N = [];
          for (var j = 0; j < n.length; j++) {
            N.push.apply(N, expand2(n[j], false));
          }
        }
        for (var j = 0; j < N.length; j++) {
          for (var k = 0; k < post.length; k++) {
            var expansion = pre + N[j] + post[k];
            if (!isTop || isSequence || expansion)
              expansions.push(expansion);
          }
        }
      }
      return expansions;
    }
  }
});

// src/runtime/runtime-constants.ts
var CONTENT_REF_ID = "r";
var ORG_LOCATION_ID = "o";
var SLOT_NODE_ID = "s";
var TEXT_NODE_ID = "t";
var HYDRATE_ID = "s-id";
var HYDRATED_STYLE_ID = "sty-id";
var STENCIL_DOC_DATA = "_stencilDocData";
var XLINK_NS = "http://www.w3.org/1999/xlink";

// src/mock-doc/attribute.ts
var attrHandler = {
  get(obj, prop) {
    if (prop in obj) {
      return obj[prop];
    }
    if (typeof prop !== "symbol" && !isNaN(prop)) {
      return obj.__items[prop];
    }
    return void 0;
  }
};
var createAttributeProxy = (caseInsensitive) => new Proxy(new MockAttributeMap(caseInsensitive), attrHandler);
var MockAttributeMap = class {
  constructor(caseInsensitive = false) {
    this.caseInsensitive = caseInsensitive;
  }
  __items = [];
  get length() {
    return this.__items.length;
  }
  item(index) {
    return this.__items[index] || null;
  }
  setNamedItem(attr) {
    attr.namespaceURI = null;
    this.setNamedItemNS(attr);
  }
  setNamedItemNS(attr) {
    if (attr != null && attr.value != null) {
      attr.value = String(attr.value);
    }
    const existingAttr = this.__items.find((a) => a.name === attr.name && a.namespaceURI === attr.namespaceURI);
    if (existingAttr != null) {
      existingAttr.value = attr.value;
    } else {
      this.__items.push(attr);
    }
  }
  getNamedItem(attrName) {
    if (this.caseInsensitive) {
      attrName = attrName.toLowerCase();
    }
    return this.getNamedItemNS(null, attrName);
  }
  getNamedItemNS(namespaceURI, attrName) {
    namespaceURI = getNamespaceURI(namespaceURI);
    return this.__items.find((attr) => attr.name === attrName && getNamespaceURI(attr.namespaceURI) === namespaceURI) || null;
  }
  removeNamedItem(attr) {
    this.removeNamedItemNS(attr);
  }
  removeNamedItemNS(attr) {
    for (let i = 0, ii = this.__items.length; i < ii; i++) {
      if (this.__items[i].name === attr.name && this.__items[i].namespaceURI === attr.namespaceURI) {
        this.__items.splice(i, 1);
        break;
      }
    }
  }
  [Symbol.iterator]() {
    let i = 0;
    return {
      next: () => ({
        done: i === this.length,
        value: this.item(i++)
      })
    };
  }
  get [Symbol.toStringTag]() {
    return "MockAttributeMap";
  }
};
function getNamespaceURI(namespaceURI) {
  return namespaceURI === XLINK_NS ? null : namespaceURI;
}
function cloneAttributes(srcAttrs, sortByName = false) {
  const dstAttrs = new MockAttributeMap(srcAttrs.caseInsensitive);
  if (srcAttrs != null) {
    const attrLen = srcAttrs.length;
    if (sortByName && attrLen > 1) {
      const sortedAttrs = [];
      for (let i = 0; i < attrLen; i++) {
        const srcAttr = srcAttrs.item(i);
        const dstAttr = new MockAttr(srcAttr.name, srcAttr.value, srcAttr.namespaceURI);
        sortedAttrs.push(dstAttr);
      }
      sortedAttrs.sort(sortAttributes).forEach((attr) => {
        dstAttrs.setNamedItemNS(attr);
      });
    } else {
      for (let i = 0; i < attrLen; i++) {
        const srcAttr = srcAttrs.item(i);
        const dstAttr = new MockAttr(srcAttr.name, srcAttr.value, srcAttr.namespaceURI);
        dstAttrs.setNamedItemNS(dstAttr);
      }
    }
  }
  return dstAttrs;
}
function sortAttributes(a, b) {
  if (a.name < b.name) return -1;
  if (a.name > b.name) return 1;
  return 0;
}
var MockAttr = class {
  _name;
  _value;
  _namespaceURI;
  constructor(attrName, attrValue, namespaceURI = null) {
    this._name = attrName;
    this._value = String(attrValue);
    this._namespaceURI = namespaceURI;
  }
  get name() {
    return this._name;
  }
  set name(value) {
    this._name = value;
  }
  get value() {
    return this._value;
  }
  set value(value) {
    this._value = String(value);
  }
  get nodeName() {
    return this._name;
  }
  set nodeName(value) {
    this._name = value;
  }
  get nodeValue() {
    return this._value;
  }
  set nodeValue(value) {
    this._value = String(value);
  }
  get namespaceURI() {
    return this._namespaceURI;
  }
  set namespaceURI(namespaceURI) {
    this._namespaceURI = namespaceURI;
  }
};

// src/mock-doc/css-style-declaration.ts
var MockCSSStyleDeclaration = class {
  _styles = /* @__PURE__ */ new Map();
  setProperty(prop, value) {
    prop = jsCaseToCssCase(prop);
    if (value == null || value === "") {
      this._styles.delete(prop);
    } else {
      this._styles.set(prop, String(value));
    }
  }
  getPropertyValue(prop) {
    prop = jsCaseToCssCase(prop);
    return String(this._styles.get(prop) || "");
  }
  removeProperty(prop) {
    prop = jsCaseToCssCase(prop);
    this._styles.delete(prop);
  }
  get length() {
    return this._styles.size;
  }
  get cssText() {
    const cssText = [];
    this._styles.forEach((value, prop) => {
      cssText.push(`${prop}: ${value};`);
    });
    return cssText.join(" ").trim();
  }
  set cssText(cssText) {
    if (cssText == null || cssText === "") {
      this._styles.clear();
      return;
    }
    cssText.split(";").forEach((rule) => {
      rule = rule.trim();
      if (rule.length > 0) {
        const splt = rule.split(":");
        if (splt.length > 1) {
          const prop = splt[0].trim();
          const value = splt.slice(1).join(":").trim();
          if (prop !== "" && value !== "") {
            this._styles.set(jsCaseToCssCase(prop), value);
          }
        }
      }
    });
  }
};
function createCSSStyleDeclaration() {
  return new Proxy(new MockCSSStyleDeclaration(), cssProxyHandler);
}
var cssProxyHandler = {
  get(cssStyle, prop) {
    if (prop in cssStyle) {
      return cssStyle[prop];
    }
    prop = cssCaseToJsCase(prop);
    return cssStyle.getPropertyValue(prop);
  },
  set(cssStyle, prop, value) {
    if (prop in cssStyle) {
      cssStyle[prop] = value;
    } else {
      cssStyle.setProperty(prop, value);
    }
    return true;
  }
};
function cssCaseToJsCase(str) {
  if (str.length > 1 && str.includes("-") === true) {
    str = str.toLowerCase().split("-").map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join("");
    str = str.slice(0, 1).toLowerCase() + str.slice(1);
  }
  return str;
}
function jsCaseToCssCase(str) {
  if (str.length > 1 && str.includes("-") === false && /[A-Z]/.test(str) === true) {
    str = str.replace(/([A-Z])/g, (g) => " " + g[0]).trim().replace(/ /g, "-").toLowerCase();
  }
  return str;
}

// src/mock-doc/custom-element-registry.ts
var MockCustomElementRegistry = class {
  constructor(win2) {
    this.win = win2;
  }
  __registry;
  __whenDefined;
  define(tagName, cstr, options) {
    if (tagName.toLowerCase() !== tagName) {
      throw new Error(
        `Failed to execute 'define' on 'CustomElementRegistry': "${tagName}" is not a valid custom element name`
      );
    }
    if (this.__registry == null) {
      this.__registry = /* @__PURE__ */ new Map();
    }
    this.__registry.set(tagName, { cstr, options });
    if (this.__whenDefined != null) {
      const whenDefinedResolveFns = this.__whenDefined.get(tagName);
      if (whenDefinedResolveFns != null) {
        whenDefinedResolveFns.forEach((whenDefinedResolveFn) => {
          whenDefinedResolveFn();
        });
        whenDefinedResolveFns.length = 0;
        this.__whenDefined.delete(tagName);
      }
    }
    const doc = this.win.document;
    if (doc != null) {
      const hosts = doc.querySelectorAll(tagName);
      hosts.forEach((host) => {
        if (upgradedElements.has(host) === false) {
          tempDisableCallbacks.add(doc);
          const upgradedCmp = createCustomElement(this, doc, tagName);
          for (let i = 0; i < host.childNodes.length; i++) {
            const childNode = host.childNodes[i];
            childNode.remove();
            upgradedCmp.appendChild(childNode);
          }
          tempDisableCallbacks.delete(doc);
          if (proxyElements.has(host)) {
            proxyElements.set(host, upgradedCmp);
          }
        }
        fireConnectedCallback(host);
      });
    }
  }
  get(tagName) {
    if (this.__registry != null) {
      const def = this.__registry.get(tagName.toLowerCase());
      if (def != null) {
        return def.cstr;
      }
    }
    return void 0;
  }
  getName(cstr) {
    for (const [tagName, def] of this.__registry.entries()) {
      if (def.cstr === cstr) {
        return tagName;
      }
    }
    return void 0;
  }
  upgrade(_rootNode) {
  }
  clear() {
    if (this.__registry != null) {
      this.__registry.clear();
    }
    if (this.__whenDefined != null) {
      this.__whenDefined.clear();
    }
  }
  whenDefined(tagName) {
    tagName = tagName.toLowerCase();
    if (this.__registry != null && this.__registry.has(tagName) === true) {
      return Promise.resolve(this.__registry.get(tagName).cstr);
    }
    return new Promise((resolve) => {
      if (this.__whenDefined == null) {
        this.__whenDefined = /* @__PURE__ */ new Map();
      }
      let whenDefinedResolveFns = this.__whenDefined.get(tagName);
      if (whenDefinedResolveFns == null) {
        whenDefinedResolveFns = [];
        this.__whenDefined.set(tagName, whenDefinedResolveFns);
      }
      whenDefinedResolveFns.push(resolve);
    });
  }
};
function createCustomElement(customElements2, ownerDocument, tagName) {
  const Cstr = customElements2.get(tagName);
  if (Cstr != null) {
    const cmp = new Cstr(ownerDocument);
    cmp.nodeName = tagName.toUpperCase();
    upgradedElements.add(cmp);
    return cmp;
  }
  const host = new Proxy(
    {},
    {
      get(obj, prop) {
        const elm2 = proxyElements.get(host);
        if (elm2 != null) {
          return elm2[prop];
        }
        return obj[prop];
      },
      set(obj, prop, val) {
        const elm2 = proxyElements.get(host);
        if (elm2 != null) {
          elm2[prop] = val;
        } else {
          obj[prop] = val;
        }
        return true;
      },
      has(obj, prop) {
        const elm2 = proxyElements.get(host);
        if (prop in elm2) {
          return true;
        }
        if (prop in obj) {
          return true;
        }
        return false;
      }
    }
  );
  const elm = new MockHTMLElement(ownerDocument, tagName);
  proxyElements.set(host, elm);
  return host;
}
var proxyElements = /* @__PURE__ */ new WeakMap();
var upgradedElements = /* @__PURE__ */ new WeakSet();
function connectNode(ownerDocument, node) {
  node.ownerDocument = ownerDocument;
  if (node.nodeType === 1 /* ELEMENT_NODE */) {
    if (ownerDocument != null && node.nodeName.includes("-")) {
      const win2 = ownerDocument.defaultView;
      if (win2 != null && typeof node.connectedCallback === "function" && node.isConnected) {
        fireConnectedCallback(node);
      }
      const shadowRoot = node.shadowRoot;
      if (shadowRoot != null) {
        shadowRoot.childNodes.forEach((childNode) => {
          connectNode(ownerDocument, childNode);
        });
      }
    }
    node.childNodes.forEach((childNode) => {
      connectNode(ownerDocument, childNode);
    });
  } else {
    node.childNodes.forEach((childNode) => {
      childNode.ownerDocument = ownerDocument;
    });
  }
}
function fireConnectedCallback(node) {
  if (typeof node.connectedCallback === "function") {
    if (tempDisableCallbacks.has(node.ownerDocument) === false) {
      try {
        node.connectedCallback();
      } catch (e) {
        console.error(e);
      }
    }
  }
}
function disconnectNode(node) {
  if (node.nodeType === 1 /* ELEMENT_NODE */) {
    if (node.nodeName.includes("-") === true && typeof node.disconnectedCallback === "function") {
      if (tempDisableCallbacks.has(node.ownerDocument) === false) {
        try {
          node.disconnectedCallback();
        } catch (e) {
          console.error(e);
        }
      }
    }
    node.childNodes.forEach(disconnectNode);
  }
}
function attributeChanged(node, attrName, oldValue, newValue) {
  attrName = attrName.toLowerCase();
  const observedAttributes = node.constructor.observedAttributes;
  if (Array.isArray(observedAttributes) === true && observedAttributes.some((obs) => obs.toLowerCase() === attrName) === true) {
    try {
      node.attributeChangedCallback(attrName, oldValue, newValue);
    } catch (e) {
      console.error(e);
    }
  }
}
function checkAttributeChanged(node) {
  return node.nodeName.includes("-") === true && typeof node.attributeChangedCallback === "function";
}
var tempDisableCallbacks = /* @__PURE__ */ new Set();

// src/mock-doc/dataset.ts
function dataset(elm) {
  const ds = {};
  const attributes = elm.attributes;
  const attrLen = attributes.length;
  for (let i = 0; i < attrLen; i++) {
    const attr = attributes.item(i);
    const nodeName = attr.nodeName;
    if (nodeName.startsWith("data-")) {
      ds[dashToPascalCase(nodeName)] = attr.nodeValue;
    }
  }
  return new Proxy(ds, {
    get(_obj, camelCaseProp) {
      return ds[camelCaseProp];
    },
    set(_obj, camelCaseProp, value) {
      const dataAttr = toDataAttribute(camelCaseProp);
      elm.setAttribute(dataAttr, value);
      return true;
    }
  });
}
function toDataAttribute(str) {
  return "data-" + String(str).replace(/([A-Z0-9])/g, (g) => " " + g[0]).trim().replace(/ /g, "-").toLowerCase();
}
function dashToPascalCase(str) {
  str = String(str).slice(5);
  return str.split("-").map((segment, index) => {
    if (index === 0) {
      return segment.charAt(0).toLowerCase() + segment.slice(1);
    }
    return segment.charAt(0).toUpperCase() + segment.slice(1);
  }).join("");
}

// src/mock-doc/event.ts
var MockEvent = class {
  bubbles = false;
  cancelBubble = false;
  cancelable = false;
  composed = false;
  currentTarget = null;
  defaultPrevented = false;
  srcElement = null;
  target = null;
  timeStamp;
  type;
  constructor(type, eventInitDict) {
    if (typeof type !== "string") {
      throw new Error(`Event type required`);
    }
    this.type = type;
    this.timeStamp = Date.now();
    if (eventInitDict != null) {
      Object.assign(this, eventInitDict);
    }
  }
  preventDefault() {
    this.defaultPrevented = true;
  }
  stopPropagation() {
    this.cancelBubble = true;
  }
  stopImmediatePropagation() {
    this.cancelBubble = true;
  }
  /**
   * @ref https://developer.mozilla.org/en-US/docs/Web/API/Event/composedPath
   * @returns a composed path of the event
   */
  composedPath() {
    const composedPath = [];
    let currentElement = this.target;
    while (currentElement) {
      composedPath.push(currentElement);
      if (!currentElement.parentElement && currentElement.nodeName === "#document" /* DOCUMENT_NODE */) {
        composedPath.push(currentElement.defaultView);
        break;
      }
      if (currentElement.parentElement == null && currentElement.tagName === "HTML") {
        currentElement = currentElement.ownerDocument;
      } else {
        currentElement = currentElement.parentElement;
      }
    }
    return composedPath;
  }
};
var MockCustomEvent = class extends MockEvent {
  detail = null;
  constructor(type, customEventInitDic) {
    super(type);
    if (customEventInitDic != null) {
      Object.assign(this, customEventInitDic);
    }
  }
};
var MockKeyboardEvent = class extends MockEvent {
  code = "";
  key = "";
  altKey = false;
  ctrlKey = false;
  metaKey = false;
  shiftKey = false;
  location = 0;
  repeat = false;
  constructor(type, keyboardEventInitDic) {
    super(type);
    if (keyboardEventInitDic != null) {
      Object.assign(this, keyboardEventInitDic);
    }
  }
};
var MockMouseEvent = class extends MockEvent {
  screenX = 0;
  screenY = 0;
  clientX = 0;
  clientY = 0;
  ctrlKey = false;
  shiftKey = false;
  altKey = false;
  metaKey = false;
  button = 0;
  buttons = 0;
  relatedTarget = null;
  constructor(type, mouseEventInitDic) {
    super(type);
    if (mouseEventInitDic != null) {
      Object.assign(this, mouseEventInitDic);
    }
  }
};
var MockUIEvent = class extends MockEvent {
  detail = null;
  view = null;
  constructor(type, uiEventInitDic) {
    super(type);
    if (uiEventInitDic != null) {
      Object.assign(this, uiEventInitDic);
    }
  }
};
var MockFocusEvent = class extends MockUIEvent {
  relatedTarget = null;
  constructor(type, focusEventInitDic) {
    super(type);
    if (focusEventInitDic != null) {
      Object.assign(this, focusEventInitDic);
    }
  }
};
var MockEventListener = class {
  type;
  handler;
  constructor(type, handler) {
    this.type = type;
    this.handler = handler;
  }
};
function addEventListener(elm, type, handler) {
  const target = elm;
  if (target.__listeners == null) {
    target.__listeners = [];
  }
  target.__listeners.push(new MockEventListener(type, handler));
}
function removeEventListener(elm, type, handler) {
  const target = elm;
  if (target != null && Array.isArray(target.__listeners) === true) {
    const elmListener = target.__listeners.find((e) => e.type === type && e.handler === handler);
    if (elmListener != null) {
      const index = target.__listeners.indexOf(elmListener);
      target.__listeners.splice(index, 1);
    }
  }
}
function resetEventListeners(target) {
  if (target != null && target.__listeners != null) {
    target.__listeners = null;
  }
}
function triggerEventListener(elm, ev) {
  if (elm == null || ev.cancelBubble === true) {
    return;
  }
  const target = elm;
  ev.currentTarget = elm;
  if (Array.isArray(target.__listeners) === true) {
    const listeners = target.__listeners.filter((e) => e.type === ev.type);
    listeners.forEach((listener) => {
      try {
        listener.handler.call(target, ev);
      } catch (err2) {
        console.error(err2);
      }
    });
  }
  if (ev.bubbles === false) {
    return;
  }
  if (elm.nodeName === "#document" /* DOCUMENT_NODE */) {
    triggerEventListener(elm.defaultView, ev);
  } else if (elm.parentElement == null && elm.tagName === "HTML") {
    triggerEventListener(elm.ownerDocument, ev);
  } else {
    const nextTarget = getNextEventTarget(elm, ev);
    triggerEventListener(nextTarget, ev);
  }
}
function getNextEventTarget(elm, ev) {
  if (elm.parentElement) {
    return elm.parentElement;
  }
  if (elm.host && ev.composed) {
    return elm.host;
  }
  if (ev.composed && elm.parentNode && elm.parentNode.host) {
    return elm.parentNode.host;
  }
  return null;
}
function dispatchEvent(currentTarget, ev) {
  ev.target = currentTarget;
  triggerEventListener(currentTarget, ev);
  return true;
}

// node_modules/parse5/dist/common/unicode.js
var UNDEFINED_CODE_POINTS = /* @__PURE__ */ new Set([
  65534,
  65535,
  131070,
  131071,
  196606,
  196607,
  262142,
  262143,
  327678,
  327679,
  393214,
  393215,
  458750,
  458751,
  524286,
  524287,
  589822,
  589823,
  655358,
  655359,
  720894,
  720895,
  786430,
  786431,
  851966,
  851967,
  917502,
  917503,
  983038,
  983039,
  1048574,
  1048575,
  1114110,
  1114111
]);
var REPLACEMENT_CHARACTER = "\uFFFD";
var CODE_POINTS;
(function(CODE_POINTS2) {
  CODE_POINTS2[CODE_POINTS2["EOF"] = -1] = "EOF";
  CODE_POINTS2[CODE_POINTS2["NULL"] = 0] = "NULL";
  CODE_POINTS2[CODE_POINTS2["TABULATION"] = 9] = "TABULATION";
  CODE_POINTS2[CODE_POINTS2["CARRIAGE_RETURN"] = 13] = "CARRIAGE_RETURN";
  CODE_POINTS2[CODE_POINTS2["LINE_FEED"] = 10] = "LINE_FEED";
  CODE_POINTS2[CODE_POINTS2["FORM_FEED"] = 12] = "FORM_FEED";
  CODE_POINTS2[CODE_POINTS2["SPACE"] = 32] = "SPACE";
  CODE_POINTS2[CODE_POINTS2["EXCLAMATION_MARK"] = 33] = "EXCLAMATION_MARK";
  CODE_POINTS2[CODE_POINTS2["QUOTATION_MARK"] = 34] = "QUOTATION_MARK";
  CODE_POINTS2[CODE_POINTS2["AMPERSAND"] = 38] = "AMPERSAND";
  CODE_POINTS2[CODE_POINTS2["APOSTROPHE"] = 39] = "APOSTROPHE";
  CODE_POINTS2[CODE_POINTS2["HYPHEN_MINUS"] = 45] = "HYPHEN_MINUS";
  CODE_POINTS2[CODE_POINTS2["SOLIDUS"] = 47] = "SOLIDUS";
  CODE_POINTS2[CODE_POINTS2["DIGIT_0"] = 48] = "DIGIT_0";
  CODE_POINTS2[CODE_POINTS2["DIGIT_9"] = 57] = "DIGIT_9";
  CODE_POINTS2[CODE_POINTS2["SEMICOLON"] = 59] = "SEMICOLON";
  CODE_POINTS2[CODE_POINTS2["LESS_THAN_SIGN"] = 60] = "LESS_THAN_SIGN";
  CODE_POINTS2[CODE_POINTS2["EQUALS_SIGN"] = 61] = "EQUALS_SIGN";
  CODE_POINTS2[CODE_POINTS2["GREATER_THAN_SIGN"] = 62] = "GREATER_THAN_SIGN";
  CODE_POINTS2[CODE_POINTS2["QUESTION_MARK"] = 63] = "QUESTION_MARK";
  CODE_POINTS2[CODE_POINTS2["LATIN_CAPITAL_A"] = 65] = "LATIN_CAPITAL_A";
  CODE_POINTS2[CODE_POINTS2["LATIN_CAPITAL_Z"] = 90] = "LATIN_CAPITAL_Z";
  CODE_POINTS2[CODE_POINTS2["RIGHT_SQUARE_BRACKET"] = 93] = "RIGHT_SQUARE_BRACKET";
  CODE_POINTS2[CODE_POINTS2["GRAVE_ACCENT"] = 96] = "GRAVE_ACCENT";
  CODE_POINTS2[CODE_POINTS2["LATIN_SMALL_A"] = 97] = "LATIN_SMALL_A";
  CODE_POINTS2[CODE_POINTS2["LATIN_SMALL_Z"] = 122] = "LATIN_SMALL_Z";
})(CODE_POINTS || (CODE_POINTS = {}));
var SEQUENCES = {
  DASH_DASH: "--",
  CDATA_START: "[CDATA[",
  DOCTYPE: "doctype",
  SCRIPT: "script",
  PUBLIC: "public",
  SYSTEM: "system"
};
function isSurrogate(cp) {
  return cp >= 55296 && cp <= 57343;
}
function isSurrogatePair(cp) {
  return cp >= 56320 && cp <= 57343;
}
function getSurrogatePairCodePoint(cp1, cp2) {
  return (cp1 - 55296) * 1024 + 9216 + cp2;
}
function isControlCodePoint(cp) {
  return cp !== 32 && cp !== 10 && cp !== 13 && cp !== 9 && cp !== 12 && cp >= 1 && cp <= 31 || cp >= 127 && cp <= 159;
}
function isUndefinedCodePoint(cp) {
  return cp >= 64976 && cp <= 65007 || UNDEFINED_CODE_POINTS.has(cp);
}

// node_modules/parse5/dist/common/error-codes.js
var ERR;
(function(ERR2) {
  ERR2["controlCharacterInInputStream"] = "control-character-in-input-stream";
  ERR2["noncharacterInInputStream"] = "noncharacter-in-input-stream";
  ERR2["surrogateInInputStream"] = "surrogate-in-input-stream";
  ERR2["nonVoidHtmlElementStartTagWithTrailingSolidus"] = "non-void-html-element-start-tag-with-trailing-solidus";
  ERR2["endTagWithAttributes"] = "end-tag-with-attributes";
  ERR2["endTagWithTrailingSolidus"] = "end-tag-with-trailing-solidus";
  ERR2["unexpectedSolidusInTag"] = "unexpected-solidus-in-tag";
  ERR2["unexpectedNullCharacter"] = "unexpected-null-character";
  ERR2["unexpectedQuestionMarkInsteadOfTagName"] = "unexpected-question-mark-instead-of-tag-name";
  ERR2["invalidFirstCharacterOfTagName"] = "invalid-first-character-of-tag-name";
  ERR2["unexpectedEqualsSignBeforeAttributeName"] = "unexpected-equals-sign-before-attribute-name";
  ERR2["missingEndTagName"] = "missing-end-tag-name";
  ERR2["unexpectedCharacterInAttributeName"] = "unexpected-character-in-attribute-name";
  ERR2["unknownNamedCharacterReference"] = "unknown-named-character-reference";
  ERR2["missingSemicolonAfterCharacterReference"] = "missing-semicolon-after-character-reference";
  ERR2["unexpectedCharacterAfterDoctypeSystemIdentifier"] = "unexpected-character-after-doctype-system-identifier";
  ERR2["unexpectedCharacterInUnquotedAttributeValue"] = "unexpected-character-in-unquoted-attribute-value";
  ERR2["eofBeforeTagName"] = "eof-before-tag-name";
  ERR2["eofInTag"] = "eof-in-tag";
  ERR2["missingAttributeValue"] = "missing-attribute-value";
  ERR2["missingWhitespaceBetweenAttributes"] = "missing-whitespace-between-attributes";
  ERR2["missingWhitespaceAfterDoctypePublicKeyword"] = "missing-whitespace-after-doctype-public-keyword";
  ERR2["missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers"] = "missing-whitespace-between-doctype-public-and-system-identifiers";
  ERR2["missingWhitespaceAfterDoctypeSystemKeyword"] = "missing-whitespace-after-doctype-system-keyword";
  ERR2["missingQuoteBeforeDoctypePublicIdentifier"] = "missing-quote-before-doctype-public-identifier";
  ERR2["missingQuoteBeforeDoctypeSystemIdentifier"] = "missing-quote-before-doctype-system-identifier";
  ERR2["missingDoctypePublicIdentifier"] = "missing-doctype-public-identifier";
  ERR2["missingDoctypeSystemIdentifier"] = "missing-doctype-system-identifier";
  ERR2["abruptDoctypePublicIdentifier"] = "abrupt-doctype-public-identifier";
  ERR2["abruptDoctypeSystemIdentifier"] = "abrupt-doctype-system-identifier";
  ERR2["cdataInHtmlContent"] = "cdata-in-html-content";
  ERR2["incorrectlyOpenedComment"] = "incorrectly-opened-comment";
  ERR2["eofInScriptHtmlCommentLikeText"] = "eof-in-script-html-comment-like-text";
  ERR2["eofInDoctype"] = "eof-in-doctype";
  ERR2["nestedComment"] = "nested-comment";
  ERR2["abruptClosingOfEmptyComment"] = "abrupt-closing-of-empty-comment";
  ERR2["eofInComment"] = "eof-in-comment";
  ERR2["incorrectlyClosedComment"] = "incorrectly-closed-comment";
  ERR2["eofInCdata"] = "eof-in-cdata";
  ERR2["absenceOfDigitsInNumericCharacterReference"] = "absence-of-digits-in-numeric-character-reference";
  ERR2["nullCharacterReference"] = "null-character-reference";
  ERR2["surrogateCharacterReference"] = "surrogate-character-reference";
  ERR2["characterReferenceOutsideUnicodeRange"] = "character-reference-outside-unicode-range";
  ERR2["controlCharacterReference"] = "control-character-reference";
  ERR2["noncharacterCharacterReference"] = "noncharacter-character-reference";
  ERR2["missingWhitespaceBeforeDoctypeName"] = "missing-whitespace-before-doctype-name";
  ERR2["missingDoctypeName"] = "missing-doctype-name";
  ERR2["invalidCharacterSequenceAfterDoctypeName"] = "invalid-character-sequence-after-doctype-name";
  ERR2["duplicateAttribute"] = "duplicate-attribute";
  ERR2["nonConformingDoctype"] = "non-conforming-doctype";
  ERR2["missingDoctype"] = "missing-doctype";
  ERR2["misplacedDoctype"] = "misplaced-doctype";
  ERR2["endTagWithoutMatchingOpenElement"] = "end-tag-without-matching-open-element";
  ERR2["closingOfElementWithOpenChildElements"] = "closing-of-element-with-open-child-elements";
  ERR2["disallowedContentInNoscriptInHead"] = "disallowed-content-in-noscript-in-head";
  ERR2["openElementsLeftAfterEof"] = "open-elements-left-after-eof";
  ERR2["abandonedHeadElementChild"] = "abandoned-head-element-child";
  ERR2["misplacedStartTagForHeadElement"] = "misplaced-start-tag-for-head-element";
  ERR2["nestedNoscriptInHead"] = "nested-noscript-in-head";
  ERR2["eofInElementThatCanContainOnlyText"] = "eof-in-element-that-can-contain-only-text";
})(ERR || (ERR = {}));

// node_modules/parse5/dist/tokenizer/preprocessor.js
var DEFAULT_BUFFER_WATERLINE = 1 << 16;
var Preprocessor = class {
  constructor(handler) {
    this.handler = handler;
    this.html = "";
    this.pos = -1;
    this.lastGapPos = -2;
    this.gapStack = [];
    this.skipNextNewLine = false;
    this.lastChunkWritten = false;
    this.endOfChunkHit = false;
    this.bufferWaterline = DEFAULT_BUFFER_WATERLINE;
    this.isEol = false;
    this.lineStartPos = 0;
    this.droppedBufferSize = 0;
    this.line = 1;
    this.lastErrOffset = -1;
  }
  /** The column on the current line. If we just saw a gap (eg. a surrogate pair), return the index before. */
  get col() {
    return this.pos - this.lineStartPos + Number(this.lastGapPos !== this.pos);
  }
  get offset() {
    return this.droppedBufferSize + this.pos;
  }
  getError(code, cpOffset) {
    const { line, col, offset } = this;
    const startCol = col + cpOffset;
    const startOffset = offset + cpOffset;
    return {
      code,
      startLine: line,
      endLine: line,
      startCol,
      endCol: startCol,
      startOffset,
      endOffset: startOffset
    };
  }
  _err(code) {
    if (this.handler.onParseError && this.lastErrOffset !== this.offset) {
      this.lastErrOffset = this.offset;
      this.handler.onParseError(this.getError(code, 0));
    }
  }
  _addGap() {
    this.gapStack.push(this.lastGapPos);
    this.lastGapPos = this.pos;
  }
  _processSurrogate(cp) {
    if (this.pos !== this.html.length - 1) {
      const nextCp = this.html.charCodeAt(this.pos + 1);
      if (isSurrogatePair(nextCp)) {
        this.pos++;
        this._addGap();
        return getSurrogatePairCodePoint(cp, nextCp);
      }
    } else if (!this.lastChunkWritten) {
      this.endOfChunkHit = true;
      return CODE_POINTS.EOF;
    }
    this._err(ERR.surrogateInInputStream);
    return cp;
  }
  willDropParsedChunk() {
    return this.pos > this.bufferWaterline;
  }
  dropParsedChunk() {
    if (this.willDropParsedChunk()) {
      this.html = this.html.substring(this.pos);
      this.lineStartPos -= this.pos;
      this.droppedBufferSize += this.pos;
      this.pos = 0;
      this.lastGapPos = -2;
      this.gapStack.length = 0;
    }
  }
  write(chunk, isLastChunk) {
    if (this.html.length > 0) {
      this.html += chunk;
    } else {
      this.html = chunk;
    }
    this.endOfChunkHit = false;
    this.lastChunkWritten = isLastChunk;
  }
  insertHtmlAtCurrentPos(chunk) {
    this.html = this.html.substring(0, this.pos + 1) + chunk + this.html.substring(this.pos + 1);
    this.endOfChunkHit = false;
  }
  startsWith(pattern, caseSensitive) {
    if (this.pos + pattern.length > this.html.length) {
      this.endOfChunkHit = !this.lastChunkWritten;
      return false;
    }
    if (caseSensitive) {
      return this.html.startsWith(pattern, this.pos);
    }
    for (let i = 0; i < pattern.length; i++) {
      const cp = this.html.charCodeAt(this.pos + i) | 32;
      if (cp !== pattern.charCodeAt(i)) {
        return false;
      }
    }
    return true;
  }
  peek(offset) {
    const pos = this.pos + offset;
    if (pos >= this.html.length) {
      this.endOfChunkHit = !this.lastChunkWritten;
      return CODE_POINTS.EOF;
    }
    const code = this.html.charCodeAt(pos);
    return code === CODE_POINTS.CARRIAGE_RETURN ? CODE_POINTS.LINE_FEED : code;
  }
  advance() {
    this.pos++;
    if (this.isEol) {
      this.isEol = false;
      this.line++;
      this.lineStartPos = this.pos;
    }
    if (this.pos >= this.html.length) {
      this.endOfChunkHit = !this.lastChunkWritten;
      return CODE_POINTS.EOF;
    }
    let cp = this.html.charCodeAt(this.pos);
    if (cp === CODE_POINTS.CARRIAGE_RETURN) {
      this.isEol = true;
      this.skipNextNewLine = true;
      return CODE_POINTS.LINE_FEED;
    }
    if (cp === CODE_POINTS.LINE_FEED) {
      this.isEol = true;
      if (this.skipNextNewLine) {
        this.line--;
        this.skipNextNewLine = false;
        this._addGap();
        return this.advance();
      }
    }
    this.skipNextNewLine = false;
    if (isSurrogate(cp)) {
      cp = this._processSurrogate(cp);
    }
    const isCommonValidRange = this.handler.onParseError === null || cp > 31 && cp < 127 || cp === CODE_POINTS.LINE_FEED || cp === CODE_POINTS.CARRIAGE_RETURN || cp > 159 && cp < 64976;
    if (!isCommonValidRange) {
      this._checkForProblematicCharacters(cp);
    }
    return cp;
  }
  _checkForProblematicCharacters(cp) {
    if (isControlCodePoint(cp)) {
      this._err(ERR.controlCharacterInInputStream);
    } else if (isUndefinedCodePoint(cp)) {
      this._err(ERR.noncharacterInInputStream);
    }
  }
  retreat(count) {
    this.pos -= count;
    while (this.pos < this.lastGapPos) {
      this.lastGapPos = this.gapStack.pop();
      this.pos--;
    }
    this.isEol = false;
  }
};

// node_modules/parse5/dist/common/token.js
var token_exports = {};
__export(token_exports, {
  TokenType: () => TokenType,
  getTokenAttr: () => getTokenAttr
});
var TokenType;
(function(TokenType2) {
  TokenType2[TokenType2["CHARACTER"] = 0] = "CHARACTER";
  TokenType2[TokenType2["NULL_CHARACTER"] = 1] = "NULL_CHARACTER";
  TokenType2[TokenType2["WHITESPACE_CHARACTER"] = 2] = "WHITESPACE_CHARACTER";
  TokenType2[TokenType2["START_TAG"] = 3] = "START_TAG";
  TokenType2[TokenType2["END_TAG"] = 4] = "END_TAG";
  TokenType2[TokenType2["COMMENT"] = 5] = "COMMENT";
  TokenType2[TokenType2["DOCTYPE"] = 6] = "DOCTYPE";
  TokenType2[TokenType2["EOF"] = 7] = "EOF";
  TokenType2[TokenType2["HIBERNATION"] = 8] = "HIBERNATION";
})(TokenType || (TokenType = {}));
function getTokenAttr(token, attrName) {
  for (let i = token.attrs.length - 1; i >= 0; i--) {
    if (token.attrs[i].name === attrName) {
      return token.attrs[i].value;
    }
  }
  return null;
}

// node_modules/entities/lib/esm/generated/decode-data-html.js
var decode_data_html_default = new Uint16Array(
  // prettier-ignore
  '\u1D41<\xD5\u0131\u028A\u049D\u057B\u05D0\u0675\u06DE\u07A2\u07D6\u080F\u0A4A\u0A91\u0DA1\u0E6D\u0F09\u0F26\u10CA\u1228\u12E1\u1415\u149D\u14C3\u14DF\u1525\0\0\0\0\0\0\u156B\u16CD\u198D\u1C12\u1DDD\u1F7E\u2060\u21B0\u228D\u23C0\u23FB\u2442\u2824\u2912\u2D08\u2E48\u2FCE\u3016\u32BA\u3639\u37AC\u38FE\u3A28\u3A71\u3AE0\u3B2E\u0800EMabcfglmnoprstu\\bfms\x7F\x84\x8B\x90\x95\x98\xA6\xB3\xB9\xC8\xCFlig\u803B\xC6\u40C6P\u803B&\u4026cute\u803B\xC1\u40C1reve;\u4102\u0100iyx}rc\u803B\xC2\u40C2;\u4410r;\uC000\u{1D504}rave\u803B\xC0\u40C0pha;\u4391acr;\u4100d;\u6A53\u0100gp\x9D\xA1on;\u4104f;\uC000\u{1D538}plyFunction;\u6061ing\u803B\xC5\u40C5\u0100cs\xBE\xC3r;\uC000\u{1D49C}ign;\u6254ilde\u803B\xC3\u40C3ml\u803B\xC4\u40C4\u0400aceforsu\xE5\xFB\xFE\u0117\u011C\u0122\u0127\u012A\u0100cr\xEA\xF2kslash;\u6216\u0176\xF6\xF8;\u6AE7ed;\u6306y;\u4411\u0180crt\u0105\u010B\u0114ause;\u6235noullis;\u612Ca;\u4392r;\uC000\u{1D505}pf;\uC000\u{1D539}eve;\u42D8c\xF2\u0113mpeq;\u624E\u0700HOacdefhilorsu\u014D\u0151\u0156\u0180\u019E\u01A2\u01B5\u01B7\u01BA\u01DC\u0215\u0273\u0278\u027Ecy;\u4427PY\u803B\xA9\u40A9\u0180cpy\u015D\u0162\u017Aute;\u4106\u0100;i\u0167\u0168\u62D2talDifferentialD;\u6145leys;\u612D\u0200aeio\u0189\u018E\u0194\u0198ron;\u410Cdil\u803B\xC7\u40C7rc;\u4108nint;\u6230ot;\u410A\u0100dn\u01A7\u01ADilla;\u40B8terDot;\u40B7\xF2\u017Fi;\u43A7rcle\u0200DMPT\u01C7\u01CB\u01D1\u01D6ot;\u6299inus;\u6296lus;\u6295imes;\u6297o\u0100cs\u01E2\u01F8kwiseContourIntegral;\u6232eCurly\u0100DQ\u0203\u020FoubleQuote;\u601Duote;\u6019\u0200lnpu\u021E\u0228\u0247\u0255on\u0100;e\u0225\u0226\u6237;\u6A74\u0180git\u022F\u0236\u023Aruent;\u6261nt;\u622FourIntegral;\u622E\u0100fr\u024C\u024E;\u6102oduct;\u6210nterClockwiseContourIntegral;\u6233oss;\u6A2Fcr;\uC000\u{1D49E}p\u0100;C\u0284\u0285\u62D3ap;\u624D\u0580DJSZacefios\u02A0\u02AC\u02B0\u02B4\u02B8\u02CB\u02D7\u02E1\u02E6\u0333\u048D\u0100;o\u0179\u02A5trahd;\u6911cy;\u4402cy;\u4405cy;\u440F\u0180grs\u02BF\u02C4\u02C7ger;\u6021r;\u61A1hv;\u6AE4\u0100ay\u02D0\u02D5ron;\u410E;\u4414l\u0100;t\u02DD\u02DE\u6207a;\u4394r;\uC000\u{1D507}\u0100af\u02EB\u0327\u0100cm\u02F0\u0322ritical\u0200ADGT\u0300\u0306\u0316\u031Ccute;\u40B4o\u0174\u030B\u030D;\u42D9bleAcute;\u42DDrave;\u4060ilde;\u42DCond;\u62C4ferentialD;\u6146\u0470\u033D\0\0\0\u0342\u0354\0\u0405f;\uC000\u{1D53B}\u0180;DE\u0348\u0349\u034D\u40A8ot;\u60DCqual;\u6250ble\u0300CDLRUV\u0363\u0372\u0382\u03CF\u03E2\u03F8ontourIntegra\xEC\u0239o\u0274\u0379\0\0\u037B\xBB\u0349nArrow;\u61D3\u0100eo\u0387\u03A4ft\u0180ART\u0390\u0396\u03A1rrow;\u61D0ightArrow;\u61D4e\xE5\u02CAng\u0100LR\u03AB\u03C4eft\u0100AR\u03B3\u03B9rrow;\u67F8ightArrow;\u67FAightArrow;\u67F9ight\u0100AT\u03D8\u03DErrow;\u61D2ee;\u62A8p\u0241\u03E9\0\0\u03EFrrow;\u61D1ownArrow;\u61D5erticalBar;\u6225n\u0300ABLRTa\u0412\u042A\u0430\u045E\u047F\u037Crrow\u0180;BU\u041D\u041E\u0422\u6193ar;\u6913pArrow;\u61F5reve;\u4311eft\u02D2\u043A\0\u0446\0\u0450ightVector;\u6950eeVector;\u695Eector\u0100;B\u0459\u045A\u61BDar;\u6956ight\u01D4\u0467\0\u0471eeVector;\u695Fector\u0100;B\u047A\u047B\u61C1ar;\u6957ee\u0100;A\u0486\u0487\u62A4rrow;\u61A7\u0100ct\u0492\u0497r;\uC000\u{1D49F}rok;\u4110\u0800NTacdfglmopqstux\u04BD\u04C0\u04C4\u04CB\u04DE\u04E2\u04E7\u04EE\u04F5\u0521\u052F\u0536\u0552\u055D\u0560\u0565G;\u414AH\u803B\xD0\u40D0cute\u803B\xC9\u40C9\u0180aiy\u04D2\u04D7\u04DCron;\u411Arc\u803B\xCA\u40CA;\u442Dot;\u4116r;\uC000\u{1D508}rave\u803B\xC8\u40C8ement;\u6208\u0100ap\u04FA\u04FEcr;\u4112ty\u0253\u0506\0\0\u0512mallSquare;\u65FBerySmallSquare;\u65AB\u0100gp\u0526\u052Aon;\u4118f;\uC000\u{1D53C}silon;\u4395u\u0100ai\u053C\u0549l\u0100;T\u0542\u0543\u6A75ilde;\u6242librium;\u61CC\u0100ci\u0557\u055Ar;\u6130m;\u6A73a;\u4397ml\u803B\xCB\u40CB\u0100ip\u056A\u056Fsts;\u6203onentialE;\u6147\u0280cfios\u0585\u0588\u058D\u05B2\u05CCy;\u4424r;\uC000\u{1D509}lled\u0253\u0597\0\0\u05A3mallSquare;\u65FCerySmallSquare;\u65AA\u0370\u05BA\0\u05BF\0\0\u05C4f;\uC000\u{1D53D}All;\u6200riertrf;\u6131c\xF2\u05CB\u0600JTabcdfgorst\u05E8\u05EC\u05EF\u05FA\u0600\u0612\u0616\u061B\u061D\u0623\u066C\u0672cy;\u4403\u803B>\u403Emma\u0100;d\u05F7\u05F8\u4393;\u43DCreve;\u411E\u0180eiy\u0607\u060C\u0610dil;\u4122rc;\u411C;\u4413ot;\u4120r;\uC000\u{1D50A};\u62D9pf;\uC000\u{1D53E}eater\u0300EFGLST\u0635\u0644\u064E\u0656\u065B\u0666qual\u0100;L\u063E\u063F\u6265ess;\u62DBullEqual;\u6267reater;\u6AA2ess;\u6277lantEqual;\u6A7Eilde;\u6273cr;\uC000\u{1D4A2};\u626B\u0400Aacfiosu\u0685\u068B\u0696\u069B\u069E\u06AA\u06BE\u06CARDcy;\u442A\u0100ct\u0690\u0694ek;\u42C7;\u405Eirc;\u4124r;\u610ClbertSpace;\u610B\u01F0\u06AF\0\u06B2f;\u610DizontalLine;\u6500\u0100ct\u06C3\u06C5\xF2\u06A9rok;\u4126mp\u0144\u06D0\u06D8ownHum\xF0\u012Fqual;\u624F\u0700EJOacdfgmnostu\u06FA\u06FE\u0703\u0707\u070E\u071A\u071E\u0721\u0728\u0744\u0778\u078B\u078F\u0795cy;\u4415lig;\u4132cy;\u4401cute\u803B\xCD\u40CD\u0100iy\u0713\u0718rc\u803B\xCE\u40CE;\u4418ot;\u4130r;\u6111rave\u803B\xCC\u40CC\u0180;ap\u0720\u072F\u073F\u0100cg\u0734\u0737r;\u412AinaryI;\u6148lie\xF3\u03DD\u01F4\u0749\0\u0762\u0100;e\u074D\u074E\u622C\u0100gr\u0753\u0758ral;\u622Bsection;\u62C2isible\u0100CT\u076C\u0772omma;\u6063imes;\u6062\u0180gpt\u077F\u0783\u0788on;\u412Ef;\uC000\u{1D540}a;\u4399cr;\u6110ilde;\u4128\u01EB\u079A\0\u079Ecy;\u4406l\u803B\xCF\u40CF\u0280cfosu\u07AC\u07B7\u07BC\u07C2\u07D0\u0100iy\u07B1\u07B5rc;\u4134;\u4419r;\uC000\u{1D50D}pf;\uC000\u{1D541}\u01E3\u07C7\0\u07CCr;\uC000\u{1D4A5}rcy;\u4408kcy;\u4404\u0380HJacfos\u07E4\u07E8\u07EC\u07F1\u07FD\u0802\u0808cy;\u4425cy;\u440Cppa;\u439A\u0100ey\u07F6\u07FBdil;\u4136;\u441Ar;\uC000\u{1D50E}pf;\uC000\u{1D542}cr;\uC000\u{1D4A6}\u0580JTaceflmost\u0825\u0829\u082C\u0850\u0863\u09B3\u09B8\u09C7\u09CD\u0A37\u0A47cy;\u4409\u803B<\u403C\u0280cmnpr\u0837\u083C\u0841\u0844\u084Dute;\u4139bda;\u439Bg;\u67EAlacetrf;\u6112r;\u619E\u0180aey\u0857\u085C\u0861ron;\u413Ddil;\u413B;\u441B\u0100fs\u0868\u0970t\u0500ACDFRTUVar\u087E\u08A9\u08B1\u08E0\u08E6\u08FC\u092F\u095B\u0390\u096A\u0100nr\u0883\u088FgleBracket;\u67E8row\u0180;BR\u0899\u089A\u089E\u6190ar;\u61E4ightArrow;\u61C6eiling;\u6308o\u01F5\u08B7\0\u08C3bleBracket;\u67E6n\u01D4\u08C8\0\u08D2eeVector;\u6961ector\u0100;B\u08DB\u08DC\u61C3ar;\u6959loor;\u630Aight\u0100AV\u08EF\u08F5rrow;\u6194ector;\u694E\u0100er\u0901\u0917e\u0180;AV\u0909\u090A\u0910\u62A3rrow;\u61A4ector;\u695Aiangle\u0180;BE\u0924\u0925\u0929\u62B2ar;\u69CFqual;\u62B4p\u0180DTV\u0937\u0942\u094CownVector;\u6951eeVector;\u6960ector\u0100;B\u0956\u0957\u61BFar;\u6958ector\u0100;B\u0965\u0966\u61BCar;\u6952ight\xE1\u039Cs\u0300EFGLST\u097E\u098B\u0995\u099D\u09A2\u09ADqualGreater;\u62DAullEqual;\u6266reater;\u6276ess;\u6AA1lantEqual;\u6A7Dilde;\u6272r;\uC000\u{1D50F}\u0100;e\u09BD\u09BE\u62D8ftarrow;\u61DAidot;\u413F\u0180npw\u09D4\u0A16\u0A1Bg\u0200LRlr\u09DE\u09F7\u0A02\u0A10eft\u0100AR\u09E6\u09ECrrow;\u67F5ightArrow;\u67F7ightArrow;\u67F6eft\u0100ar\u03B3\u0A0Aight\xE1\u03BFight\xE1\u03CAf;\uC000\u{1D543}er\u0100LR\u0A22\u0A2CeftArrow;\u6199ightArrow;\u6198\u0180cht\u0A3E\u0A40\u0A42\xF2\u084C;\u61B0rok;\u4141;\u626A\u0400acefiosu\u0A5A\u0A5D\u0A60\u0A77\u0A7C\u0A85\u0A8B\u0A8Ep;\u6905y;\u441C\u0100dl\u0A65\u0A6FiumSpace;\u605Flintrf;\u6133r;\uC000\u{1D510}nusPlus;\u6213pf;\uC000\u{1D544}c\xF2\u0A76;\u439C\u0480Jacefostu\u0AA3\u0AA7\u0AAD\u0AC0\u0B14\u0B19\u0D91\u0D97\u0D9Ecy;\u440Acute;\u4143\u0180aey\u0AB4\u0AB9\u0ABEron;\u4147dil;\u4145;\u441D\u0180gsw\u0AC7\u0AF0\u0B0Eative\u0180MTV\u0AD3\u0ADF\u0AE8ediumSpace;\u600Bhi\u0100cn\u0AE6\u0AD8\xEB\u0AD9eryThi\xEE\u0AD9ted\u0100GL\u0AF8\u0B06reaterGreate\xF2\u0673essLes\xF3\u0A48Line;\u400Ar;\uC000\u{1D511}\u0200Bnpt\u0B22\u0B28\u0B37\u0B3Areak;\u6060BreakingSpace;\u40A0f;\u6115\u0680;CDEGHLNPRSTV\u0B55\u0B56\u0B6A\u0B7C\u0BA1\u0BEB\u0C04\u0C5E\u0C84\u0CA6\u0CD8\u0D61\u0D85\u6AEC\u0100ou\u0B5B\u0B64ngruent;\u6262pCap;\u626DoubleVerticalBar;\u6226\u0180lqx\u0B83\u0B8A\u0B9Bement;\u6209ual\u0100;T\u0B92\u0B93\u6260ilde;\uC000\u2242\u0338ists;\u6204reater\u0380;EFGLST\u0BB6\u0BB7\u0BBD\u0BC9\u0BD3\u0BD8\u0BE5\u626Fqual;\u6271ullEqual;\uC000\u2267\u0338reater;\uC000\u226B\u0338ess;\u6279lantEqual;\uC000\u2A7E\u0338ilde;\u6275ump\u0144\u0BF2\u0BFDownHump;\uC000\u224E\u0338qual;\uC000\u224F\u0338e\u0100fs\u0C0A\u0C27tTriangle\u0180;BE\u0C1A\u0C1B\u0C21\u62EAar;\uC000\u29CF\u0338qual;\u62ECs\u0300;EGLST\u0C35\u0C36\u0C3C\u0C44\u0C4B\u0C58\u626Equal;\u6270reater;\u6278ess;\uC000\u226A\u0338lantEqual;\uC000\u2A7D\u0338ilde;\u6274ested\u0100GL\u0C68\u0C79reaterGreater;\uC000\u2AA2\u0338essLess;\uC000\u2AA1\u0338recedes\u0180;ES\u0C92\u0C93\u0C9B\u6280qual;\uC000\u2AAF\u0338lantEqual;\u62E0\u0100ei\u0CAB\u0CB9verseElement;\u620CghtTriangle\u0180;BE\u0CCB\u0CCC\u0CD2\u62EBar;\uC000\u29D0\u0338qual;\u62ED\u0100qu\u0CDD\u0D0CuareSu\u0100bp\u0CE8\u0CF9set\u0100;E\u0CF0\u0CF3\uC000\u228F\u0338qual;\u62E2erset\u0100;E\u0D03\u0D06\uC000\u2290\u0338qual;\u62E3\u0180bcp\u0D13\u0D24\u0D4Eset\u0100;E\u0D1B\u0D1E\uC000\u2282\u20D2qual;\u6288ceeds\u0200;EST\u0D32\u0D33\u0D3B\u0D46\u6281qual;\uC000\u2AB0\u0338lantEqual;\u62E1ilde;\uC000\u227F\u0338erset\u0100;E\u0D58\u0D5B\uC000\u2283\u20D2qual;\u6289ilde\u0200;EFT\u0D6E\u0D6F\u0D75\u0D7F\u6241qual;\u6244ullEqual;\u6247ilde;\u6249erticalBar;\u6224cr;\uC000\u{1D4A9}ilde\u803B\xD1\u40D1;\u439D\u0700Eacdfgmoprstuv\u0DBD\u0DC2\u0DC9\u0DD5\u0DDB\u0DE0\u0DE7\u0DFC\u0E02\u0E20\u0E22\u0E32\u0E3F\u0E44lig;\u4152cute\u803B\xD3\u40D3\u0100iy\u0DCE\u0DD3rc\u803B\xD4\u40D4;\u441Eblac;\u4150r;\uC000\u{1D512}rave\u803B\xD2\u40D2\u0180aei\u0DEE\u0DF2\u0DF6cr;\u414Cga;\u43A9cron;\u439Fpf;\uC000\u{1D546}enCurly\u0100DQ\u0E0E\u0E1AoubleQuote;\u601Cuote;\u6018;\u6A54\u0100cl\u0E27\u0E2Cr;\uC000\u{1D4AA}ash\u803B\xD8\u40D8i\u016C\u0E37\u0E3Cde\u803B\xD5\u40D5es;\u6A37ml\u803B\xD6\u40D6er\u0100BP\u0E4B\u0E60\u0100ar\u0E50\u0E53r;\u603Eac\u0100ek\u0E5A\u0E5C;\u63DEet;\u63B4arenthesis;\u63DC\u0480acfhilors\u0E7F\u0E87\u0E8A\u0E8F\u0E92\u0E94\u0E9D\u0EB0\u0EFCrtialD;\u6202y;\u441Fr;\uC000\u{1D513}i;\u43A6;\u43A0usMinus;\u40B1\u0100ip\u0EA2\u0EADncareplan\xE5\u069Df;\u6119\u0200;eio\u0EB9\u0EBA\u0EE0\u0EE4\u6ABBcedes\u0200;EST\u0EC8\u0EC9\u0ECF\u0EDA\u627Aqual;\u6AAFlantEqual;\u627Cilde;\u627Eme;\u6033\u0100dp\u0EE9\u0EEEuct;\u620Fortion\u0100;a\u0225\u0EF9l;\u621D\u0100ci\u0F01\u0F06r;\uC000\u{1D4AB};\u43A8\u0200Ufos\u0F11\u0F16\u0F1B\u0F1FOT\u803B"\u4022r;\uC000\u{1D514}pf;\u611Acr;\uC000\u{1D4AC}\u0600BEacefhiorsu\u0F3E\u0F43\u0F47\u0F60\u0F73\u0FA7\u0FAA\u0FAD\u1096\u10A9\u10B4\u10BEarr;\u6910G\u803B\xAE\u40AE\u0180cnr\u0F4E\u0F53\u0F56ute;\u4154g;\u67EBr\u0100;t\u0F5C\u0F5D\u61A0l;\u6916\u0180aey\u0F67\u0F6C\u0F71ron;\u4158dil;\u4156;\u4420\u0100;v\u0F78\u0F79\u611Cerse\u0100EU\u0F82\u0F99\u0100lq\u0F87\u0F8Eement;\u620Builibrium;\u61CBpEquilibrium;\u696Fr\xBB\u0F79o;\u43A1ght\u0400ACDFTUVa\u0FC1\u0FEB\u0FF3\u1022\u1028\u105B\u1087\u03D8\u0100nr\u0FC6\u0FD2gleBracket;\u67E9row\u0180;BL\u0FDC\u0FDD\u0FE1\u6192ar;\u61E5eftArrow;\u61C4eiling;\u6309o\u01F5\u0FF9\0\u1005bleBracket;\u67E7n\u01D4\u100A\0\u1014eeVector;\u695Dector\u0100;B\u101D\u101E\u61C2ar;\u6955loor;\u630B\u0100er\u102D\u1043e\u0180;AV\u1035\u1036\u103C\u62A2rrow;\u61A6ector;\u695Biangle\u0180;BE\u1050\u1051\u1055\u62B3ar;\u69D0qual;\u62B5p\u0180DTV\u1063\u106E\u1078ownVector;\u694FeeVector;\u695Cector\u0100;B\u1082\u1083\u61BEar;\u6954ector\u0100;B\u1091\u1092\u61C0ar;\u6953\u0100pu\u109B\u109Ef;\u611DndImplies;\u6970ightarrow;\u61DB\u0100ch\u10B9\u10BCr;\u611B;\u61B1leDelayed;\u69F4\u0680HOacfhimoqstu\u10E4\u10F1\u10F7\u10FD\u1119\u111E\u1151\u1156\u1161\u1167\u11B5\u11BB\u11BF\u0100Cc\u10E9\u10EEHcy;\u4429y;\u4428FTcy;\u442Ccute;\u415A\u0280;aeiy\u1108\u1109\u110E\u1113\u1117\u6ABCron;\u4160dil;\u415Erc;\u415C;\u4421r;\uC000\u{1D516}ort\u0200DLRU\u112A\u1134\u113E\u1149ownArrow\xBB\u041EeftArrow\xBB\u089AightArrow\xBB\u0FDDpArrow;\u6191gma;\u43A3allCircle;\u6218pf;\uC000\u{1D54A}\u0272\u116D\0\0\u1170t;\u621Aare\u0200;ISU\u117B\u117C\u1189\u11AF\u65A1ntersection;\u6293u\u0100bp\u118F\u119Eset\u0100;E\u1197\u1198\u628Fqual;\u6291erset\u0100;E\u11A8\u11A9\u6290qual;\u6292nion;\u6294cr;\uC000\u{1D4AE}ar;\u62C6\u0200bcmp\u11C8\u11DB\u1209\u120B\u0100;s\u11CD\u11CE\u62D0et\u0100;E\u11CD\u11D5qual;\u6286\u0100ch\u11E0\u1205eeds\u0200;EST\u11ED\u11EE\u11F4\u11FF\u627Bqual;\u6AB0lantEqual;\u627Dilde;\u627FTh\xE1\u0F8C;\u6211\u0180;es\u1212\u1213\u1223\u62D1rset\u0100;E\u121C\u121D\u6283qual;\u6287et\xBB\u1213\u0580HRSacfhiors\u123E\u1244\u1249\u1255\u125E\u1271\u1276\u129F\u12C2\u12C8\u12D1ORN\u803B\xDE\u40DEADE;\u6122\u0100Hc\u124E\u1252cy;\u440By;\u4426\u0100bu\u125A\u125C;\u4009;\u43A4\u0180aey\u1265\u126A\u126Fron;\u4164dil;\u4162;\u4422r;\uC000\u{1D517}\u0100ei\u127B\u1289\u01F2\u1280\0\u1287efore;\u6234a;\u4398\u0100cn\u128E\u1298kSpace;\uC000\u205F\u200ASpace;\u6009lde\u0200;EFT\u12AB\u12AC\u12B2\u12BC\u623Cqual;\u6243ullEqual;\u6245ilde;\u6248pf;\uC000\u{1D54B}ipleDot;\u60DB\u0100ct\u12D6\u12DBr;\uC000\u{1D4AF}rok;\u4166\u0AE1\u12F7\u130E\u131A\u1326\0\u132C\u1331\0\0\0\0\0\u1338\u133D\u1377\u1385\0\u13FF\u1404\u140A\u1410\u0100cr\u12FB\u1301ute\u803B\xDA\u40DAr\u0100;o\u1307\u1308\u619Fcir;\u6949r\u01E3\u1313\0\u1316y;\u440Eve;\u416C\u0100iy\u131E\u1323rc\u803B\xDB\u40DB;\u4423blac;\u4170r;\uC000\u{1D518}rave\u803B\xD9\u40D9acr;\u416A\u0100di\u1341\u1369er\u0100BP\u1348\u135D\u0100ar\u134D\u1350r;\u405Fac\u0100ek\u1357\u1359;\u63DFet;\u63B5arenthesis;\u63DDon\u0100;P\u1370\u1371\u62C3lus;\u628E\u0100gp\u137B\u137Fon;\u4172f;\uC000\u{1D54C}\u0400ADETadps\u1395\u13AE\u13B8\u13C4\u03E8\u13D2\u13D7\u13F3rrow\u0180;BD\u1150\u13A0\u13A4ar;\u6912ownArrow;\u61C5ownArrow;\u6195quilibrium;\u696Eee\u0100;A\u13CB\u13CC\u62A5rrow;\u61A5own\xE1\u03F3er\u0100LR\u13DE\u13E8eftArrow;\u6196ightArrow;\u6197i\u0100;l\u13F9\u13FA\u43D2on;\u43A5ing;\u416Ecr;\uC000\u{1D4B0}ilde;\u4168ml\u803B\xDC\u40DC\u0480Dbcdefosv\u1427\u142C\u1430\u1433\u143E\u1485\u148A\u1490\u1496ash;\u62ABar;\u6AEBy;\u4412ash\u0100;l\u143B\u143C\u62A9;\u6AE6\u0100er\u1443\u1445;\u62C1\u0180bty\u144C\u1450\u147Aar;\u6016\u0100;i\u144F\u1455cal\u0200BLST\u1461\u1465\u146A\u1474ar;\u6223ine;\u407Ceparator;\u6758ilde;\u6240ThinSpace;\u600Ar;\uC000\u{1D519}pf;\uC000\u{1D54D}cr;\uC000\u{1D4B1}dash;\u62AA\u0280cefos\u14A7\u14AC\u14B1\u14B6\u14BCirc;\u4174dge;\u62C0r;\uC000\u{1D51A}pf;\uC000\u{1D54E}cr;\uC000\u{1D4B2}\u0200fios\u14CB\u14D0\u14D2\u14D8r;\uC000\u{1D51B};\u439Epf;\uC000\u{1D54F}cr;\uC000\u{1D4B3}\u0480AIUacfosu\u14F1\u14F5\u14F9\u14FD\u1504\u150F\u1514\u151A\u1520cy;\u442Fcy;\u4407cy;\u442Ecute\u803B\xDD\u40DD\u0100iy\u1509\u150Drc;\u4176;\u442Br;\uC000\u{1D51C}pf;\uC000\u{1D550}cr;\uC000\u{1D4B4}ml;\u4178\u0400Hacdefos\u1535\u1539\u153F\u154B\u154F\u155D\u1560\u1564cy;\u4416cute;\u4179\u0100ay\u1544\u1549ron;\u417D;\u4417ot;\u417B\u01F2\u1554\0\u155BoWidt\xE8\u0AD9a;\u4396r;\u6128pf;\u6124cr;\uC000\u{1D4B5}\u0BE1\u1583\u158A\u1590\0\u15B0\u15B6\u15BF\0\0\0\0\u15C6\u15DB\u15EB\u165F\u166D\0\u1695\u169B\u16B2\u16B9\0\u16BEcute\u803B\xE1\u40E1reve;\u4103\u0300;Ediuy\u159C\u159D\u15A1\u15A3\u15A8\u15AD\u623E;\uC000\u223E\u0333;\u623Frc\u803B\xE2\u40E2te\u80BB\xB4\u0306;\u4430lig\u803B\xE6\u40E6\u0100;r\xB2\u15BA;\uC000\u{1D51E}rave\u803B\xE0\u40E0\u0100ep\u15CA\u15D6\u0100fp\u15CF\u15D4sym;\u6135\xE8\u15D3ha;\u43B1\u0100ap\u15DFc\u0100cl\u15E4\u15E7r;\u4101g;\u6A3F\u0264\u15F0\0\0\u160A\u0280;adsv\u15FA\u15FB\u15FF\u1601\u1607\u6227nd;\u6A55;\u6A5Clope;\u6A58;\u6A5A\u0380;elmrsz\u1618\u1619\u161B\u161E\u163F\u164F\u1659\u6220;\u69A4e\xBB\u1619sd\u0100;a\u1625\u1626\u6221\u0461\u1630\u1632\u1634\u1636\u1638\u163A\u163C\u163E;\u69A8;\u69A9;\u69AA;\u69AB;\u69AC;\u69AD;\u69AE;\u69AFt\u0100;v\u1645\u1646\u621Fb\u0100;d\u164C\u164D\u62BE;\u699D\u0100pt\u1654\u1657h;\u6222\xBB\xB9arr;\u637C\u0100gp\u1663\u1667on;\u4105f;\uC000\u{1D552}\u0380;Eaeiop\u12C1\u167B\u167D\u1682\u1684\u1687\u168A;\u6A70cir;\u6A6F;\u624Ad;\u624Bs;\u4027rox\u0100;e\u12C1\u1692\xF1\u1683ing\u803B\xE5\u40E5\u0180cty\u16A1\u16A6\u16A8r;\uC000\u{1D4B6};\u402Amp\u0100;e\u12C1\u16AF\xF1\u0288ilde\u803B\xE3\u40E3ml\u803B\xE4\u40E4\u0100ci\u16C2\u16C8onin\xF4\u0272nt;\u6A11\u0800Nabcdefiklnoprsu\u16ED\u16F1\u1730\u173C\u1743\u1748\u1778\u177D\u17E0\u17E6\u1839\u1850\u170D\u193D\u1948\u1970ot;\u6AED\u0100cr\u16F6\u171Ek\u0200ceps\u1700\u1705\u170D\u1713ong;\u624Cpsilon;\u43F6rime;\u6035im\u0100;e\u171A\u171B\u623Dq;\u62CD\u0176\u1722\u1726ee;\u62BDed\u0100;g\u172C\u172D\u6305e\xBB\u172Drk\u0100;t\u135C\u1737brk;\u63B6\u0100oy\u1701\u1741;\u4431quo;\u601E\u0280cmprt\u1753\u175B\u1761\u1764\u1768aus\u0100;e\u010A\u0109ptyv;\u69B0s\xE9\u170Cno\xF5\u0113\u0180ahw\u176F\u1771\u1773;\u43B2;\u6136een;\u626Cr;\uC000\u{1D51F}g\u0380costuvw\u178D\u179D\u17B3\u17C1\u17D5\u17DB\u17DE\u0180aiu\u1794\u1796\u179A\xF0\u0760rc;\u65EFp\xBB\u1371\u0180dpt\u17A4\u17A8\u17ADot;\u6A00lus;\u6A01imes;\u6A02\u0271\u17B9\0\0\u17BEcup;\u6A06ar;\u6605riangle\u0100du\u17CD\u17D2own;\u65BDp;\u65B3plus;\u6A04e\xE5\u1444\xE5\u14ADarow;\u690D\u0180ako\u17ED\u1826\u1835\u0100cn\u17F2\u1823k\u0180lst\u17FA\u05AB\u1802ozenge;\u69EBriangle\u0200;dlr\u1812\u1813\u1818\u181D\u65B4own;\u65BEeft;\u65C2ight;\u65B8k;\u6423\u01B1\u182B\0\u1833\u01B2\u182F\0\u1831;\u6592;\u65914;\u6593ck;\u6588\u0100eo\u183E\u184D\u0100;q\u1843\u1846\uC000=\u20E5uiv;\uC000\u2261\u20E5t;\u6310\u0200ptwx\u1859\u185E\u1867\u186Cf;\uC000\u{1D553}\u0100;t\u13CB\u1863om\xBB\u13CCtie;\u62C8\u0600DHUVbdhmptuv\u1885\u1896\u18AA\u18BB\u18D7\u18DB\u18EC\u18FF\u1905\u190A\u1910\u1921\u0200LRlr\u188E\u1890\u1892\u1894;\u6557;\u6554;\u6556;\u6553\u0280;DUdu\u18A1\u18A2\u18A4\u18A6\u18A8\u6550;\u6566;\u6569;\u6564;\u6567\u0200LRlr\u18B3\u18B5\u18B7\u18B9;\u655D;\u655A;\u655C;\u6559\u0380;HLRhlr\u18CA\u18CB\u18CD\u18CF\u18D1\u18D3\u18D5\u6551;\u656C;\u6563;\u6560;\u656B;\u6562;\u655Fox;\u69C9\u0200LRlr\u18E4\u18E6\u18E8\u18EA;\u6555;\u6552;\u6510;\u650C\u0280;DUdu\u06BD\u18F7\u18F9\u18FB\u18FD;\u6565;\u6568;\u652C;\u6534inus;\u629Flus;\u629Eimes;\u62A0\u0200LRlr\u1919\u191B\u191D\u191F;\u655B;\u6558;\u6518;\u6514\u0380;HLRhlr\u1930\u1931\u1933\u1935\u1937\u1939\u193B\u6502;\u656A;\u6561;\u655E;\u653C;\u6524;\u651C\u0100ev\u0123\u1942bar\u803B\xA6\u40A6\u0200ceio\u1951\u1956\u195A\u1960r;\uC000\u{1D4B7}mi;\u604Fm\u0100;e\u171A\u171Cl\u0180;bh\u1968\u1969\u196B\u405C;\u69C5sub;\u67C8\u016C\u1974\u197El\u0100;e\u1979\u197A\u6022t\xBB\u197Ap\u0180;Ee\u012F\u1985\u1987;\u6AAE\u0100;q\u06DC\u06DB\u0CE1\u19A7\0\u19E8\u1A11\u1A15\u1A32\0\u1A37\u1A50\0\0\u1AB4\0\0\u1AC1\0\0\u1B21\u1B2E\u1B4D\u1B52\0\u1BFD\0\u1C0C\u0180cpr\u19AD\u19B2\u19DDute;\u4107\u0300;abcds\u19BF\u19C0\u19C4\u19CA\u19D5\u19D9\u6229nd;\u6A44rcup;\u6A49\u0100au\u19CF\u19D2p;\u6A4Bp;\u6A47ot;\u6A40;\uC000\u2229\uFE00\u0100eo\u19E2\u19E5t;\u6041\xEE\u0693\u0200aeiu\u19F0\u19FB\u1A01\u1A05\u01F0\u19F5\0\u19F8s;\u6A4Don;\u410Ddil\u803B\xE7\u40E7rc;\u4109ps\u0100;s\u1A0C\u1A0D\u6A4Cm;\u6A50ot;\u410B\u0180dmn\u1A1B\u1A20\u1A26il\u80BB\xB8\u01ADptyv;\u69B2t\u8100\xA2;e\u1A2D\u1A2E\u40A2r\xE4\u01B2r;\uC000\u{1D520}\u0180cei\u1A3D\u1A40\u1A4Dy;\u4447ck\u0100;m\u1A47\u1A48\u6713ark\xBB\u1A48;\u43C7r\u0380;Ecefms\u1A5F\u1A60\u1A62\u1A6B\u1AA4\u1AAA\u1AAE\u65CB;\u69C3\u0180;el\u1A69\u1A6A\u1A6D\u42C6q;\u6257e\u0261\u1A74\0\0\u1A88rrow\u0100lr\u1A7C\u1A81eft;\u61BAight;\u61BB\u0280RSacd\u1A92\u1A94\u1A96\u1A9A\u1A9F\xBB\u0F47;\u64C8st;\u629Birc;\u629Aash;\u629Dnint;\u6A10id;\u6AEFcir;\u69C2ubs\u0100;u\u1ABB\u1ABC\u6663it\xBB\u1ABC\u02EC\u1AC7\u1AD4\u1AFA\0\u1B0Aon\u0100;e\u1ACD\u1ACE\u403A\u0100;q\xC7\xC6\u026D\u1AD9\0\0\u1AE2a\u0100;t\u1ADE\u1ADF\u402C;\u4040\u0180;fl\u1AE8\u1AE9\u1AEB\u6201\xEE\u1160e\u0100mx\u1AF1\u1AF6ent\xBB\u1AE9e\xF3\u024D\u01E7\u1AFE\0\u1B07\u0100;d\u12BB\u1B02ot;\u6A6Dn\xF4\u0246\u0180fry\u1B10\u1B14\u1B17;\uC000\u{1D554}o\xE4\u0254\u8100\xA9;s\u0155\u1B1Dr;\u6117\u0100ao\u1B25\u1B29rr;\u61B5ss;\u6717\u0100cu\u1B32\u1B37r;\uC000\u{1D4B8}\u0100bp\u1B3C\u1B44\u0100;e\u1B41\u1B42\u6ACF;\u6AD1\u0100;e\u1B49\u1B4A\u6AD0;\u6AD2dot;\u62EF\u0380delprvw\u1B60\u1B6C\u1B77\u1B82\u1BAC\u1BD4\u1BF9arr\u0100lr\u1B68\u1B6A;\u6938;\u6935\u0270\u1B72\0\0\u1B75r;\u62DEc;\u62DFarr\u0100;p\u1B7F\u1B80\u61B6;\u693D\u0300;bcdos\u1B8F\u1B90\u1B96\u1BA1\u1BA5\u1BA8\u622Arcap;\u6A48\u0100au\u1B9B\u1B9Ep;\u6A46p;\u6A4Aot;\u628Dr;\u6A45;\uC000\u222A\uFE00\u0200alrv\u1BB5\u1BBF\u1BDE\u1BE3rr\u0100;m\u1BBC\u1BBD\u61B7;\u693Cy\u0180evw\u1BC7\u1BD4\u1BD8q\u0270\u1BCE\0\0\u1BD2re\xE3\u1B73u\xE3\u1B75ee;\u62CEedge;\u62CFen\u803B\xA4\u40A4earrow\u0100lr\u1BEE\u1BF3eft\xBB\u1B80ight\xBB\u1BBDe\xE4\u1BDD\u0100ci\u1C01\u1C07onin\xF4\u01F7nt;\u6231lcty;\u632D\u0980AHabcdefhijlorstuwz\u1C38\u1C3B\u1C3F\u1C5D\u1C69\u1C75\u1C8A\u1C9E\u1CAC\u1CB7\u1CFB\u1CFF\u1D0D\u1D7B\u1D91\u1DAB\u1DBB\u1DC6\u1DCDr\xF2\u0381ar;\u6965\u0200glrs\u1C48\u1C4D\u1C52\u1C54ger;\u6020eth;\u6138\xF2\u1133h\u0100;v\u1C5A\u1C5B\u6010\xBB\u090A\u016B\u1C61\u1C67arow;\u690Fa\xE3\u0315\u0100ay\u1C6E\u1C73ron;\u410F;\u4434\u0180;ao\u0332\u1C7C\u1C84\u0100gr\u02BF\u1C81r;\u61CAtseq;\u6A77\u0180glm\u1C91\u1C94\u1C98\u803B\xB0\u40B0ta;\u43B4ptyv;\u69B1\u0100ir\u1CA3\u1CA8sht;\u697F;\uC000\u{1D521}ar\u0100lr\u1CB3\u1CB5\xBB\u08DC\xBB\u101E\u0280aegsv\u1CC2\u0378\u1CD6\u1CDC\u1CE0m\u0180;os\u0326\u1CCA\u1CD4nd\u0100;s\u0326\u1CD1uit;\u6666amma;\u43DDin;\u62F2\u0180;io\u1CE7\u1CE8\u1CF8\u40F7de\u8100\xF7;o\u1CE7\u1CF0ntimes;\u62C7n\xF8\u1CF7cy;\u4452c\u026F\u1D06\0\0\u1D0Arn;\u631Eop;\u630D\u0280lptuw\u1D18\u1D1D\u1D22\u1D49\u1D55lar;\u4024f;\uC000\u{1D555}\u0280;emps\u030B\u1D2D\u1D37\u1D3D\u1D42q\u0100;d\u0352\u1D33ot;\u6251inus;\u6238lus;\u6214quare;\u62A1blebarwedg\xE5\xFAn\u0180adh\u112E\u1D5D\u1D67ownarrow\xF3\u1C83arpoon\u0100lr\u1D72\u1D76ef\xF4\u1CB4igh\xF4\u1CB6\u0162\u1D7F\u1D85karo\xF7\u0F42\u026F\u1D8A\0\0\u1D8Ern;\u631Fop;\u630C\u0180cot\u1D98\u1DA3\u1DA6\u0100ry\u1D9D\u1DA1;\uC000\u{1D4B9};\u4455l;\u69F6rok;\u4111\u0100dr\u1DB0\u1DB4ot;\u62F1i\u0100;f\u1DBA\u1816\u65BF\u0100ah\u1DC0\u1DC3r\xF2\u0429a\xF2\u0FA6angle;\u69A6\u0100ci\u1DD2\u1DD5y;\u445Fgrarr;\u67FF\u0900Dacdefglmnopqrstux\u1E01\u1E09\u1E19\u1E38\u0578\u1E3C\u1E49\u1E61\u1E7E\u1EA5\u1EAF\u1EBD\u1EE1\u1F2A\u1F37\u1F44\u1F4E\u1F5A\u0100Do\u1E06\u1D34o\xF4\u1C89\u0100cs\u1E0E\u1E14ute\u803B\xE9\u40E9ter;\u6A6E\u0200aioy\u1E22\u1E27\u1E31\u1E36ron;\u411Br\u0100;c\u1E2D\u1E2E\u6256\u803B\xEA\u40EAlon;\u6255;\u444Dot;\u4117\u0100Dr\u1E41\u1E45ot;\u6252;\uC000\u{1D522}\u0180;rs\u1E50\u1E51\u1E57\u6A9Aave\u803B\xE8\u40E8\u0100;d\u1E5C\u1E5D\u6A96ot;\u6A98\u0200;ils\u1E6A\u1E6B\u1E72\u1E74\u6A99nters;\u63E7;\u6113\u0100;d\u1E79\u1E7A\u6A95ot;\u6A97\u0180aps\u1E85\u1E89\u1E97cr;\u4113ty\u0180;sv\u1E92\u1E93\u1E95\u6205et\xBB\u1E93p\u01001;\u1E9D\u1EA4\u0133\u1EA1\u1EA3;\u6004;\u6005\u6003\u0100gs\u1EAA\u1EAC;\u414Bp;\u6002\u0100gp\u1EB4\u1EB8on;\u4119f;\uC000\u{1D556}\u0180als\u1EC4\u1ECE\u1ED2r\u0100;s\u1ECA\u1ECB\u62D5l;\u69E3us;\u6A71i\u0180;lv\u1EDA\u1EDB\u1EDF\u43B5on\xBB\u1EDB;\u43F5\u0200csuv\u1EEA\u1EF3\u1F0B\u1F23\u0100io\u1EEF\u1E31rc\xBB\u1E2E\u0269\u1EF9\0\0\u1EFB\xED\u0548ant\u0100gl\u1F02\u1F06tr\xBB\u1E5Dess\xBB\u1E7A\u0180aei\u1F12\u1F16\u1F1Als;\u403Dst;\u625Fv\u0100;D\u0235\u1F20D;\u6A78parsl;\u69E5\u0100Da\u1F2F\u1F33ot;\u6253rr;\u6971\u0180cdi\u1F3E\u1F41\u1EF8r;\u612Fo\xF4\u0352\u0100ah\u1F49\u1F4B;\u43B7\u803B\xF0\u40F0\u0100mr\u1F53\u1F57l\u803B\xEB\u40EBo;\u60AC\u0180cip\u1F61\u1F64\u1F67l;\u4021s\xF4\u056E\u0100eo\u1F6C\u1F74ctatio\xEE\u0559nential\xE5\u0579\u09E1\u1F92\0\u1F9E\0\u1FA1\u1FA7\0\0\u1FC6\u1FCC\0\u1FD3\0\u1FE6\u1FEA\u2000\0\u2008\u205Allingdotse\xF1\u1E44y;\u4444male;\u6640\u0180ilr\u1FAD\u1FB3\u1FC1lig;\u8000\uFB03\u0269\u1FB9\0\0\u1FBDg;\u8000\uFB00ig;\u8000\uFB04;\uC000\u{1D523}lig;\u8000\uFB01lig;\uC000fj\u0180alt\u1FD9\u1FDC\u1FE1t;\u666Dig;\u8000\uFB02ns;\u65B1of;\u4192\u01F0\u1FEE\0\u1FF3f;\uC000\u{1D557}\u0100ak\u05BF\u1FF7\u0100;v\u1FFC\u1FFD\u62D4;\u6AD9artint;\u6A0D\u0100ao\u200C\u2055\u0100cs\u2011\u2052\u03B1\u201A\u2030\u2038\u2045\u2048\0\u2050\u03B2\u2022\u2025\u2027\u202A\u202C\0\u202E\u803B\xBD\u40BD;\u6153\u803B\xBC\u40BC;\u6155;\u6159;\u615B\u01B3\u2034\0\u2036;\u6154;\u6156\u02B4\u203E\u2041\0\0\u2043\u803B\xBE\u40BE;\u6157;\u615C5;\u6158\u01B6\u204C\0\u204E;\u615A;\u615D8;\u615El;\u6044wn;\u6322cr;\uC000\u{1D4BB}\u0880Eabcdefgijlnorstv\u2082\u2089\u209F\u20A5\u20B0\u20B4\u20F0\u20F5\u20FA\u20FF\u2103\u2112\u2138\u0317\u213E\u2152\u219E\u0100;l\u064D\u2087;\u6A8C\u0180cmp\u2090\u2095\u209Dute;\u41F5ma\u0100;d\u209C\u1CDA\u43B3;\u6A86reve;\u411F\u0100iy\u20AA\u20AErc;\u411D;\u4433ot;\u4121\u0200;lqs\u063E\u0642\u20BD\u20C9\u0180;qs\u063E\u064C\u20C4lan\xF4\u0665\u0200;cdl\u0665\u20D2\u20D5\u20E5c;\u6AA9ot\u0100;o\u20DC\u20DD\u6A80\u0100;l\u20E2\u20E3\u6A82;\u6A84\u0100;e\u20EA\u20ED\uC000\u22DB\uFE00s;\u6A94r;\uC000\u{1D524}\u0100;g\u0673\u061Bmel;\u6137cy;\u4453\u0200;Eaj\u065A\u210C\u210E\u2110;\u6A92;\u6AA5;\u6AA4\u0200Eaes\u211B\u211D\u2129\u2134;\u6269p\u0100;p\u2123\u2124\u6A8Arox\xBB\u2124\u0100;q\u212E\u212F\u6A88\u0100;q\u212E\u211Bim;\u62E7pf;\uC000\u{1D558}\u0100ci\u2143\u2146r;\u610Am\u0180;el\u066B\u214E\u2150;\u6A8E;\u6A90\u8300>;cdlqr\u05EE\u2160\u216A\u216E\u2173\u2179\u0100ci\u2165\u2167;\u6AA7r;\u6A7Aot;\u62D7Par;\u6995uest;\u6A7C\u0280adels\u2184\u216A\u2190\u0656\u219B\u01F0\u2189\0\u218Epro\xF8\u209Er;\u6978q\u0100lq\u063F\u2196les\xF3\u2088i\xED\u066B\u0100en\u21A3\u21ADrtneqq;\uC000\u2269\uFE00\xC5\u21AA\u0500Aabcefkosy\u21C4\u21C7\u21F1\u21F5\u21FA\u2218\u221D\u222F\u2268\u227Dr\xF2\u03A0\u0200ilmr\u21D0\u21D4\u21D7\u21DBrs\xF0\u1484f\xBB\u2024il\xF4\u06A9\u0100dr\u21E0\u21E4cy;\u444A\u0180;cw\u08F4\u21EB\u21EFir;\u6948;\u61ADar;\u610Firc;\u4125\u0180alr\u2201\u220E\u2213rts\u0100;u\u2209\u220A\u6665it\xBB\u220Alip;\u6026con;\u62B9r;\uC000\u{1D525}s\u0100ew\u2223\u2229arow;\u6925arow;\u6926\u0280amopr\u223A\u223E\u2243\u225E\u2263rr;\u61FFtht;\u623Bk\u0100lr\u2249\u2253eftarrow;\u61A9ightarrow;\u61AAf;\uC000\u{1D559}bar;\u6015\u0180clt\u226F\u2274\u2278r;\uC000\u{1D4BD}as\xE8\u21F4rok;\u4127\u0100bp\u2282\u2287ull;\u6043hen\xBB\u1C5B\u0AE1\u22A3\0\u22AA\0\u22B8\u22C5\u22CE\0\u22D5\u22F3\0\0\u22F8\u2322\u2367\u2362\u237F\0\u2386\u23AA\u23B4cute\u803B\xED\u40ED\u0180;iy\u0771\u22B0\u22B5rc\u803B\xEE\u40EE;\u4438\u0100cx\u22BC\u22BFy;\u4435cl\u803B\xA1\u40A1\u0100fr\u039F\u22C9;\uC000\u{1D526}rave\u803B\xEC\u40EC\u0200;ino\u073E\u22DD\u22E9\u22EE\u0100in\u22E2\u22E6nt;\u6A0Ct;\u622Dfin;\u69DCta;\u6129lig;\u4133\u0180aop\u22FE\u231A\u231D\u0180cgt\u2305\u2308\u2317r;\u412B\u0180elp\u071F\u230F\u2313in\xE5\u078Ear\xF4\u0720h;\u4131f;\u62B7ed;\u41B5\u0280;cfot\u04F4\u232C\u2331\u233D\u2341are;\u6105in\u0100;t\u2338\u2339\u621Eie;\u69DDdo\xF4\u2319\u0280;celp\u0757\u234C\u2350\u235B\u2361al;\u62BA\u0100gr\u2355\u2359er\xF3\u1563\xE3\u234Darhk;\u6A17rod;\u6A3C\u0200cgpt\u236F\u2372\u2376\u237By;\u4451on;\u412Ff;\uC000\u{1D55A}a;\u43B9uest\u803B\xBF\u40BF\u0100ci\u238A\u238Fr;\uC000\u{1D4BE}n\u0280;Edsv\u04F4\u239B\u239D\u23A1\u04F3;\u62F9ot;\u62F5\u0100;v\u23A6\u23A7\u62F4;\u62F3\u0100;i\u0777\u23AElde;\u4129\u01EB\u23B8\0\u23BCcy;\u4456l\u803B\xEF\u40EF\u0300cfmosu\u23CC\u23D7\u23DC\u23E1\u23E7\u23F5\u0100iy\u23D1\u23D5rc;\u4135;\u4439r;\uC000\u{1D527}ath;\u4237pf;\uC000\u{1D55B}\u01E3\u23EC\0\u23F1r;\uC000\u{1D4BF}rcy;\u4458kcy;\u4454\u0400acfghjos\u240B\u2416\u2422\u2427\u242D\u2431\u2435\u243Bppa\u0100;v\u2413\u2414\u43BA;\u43F0\u0100ey\u241B\u2420dil;\u4137;\u443Ar;\uC000\u{1D528}reen;\u4138cy;\u4445cy;\u445Cpf;\uC000\u{1D55C}cr;\uC000\u{1D4C0}\u0B80ABEHabcdefghjlmnoprstuv\u2470\u2481\u2486\u248D\u2491\u250E\u253D\u255A\u2580\u264E\u265E\u2665\u2679\u267D\u269A\u26B2\u26D8\u275D\u2768\u278B\u27C0\u2801\u2812\u0180art\u2477\u247A\u247Cr\xF2\u09C6\xF2\u0395ail;\u691Barr;\u690E\u0100;g\u0994\u248B;\u6A8Bar;\u6962\u0963\u24A5\0\u24AA\0\u24B1\0\0\0\0\0\u24B5\u24BA\0\u24C6\u24C8\u24CD\0\u24F9ute;\u413Amptyv;\u69B4ra\xEE\u084Cbda;\u43BBg\u0180;dl\u088E\u24C1\u24C3;\u6991\xE5\u088E;\u6A85uo\u803B\xAB\u40ABr\u0400;bfhlpst\u0899\u24DE\u24E6\u24E9\u24EB\u24EE\u24F1\u24F5\u0100;f\u089D\u24E3s;\u691Fs;\u691D\xEB\u2252p;\u61ABl;\u6939im;\u6973l;\u61A2\u0180;ae\u24FF\u2500\u2504\u6AABil;\u6919\u0100;s\u2509\u250A\u6AAD;\uC000\u2AAD\uFE00\u0180abr\u2515\u2519\u251Drr;\u690Crk;\u6772\u0100ak\u2522\u252Cc\u0100ek\u2528\u252A;\u407B;\u405B\u0100es\u2531\u2533;\u698Bl\u0100du\u2539\u253B;\u698F;\u698D\u0200aeuy\u2546\u254B\u2556\u2558ron;\u413E\u0100di\u2550\u2554il;\u413C\xEC\u08B0\xE2\u2529;\u443B\u0200cqrs\u2563\u2566\u256D\u257Da;\u6936uo\u0100;r\u0E19\u1746\u0100du\u2572\u2577har;\u6967shar;\u694Bh;\u61B2\u0280;fgqs\u258B\u258C\u0989\u25F3\u25FF\u6264t\u0280ahlrt\u2598\u25A4\u25B7\u25C2\u25E8rrow\u0100;t\u0899\u25A1a\xE9\u24F6arpoon\u0100du\u25AF\u25B4own\xBB\u045Ap\xBB\u0966eftarrows;\u61C7ight\u0180ahs\u25CD\u25D6\u25DErrow\u0100;s\u08F4\u08A7arpoon\xF3\u0F98quigarro\xF7\u21F0hreetimes;\u62CB\u0180;qs\u258B\u0993\u25FAlan\xF4\u09AC\u0280;cdgs\u09AC\u260A\u260D\u261D\u2628c;\u6AA8ot\u0100;o\u2614\u2615\u6A7F\u0100;r\u261A\u261B\u6A81;\u6A83\u0100;e\u2622\u2625\uC000\u22DA\uFE00s;\u6A93\u0280adegs\u2633\u2639\u263D\u2649\u264Bppro\xF8\u24C6ot;\u62D6q\u0100gq\u2643\u2645\xF4\u0989gt\xF2\u248C\xF4\u099Bi\xED\u09B2\u0180ilr\u2655\u08E1\u265Asht;\u697C;\uC000\u{1D529}\u0100;E\u099C\u2663;\u6A91\u0161\u2669\u2676r\u0100du\u25B2\u266E\u0100;l\u0965\u2673;\u696Alk;\u6584cy;\u4459\u0280;acht\u0A48\u2688\u268B\u2691\u2696r\xF2\u25C1orne\xF2\u1D08ard;\u696Bri;\u65FA\u0100io\u269F\u26A4dot;\u4140ust\u0100;a\u26AC\u26AD\u63B0che\xBB\u26AD\u0200Eaes\u26BB\u26BD\u26C9\u26D4;\u6268p\u0100;p\u26C3\u26C4\u6A89rox\xBB\u26C4\u0100;q\u26CE\u26CF\u6A87\u0100;q\u26CE\u26BBim;\u62E6\u0400abnoptwz\u26E9\u26F4\u26F7\u271A\u272F\u2741\u2747\u2750\u0100nr\u26EE\u26F1g;\u67ECr;\u61FDr\xEB\u08C1g\u0180lmr\u26FF\u270D\u2714eft\u0100ar\u09E6\u2707ight\xE1\u09F2apsto;\u67FCight\xE1\u09FDparrow\u0100lr\u2725\u2729ef\xF4\u24EDight;\u61AC\u0180afl\u2736\u2739\u273Dr;\u6985;\uC000\u{1D55D}us;\u6A2Dimes;\u6A34\u0161\u274B\u274Fst;\u6217\xE1\u134E\u0180;ef\u2757\u2758\u1800\u65CAnge\xBB\u2758ar\u0100;l\u2764\u2765\u4028t;\u6993\u0280achmt\u2773\u2776\u277C\u2785\u2787r\xF2\u08A8orne\xF2\u1D8Car\u0100;d\u0F98\u2783;\u696D;\u600Eri;\u62BF\u0300achiqt\u2798\u279D\u0A40\u27A2\u27AE\u27BBquo;\u6039r;\uC000\u{1D4C1}m\u0180;eg\u09B2\u27AA\u27AC;\u6A8D;\u6A8F\u0100bu\u252A\u27B3o\u0100;r\u0E1F\u27B9;\u601Arok;\u4142\u8400<;cdhilqr\u082B\u27D2\u2639\u27DC\u27E0\u27E5\u27EA\u27F0\u0100ci\u27D7\u27D9;\u6AA6r;\u6A79re\xE5\u25F2mes;\u62C9arr;\u6976uest;\u6A7B\u0100Pi\u27F5\u27F9ar;\u6996\u0180;ef\u2800\u092D\u181B\u65C3r\u0100du\u2807\u280Dshar;\u694Ahar;\u6966\u0100en\u2817\u2821rtneqq;\uC000\u2268\uFE00\xC5\u281E\u0700Dacdefhilnopsu\u2840\u2845\u2882\u288E\u2893\u28A0\u28A5\u28A8\u28DA\u28E2\u28E4\u0A83\u28F3\u2902Dot;\u623A\u0200clpr\u284E\u2852\u2863\u287Dr\u803B\xAF\u40AF\u0100et\u2857\u2859;\u6642\u0100;e\u285E\u285F\u6720se\xBB\u285F\u0100;s\u103B\u2868to\u0200;dlu\u103B\u2873\u2877\u287Bow\xEE\u048Cef\xF4\u090F\xF0\u13D1ker;\u65AE\u0100oy\u2887\u288Cmma;\u6A29;\u443Cash;\u6014asuredangle\xBB\u1626r;\uC000\u{1D52A}o;\u6127\u0180cdn\u28AF\u28B4\u28C9ro\u803B\xB5\u40B5\u0200;acd\u1464\u28BD\u28C0\u28C4s\xF4\u16A7ir;\u6AF0ot\u80BB\xB7\u01B5us\u0180;bd\u28D2\u1903\u28D3\u6212\u0100;u\u1D3C\u28D8;\u6A2A\u0163\u28DE\u28E1p;\u6ADB\xF2\u2212\xF0\u0A81\u0100dp\u28E9\u28EEels;\u62A7f;\uC000\u{1D55E}\u0100ct\u28F8\u28FDr;\uC000\u{1D4C2}pos\xBB\u159D\u0180;lm\u2909\u290A\u290D\u43BCtimap;\u62B8\u0C00GLRVabcdefghijlmoprstuvw\u2942\u2953\u297E\u2989\u2998\u29DA\u29E9\u2A15\u2A1A\u2A58\u2A5D\u2A83\u2A95\u2AA4\u2AA8\u2B04\u2B07\u2B44\u2B7F\u2BAE\u2C34\u2C67\u2C7C\u2CE9\u0100gt\u2947\u294B;\uC000\u22D9\u0338\u0100;v\u2950\u0BCF\uC000\u226B\u20D2\u0180elt\u295A\u2972\u2976ft\u0100ar\u2961\u2967rrow;\u61CDightarrow;\u61CE;\uC000\u22D8\u0338\u0100;v\u297B\u0C47\uC000\u226A\u20D2ightarrow;\u61CF\u0100Dd\u298E\u2993ash;\u62AFash;\u62AE\u0280bcnpt\u29A3\u29A7\u29AC\u29B1\u29CCla\xBB\u02DEute;\u4144g;\uC000\u2220\u20D2\u0280;Eiop\u0D84\u29BC\u29C0\u29C5\u29C8;\uC000\u2A70\u0338d;\uC000\u224B\u0338s;\u4149ro\xF8\u0D84ur\u0100;a\u29D3\u29D4\u666El\u0100;s\u29D3\u0B38\u01F3\u29DF\0\u29E3p\u80BB\xA0\u0B37mp\u0100;e\u0BF9\u0C00\u0280aeouy\u29F4\u29FE\u2A03\u2A10\u2A13\u01F0\u29F9\0\u29FB;\u6A43on;\u4148dil;\u4146ng\u0100;d\u0D7E\u2A0Aot;\uC000\u2A6D\u0338p;\u6A42;\u443Dash;\u6013\u0380;Aadqsx\u0B92\u2A29\u2A2D\u2A3B\u2A41\u2A45\u2A50rr;\u61D7r\u0100hr\u2A33\u2A36k;\u6924\u0100;o\u13F2\u13F0ot;\uC000\u2250\u0338ui\xF6\u0B63\u0100ei\u2A4A\u2A4Ear;\u6928\xED\u0B98ist\u0100;s\u0BA0\u0B9Fr;\uC000\u{1D52B}\u0200Eest\u0BC5\u2A66\u2A79\u2A7C\u0180;qs\u0BBC\u2A6D\u0BE1\u0180;qs\u0BBC\u0BC5\u2A74lan\xF4\u0BE2i\xED\u0BEA\u0100;r\u0BB6\u2A81\xBB\u0BB7\u0180Aap\u2A8A\u2A8D\u2A91r\xF2\u2971rr;\u61AEar;\u6AF2\u0180;sv\u0F8D\u2A9C\u0F8C\u0100;d\u2AA1\u2AA2\u62FC;\u62FAcy;\u445A\u0380AEadest\u2AB7\u2ABA\u2ABE\u2AC2\u2AC5\u2AF6\u2AF9r\xF2\u2966;\uC000\u2266\u0338rr;\u619Ar;\u6025\u0200;fqs\u0C3B\u2ACE\u2AE3\u2AEFt\u0100ar\u2AD4\u2AD9rro\xF7\u2AC1ightarro\xF7\u2A90\u0180;qs\u0C3B\u2ABA\u2AEAlan\xF4\u0C55\u0100;s\u0C55\u2AF4\xBB\u0C36i\xED\u0C5D\u0100;r\u0C35\u2AFEi\u0100;e\u0C1A\u0C25i\xE4\u0D90\u0100pt\u2B0C\u2B11f;\uC000\u{1D55F}\u8180\xAC;in\u2B19\u2B1A\u2B36\u40ACn\u0200;Edv\u0B89\u2B24\u2B28\u2B2E;\uC000\u22F9\u0338ot;\uC000\u22F5\u0338\u01E1\u0B89\u2B33\u2B35;\u62F7;\u62F6i\u0100;v\u0CB8\u2B3C\u01E1\u0CB8\u2B41\u2B43;\u62FE;\u62FD\u0180aor\u2B4B\u2B63\u2B69r\u0200;ast\u0B7B\u2B55\u2B5A\u2B5Flle\xEC\u0B7Bl;\uC000\u2AFD\u20E5;\uC000\u2202\u0338lint;\u6A14\u0180;ce\u0C92\u2B70\u2B73u\xE5\u0CA5\u0100;c\u0C98\u2B78\u0100;e\u0C92\u2B7D\xF1\u0C98\u0200Aait\u2B88\u2B8B\u2B9D\u2BA7r\xF2\u2988rr\u0180;cw\u2B94\u2B95\u2B99\u619B;\uC000\u2933\u0338;\uC000\u219D\u0338ghtarrow\xBB\u2B95ri\u0100;e\u0CCB\u0CD6\u0380chimpqu\u2BBD\u2BCD\u2BD9\u2B04\u0B78\u2BE4\u2BEF\u0200;cer\u0D32\u2BC6\u0D37\u2BC9u\xE5\u0D45;\uC000\u{1D4C3}ort\u026D\u2B05\0\0\u2BD6ar\xE1\u2B56m\u0100;e\u0D6E\u2BDF\u0100;q\u0D74\u0D73su\u0100bp\u2BEB\u2BED\xE5\u0CF8\xE5\u0D0B\u0180bcp\u2BF6\u2C11\u2C19\u0200;Ees\u2BFF\u2C00\u0D22\u2C04\u6284;\uC000\u2AC5\u0338et\u0100;e\u0D1B\u2C0Bq\u0100;q\u0D23\u2C00c\u0100;e\u0D32\u2C17\xF1\u0D38\u0200;Ees\u2C22\u2C23\u0D5F\u2C27\u6285;\uC000\u2AC6\u0338et\u0100;e\u0D58\u2C2Eq\u0100;q\u0D60\u2C23\u0200gilr\u2C3D\u2C3F\u2C45\u2C47\xEC\u0BD7lde\u803B\xF1\u40F1\xE7\u0C43iangle\u0100lr\u2C52\u2C5Ceft\u0100;e\u0C1A\u2C5A\xF1\u0C26ight\u0100;e\u0CCB\u2C65\xF1\u0CD7\u0100;m\u2C6C\u2C6D\u43BD\u0180;es\u2C74\u2C75\u2C79\u4023ro;\u6116p;\u6007\u0480DHadgilrs\u2C8F\u2C94\u2C99\u2C9E\u2CA3\u2CB0\u2CB6\u2CD3\u2CE3ash;\u62ADarr;\u6904p;\uC000\u224D\u20D2ash;\u62AC\u0100et\u2CA8\u2CAC;\uC000\u2265\u20D2;\uC000>\u20D2nfin;\u69DE\u0180Aet\u2CBD\u2CC1\u2CC5rr;\u6902;\uC000\u2264\u20D2\u0100;r\u2CCA\u2CCD\uC000<\u20D2ie;\uC000\u22B4\u20D2\u0100At\u2CD8\u2CDCrr;\u6903rie;\uC000\u22B5\u20D2im;\uC000\u223C\u20D2\u0180Aan\u2CF0\u2CF4\u2D02rr;\u61D6r\u0100hr\u2CFA\u2CFDk;\u6923\u0100;o\u13E7\u13E5ear;\u6927\u1253\u1A95\0\0\0\0\0\0\0\0\0\0\0\0\0\u2D2D\0\u2D38\u2D48\u2D60\u2D65\u2D72\u2D84\u1B07\0\0\u2D8D\u2DAB\0\u2DC8\u2DCE\0\u2DDC\u2E19\u2E2B\u2E3E\u2E43\u0100cs\u2D31\u1A97ute\u803B\xF3\u40F3\u0100iy\u2D3C\u2D45r\u0100;c\u1A9E\u2D42\u803B\xF4\u40F4;\u443E\u0280abios\u1AA0\u2D52\u2D57\u01C8\u2D5Alac;\u4151v;\u6A38old;\u69BClig;\u4153\u0100cr\u2D69\u2D6Dir;\u69BF;\uC000\u{1D52C}\u036F\u2D79\0\0\u2D7C\0\u2D82n;\u42DBave\u803B\xF2\u40F2;\u69C1\u0100bm\u2D88\u0DF4ar;\u69B5\u0200acit\u2D95\u2D98\u2DA5\u2DA8r\xF2\u1A80\u0100ir\u2D9D\u2DA0r;\u69BEoss;\u69BBn\xE5\u0E52;\u69C0\u0180aei\u2DB1\u2DB5\u2DB9cr;\u414Dga;\u43C9\u0180cdn\u2DC0\u2DC5\u01CDron;\u43BF;\u69B6pf;\uC000\u{1D560}\u0180ael\u2DD4\u2DD7\u01D2r;\u69B7rp;\u69B9\u0380;adiosv\u2DEA\u2DEB\u2DEE\u2E08\u2E0D\u2E10\u2E16\u6228r\xF2\u1A86\u0200;efm\u2DF7\u2DF8\u2E02\u2E05\u6A5Dr\u0100;o\u2DFE\u2DFF\u6134f\xBB\u2DFF\u803B\xAA\u40AA\u803B\xBA\u40BAgof;\u62B6r;\u6A56lope;\u6A57;\u6A5B\u0180clo\u2E1F\u2E21\u2E27\xF2\u2E01ash\u803B\xF8\u40F8l;\u6298i\u016C\u2E2F\u2E34de\u803B\xF5\u40F5es\u0100;a\u01DB\u2E3As;\u6A36ml\u803B\xF6\u40F6bar;\u633D\u0AE1\u2E5E\0\u2E7D\0\u2E80\u2E9D\0\u2EA2\u2EB9\0\0\u2ECB\u0E9C\0\u2F13\0\0\u2F2B\u2FBC\0\u2FC8r\u0200;ast\u0403\u2E67\u2E72\u0E85\u8100\xB6;l\u2E6D\u2E6E\u40B6le\xEC\u0403\u0269\u2E78\0\0\u2E7Bm;\u6AF3;\u6AFDy;\u443Fr\u0280cimpt\u2E8B\u2E8F\u2E93\u1865\u2E97nt;\u4025od;\u402Eil;\u6030enk;\u6031r;\uC000\u{1D52D}\u0180imo\u2EA8\u2EB0\u2EB4\u0100;v\u2EAD\u2EAE\u43C6;\u43D5ma\xF4\u0A76ne;\u660E\u0180;tv\u2EBF\u2EC0\u2EC8\u43C0chfork\xBB\u1FFD;\u43D6\u0100au\u2ECF\u2EDFn\u0100ck\u2ED5\u2EDDk\u0100;h\u21F4\u2EDB;\u610E\xF6\u21F4s\u0480;abcdemst\u2EF3\u2EF4\u1908\u2EF9\u2EFD\u2F04\u2F06\u2F0A\u2F0E\u402Bcir;\u6A23ir;\u6A22\u0100ou\u1D40\u2F02;\u6A25;\u6A72n\u80BB\xB1\u0E9Dim;\u6A26wo;\u6A27\u0180ipu\u2F19\u2F20\u2F25ntint;\u6A15f;\uC000\u{1D561}nd\u803B\xA3\u40A3\u0500;Eaceinosu\u0EC8\u2F3F\u2F41\u2F44\u2F47\u2F81\u2F89\u2F92\u2F7E\u2FB6;\u6AB3p;\u6AB7u\xE5\u0ED9\u0100;c\u0ECE\u2F4C\u0300;acens\u0EC8\u2F59\u2F5F\u2F66\u2F68\u2F7Eppro\xF8\u2F43urlye\xF1\u0ED9\xF1\u0ECE\u0180aes\u2F6F\u2F76\u2F7Approx;\u6AB9qq;\u6AB5im;\u62E8i\xED\u0EDFme\u0100;s\u2F88\u0EAE\u6032\u0180Eas\u2F78\u2F90\u2F7A\xF0\u2F75\u0180dfp\u0EEC\u2F99\u2FAF\u0180als\u2FA0\u2FA5\u2FAAlar;\u632Eine;\u6312urf;\u6313\u0100;t\u0EFB\u2FB4\xEF\u0EFBrel;\u62B0\u0100ci\u2FC0\u2FC5r;\uC000\u{1D4C5};\u43C8ncsp;\u6008\u0300fiopsu\u2FDA\u22E2\u2FDF\u2FE5\u2FEB\u2FF1r;\uC000\u{1D52E}pf;\uC000\u{1D562}rime;\u6057cr;\uC000\u{1D4C6}\u0180aeo\u2FF8\u3009\u3013t\u0100ei\u2FFE\u3005rnion\xF3\u06B0nt;\u6A16st\u0100;e\u3010\u3011\u403F\xF1\u1F19\xF4\u0F14\u0A80ABHabcdefhilmnoprstux\u3040\u3051\u3055\u3059\u30E0\u310E\u312B\u3147\u3162\u3172\u318E\u3206\u3215\u3224\u3229\u3258\u326E\u3272\u3290\u32B0\u32B7\u0180art\u3047\u304A\u304Cr\xF2\u10B3\xF2\u03DDail;\u691Car\xF2\u1C65ar;\u6964\u0380cdenqrt\u3068\u3075\u3078\u307F\u308F\u3094\u30CC\u0100eu\u306D\u3071;\uC000\u223D\u0331te;\u4155i\xE3\u116Emptyv;\u69B3g\u0200;del\u0FD1\u3089\u308B\u308D;\u6992;\u69A5\xE5\u0FD1uo\u803B\xBB\u40BBr\u0580;abcfhlpstw\u0FDC\u30AC\u30AF\u30B7\u30B9\u30BC\u30BE\u30C0\u30C3\u30C7\u30CAp;\u6975\u0100;f\u0FE0\u30B4s;\u6920;\u6933s;\u691E\xEB\u225D\xF0\u272El;\u6945im;\u6974l;\u61A3;\u619D\u0100ai\u30D1\u30D5il;\u691Ao\u0100;n\u30DB\u30DC\u6236al\xF3\u0F1E\u0180abr\u30E7\u30EA\u30EEr\xF2\u17E5rk;\u6773\u0100ak\u30F3\u30FDc\u0100ek\u30F9\u30FB;\u407D;\u405D\u0100es\u3102\u3104;\u698Cl\u0100du\u310A\u310C;\u698E;\u6990\u0200aeuy\u3117\u311C\u3127\u3129ron;\u4159\u0100di\u3121\u3125il;\u4157\xEC\u0FF2\xE2\u30FA;\u4440\u0200clqs\u3134\u3137\u313D\u3144a;\u6937dhar;\u6969uo\u0100;r\u020E\u020Dh;\u61B3\u0180acg\u314E\u315F\u0F44l\u0200;ips\u0F78\u3158\u315B\u109Cn\xE5\u10BBar\xF4\u0FA9t;\u65AD\u0180ilr\u3169\u1023\u316Esht;\u697D;\uC000\u{1D52F}\u0100ao\u3177\u3186r\u0100du\u317D\u317F\xBB\u047B\u0100;l\u1091\u3184;\u696C\u0100;v\u318B\u318C\u43C1;\u43F1\u0180gns\u3195\u31F9\u31FCht\u0300ahlrst\u31A4\u31B0\u31C2\u31D8\u31E4\u31EErrow\u0100;t\u0FDC\u31ADa\xE9\u30C8arpoon\u0100du\u31BB\u31BFow\xEE\u317Ep\xBB\u1092eft\u0100ah\u31CA\u31D0rrow\xF3\u0FEAarpoon\xF3\u0551ightarrows;\u61C9quigarro\xF7\u30CBhreetimes;\u62CCg;\u42DAingdotse\xF1\u1F32\u0180ahm\u320D\u3210\u3213r\xF2\u0FEAa\xF2\u0551;\u600Foust\u0100;a\u321E\u321F\u63B1che\xBB\u321Fmid;\u6AEE\u0200abpt\u3232\u323D\u3240\u3252\u0100nr\u3237\u323Ag;\u67EDr;\u61FEr\xEB\u1003\u0180afl\u3247\u324A\u324Er;\u6986;\uC000\u{1D563}us;\u6A2Eimes;\u6A35\u0100ap\u325D\u3267r\u0100;g\u3263\u3264\u4029t;\u6994olint;\u6A12ar\xF2\u31E3\u0200achq\u327B\u3280\u10BC\u3285quo;\u603Ar;\uC000\u{1D4C7}\u0100bu\u30FB\u328Ao\u0100;r\u0214\u0213\u0180hir\u3297\u329B\u32A0re\xE5\u31F8mes;\u62CAi\u0200;efl\u32AA\u1059\u1821\u32AB\u65B9tri;\u69CEluhar;\u6968;\u611E\u0D61\u32D5\u32DB\u32DF\u332C\u3338\u3371\0\u337A\u33A4\0\0\u33EC\u33F0\0\u3428\u3448\u345A\u34AD\u34B1\u34CA\u34F1\0\u3616\0\0\u3633cute;\u415Bqu\xEF\u27BA\u0500;Eaceinpsy\u11ED\u32F3\u32F5\u32FF\u3302\u330B\u330F\u331F\u3326\u3329;\u6AB4\u01F0\u32FA\0\u32FC;\u6AB8on;\u4161u\xE5\u11FE\u0100;d\u11F3\u3307il;\u415Frc;\u415D\u0180Eas\u3316\u3318\u331B;\u6AB6p;\u6ABAim;\u62E9olint;\u6A13i\xED\u1204;\u4441ot\u0180;be\u3334\u1D47\u3335\u62C5;\u6A66\u0380Aacmstx\u3346\u334A\u3357\u335B\u335E\u3363\u336Drr;\u61D8r\u0100hr\u3350\u3352\xEB\u2228\u0100;o\u0A36\u0A34t\u803B\xA7\u40A7i;\u403Bwar;\u6929m\u0100in\u3369\xF0nu\xF3\xF1t;\u6736r\u0100;o\u3376\u2055\uC000\u{1D530}\u0200acoy\u3382\u3386\u3391\u33A0rp;\u666F\u0100hy\u338B\u338Fcy;\u4449;\u4448rt\u026D\u3399\0\0\u339Ci\xE4\u1464ara\xEC\u2E6F\u803B\xAD\u40AD\u0100gm\u33A8\u33B4ma\u0180;fv\u33B1\u33B2\u33B2\u43C3;\u43C2\u0400;deglnpr\u12AB\u33C5\u33C9\u33CE\u33D6\u33DE\u33E1\u33E6ot;\u6A6A\u0100;q\u12B1\u12B0\u0100;E\u33D3\u33D4\u6A9E;\u6AA0\u0100;E\u33DB\u33DC\u6A9D;\u6A9Fe;\u6246lus;\u6A24arr;\u6972ar\xF2\u113D\u0200aeit\u33F8\u3408\u340F\u3417\u0100ls\u33FD\u3404lsetm\xE9\u336Ahp;\u6A33parsl;\u69E4\u0100dl\u1463\u3414e;\u6323\u0100;e\u341C\u341D\u6AAA\u0100;s\u3422\u3423\u6AAC;\uC000\u2AAC\uFE00\u0180flp\u342E\u3433\u3442tcy;\u444C\u0100;b\u3438\u3439\u402F\u0100;a\u343E\u343F\u69C4r;\u633Ff;\uC000\u{1D564}a\u0100dr\u344D\u0402es\u0100;u\u3454\u3455\u6660it\xBB\u3455\u0180csu\u3460\u3479\u349F\u0100au\u3465\u346Fp\u0100;s\u1188\u346B;\uC000\u2293\uFE00p\u0100;s\u11B4\u3475;\uC000\u2294\uFE00u\u0100bp\u347F\u348F\u0180;es\u1197\u119C\u3486et\u0100;e\u1197\u348D\xF1\u119D\u0180;es\u11A8\u11AD\u3496et\u0100;e\u11A8\u349D\xF1\u11AE\u0180;af\u117B\u34A6\u05B0r\u0165\u34AB\u05B1\xBB\u117Car\xF2\u1148\u0200cemt\u34B9\u34BE\u34C2\u34C5r;\uC000\u{1D4C8}tm\xEE\xF1i\xEC\u3415ar\xE6\u11BE\u0100ar\u34CE\u34D5r\u0100;f\u34D4\u17BF\u6606\u0100an\u34DA\u34EDight\u0100ep\u34E3\u34EApsilo\xEE\u1EE0h\xE9\u2EAFs\xBB\u2852\u0280bcmnp\u34FB\u355E\u1209\u358B\u358E\u0480;Edemnprs\u350E\u350F\u3511\u3515\u351E\u3523\u352C\u3531\u3536\u6282;\u6AC5ot;\u6ABD\u0100;d\u11DA\u351Aot;\u6AC3ult;\u6AC1\u0100Ee\u3528\u352A;\u6ACB;\u628Alus;\u6ABFarr;\u6979\u0180eiu\u353D\u3552\u3555t\u0180;en\u350E\u3545\u354Bq\u0100;q\u11DA\u350Feq\u0100;q\u352B\u3528m;\u6AC7\u0100bp\u355A\u355C;\u6AD5;\u6AD3c\u0300;acens\u11ED\u356C\u3572\u3579\u357B\u3326ppro\xF8\u32FAurlye\xF1\u11FE\xF1\u11F3\u0180aes\u3582\u3588\u331Bppro\xF8\u331Aq\xF1\u3317g;\u666A\u0680123;Edehlmnps\u35A9\u35AC\u35AF\u121C\u35B2\u35B4\u35C0\u35C9\u35D5\u35DA\u35DF\u35E8\u35ED\u803B\xB9\u40B9\u803B\xB2\u40B2\u803B\xB3\u40B3;\u6AC6\u0100os\u35B9\u35BCt;\u6ABEub;\u6AD8\u0100;d\u1222\u35C5ot;\u6AC4s\u0100ou\u35CF\u35D2l;\u67C9b;\u6AD7arr;\u697Bult;\u6AC2\u0100Ee\u35E4\u35E6;\u6ACC;\u628Blus;\u6AC0\u0180eiu\u35F4\u3609\u360Ct\u0180;en\u121C\u35FC\u3602q\u0100;q\u1222\u35B2eq\u0100;q\u35E7\u35E4m;\u6AC8\u0100bp\u3611\u3613;\u6AD4;\u6AD6\u0180Aan\u361C\u3620\u362Drr;\u61D9r\u0100hr\u3626\u3628\xEB\u222E\u0100;o\u0A2B\u0A29war;\u692Alig\u803B\xDF\u40DF\u0BE1\u3651\u365D\u3660\u12CE\u3673\u3679\0\u367E\u36C2\0\0\0\0\0\u36DB\u3703\0\u3709\u376C\0\0\0\u3787\u0272\u3656\0\0\u365Bget;\u6316;\u43C4r\xEB\u0E5F\u0180aey\u3666\u366B\u3670ron;\u4165dil;\u4163;\u4442lrec;\u6315r;\uC000\u{1D531}\u0200eiko\u3686\u369D\u36B5\u36BC\u01F2\u368B\0\u3691e\u01004f\u1284\u1281a\u0180;sv\u3698\u3699\u369B\u43B8ym;\u43D1\u0100cn\u36A2\u36B2k\u0100as\u36A8\u36AEppro\xF8\u12C1im\xBB\u12ACs\xF0\u129E\u0100as\u36BA\u36AE\xF0\u12C1rn\u803B\xFE\u40FE\u01EC\u031F\u36C6\u22E7es\u8180\xD7;bd\u36CF\u36D0\u36D8\u40D7\u0100;a\u190F\u36D5r;\u6A31;\u6A30\u0180eps\u36E1\u36E3\u3700\xE1\u2A4D\u0200;bcf\u0486\u36EC\u36F0\u36F4ot;\u6336ir;\u6AF1\u0100;o\u36F9\u36FC\uC000\u{1D565}rk;\u6ADA\xE1\u3362rime;\u6034\u0180aip\u370F\u3712\u3764d\xE5\u1248\u0380adempst\u3721\u374D\u3740\u3751\u3757\u375C\u375Fngle\u0280;dlqr\u3730\u3731\u3736\u3740\u3742\u65B5own\xBB\u1DBBeft\u0100;e\u2800\u373E\xF1\u092E;\u625Cight\u0100;e\u32AA\u374B\xF1\u105Aot;\u65ECinus;\u6A3Alus;\u6A39b;\u69CDime;\u6A3Bezium;\u63E2\u0180cht\u3772\u377D\u3781\u0100ry\u3777\u377B;\uC000\u{1D4C9};\u4446cy;\u445Brok;\u4167\u0100io\u378B\u378Ex\xF4\u1777head\u0100lr\u3797\u37A0eftarro\xF7\u084Fightarrow\xBB\u0F5D\u0900AHabcdfghlmoprstuw\u37D0\u37D3\u37D7\u37E4\u37F0\u37FC\u380E\u381C\u3823\u3834\u3851\u385D\u386B\u38A9\u38CC\u38D2\u38EA\u38F6r\xF2\u03EDar;\u6963\u0100cr\u37DC\u37E2ute\u803B\xFA\u40FA\xF2\u1150r\u01E3\u37EA\0\u37EDy;\u445Eve;\u416D\u0100iy\u37F5\u37FArc\u803B\xFB\u40FB;\u4443\u0180abh\u3803\u3806\u380Br\xF2\u13ADlac;\u4171a\xF2\u13C3\u0100ir\u3813\u3818sht;\u697E;\uC000\u{1D532}rave\u803B\xF9\u40F9\u0161\u3827\u3831r\u0100lr\u382C\u382E\xBB\u0957\xBB\u1083lk;\u6580\u0100ct\u3839\u384D\u026F\u383F\0\0\u384Arn\u0100;e\u3845\u3846\u631Cr\xBB\u3846op;\u630Fri;\u65F8\u0100al\u3856\u385Acr;\u416B\u80BB\xA8\u0349\u0100gp\u3862\u3866on;\u4173f;\uC000\u{1D566}\u0300adhlsu\u114B\u3878\u387D\u1372\u3891\u38A0own\xE1\u13B3arpoon\u0100lr\u3888\u388Cef\xF4\u382Digh\xF4\u382Fi\u0180;hl\u3899\u389A\u389C\u43C5\xBB\u13FAon\xBB\u389Aparrows;\u61C8\u0180cit\u38B0\u38C4\u38C8\u026F\u38B6\0\0\u38C1rn\u0100;e\u38BC\u38BD\u631Dr\xBB\u38BDop;\u630Eng;\u416Fri;\u65F9cr;\uC000\u{1D4CA}\u0180dir\u38D9\u38DD\u38E2ot;\u62F0lde;\u4169i\u0100;f\u3730\u38E8\xBB\u1813\u0100am\u38EF\u38F2r\xF2\u38A8l\u803B\xFC\u40FCangle;\u69A7\u0780ABDacdeflnoprsz\u391C\u391F\u3929\u392D\u39B5\u39B8\u39BD\u39DF\u39E4\u39E8\u39F3\u39F9\u39FD\u3A01\u3A20r\xF2\u03F7ar\u0100;v\u3926\u3927\u6AE8;\u6AE9as\xE8\u03E1\u0100nr\u3932\u3937grt;\u699C\u0380eknprst\u34E3\u3946\u394B\u3952\u395D\u3964\u3996app\xE1\u2415othin\xE7\u1E96\u0180hir\u34EB\u2EC8\u3959op\xF4\u2FB5\u0100;h\u13B7\u3962\xEF\u318D\u0100iu\u3969\u396Dgm\xE1\u33B3\u0100bp\u3972\u3984setneq\u0100;q\u397D\u3980\uC000\u228A\uFE00;\uC000\u2ACB\uFE00setneq\u0100;q\u398F\u3992\uC000\u228B\uFE00;\uC000\u2ACC\uFE00\u0100hr\u399B\u399Fet\xE1\u369Ciangle\u0100lr\u39AA\u39AFeft\xBB\u0925ight\xBB\u1051y;\u4432ash\xBB\u1036\u0180elr\u39C4\u39D2\u39D7\u0180;be\u2DEA\u39CB\u39CFar;\u62BBq;\u625Alip;\u62EE\u0100bt\u39DC\u1468a\xF2\u1469r;\uC000\u{1D533}tr\xE9\u39AEsu\u0100bp\u39EF\u39F1\xBB\u0D1C\xBB\u0D59pf;\uC000\u{1D567}ro\xF0\u0EFBtr\xE9\u39B4\u0100cu\u3A06\u3A0Br;\uC000\u{1D4CB}\u0100bp\u3A10\u3A18n\u0100Ee\u3980\u3A16\xBB\u397En\u0100Ee\u3992\u3A1E\xBB\u3990igzag;\u699A\u0380cefoprs\u3A36\u3A3B\u3A56\u3A5B\u3A54\u3A61\u3A6Airc;\u4175\u0100di\u3A40\u3A51\u0100bg\u3A45\u3A49ar;\u6A5Fe\u0100;q\u15FA\u3A4F;\u6259erp;\u6118r;\uC000\u{1D534}pf;\uC000\u{1D568}\u0100;e\u1479\u3A66at\xE8\u1479cr;\uC000\u{1D4CC}\u0AE3\u178E\u3A87\0\u3A8B\0\u3A90\u3A9B\0\0\u3A9D\u3AA8\u3AAB\u3AAF\0\0\u3AC3\u3ACE\0\u3AD8\u17DC\u17DFtr\xE9\u17D1r;\uC000\u{1D535}\u0100Aa\u3A94\u3A97r\xF2\u03C3r\xF2\u09F6;\u43BE\u0100Aa\u3AA1\u3AA4r\xF2\u03B8r\xF2\u09EBa\xF0\u2713is;\u62FB\u0180dpt\u17A4\u3AB5\u3ABE\u0100fl\u3ABA\u17A9;\uC000\u{1D569}im\xE5\u17B2\u0100Aa\u3AC7\u3ACAr\xF2\u03CEr\xF2\u0A01\u0100cq\u3AD2\u17B8r;\uC000\u{1D4CD}\u0100pt\u17D6\u3ADCr\xE9\u17D4\u0400acefiosu\u3AF0\u3AFD\u3B08\u3B0C\u3B11\u3B15\u3B1B\u3B21c\u0100uy\u3AF6\u3AFBte\u803B\xFD\u40FD;\u444F\u0100iy\u3B02\u3B06rc;\u4177;\u444Bn\u803B\xA5\u40A5r;\uC000\u{1D536}cy;\u4457pf;\uC000\u{1D56A}cr;\uC000\u{1D4CE}\u0100cm\u3B26\u3B29y;\u444El\u803B\xFF\u40FF\u0500acdefhiosw\u3B42\u3B48\u3B54\u3B58\u3B64\u3B69\u3B6D\u3B74\u3B7A\u3B80cute;\u417A\u0100ay\u3B4D\u3B52ron;\u417E;\u4437ot;\u417C\u0100et\u3B5D\u3B61tr\xE6\u155Fa;\u43B6r;\uC000\u{1D537}cy;\u4436grarr;\u61DDpf;\uC000\u{1D56B}cr;\uC000\u{1D4CF}\u0100jn\u3B85\u3B87;\u600Dj;\u600C'.split("").map((c) => c.charCodeAt(0))
);

// node_modules/entities/lib/esm/generated/decode-data-xml.js
var decode_data_xml_default = new Uint16Array(
  // prettier-ignore
  "\u0200aglq	\x1B\u026D\0\0p;\u4026os;\u4027t;\u403Et;\u403Cuot;\u4022".split("").map((c) => c.charCodeAt(0))
);

// node_modules/entities/lib/esm/decode_codepoint.js
var _a;
var decodeMap = /* @__PURE__ */ new Map([
  [0, 65533],
  // C1 Unicode control character reference replacements
  [128, 8364],
  [130, 8218],
  [131, 402],
  [132, 8222],
  [133, 8230],
  [134, 8224],
  [135, 8225],
  [136, 710],
  [137, 8240],
  [138, 352],
  [139, 8249],
  [140, 338],
  [142, 381],
  [145, 8216],
  [146, 8217],
  [147, 8220],
  [148, 8221],
  [149, 8226],
  [150, 8211],
  [151, 8212],
  [152, 732],
  [153, 8482],
  [154, 353],
  [155, 8250],
  [156, 339],
  [158, 382],
  [159, 376]
]);
var fromCodePoint = (
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, node/no-unsupported-features/es-builtins
  (_a = String.fromCodePoint) !== null && _a !== void 0 ? _a : function(codePoint) {
    let output = "";
    if (codePoint > 65535) {
      codePoint -= 65536;
      output += String.fromCharCode(codePoint >>> 10 & 1023 | 55296);
      codePoint = 56320 | codePoint & 1023;
    }
    output += String.fromCharCode(codePoint);
    return output;
  }
);
function replaceCodePoint(codePoint) {
  var _a2;
  if (codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111) {
    return 65533;
  }
  return (_a2 = decodeMap.get(codePoint)) !== null && _a2 !== void 0 ? _a2 : codePoint;
}

// node_modules/entities/lib/esm/decode.js
var CharCodes;
(function(CharCodes2) {
  CharCodes2[CharCodes2["NUM"] = 35] = "NUM";
  CharCodes2[CharCodes2["SEMI"] = 59] = "SEMI";
  CharCodes2[CharCodes2["EQUALS"] = 61] = "EQUALS";
  CharCodes2[CharCodes2["ZERO"] = 48] = "ZERO";
  CharCodes2[CharCodes2["NINE"] = 57] = "NINE";
  CharCodes2[CharCodes2["LOWER_A"] = 97] = "LOWER_A";
  CharCodes2[CharCodes2["LOWER_F"] = 102] = "LOWER_F";
  CharCodes2[CharCodes2["LOWER_X"] = 120] = "LOWER_X";
  CharCodes2[CharCodes2["LOWER_Z"] = 122] = "LOWER_Z";
  CharCodes2[CharCodes2["UPPER_A"] = 65] = "UPPER_A";
  CharCodes2[CharCodes2["UPPER_F"] = 70] = "UPPER_F";
  CharCodes2[CharCodes2["UPPER_Z"] = 90] = "UPPER_Z";
})(CharCodes || (CharCodes = {}));
var TO_LOWER_BIT = 32;
var BinTrieFlags;
(function(BinTrieFlags2) {
  BinTrieFlags2[BinTrieFlags2["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
  BinTrieFlags2[BinTrieFlags2["BRANCH_LENGTH"] = 16256] = "BRANCH_LENGTH";
  BinTrieFlags2[BinTrieFlags2["JUMP_TABLE"] = 127] = "JUMP_TABLE";
})(BinTrieFlags || (BinTrieFlags = {}));
function isNumber(code) {
  return code >= CharCodes.ZERO && code <= CharCodes.NINE;
}
function isHexadecimalCharacter(code) {
  return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_F || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_F;
}
function isAsciiAlphaNumeric(code) {
  return code >= CharCodes.UPPER_A && code <= CharCodes.UPPER_Z || code >= CharCodes.LOWER_A && code <= CharCodes.LOWER_Z || isNumber(code);
}
function isEntityInAttributeInvalidEnd(code) {
  return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);
}
var EntityDecoderState;
(function(EntityDecoderState2) {
  EntityDecoderState2[EntityDecoderState2["EntityStart"] = 0] = "EntityStart";
  EntityDecoderState2[EntityDecoderState2["NumericStart"] = 1] = "NumericStart";
  EntityDecoderState2[EntityDecoderState2["NumericDecimal"] = 2] = "NumericDecimal";
  EntityDecoderState2[EntityDecoderState2["NumericHex"] = 3] = "NumericHex";
  EntityDecoderState2[EntityDecoderState2["NamedEntity"] = 4] = "NamedEntity";
})(EntityDecoderState || (EntityDecoderState = {}));
var DecodingMode;
(function(DecodingMode2) {
  DecodingMode2[DecodingMode2["Legacy"] = 0] = "Legacy";
  DecodingMode2[DecodingMode2["Strict"] = 1] = "Strict";
  DecodingMode2[DecodingMode2["Attribute"] = 2] = "Attribute";
})(DecodingMode || (DecodingMode = {}));
var EntityDecoder = class {
  constructor(decodeTree, emitCodePoint, errors) {
    this.decodeTree = decodeTree;
    this.emitCodePoint = emitCodePoint;
    this.errors = errors;
    this.state = EntityDecoderState.EntityStart;
    this.consumed = 1;
    this.result = 0;
    this.treeIndex = 0;
    this.excess = 1;
    this.decodeMode = DecodingMode.Strict;
  }
  /** Resets the instance to make it reusable. */
  startEntity(decodeMode) {
    this.decodeMode = decodeMode;
    this.state = EntityDecoderState.EntityStart;
    this.result = 0;
    this.treeIndex = 0;
    this.excess = 1;
    this.consumed = 1;
  }
  /**
   * Write an entity to the decoder. This can be called multiple times with partial entities.
   * If the entity is incomplete, the decoder will return -1.
   *
   * Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
   * entity is incomplete, and resume when the next string is written.
   *
   * @param string The string containing the entity (or a continuation of the entity).
   * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
   * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
   */
  write(str, offset) {
    switch (this.state) {
      case EntityDecoderState.EntityStart: {
        if (str.charCodeAt(offset) === CharCodes.NUM) {
          this.state = EntityDecoderState.NumericStart;
          this.consumed += 1;
          return this.stateNumericStart(str, offset + 1);
        }
        this.state = EntityDecoderState.NamedEntity;
        return this.stateNamedEntity(str, offset);
      }
      case EntityDecoderState.NumericStart: {
        return this.stateNumericStart(str, offset);
      }
      case EntityDecoderState.NumericDecimal: {
        return this.stateNumericDecimal(str, offset);
      }
      case EntityDecoderState.NumericHex: {
        return this.stateNumericHex(str, offset);
      }
      case EntityDecoderState.NamedEntity: {
        return this.stateNamedEntity(str, offset);
      }
    }
  }
  /**
   * Switches between the numeric decimal and hexadecimal states.
   *
   * Equivalent to the `Numeric character reference state` in the HTML spec.
   *
   * @param str The string containing the entity (or a continuation of the entity).
   * @param offset The current offset.
   * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
   */
  stateNumericStart(str, offset) {
    if (offset >= str.length) {
      return -1;
    }
    if ((str.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
      this.state = EntityDecoderState.NumericHex;
      this.consumed += 1;
      return this.stateNumericHex(str, offset + 1);
    }
    this.state = EntityDecoderState.NumericDecimal;
    return this.stateNumericDecimal(str, offset);
  }
  addToNumericResult(str, start, end, base) {
    if (start !== end) {
      const digitCount = end - start;
      this.result = this.result * Math.pow(base, digitCount) + parseInt(str.substr(start, digitCount), base);
      this.consumed += digitCount;
    }
  }
  /**
   * Parses a hexadecimal numeric entity.
   *
   * Equivalent to the `Hexademical character reference state` in the HTML spec.
   *
   * @param str The string containing the entity (or a continuation of the entity).
   * @param offset The current offset.
   * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
   */
  stateNumericHex(str, offset) {
    const startIdx = offset;
    while (offset < str.length) {
      const char = str.charCodeAt(offset);
      if (isNumber(char) || isHexadecimalCharacter(char)) {
        offset += 1;
      } else {
        this.addToNumericResult(str, startIdx, offset, 16);
        return this.emitNumericEntity(char, 3);
      }
    }
    this.addToNumericResult(str, startIdx, offset, 16);
    return -1;
  }
  /**
   * Parses a decimal numeric entity.
   *
   * Equivalent to the `Decimal character reference state` in the HTML spec.
   *
   * @param str The string containing the entity (or a continuation of the entity).
   * @param offset The current offset.
   * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
   */
  stateNumericDecimal(str, offset) {
    const startIdx = offset;
    while (offset < str.length) {
      const char = str.charCodeAt(offset);
      if (isNumber(char)) {
        offset += 1;
      } else {
        this.addToNumericResult(str, startIdx, offset, 10);
        return this.emitNumericEntity(char, 2);
      }
    }
    this.addToNumericResult(str, startIdx, offset, 10);
    return -1;
  }
  /**
   * Validate and emit a numeric entity.
   *
   * Implements the logic from the `Hexademical character reference start
   * state` and `Numeric character reference end state` in the HTML spec.
   *
   * @param lastCp The last code point of the entity. Used to see if the
   *               entity was terminated with a semicolon.
   * @param expectedLength The minimum number of characters that should be
   *                       consumed. Used to validate that at least one digit
   *                       was consumed.
   * @returns The number of characters that were consumed.
   */
  emitNumericEntity(lastCp, expectedLength) {
    var _a2;
    if (this.consumed <= expectedLength) {
      (_a2 = this.errors) === null || _a2 === void 0 ? void 0 : _a2.absenceOfDigitsInNumericCharacterReference(this.consumed);
      return 0;
    }
    if (lastCp === CharCodes.SEMI) {
      this.consumed += 1;
    } else if (this.decodeMode === DecodingMode.Strict) {
      return 0;
    }
    this.emitCodePoint(replaceCodePoint(this.result), this.consumed);
    if (this.errors) {
      if (lastCp !== CharCodes.SEMI) {
        this.errors.missingSemicolonAfterCharacterReference();
      }
      this.errors.validateNumericCharacterReference(this.result);
    }
    return this.consumed;
  }
  /**
   * Parses a named entity.
   *
   * Equivalent to the `Named character reference state` in the HTML spec.
   *
   * @param str The string containing the entity (or a continuation of the entity).
   * @param offset The current offset.
   * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
   */
  stateNamedEntity(str, offset) {
    const { decodeTree } = this;
    let current = decodeTree[this.treeIndex];
    let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
    for (; offset < str.length; offset++, this.excess++) {
      const char = str.charCodeAt(offset);
      this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);
      if (this.treeIndex < 0) {
        return this.result === 0 || // If we are parsing an attribute
        this.decodeMode === DecodingMode.Attribute && // We shouldn't have consumed any characters after the entity,
        (valueLength === 0 || // And there should be no invalid characters.
        isEntityInAttributeInvalidEnd(char)) ? 0 : this.emitNotTerminatedNamedEntity();
      }
      current = decodeTree[this.treeIndex];
      valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
      if (valueLength !== 0) {
        if (char === CharCodes.SEMI) {
          return this.emitNamedEntityData(this.treeIndex, valueLength, this.consumed + this.excess);
        }
        if (this.decodeMode !== DecodingMode.Strict) {
          this.result = this.treeIndex;
          this.consumed += this.excess;
          this.excess = 0;
        }
      }
    }
    return -1;
  }
  /**
   * Emit a named entity that was not terminated with a semicolon.
   *
   * @returns The number of characters consumed.
   */
  emitNotTerminatedNamedEntity() {
    var _a2;
    const { result, decodeTree } = this;
    const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;
    this.emitNamedEntityData(result, valueLength, this.consumed);
    (_a2 = this.errors) === null || _a2 === void 0 ? void 0 : _a2.missingSemicolonAfterCharacterReference();
    return this.consumed;
  }
  /**
   * Emit a named entity.
   *
   * @param result The index of the entity in the decode tree.
   * @param valueLength The number of bytes in the entity.
   * @param consumed The number of characters consumed.
   *
   * @returns The number of characters consumed.
   */
  emitNamedEntityData(result, valueLength, consumed) {
    const { decodeTree } = this;
    this.emitCodePoint(valueLength === 1 ? decodeTree[result] & ~BinTrieFlags.VALUE_LENGTH : decodeTree[result + 1], consumed);
    if (valueLength === 3) {
      this.emitCodePoint(decodeTree[result + 2], consumed);
    }
    return consumed;
  }
  /**
   * Signal to the parser that the end of the input was reached.
   *
   * Remaining data will be emitted and relevant errors will be produced.
   *
   * @returns The number of characters consumed.
   */
  end() {
    var _a2;
    switch (this.state) {
      case EntityDecoderState.NamedEntity: {
        return this.result !== 0 && (this.decodeMode !== DecodingMode.Attribute || this.result === this.treeIndex) ? this.emitNotTerminatedNamedEntity() : 0;
      }
      // Otherwise, emit a numeric entity if we have one.
      case EntityDecoderState.NumericDecimal: {
        return this.emitNumericEntity(0, 2);
      }
      case EntityDecoderState.NumericHex: {
        return this.emitNumericEntity(0, 3);
      }
      case EntityDecoderState.NumericStart: {
        (_a2 = this.errors) === null || _a2 === void 0 ? void 0 : _a2.absenceOfDigitsInNumericCharacterReference(this.consumed);
        return 0;
      }
      case EntityDecoderState.EntityStart: {
        return 0;
      }
    }
  }
};
function getDecoder(decodeTree) {
  let ret = "";
  const decoder = new EntityDecoder(decodeTree, (str) => ret += fromCodePoint(str));
  return function decodeWithTrie(str, decodeMode) {
    let lastIndex = 0;
    let offset = 0;
    while ((offset = str.indexOf("&", offset)) >= 0) {
      ret += str.slice(lastIndex, offset);
      decoder.startEntity(decodeMode);
      const len = decoder.write(
        str,
        // Skip the "&"
        offset + 1
      );
      if (len < 0) {
        lastIndex = offset + decoder.end();
        break;
      }
      lastIndex = offset + len;
      offset = len === 0 ? lastIndex + 1 : lastIndex;
    }
    const result = ret + str.slice(lastIndex);
    ret = "";
    return result;
  };
}
function determineBranch(decodeTree, current, nodeIdx, char) {
  const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
  const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
  if (branchCount === 0) {
    return jumpOffset !== 0 && char === jumpOffset ? nodeIdx : -1;
  }
  if (jumpOffset) {
    const value = char - jumpOffset;
    return value < 0 || value >= branchCount ? -1 : decodeTree[nodeIdx + value] - 1;
  }
  let lo = nodeIdx;
  let hi = lo + branchCount - 1;
  while (lo <= hi) {
    const mid = lo + hi >>> 1;
    const midVal = decodeTree[mid];
    if (midVal < char) {
      lo = mid + 1;
    } else if (midVal > char) {
      hi = mid - 1;
    } else {
      return decodeTree[mid + branchCount];
    }
  }
  return -1;
}
var htmlDecoder = getDecoder(decode_data_html_default);
var xmlDecoder = getDecoder(decode_data_xml_default);

// node_modules/parse5/dist/common/html.js
var html_exports = {};
__export(html_exports, {
  ATTRS: () => ATTRS,
  DOCUMENT_MODE: () => DOCUMENT_MODE,
  NS: () => NS,
  NUMBERED_HEADERS: () => NUMBERED_HEADERS,
  SPECIAL_ELEMENTS: () => SPECIAL_ELEMENTS,
  TAG_ID: () => TAG_ID,
  TAG_NAMES: () => TAG_NAMES,
  getTagID: () => getTagID,
  hasUnescapedText: () => hasUnescapedText
});
var NS;
(function(NS2) {
  NS2["HTML"] = "http://www.w3.org/1999/xhtml";
  NS2["MATHML"] = "http://www.w3.org/1998/Math/MathML";
  NS2["SVG"] = "http://www.w3.org/2000/svg";
  NS2["XLINK"] = "http://www.w3.org/1999/xlink";
  NS2["XML"] = "http://www.w3.org/XML/1998/namespace";
  NS2["XMLNS"] = "http://www.w3.org/2000/xmlns/";
})(NS || (NS = {}));
var ATTRS;
(function(ATTRS2) {
  ATTRS2["TYPE"] = "type";
  ATTRS2["ACTION"] = "action";
  ATTRS2["ENCODING"] = "encoding";
  ATTRS2["PROMPT"] = "prompt";
  ATTRS2["NAME"] = "name";
  ATTRS2["COLOR"] = "color";
  ATTRS2["FACE"] = "face";
  ATTRS2["SIZE"] = "size";
})(ATTRS || (ATTRS = {}));
var DOCUMENT_MODE;
(function(DOCUMENT_MODE2) {
  DOCUMENT_MODE2["NO_QUIRKS"] = "no-quirks";
  DOCUMENT_MODE2["QUIRKS"] = "quirks";
  DOCUMENT_MODE2["LIMITED_QUIRKS"] = "limited-quirks";
})(DOCUMENT_MODE || (DOCUMENT_MODE = {}));
var TAG_NAMES;
(function(TAG_NAMES2) {
  TAG_NAMES2["A"] = "a";
  TAG_NAMES2["ADDRESS"] = "address";
  TAG_NAMES2["ANNOTATION_XML"] = "annotation-xml";
  TAG_NAMES2["APPLET"] = "applet";
  TAG_NAMES2["AREA"] = "area";
  TAG_NAMES2["ARTICLE"] = "article";
  TAG_NAMES2["ASIDE"] = "aside";
  TAG_NAMES2["B"] = "b";
  TAG_NAMES2["BASE"] = "base";
  TAG_NAMES2["BASEFONT"] = "basefont";
  TAG_NAMES2["BGSOUND"] = "bgsound";
  TAG_NAMES2["BIG"] = "big";
  TAG_NAMES2["BLOCKQUOTE"] = "blockquote";
  TAG_NAMES2["BODY"] = "body";
  TAG_NAMES2["BR"] = "br";
  TAG_NAMES2["BUTTON"] = "button";
  TAG_NAMES2["CAPTION"] = "caption";
  TAG_NAMES2["CENTER"] = "center";
  TAG_NAMES2["CODE"] = "code";
  TAG_NAMES2["COL"] = "col";
  TAG_NAMES2["COLGROUP"] = "colgroup";
  TAG_NAMES2["DD"] = "dd";
  TAG_NAMES2["DESC"] = "desc";
  TAG_NAMES2["DETAILS"] = "details";
  TAG_NAMES2["DIALOG"] = "dialog";
  TAG_NAMES2["DIR"] = "dir";
  TAG_NAMES2["DIV"] = "div";
  TAG_NAMES2["DL"] = "dl";
  TAG_NAMES2["DT"] = "dt";
  TAG_NAMES2["EM"] = "em";
  TAG_NAMES2["EMBED"] = "embed";
  TAG_NAMES2["FIELDSET"] = "fieldset";
  TAG_NAMES2["FIGCAPTION"] = "figcaption";
  TAG_NAMES2["FIGURE"] = "figure";
  TAG_NAMES2["FONT"] = "font";
  TAG_NAMES2["FOOTER"] = "footer";
  TAG_NAMES2["FOREIGN_OBJECT"] = "foreignObject";
  TAG_NAMES2["FORM"] = "form";
  TAG_NAMES2["FRAME"] = "frame";
  TAG_NAMES2["FRAMESET"] = "frameset";
  TAG_NAMES2["H1"] = "h1";
  TAG_NAMES2["H2"] = "h2";
  TAG_NAMES2["H3"] = "h3";
  TAG_NAMES2["H4"] = "h4";
  TAG_NAMES2["H5"] = "h5";
  TAG_NAMES2["H6"] = "h6";
  TAG_NAMES2["HEAD"] = "head";
  TAG_NAMES2["HEADER"] = "header";
  TAG_NAMES2["HGROUP"] = "hgroup";
  TAG_NAMES2["HR"] = "hr";
  TAG_NAMES2["HTML"] = "html";
  TAG_NAMES2["I"] = "i";
  TAG_NAMES2["IMG"] = "img";
  TAG_NAMES2["IMAGE"] = "image";
  TAG_NAMES2["INPUT"] = "input";
  TAG_NAMES2["IFRAME"] = "iframe";
  TAG_NAMES2["KEYGEN"] = "keygen";
  TAG_NAMES2["LABEL"] = "label";
  TAG_NAMES2["LI"] = "li";
  TAG_NAMES2["LINK"] = "link";
  TAG_NAMES2["LISTING"] = "listing";
  TAG_NAMES2["MAIN"] = "main";
  TAG_NAMES2["MALIGNMARK"] = "malignmark";
  TAG_NAMES2["MARQUEE"] = "marquee";
  TAG_NAMES2["MATH"] = "math";
  TAG_NAMES2["MENU"] = "menu";
  TAG_NAMES2["META"] = "meta";
  TAG_NAMES2["MGLYPH"] = "mglyph";
  TAG_NAMES2["MI"] = "mi";
  TAG_NAMES2["MO"] = "mo";
  TAG_NAMES2["MN"] = "mn";
  TAG_NAMES2["MS"] = "ms";
  TAG_NAMES2["MTEXT"] = "mtext";
  TAG_NAMES2["NAV"] = "nav";
  TAG_NAMES2["NOBR"] = "nobr";
  TAG_NAMES2["NOFRAMES"] = "noframes";
  TAG_NAMES2["NOEMBED"] = "noembed";
  TAG_NAMES2["NOSCRIPT"] = "noscript";
  TAG_NAMES2["OBJECT"] = "object";
  TAG_NAMES2["OL"] = "ol";
  TAG_NAMES2["OPTGROUP"] = "optgroup";
  TAG_NAMES2["OPTION"] = "option";
  TAG_NAMES2["P"] = "p";
  TAG_NAMES2["PARAM"] = "param";
  TAG_NAMES2["PLAINTEXT"] = "plaintext";
  TAG_NAMES2["PRE"] = "pre";
  TAG_NAMES2["RB"] = "rb";
  TAG_NAMES2["RP"] = "rp";
  TAG_NAMES2["RT"] = "rt";
  TAG_NAMES2["RTC"] = "rtc";
  TAG_NAMES2["RUBY"] = "ruby";
  TAG_NAMES2["S"] = "s";
  TAG_NAMES2["SCRIPT"] = "script";
  TAG_NAMES2["SEARCH"] = "search";
  TAG_NAMES2["SECTION"] = "section";
  TAG_NAMES2["SELECT"] = "select";
  TAG_NAMES2["SOURCE"] = "source";
  TAG_NAMES2["SMALL"] = "small";
  TAG_NAMES2["SPAN"] = "span";
  TAG_NAMES2["STRIKE"] = "strike";
  TAG_NAMES2["STRONG"] = "strong";
  TAG_NAMES2["STYLE"] = "style";
  TAG_NAMES2["SUB"] = "sub";
  TAG_NAMES2["SUMMARY"] = "summary";
  TAG_NAMES2["SUP"] = "sup";
  TAG_NAMES2["TABLE"] = "table";
  TAG_NAMES2["TBODY"] = "tbody";
  TAG_NAMES2["TEMPLATE"] = "template";
  TAG_NAMES2["TEXTAREA"] = "textarea";
  TAG_NAMES2["TFOOT"] = "tfoot";
  TAG_NAMES2["TD"] = "td";
  TAG_NAMES2["TH"] = "th";
  TAG_NAMES2["THEAD"] = "thead";
  TAG_NAMES2["TITLE"] = "title";
  TAG_NAMES2["TR"] = "tr";
  TAG_NAMES2["TRACK"] = "track";
  TAG_NAMES2["TT"] = "tt";
  TAG_NAMES2["U"] = "u";
  TAG_NAMES2["UL"] = "ul";
  TAG_NAMES2["SVG"] = "svg";
  TAG_NAMES2["VAR"] = "var";
  TAG_NAMES2["WBR"] = "wbr";
  TAG_NAMES2["XMP"] = "xmp";
})(TAG_NAMES || (TAG_NAMES = {}));
var TAG_ID;
(function(TAG_ID2) {
  TAG_ID2[TAG_ID2["UNKNOWN"] = 0] = "UNKNOWN";
  TAG_ID2[TAG_ID2["A"] = 1] = "A";
  TAG_ID2[TAG_ID2["ADDRESS"] = 2] = "ADDRESS";
  TAG_ID2[TAG_ID2["ANNOTATION_XML"] = 3] = "ANNOTATION_XML";
  TAG_ID2[TAG_ID2["APPLET"] = 4] = "APPLET";
  TAG_ID2[TAG_ID2["AREA"] = 5] = "AREA";
  TAG_ID2[TAG_ID2["ARTICLE"] = 6] = "ARTICLE";
  TAG_ID2[TAG_ID2["ASIDE"] = 7] = "ASIDE";
  TAG_ID2[TAG_ID2["B"] = 8] = "B";
  TAG_ID2[TAG_ID2["BASE"] = 9] = "BASE";
  TAG_ID2[TAG_ID2["BASEFONT"] = 10] = "BASEFONT";
  TAG_ID2[TAG_ID2["BGSOUND"] = 11] = "BGSOUND";
  TAG_ID2[TAG_ID2["BIG"] = 12] = "BIG";
  TAG_ID2[TAG_ID2["BLOCKQUOTE"] = 13] = "BLOCKQUOTE";
  TAG_ID2[TAG_ID2["BODY"] = 14] = "BODY";
  TAG_ID2[TAG_ID2["BR"] = 15] = "BR";
  TAG_ID2[TAG_ID2["BUTTON"] = 16] = "BUTTON";
  TAG_ID2[TAG_ID2["CAPTION"] = 17] = "CAPTION";
  TAG_ID2[TAG_ID2["CENTER"] = 18] = "CENTER";
  TAG_ID2[TAG_ID2["CODE"] = 19] = "CODE";
  TAG_ID2[TAG_ID2["COL"] = 20] = "COL";
  TAG_ID2[TAG_ID2["COLGROUP"] = 21] = "COLGROUP";
  TAG_ID2[TAG_ID2["DD"] = 22] = "DD";
  TAG_ID2[TAG_ID2["DESC"] = 23] = "DESC";
  TAG_ID2[TAG_ID2["DETAILS"] = 24] = "DETAILS";
  TAG_ID2[TAG_ID2["DIALOG"] = 25] = "DIALOG";
  TAG_ID2[TAG_ID2["DIR"] = 26] = "DIR";
  TAG_ID2[TAG_ID2["DIV"] = 27] = "DIV";
  TAG_ID2[TAG_ID2["DL"] = 28] = "DL";
  TAG_ID2[TAG_ID2["DT"] = 29] = "DT";
  TAG_ID2[TAG_ID2["EM"] = 30] = "EM";
  TAG_ID2[TAG_ID2["EMBED"] = 31] = "EMBED";
  TAG_ID2[TAG_ID2["FIELDSET"] = 32] = "FIELDSET";
  TAG_ID2[TAG_ID2["FIGCAPTION"] = 33] = "FIGCAPTION";
  TAG_ID2[TAG_ID2["FIGURE"] = 34] = "FIGURE";
  TAG_ID2[TAG_ID2["FONT"] = 35] = "FONT";
  TAG_ID2[TAG_ID2["FOOTER"] = 36] = "FOOTER";
  TAG_ID2[TAG_ID2["FOREIGN_OBJECT"] = 37] = "FOREIGN_OBJECT";
  TAG_ID2[TAG_ID2["FORM"] = 38] = "FORM";
  TAG_ID2[TAG_ID2["FRAME"] = 39] = "FRAME";
  TAG_ID2[TAG_ID2["FRAMESET"] = 40] = "FRAMESET";
  TAG_ID2[TAG_ID2["H1"] = 41] = "H1";
  TAG_ID2[TAG_ID2["H2"] = 42] = "H2";
  TAG_ID2[TAG_ID2["H3"] = 43] = "H3";
  TAG_ID2[TAG_ID2["H4"] = 44] = "H4";
  TAG_ID2[TAG_ID2["H5"] = 45] = "H5";
  TAG_ID2[TAG_ID2["H6"] = 46] = "H6";
  TAG_ID2[TAG_ID2["HEAD"] = 47] = "HEAD";
  TAG_ID2[TAG_ID2["HEADER"] = 48] = "HEADER";
  TAG_ID2[TAG_ID2["HGROUP"] = 49] = "HGROUP";
  TAG_ID2[TAG_ID2["HR"] = 50] = "HR";
  TAG_ID2[TAG_ID2["HTML"] = 51] = "HTML";
  TAG_ID2[TAG_ID2["I"] = 52] = "I";
  TAG_ID2[TAG_ID2["IMG"] = 53] = "IMG";
  TAG_ID2[TAG_ID2["IMAGE"] = 54] = "IMAGE";
  TAG_ID2[TAG_ID2["INPUT"] = 55] = "INPUT";
  TAG_ID2[TAG_ID2["IFRAME"] = 56] = "IFRAME";
  TAG_ID2[TAG_ID2["KEYGEN"] = 57] = "KEYGEN";
  TAG_ID2[TAG_ID2["LABEL"] = 58] = "LABEL";
  TAG_ID2[TAG_ID2["LI"] = 59] = "LI";
  TAG_ID2[TAG_ID2["LINK"] = 60] = "LINK";
  TAG_ID2[TAG_ID2["LISTING"] = 61] = "LISTING";
  TAG_ID2[TAG_ID2["MAIN"] = 62] = "MAIN";
  TAG_ID2[TAG_ID2["MALIGNMARK"] = 63] = "MALIGNMARK";
  TAG_ID2[TAG_ID2["MARQUEE"] = 64] = "MARQUEE";
  TAG_ID2[TAG_ID2["MATH"] = 65] = "MATH";
  TAG_ID2[TAG_ID2["MENU"] = 66] = "MENU";
  TAG_ID2[TAG_ID2["META"] = 67] = "META";
  TAG_ID2[TAG_ID2["MGLYPH"] = 68] = "MGLYPH";
  TAG_ID2[TAG_ID2["MI"] = 69] = "MI";
  TAG_ID2[TAG_ID2["MO"] = 70] = "MO";
  TAG_ID2[TAG_ID2["MN"] = 71] = "MN";
  TAG_ID2[TAG_ID2["MS"] = 72] = "MS";
  TAG_ID2[TAG_ID2["MTEXT"] = 73] = "MTEXT";
  TAG_ID2[TAG_ID2["NAV"] = 74] = "NAV";
  TAG_ID2[TAG_ID2["NOBR"] = 75] = "NOBR";
  TAG_ID2[TAG_ID2["NOFRAMES"] = 76] = "NOFRAMES";
  TAG_ID2[TAG_ID2["NOEMBED"] = 77] = "NOEMBED";
  TAG_ID2[TAG_ID2["NOSCRIPT"] = 78] = "NOSCRIPT";
  TAG_ID2[TAG_ID2["OBJECT"] = 79] = "OBJECT";
  TAG_ID2[TAG_ID2["OL"] = 80] = "OL";
  TAG_ID2[TAG_ID2["OPTGROUP"] = 81] = "OPTGROUP";
  TAG_ID2[TAG_ID2["OPTION"] = 82] = "OPTION";
  TAG_ID2[TAG_ID2["P"] = 83] = "P";
  TAG_ID2[TAG_ID2["PARAM"] = 84] = "PARAM";
  TAG_ID2[TAG_ID2["PLAINTEXT"] = 85] = "PLAINTEXT";
  TAG_ID2[TAG_ID2["PRE"] = 86] = "PRE";
  TAG_ID2[TAG_ID2["RB"] = 87] = "RB";
  TAG_ID2[TAG_ID2["RP"] = 88] = "RP";
  TAG_ID2[TAG_ID2["RT"] = 89] = "RT";
  TAG_ID2[TAG_ID2["RTC"] = 90] = "RTC";
  TAG_ID2[TAG_ID2["RUBY"] = 91] = "RUBY";
  TAG_ID2[TAG_ID2["S"] = 92] = "S";
  TAG_ID2[TAG_ID2["SCRIPT"] = 93] = "SCRIPT";
  TAG_ID2[TAG_ID2["SEARCH"] = 94] = "SEARCH";
  TAG_ID2[TAG_ID2["SECTION"] = 95] = "SECTION";
  TAG_ID2[TAG_ID2["SELECT"] = 96] = "SELECT";
  TAG_ID2[TAG_ID2["SOURCE"] = 97] = "SOURCE";
  TAG_ID2[TAG_ID2["SMALL"] = 98] = "SMALL";
  TAG_ID2[TAG_ID2["SPAN"] = 99] = "SPAN";
  TAG_ID2[TAG_ID2["STRIKE"] = 100] = "STRIKE";
  TAG_ID2[TAG_ID2["STRONG"] = 101] = "STRONG";
  TAG_ID2[TAG_ID2["STYLE"] = 102] = "STYLE";
  TAG_ID2[TAG_ID2["SUB"] = 103] = "SUB";
  TAG_ID2[TAG_ID2["SUMMARY"] = 104] = "SUMMARY";
  TAG_ID2[TAG_ID2["SUP"] = 105] = "SUP";
  TAG_ID2[TAG_ID2["TABLE"] = 106] = "TABLE";
  TAG_ID2[TAG_ID2["TBODY"] = 107] = "TBODY";
  TAG_ID2[TAG_ID2["TEMPLATE"] = 108] = "TEMPLATE";
  TAG_ID2[TAG_ID2["TEXTAREA"] = 109] = "TEXTAREA";
  TAG_ID2[TAG_ID2["TFOOT"] = 110] = "TFOOT";
  TAG_ID2[TAG_ID2["TD"] = 111] = "TD";
  TAG_ID2[TAG_ID2["TH"] = 112] = "TH";
  TAG_ID2[TAG_ID2["THEAD"] = 113] = "THEAD";
  TAG_ID2[TAG_ID2["TITLE"] = 114] = "TITLE";
  TAG_ID2[TAG_ID2["TR"] = 115] = "TR";
  TAG_ID2[TAG_ID2["TRACK"] = 116] = "TRACK";
  TAG_ID2[TAG_ID2["TT"] = 117] = "TT";
  TAG_ID2[TAG_ID2["U"] = 118] = "U";
  TAG_ID2[TAG_ID2["UL"] = 119] = "UL";
  TAG_ID2[TAG_ID2["SVG"] = 120] = "SVG";
  TAG_ID2[TAG_ID2["VAR"] = 121] = "VAR";
  TAG_ID2[TAG_ID2["WBR"] = 122] = "WBR";
  TAG_ID2[TAG_ID2["XMP"] = 123] = "XMP";
})(TAG_ID || (TAG_ID = {}));
var TAG_NAME_TO_ID = /* @__PURE__ */ new Map([
  [TAG_NAMES.A, TAG_ID.A],
  [TAG_NAMES.ADDRESS, TAG_ID.ADDRESS],
  [TAG_NAMES.ANNOTATION_XML, TAG_ID.ANNOTATION_XML],
  [TAG_NAMES.APPLET, TAG_ID.APPLET],
  [TAG_NAMES.AREA, TAG_ID.AREA],
  [TAG_NAMES.ARTICLE, TAG_ID.ARTICLE],
  [TAG_NAMES.ASIDE, TAG_ID.ASIDE],
  [TAG_NAMES.B, TAG_ID.B],
  [TAG_NAMES.BASE, TAG_ID.BASE],
  [TAG_NAMES.BASEFONT, TAG_ID.BASEFONT],
  [TAG_NAMES.BGSOUND, TAG_ID.BGSOUND],
  [TAG_NAMES.BIG, TAG_ID.BIG],
  [TAG_NAMES.BLOCKQUOTE, TAG_ID.BLOCKQUOTE],
  [TAG_NAMES.BODY, TAG_ID.BODY],
  [TAG_NAMES.BR, TAG_ID.BR],
  [TAG_NAMES.BUTTON, TAG_ID.BUTTON],
  [TAG_NAMES.CAPTION, TAG_ID.CAPTION],
  [TAG_NAMES.CENTER, TAG_ID.CENTER],
  [TAG_NAMES.CODE, TAG_ID.CODE],
  [TAG_NAMES.COL, TAG_ID.COL],
  [TAG_NAMES.COLGROUP, TAG_ID.COLGROUP],
  [TAG_NAMES.DD, TAG_ID.DD],
  [TAG_NAMES.DESC, TAG_ID.DESC],
  [TAG_NAMES.DETAILS, TAG_ID.DETAILS],
  [TAG_NAMES.DIALOG, TAG_ID.DIALOG],
  [TAG_NAMES.DIR, TAG_ID.DIR],
  [TAG_NAMES.DIV, TAG_ID.DIV],
  [TAG_NAMES.DL, TAG_ID.DL],
  [TAG_NAMES.DT, TAG_ID.DT],
  [TAG_NAMES.EM, TAG_ID.EM],
  [TAG_NAMES.EMBED, TAG_ID.EMBED],
  [TAG_NAMES.FIELDSET, TAG_ID.FIELDSET],
  [TAG_NAMES.FIGCAPTION, TAG_ID.FIGCAPTION],
  [TAG_NAMES.FIGURE, TAG_ID.FIGURE],
  [TAG_NAMES.FONT, TAG_ID.FONT],
  [TAG_NAMES.FOOTER, TAG_ID.FOOTER],
  [TAG_NAMES.FOREIGN_OBJECT, TAG_ID.FOREIGN_OBJECT],
  [TAG_NAMES.FORM, TAG_ID.FORM],
  [TAG_NAMES.FRAME, TAG_ID.FRAME],
  [TAG_NAMES.FRAMESET, TAG_ID.FRAMESET],
  [TAG_NAMES.H1, TAG_ID.H1],
  [TAG_NAMES.H2, TAG_ID.H2],
  [TAG_NAMES.H3, TAG_ID.H3],
  [TAG_NAMES.H4, TAG_ID.H4],
  [TAG_NAMES.H5, TAG_ID.H5],
  [TAG_NAMES.H6, TAG_ID.H6],
  [TAG_NAMES.HEAD, TAG_ID.HEAD],
  [TAG_NAMES.HEADER, TAG_ID.HEADER],
  [TAG_NAMES.HGROUP, TAG_ID.HGROUP],
  [TAG_NAMES.HR, TAG_ID.HR],
  [TAG_NAMES.HTML, TAG_ID.HTML],
  [TAG_NAMES.I, TAG_ID.I],
  [TAG_NAMES.IMG, TAG_ID.IMG],
  [TAG_NAMES.IMAGE, TAG_ID.IMAGE],
  [TAG_NAMES.INPUT, TAG_ID.INPUT],
  [TAG_NAMES.IFRAME, TAG_ID.IFRAME],
  [TAG_NAMES.KEYGEN, TAG_ID.KEYGEN],
  [TAG_NAMES.LABEL, TAG_ID.LABEL],
  [TAG_NAMES.LI, TAG_ID.LI],
  [TAG_NAMES.LINK, TAG_ID.LINK],
  [TAG_NAMES.LISTING, TAG_ID.LISTING],
  [TAG_NAMES.MAIN, TAG_ID.MAIN],
  [TAG_NAMES.MALIGNMARK, TAG_ID.MALIGNMARK],
  [TAG_NAMES.MARQUEE, TAG_ID.MARQUEE],
  [TAG_NAMES.MATH, TAG_ID.MATH],
  [TAG_NAMES.MENU, TAG_ID.MENU],
  [TAG_NAMES.META, TAG_ID.META],
  [TAG_NAMES.MGLYPH, TAG_ID.MGLYPH],
  [TAG_NAMES.MI, TAG_ID.MI],
  [TAG_NAMES.MO, TAG_ID.MO],
  [TAG_NAMES.MN, TAG_ID.MN],
  [TAG_NAMES.MS, TAG_ID.MS],
  [TAG_NAMES.MTEXT, TAG_ID.MTEXT],
  [TAG_NAMES.NAV, TAG_ID.NAV],
  [TAG_NAMES.NOBR, TAG_ID.NOBR],
  [TAG_NAMES.NOFRAMES, TAG_ID.NOFRAMES],
  [TAG_NAMES.NOEMBED, TAG_ID.NOEMBED],
  [TAG_NAMES.NOSCRIPT, TAG_ID.NOSCRIPT],
  [TAG_NAMES.OBJECT, TAG_ID.OBJECT],
  [TAG_NAMES.OL, TAG_ID.OL],
  [TAG_NAMES.OPTGROUP, TAG_ID.OPTGROUP],
  [TAG_NAMES.OPTION, TAG_ID.OPTION],
  [TAG_NAMES.P, TAG_ID.P],
  [TAG_NAMES.PARAM, TAG_ID.PARAM],
  [TAG_NAMES.PLAINTEXT, TAG_ID.PLAINTEXT],
  [TAG_NAMES.PRE, TAG_ID.PRE],
  [TAG_NAMES.RB, TAG_ID.RB],
  [TAG_NAMES.RP, TAG_ID.RP],
  [TAG_NAMES.RT, TAG_ID.RT],
  [TAG_NAMES.RTC, TAG_ID.RTC],
  [TAG_NAMES.RUBY, TAG_ID.RUBY],
  [TAG_NAMES.S, TAG_ID.S],
  [TAG_NAMES.SCRIPT, TAG_ID.SCRIPT],
  [TAG_NAMES.SEARCH, TAG_ID.SEARCH],
  [TAG_NAMES.SECTION, TAG_ID.SECTION],
  [TAG_NAMES.SELECT, TAG_ID.SELECT],
  [TAG_NAMES.SOURCE, TAG_ID.SOURCE],
  [TAG_NAMES.SMALL, TAG_ID.SMALL],
  [TAG_NAMES.SPAN, TAG_ID.SPAN],
  [TAG_NAMES.STRIKE, TAG_ID.STRIKE],
  [TAG_NAMES.STRONG, TAG_ID.STRONG],
  [TAG_NAMES.STYLE, TAG_ID.STYLE],
  [TAG_NAMES.SUB, TAG_ID.SUB],
  [TAG_NAMES.SUMMARY, TAG_ID.SUMMARY],
  [TAG_NAMES.SUP, TAG_ID.SUP],
  [TAG_NAMES.TABLE, TAG_ID.TABLE],
  [TAG_NAMES.TBODY, TAG_ID.TBODY],
  [TAG_NAMES.TEMPLATE, TAG_ID.TEMPLATE],
  [TAG_NAMES.TEXTAREA, TAG_ID.TEXTAREA],
  [TAG_NAMES.TFOOT, TAG_ID.TFOOT],
  [TAG_NAMES.TD, TAG_ID.TD],
  [TAG_NAMES.TH, TAG_ID.TH],
  [TAG_NAMES.THEAD, TAG_ID.THEAD],
  [TAG_NAMES.TITLE, TAG_ID.TITLE],
  [TAG_NAMES.TR, TAG_ID.TR],
  [TAG_NAMES.TRACK, TAG_ID.TRACK],
  [TAG_NAMES.TT, TAG_ID.TT],
  [TAG_NAMES.U, TAG_ID.U],
  [TAG_NAMES.UL, TAG_ID.UL],
  [TAG_NAMES.SVG, TAG_ID.SVG],
  [TAG_NAMES.VAR, TAG_ID.VAR],
  [TAG_NAMES.WBR, TAG_ID.WBR],
  [TAG_NAMES.XMP, TAG_ID.XMP]
]);
function getTagID(tagName) {
  var _a2;
  return (_a2 = TAG_NAME_TO_ID.get(tagName)) !== null && _a2 !== void 0 ? _a2 : TAG_ID.UNKNOWN;
}
var $ = TAG_ID;
var SPECIAL_ELEMENTS = {
  [NS.HTML]: /* @__PURE__ */ new Set([
    $.ADDRESS,
    $.APPLET,
    $.AREA,
    $.ARTICLE,
    $.ASIDE,
    $.BASE,
    $.BASEFONT,
    $.BGSOUND,
    $.BLOCKQUOTE,
    $.BODY,
    $.BR,
    $.BUTTON,
    $.CAPTION,
    $.CENTER,
    $.COL,
    $.COLGROUP,
    $.DD,
    $.DETAILS,
    $.DIR,
    $.DIV,
    $.DL,
    $.DT,
    $.EMBED,
    $.FIELDSET,
    $.FIGCAPTION,
    $.FIGURE,
    $.FOOTER,
    $.FORM,
    $.FRAME,
    $.FRAMESET,
    $.H1,
    $.H2,
    $.H3,
    $.H4,
    $.H5,
    $.H6,
    $.HEAD,
    $.HEADER,
    $.HGROUP,
    $.HR,
    $.HTML,
    $.IFRAME,
    $.IMG,
    $.INPUT,
    $.LI,
    $.LINK,
    $.LISTING,
    $.MAIN,
    $.MARQUEE,
    $.MENU,
    $.META,
    $.NAV,
    $.NOEMBED,
    $.NOFRAMES,
    $.NOSCRIPT,
    $.OBJECT,
    $.OL,
    $.P,
    $.PARAM,
    $.PLAINTEXT,
    $.PRE,
    $.SCRIPT,
    $.SECTION,
    $.SELECT,
    $.SOURCE,
    $.STYLE,
    $.SUMMARY,
    $.TABLE,
    $.TBODY,
    $.TD,
    $.TEMPLATE,
    $.TEXTAREA,
    $.TFOOT,
    $.TH,
    $.THEAD,
    $.TITLE,
    $.TR,
    $.TRACK,
    $.UL,
    $.WBR,
    $.XMP
  ]),
  [NS.MATHML]: /* @__PURE__ */ new Set([$.MI, $.MO, $.MN, $.MS, $.MTEXT, $.ANNOTATION_XML]),
  [NS.SVG]: /* @__PURE__ */ new Set([$.TITLE, $.FOREIGN_OBJECT, $.DESC]),
  [NS.XLINK]: /* @__PURE__ */ new Set(),
  [NS.XML]: /* @__PURE__ */ new Set(),
  [NS.XMLNS]: /* @__PURE__ */ new Set()
};
var NUMBERED_HEADERS = /* @__PURE__ */ new Set([$.H1, $.H2, $.H3, $.H4, $.H5, $.H6]);
var UNESCAPED_TEXT = /* @__PURE__ */ new Set([
  TAG_NAMES.STYLE,
  TAG_NAMES.SCRIPT,
  TAG_NAMES.XMP,
  TAG_NAMES.IFRAME,
  TAG_NAMES.NOEMBED,
  TAG_NAMES.NOFRAMES,
  TAG_NAMES.PLAINTEXT
]);
function hasUnescapedText(tn, scriptingEnabled) {
  return UNESCAPED_TEXT.has(tn) || scriptingEnabled && tn === TAG_NAMES.NOSCRIPT;
}

// node_modules/parse5/dist/tokenizer/index.js
var State;
(function(State2) {
  State2[State2["DATA"] = 0] = "DATA";
  State2[State2["RCDATA"] = 1] = "RCDATA";
  State2[State2["RAWTEXT"] = 2] = "RAWTEXT";
  State2[State2["SCRIPT_DATA"] = 3] = "SCRIPT_DATA";
  State2[State2["PLAINTEXT"] = 4] = "PLAINTEXT";
  State2[State2["TAG_OPEN"] = 5] = "TAG_OPEN";
  State2[State2["END_TAG_OPEN"] = 6] = "END_TAG_OPEN";
  State2[State2["TAG_NAME"] = 7] = "TAG_NAME";
  State2[State2["RCDATA_LESS_THAN_SIGN"] = 8] = "RCDATA_LESS_THAN_SIGN";
  State2[State2["RCDATA_END_TAG_OPEN"] = 9] = "RCDATA_END_TAG_OPEN";
  State2[State2["RCDATA_END_TAG_NAME"] = 10] = "RCDATA_END_TAG_NAME";
  State2[State2["RAWTEXT_LESS_THAN_SIGN"] = 11] = "RAWTEXT_LESS_THAN_SIGN";
  State2[State2["RAWTEXT_END_TAG_OPEN"] = 12] = "RAWTEXT_END_TAG_OPEN";
  State2[State2["RAWTEXT_END_TAG_NAME"] = 13] = "RAWTEXT_END_TAG_NAME";
  State2[State2["SCRIPT_DATA_LESS_THAN_SIGN"] = 14] = "SCRIPT_DATA_LESS_THAN_SIGN";
  State2[State2["SCRIPT_DATA_END_TAG_OPEN"] = 15] = "SCRIPT_DATA_END_TAG_OPEN";
  State2[State2["SCRIPT_DATA_END_TAG_NAME"] = 16] = "SCRIPT_DATA_END_TAG_NAME";
  State2[State2["SCRIPT_DATA_ESCAPE_START"] = 17] = "SCRIPT_DATA_ESCAPE_START";
  State2[State2["SCRIPT_DATA_ESCAPE_START_DASH"] = 18] = "SCRIPT_DATA_ESCAPE_START_DASH";
  State2[State2["SCRIPT_DATA_ESCAPED"] = 19] = "SCRIPT_DATA_ESCAPED";
  State2[State2["SCRIPT_DATA_ESCAPED_DASH"] = 20] = "SCRIPT_DATA_ESCAPED_DASH";
  State2[State2["SCRIPT_DATA_ESCAPED_DASH_DASH"] = 21] = "SCRIPT_DATA_ESCAPED_DASH_DASH";
  State2[State2["SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN"] = 22] = "SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN";
  State2[State2["SCRIPT_DATA_ESCAPED_END_TAG_OPEN"] = 23] = "SCRIPT_DATA_ESCAPED_END_TAG_OPEN";
  State2[State2["SCRIPT_DATA_ESCAPED_END_TAG_NAME"] = 24] = "SCRIPT_DATA_ESCAPED_END_TAG_NAME";
  State2[State2["SCRIPT_DATA_DOUBLE_ESCAPE_START"] = 25] = "SCRIPT_DATA_DOUBLE_ESCAPE_START";
  State2[State2["SCRIPT_DATA_DOUBLE_ESCAPED"] = 26] = "SCRIPT_DATA_DOUBLE_ESCAPED";
  State2[State2["SCRIPT_DATA_DOUBLE_ESCAPED_DASH"] = 27] = "SCRIPT_DATA_DOUBLE_ESCAPED_DASH";
  State2[State2["SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH"] = 28] = "SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH";
  State2[State2["SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN"] = 29] = "SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN";
  State2[State2["SCRIPT_DATA_DOUBLE_ESCAPE_END"] = 30] = "SCRIPT_DATA_DOUBLE_ESCAPE_END";
  State2[State2["BEFORE_ATTRIBUTE_NAME"] = 31] = "BEFORE_ATTRIBUTE_NAME";
  State2[State2["ATTRIBUTE_NAME"] = 32] = "ATTRIBUTE_NAME";
  State2[State2["AFTER_ATTRIBUTE_NAME"] = 33] = "AFTER_ATTRIBUTE_NAME";
  State2[State2["BEFORE_ATTRIBUTE_VALUE"] = 34] = "BEFORE_ATTRIBUTE_VALUE";
  State2[State2["ATTRIBUTE_VALUE_DOUBLE_QUOTED"] = 35] = "ATTRIBUTE_VALUE_DOUBLE_QUOTED";
  State2[State2["ATTRIBUTE_VALUE_SINGLE_QUOTED"] = 36] = "ATTRIBUTE_VALUE_SINGLE_QUOTED";
  State2[State2["ATTRIBUTE_VALUE_UNQUOTED"] = 37] = "ATTRIBUTE_VALUE_UNQUOTED";
  State2[State2["AFTER_ATTRIBUTE_VALUE_QUOTED"] = 38] = "AFTER_ATTRIBUTE_VALUE_QUOTED";
  State2[State2["SELF_CLOSING_START_TAG"] = 39] = "SELF_CLOSING_START_TAG";
  State2[State2["BOGUS_COMMENT"] = 40] = "BOGUS_COMMENT";
  State2[State2["MARKUP_DECLARATION_OPEN"] = 41] = "MARKUP_DECLARATION_OPEN";
  State2[State2["COMMENT_START"] = 42] = "COMMENT_START";
  State2[State2["COMMENT_START_DASH"] = 43] = "COMMENT_START_DASH";
  State2[State2["COMMENT"] = 44] = "COMMENT";
  State2[State2["COMMENT_LESS_THAN_SIGN"] = 45] = "COMMENT_LESS_THAN_SIGN";
  State2[State2["COMMENT_LESS_THAN_SIGN_BANG"] = 46] = "COMMENT_LESS_THAN_SIGN_BANG";
  State2[State2["COMMENT_LESS_THAN_SIGN_BANG_DASH"] = 47] = "COMMENT_LESS_THAN_SIGN_BANG_DASH";
  State2[State2["COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH"] = 48] = "COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH";
  State2[State2["COMMENT_END_DASH"] = 49] = "COMMENT_END_DASH";
  State2[State2["COMMENT_END"] = 50] = "COMMENT_END";
  State2[State2["COMMENT_END_BANG"] = 51] = "COMMENT_END_BANG";
  State2[State2["DOCTYPE"] = 52] = "DOCTYPE";
  State2[State2["BEFORE_DOCTYPE_NAME"] = 53] = "BEFORE_DOCTYPE_NAME";
  State2[State2["DOCTYPE_NAME"] = 54] = "DOCTYPE_NAME";
  State2[State2["AFTER_DOCTYPE_NAME"] = 55] = "AFTER_DOCTYPE_NAME";
  State2[State2["AFTER_DOCTYPE_PUBLIC_KEYWORD"] = 56] = "AFTER_DOCTYPE_PUBLIC_KEYWORD";
  State2[State2["BEFORE_DOCTYPE_PUBLIC_IDENTIFIER"] = 57] = "BEFORE_DOCTYPE_PUBLIC_IDENTIFIER";
  State2[State2["DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED"] = 58] = "DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED";
  State2[State2["DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED"] = 59] = "DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED";
  State2[State2["AFTER_DOCTYPE_PUBLIC_IDENTIFIER"] = 60] = "AFTER_DOCTYPE_PUBLIC_IDENTIFIER";
  State2[State2["BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS"] = 61] = "BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS";
  State2[State2["AFTER_DOCTYPE_SYSTEM_KEYWORD"] = 62] = "AFTER_DOCTYPE_SYSTEM_KEYWORD";
  State2[State2["BEFORE_DOCTYPE_SYSTEM_IDENTIFIER"] = 63] = "BEFORE_DOCTYPE_SYSTEM_IDENTIFIER";
  State2[State2["DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED"] = 64] = "DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED";
  State2[State2["DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED"] = 65] = "DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED";
  State2[State2["AFTER_DOCTYPE_SYSTEM_IDENTIFIER"] = 66] = "AFTER_DOCTYPE_SYSTEM_IDENTIFIER";
  State2[State2["BOGUS_DOCTYPE"] = 67] = "BOGUS_DOCTYPE";
  State2[State2["CDATA_SECTION"] = 68] = "CDATA_SECTION";
  State2[State2["CDATA_SECTION_BRACKET"] = 69] = "CDATA_SECTION_BRACKET";
  State2[State2["CDATA_SECTION_END"] = 70] = "CDATA_SECTION_END";
  State2[State2["CHARACTER_REFERENCE"] = 71] = "CHARACTER_REFERENCE";
  State2[State2["AMBIGUOUS_AMPERSAND"] = 72] = "AMBIGUOUS_AMPERSAND";
})(State || (State = {}));
var TokenizerMode = {
  DATA: State.DATA,
  RCDATA: State.RCDATA,
  RAWTEXT: State.RAWTEXT,
  SCRIPT_DATA: State.SCRIPT_DATA,
  PLAINTEXT: State.PLAINTEXT,
  CDATA_SECTION: State.CDATA_SECTION
};
function isAsciiDigit(cp) {
  return cp >= CODE_POINTS.DIGIT_0 && cp <= CODE_POINTS.DIGIT_9;
}
function isAsciiUpper(cp) {
  return cp >= CODE_POINTS.LATIN_CAPITAL_A && cp <= CODE_POINTS.LATIN_CAPITAL_Z;
}
function isAsciiLower(cp) {
  return cp >= CODE_POINTS.LATIN_SMALL_A && cp <= CODE_POINTS.LATIN_SMALL_Z;
}
function isAsciiLetter(cp) {
  return isAsciiLower(cp) || isAsciiUpper(cp);
}
function isAsciiAlphaNumeric2(cp) {
  return isAsciiLetter(cp) || isAsciiDigit(cp);
}
function toAsciiLower(cp) {
  return cp + 32;
}
function isWhitespace(cp) {
  return cp === CODE_POINTS.SPACE || cp === CODE_POINTS.LINE_FEED || cp === CODE_POINTS.TABULATION || cp === CODE_POINTS.FORM_FEED;
}
function isScriptDataDoubleEscapeSequenceEnd(cp) {
  return isWhitespace(cp) || cp === CODE_POINTS.SOLIDUS || cp === CODE_POINTS.GREATER_THAN_SIGN;
}
function getErrorForNumericCharacterReference(code) {
  if (code === CODE_POINTS.NULL) {
    return ERR.nullCharacterReference;
  } else if (code > 1114111) {
    return ERR.characterReferenceOutsideUnicodeRange;
  } else if (isSurrogate(code)) {
    return ERR.surrogateCharacterReference;
  } else if (isUndefinedCodePoint(code)) {
    return ERR.noncharacterCharacterReference;
  } else if (isControlCodePoint(code) || code === CODE_POINTS.CARRIAGE_RETURN) {
    return ERR.controlCharacterReference;
  }
  return null;
}
var Tokenizer = class {
  constructor(options, handler) {
    this.options = options;
    this.handler = handler;
    this.paused = false;
    this.inLoop = false;
    this.inForeignNode = false;
    this.lastStartTagName = "";
    this.active = false;
    this.state = State.DATA;
    this.returnState = State.DATA;
    this.entityStartPos = 0;
    this.consumedAfterSnapshot = -1;
    this.currentCharacterToken = null;
    this.currentToken = null;
    this.currentAttr = { name: "", value: "" };
    this.preprocessor = new Preprocessor(handler);
    this.currentLocation = this.getCurrentLocation(-1);
    this.entityDecoder = new EntityDecoder(decode_data_html_default, (cp, consumed) => {
      this.preprocessor.pos = this.entityStartPos + consumed - 1;
      this._flushCodePointConsumedAsCharacterReference(cp);
    }, handler.onParseError ? {
      missingSemicolonAfterCharacterReference: () => {
        this._err(ERR.missingSemicolonAfterCharacterReference, 1);
      },
      absenceOfDigitsInNumericCharacterReference: (consumed) => {
        this._err(ERR.absenceOfDigitsInNumericCharacterReference, this.entityStartPos - this.preprocessor.pos + consumed);
      },
      validateNumericCharacterReference: (code) => {
        const error = getErrorForNumericCharacterReference(code);
        if (error)
          this._err(error, 1);
      }
    } : void 0);
  }
  //Errors
  _err(code, cpOffset = 0) {
    var _a2, _b;
    (_b = (_a2 = this.handler).onParseError) === null || _b === void 0 ? void 0 : _b.call(_a2, this.preprocessor.getError(code, cpOffset));
  }
  // NOTE: `offset` may never run across line boundaries.
  getCurrentLocation(offset) {
    if (!this.options.sourceCodeLocationInfo) {
      return null;
    }
    return {
      startLine: this.preprocessor.line,
      startCol: this.preprocessor.col - offset,
      startOffset: this.preprocessor.offset - offset,
      endLine: -1,
      endCol: -1,
      endOffset: -1
    };
  }
  _runParsingLoop() {
    if (this.inLoop)
      return;
    this.inLoop = true;
    while (this.active && !this.paused) {
      this.consumedAfterSnapshot = 0;
      const cp = this._consume();
      if (!this._ensureHibernation()) {
        this._callState(cp);
      }
    }
    this.inLoop = false;
  }
  //API
  pause() {
    this.paused = true;
  }
  resume(writeCallback) {
    if (!this.paused) {
      throw new Error("Parser was already resumed");
    }
    this.paused = false;
    if (this.inLoop)
      return;
    this._runParsingLoop();
    if (!this.paused) {
      writeCallback === null || writeCallback === void 0 ? void 0 : writeCallback();
    }
  }
  write(chunk, isLastChunk, writeCallback) {
    this.active = true;
    this.preprocessor.write(chunk, isLastChunk);
    this._runParsingLoop();
    if (!this.paused) {
      writeCallback === null || writeCallback === void 0 ? void 0 : writeCallback();
    }
  }
  insertHtmlAtCurrentPos(chunk) {
    this.active = true;
    this.preprocessor.insertHtmlAtCurrentPos(chunk);
    this._runParsingLoop();
  }
  //Hibernation
  _ensureHibernation() {
    if (this.preprocessor.endOfChunkHit) {
      this.preprocessor.retreat(this.consumedAfterSnapshot);
      this.consumedAfterSnapshot = 0;
      this.active = false;
      return true;
    }
    return false;
  }
  //Consumption
  _consume() {
    this.consumedAfterSnapshot++;
    return this.preprocessor.advance();
  }
  _advanceBy(count) {
    this.consumedAfterSnapshot += count;
    for (let i = 0; i < count; i++) {
      this.preprocessor.advance();
    }
  }
  _consumeSequenceIfMatch(pattern, caseSensitive) {
    if (this.preprocessor.startsWith(pattern, caseSensitive)) {
      this._advanceBy(pattern.length - 1);
      return true;
    }
    return false;
  }
  //Token creation
  _createStartTagToken() {
    this.currentToken = {
      type: TokenType.START_TAG,
      tagName: "",
      tagID: TAG_ID.UNKNOWN,
      selfClosing: false,
      ackSelfClosing: false,
      attrs: [],
      location: this.getCurrentLocation(1)
    };
  }
  _createEndTagToken() {
    this.currentToken = {
      type: TokenType.END_TAG,
      tagName: "",
      tagID: TAG_ID.UNKNOWN,
      selfClosing: false,
      ackSelfClosing: false,
      attrs: [],
      location: this.getCurrentLocation(2)
    };
  }
  _createCommentToken(offset) {
    this.currentToken = {
      type: TokenType.COMMENT,
      data: "",
      location: this.getCurrentLocation(offset)
    };
  }
  _createDoctypeToken(initialName) {
    this.currentToken = {
      type: TokenType.DOCTYPE,
      name: initialName,
      forceQuirks: false,
      publicId: null,
      systemId: null,
      location: this.currentLocation
    };
  }
  _createCharacterToken(type, chars) {
    this.currentCharacterToken = {
      type,
      chars,
      location: this.currentLocation
    };
  }
  //Tag attributes
  _createAttr(attrNameFirstCh) {
    this.currentAttr = {
      name: attrNameFirstCh,
      value: ""
    };
    this.currentLocation = this.getCurrentLocation(0);
  }
  _leaveAttrName() {
    var _a2;
    var _b;
    const token = this.currentToken;
    if (getTokenAttr(token, this.currentAttr.name) === null) {
      token.attrs.push(this.currentAttr);
      if (token.location && this.currentLocation) {
        const attrLocations = (_a2 = (_b = token.location).attrs) !== null && _a2 !== void 0 ? _a2 : _b.attrs = /* @__PURE__ */ Object.create(null);
        attrLocations[this.currentAttr.name] = this.currentLocation;
        this._leaveAttrValue();
      }
    } else {
      this._err(ERR.duplicateAttribute);
    }
  }
  _leaveAttrValue() {
    if (this.currentLocation) {
      this.currentLocation.endLine = this.preprocessor.line;
      this.currentLocation.endCol = this.preprocessor.col;
      this.currentLocation.endOffset = this.preprocessor.offset;
    }
  }
  //Token emission
  prepareToken(ct) {
    this._emitCurrentCharacterToken(ct.location);
    this.currentToken = null;
    if (ct.location) {
      ct.location.endLine = this.preprocessor.line;
      ct.location.endCol = this.preprocessor.col + 1;
      ct.location.endOffset = this.preprocessor.offset + 1;
    }
    this.currentLocation = this.getCurrentLocation(-1);
  }
  emitCurrentTagToken() {
    const ct = this.currentToken;
    this.prepareToken(ct);
    ct.tagID = getTagID(ct.tagName);
    if (ct.type === TokenType.START_TAG) {
      this.lastStartTagName = ct.tagName;
      this.handler.onStartTag(ct);
    } else {
      if (ct.attrs.length > 0) {
        this._err(ERR.endTagWithAttributes);
      }
      if (ct.selfClosing) {
        this._err(ERR.endTagWithTrailingSolidus);
      }
      this.handler.onEndTag(ct);
    }
    this.preprocessor.dropParsedChunk();
  }
  emitCurrentComment(ct) {
    this.prepareToken(ct);
    this.handler.onComment(ct);
    this.preprocessor.dropParsedChunk();
  }
  emitCurrentDoctype(ct) {
    this.prepareToken(ct);
    this.handler.onDoctype(ct);
    this.preprocessor.dropParsedChunk();
  }
  _emitCurrentCharacterToken(nextLocation) {
    if (this.currentCharacterToken) {
      if (nextLocation && this.currentCharacterToken.location) {
        this.currentCharacterToken.location.endLine = nextLocation.startLine;
        this.currentCharacterToken.location.endCol = nextLocation.startCol;
        this.currentCharacterToken.location.endOffset = nextLocation.startOffset;
      }
      switch (this.currentCharacterToken.type) {
        case TokenType.CHARACTER: {
          this.handler.onCharacter(this.currentCharacterToken);
          break;
        }
        case TokenType.NULL_CHARACTER: {
          this.handler.onNullCharacter(this.currentCharacterToken);
          break;
        }
        case TokenType.WHITESPACE_CHARACTER: {
          this.handler.onWhitespaceCharacter(this.currentCharacterToken);
          break;
        }
      }
      this.currentCharacterToken = null;
    }
  }
  _emitEOFToken() {
    const location2 = this.getCurrentLocation(0);
    if (location2) {
      location2.endLine = location2.startLine;
      location2.endCol = location2.startCol;
      location2.endOffset = location2.startOffset;
    }
    this._emitCurrentCharacterToken(location2);
    this.handler.onEof({ type: TokenType.EOF, location: location2 });
    this.active = false;
  }
  //Characters emission
  //OPTIMIZATION: The specification uses only one type of character token (one token per character).
  //This causes a huge memory overhead and a lot of unnecessary parser loops. parse5 uses 3 groups of characters.
  //If we have a sequence of characters that belong to the same group, the parser can process it
  //as a single solid character token.
  //So, there are 3 types of character tokens in parse5:
  //1)TokenType.NULL_CHARACTER - \u0000-character sequences (e.g. '\u0000\u0000\u0000')
  //2)TokenType.WHITESPACE_CHARACTER - any whitespace/new-line character sequences (e.g. '\n  \r\t   \f')
  //3)TokenType.CHARACTER - any character sequence which don't belong to groups 1 and 2 (e.g. 'abcdef1234@@#$%^')
  _appendCharToCurrentCharacterToken(type, ch) {
    if (this.currentCharacterToken) {
      if (this.currentCharacterToken.type === type) {
        this.currentCharacterToken.chars += ch;
        return;
      } else {
        this.currentLocation = this.getCurrentLocation(0);
        this._emitCurrentCharacterToken(this.currentLocation);
        this.preprocessor.dropParsedChunk();
      }
    }
    this._createCharacterToken(type, ch);
  }
  _emitCodePoint(cp) {
    const type = isWhitespace(cp) ? TokenType.WHITESPACE_CHARACTER : cp === CODE_POINTS.NULL ? TokenType.NULL_CHARACTER : TokenType.CHARACTER;
    this._appendCharToCurrentCharacterToken(type, String.fromCodePoint(cp));
  }
  //NOTE: used when we emit characters explicitly.
  //This is always for non-whitespace and non-null characters, which allows us to avoid additional checks.
  _emitChars(ch) {
    this._appendCharToCurrentCharacterToken(TokenType.CHARACTER, ch);
  }
  // Character reference helpers
  _startCharacterReference() {
    this.returnState = this.state;
    this.state = State.CHARACTER_REFERENCE;
    this.entityStartPos = this.preprocessor.pos;
    this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute() ? DecodingMode.Attribute : DecodingMode.Legacy);
  }
  _isCharacterReferenceInAttribute() {
    return this.returnState === State.ATTRIBUTE_VALUE_DOUBLE_QUOTED || this.returnState === State.ATTRIBUTE_VALUE_SINGLE_QUOTED || this.returnState === State.ATTRIBUTE_VALUE_UNQUOTED;
  }
  _flushCodePointConsumedAsCharacterReference(cp) {
    if (this._isCharacterReferenceInAttribute()) {
      this.currentAttr.value += String.fromCodePoint(cp);
    } else {
      this._emitCodePoint(cp);
    }
  }
  // Calling states this way turns out to be much faster than any other approach.
  _callState(cp) {
    switch (this.state) {
      case State.DATA: {
        this._stateData(cp);
        break;
      }
      case State.RCDATA: {
        this._stateRcdata(cp);
        break;
      }
      case State.RAWTEXT: {
        this._stateRawtext(cp);
        break;
      }
      case State.SCRIPT_DATA: {
        this._stateScriptData(cp);
        break;
      }
      case State.PLAINTEXT: {
        this._statePlaintext(cp);
        break;
      }
      case State.TAG_OPEN: {
        this._stateTagOpen(cp);
        break;
      }
      case State.END_TAG_OPEN: {
        this._stateEndTagOpen(cp);
        break;
      }
      case State.TAG_NAME: {
        this._stateTagName(cp);
        break;
      }
      case State.RCDATA_LESS_THAN_SIGN: {
        this._stateRcdataLessThanSign(cp);
        break;
      }
      case State.RCDATA_END_TAG_OPEN: {
        this._stateRcdataEndTagOpen(cp);
        break;
      }
      case State.RCDATA_END_TAG_NAME: {
        this._stateRcdataEndTagName(cp);
        break;
      }
      case State.RAWTEXT_LESS_THAN_SIGN: {
        this._stateRawtextLessThanSign(cp);
        break;
      }
      case State.RAWTEXT_END_TAG_OPEN: {
        this._stateRawtextEndTagOpen(cp);
        break;
      }
      case State.RAWTEXT_END_TAG_NAME: {
        this._stateRawtextEndTagName(cp);
        break;
      }
      case State.SCRIPT_DATA_LESS_THAN_SIGN: {
        this._stateScriptDataLessThanSign(cp);
        break;
      }
      case State.SCRIPT_DATA_END_TAG_OPEN: {
        this._stateScriptDataEndTagOpen(cp);
        break;
      }
      case State.SCRIPT_DATA_END_TAG_NAME: {
        this._stateScriptDataEndTagName(cp);
        break;
      }
      case State.SCRIPT_DATA_ESCAPE_START: {
        this._stateScriptDataEscapeStart(cp);
        break;
      }
      case State.SCRIPT_DATA_ESCAPE_START_DASH: {
        this._stateScriptDataEscapeStartDash(cp);
        break;
      }
      case State.SCRIPT_DATA_ESCAPED: {
        this._stateScriptDataEscaped(cp);
        break;
      }
      case State.SCRIPT_DATA_ESCAPED_DASH: {
        this._stateScriptDataEscapedDash(cp);
        break;
      }
      case State.SCRIPT_DATA_ESCAPED_DASH_DASH: {
        this._stateScriptDataEscapedDashDash(cp);
        break;
      }
      case State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: {
        this._stateScriptDataEscapedLessThanSign(cp);
        break;
      }
      case State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN: {
        this._stateScriptDataEscapedEndTagOpen(cp);
        break;
      }
      case State.SCRIPT_DATA_ESCAPED_END_TAG_NAME: {
        this._stateScriptDataEscapedEndTagName(cp);
        break;
      }
      case State.SCRIPT_DATA_DOUBLE_ESCAPE_START: {
        this._stateScriptDataDoubleEscapeStart(cp);
        break;
      }
      case State.SCRIPT_DATA_DOUBLE_ESCAPED: {
        this._stateScriptDataDoubleEscaped(cp);
        break;
      }
      case State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH: {
        this._stateScriptDataDoubleEscapedDash(cp);
        break;
      }
      case State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH: {
        this._stateScriptDataDoubleEscapedDashDash(cp);
        break;
      }
      case State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN: {
        this._stateScriptDataDoubleEscapedLessThanSign(cp);
        break;
      }
      case State.SCRIPT_DATA_DOUBLE_ESCAPE_END: {
        this._stateScriptDataDoubleEscapeEnd(cp);
        break;
      }
      case State.BEFORE_ATTRIBUTE_NAME: {
        this._stateBeforeAttributeName(cp);
        break;
      }
      case State.ATTRIBUTE_NAME: {
        this._stateAttributeName(cp);
        break;
      }
      case State.AFTER_ATTRIBUTE_NAME: {
        this._stateAfterAttributeName(cp);
        break;
      }
      case State.BEFORE_ATTRIBUTE_VALUE: {
        this._stateBeforeAttributeValue(cp);
        break;
      }
      case State.ATTRIBUTE_VALUE_DOUBLE_QUOTED: {
        this._stateAttributeValueDoubleQuoted(cp);
        break;
      }
      case State.ATTRIBUTE_VALUE_SINGLE_QUOTED: {
        this._stateAttributeValueSingleQuoted(cp);
        break;
      }
      case State.ATTRIBUTE_VALUE_UNQUOTED: {
        this._stateAttributeValueUnquoted(cp);
        break;
      }
      case State.AFTER_ATTRIBUTE_VALUE_QUOTED: {
        this._stateAfterAttributeValueQuoted(cp);
        break;
      }
      case State.SELF_CLOSING_START_TAG: {
        this._stateSelfClosingStartTag(cp);
        break;
      }
      case State.BOGUS_COMMENT: {
        this._stateBogusComment(cp);
        break;
      }
      case State.MARKUP_DECLARATION_OPEN: {
        this._stateMarkupDeclarationOpen(cp);
        break;
      }
      case State.COMMENT_START: {
        this._stateCommentStart(cp);
        break;
      }
      case State.COMMENT_START_DASH: {
        this._stateCommentStartDash(cp);
        break;
      }
      case State.COMMENT: {
        this._stateComment(cp);
        break;
      }
      case State.COMMENT_LESS_THAN_SIGN: {
        this._stateCommentLessThanSign(cp);
        break;
      }
      case State.COMMENT_LESS_THAN_SIGN_BANG: {
        this._stateCommentLessThanSignBang(cp);
        break;
      }
      case State.COMMENT_LESS_THAN_SIGN_BANG_DASH: {
        this._stateCommentLessThanSignBangDash(cp);
        break;
      }
      case State.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH: {
        this._stateCommentLessThanSignBangDashDash(cp);
        break;
      }
      case State.COMMENT_END_DASH: {
        this._stateCommentEndDash(cp);
        break;
      }
      case State.COMMENT_END: {
        this._stateCommentEnd(cp);
        break;
      }
      case State.COMMENT_END_BANG: {
        this._stateCommentEndBang(cp);
        break;
      }
      case State.DOCTYPE: {
        this._stateDoctype(cp);
        break;
      }
      case State.BEFORE_DOCTYPE_NAME: {
        this._stateBeforeDoctypeName(cp);
        break;
      }
      case State.DOCTYPE_NAME: {
        this._stateDoctypeName(cp);
        break;
      }
      case State.AFTER_DOCTYPE_NAME: {
        this._stateAfterDoctypeName(cp);
        break;
      }
      case State.AFTER_DOCTYPE_PUBLIC_KEYWORD: {
        this._stateAfterDoctypePublicKeyword(cp);
        break;
      }
      case State.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: {
        this._stateBeforeDoctypePublicIdentifier(cp);
        break;
      }
      case State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED: {
        this._stateDoctypePublicIdentifierDoubleQuoted(cp);
        break;
      }
      case State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: {
        this._stateDoctypePublicIdentifierSingleQuoted(cp);
        break;
      }
      case State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER: {
        this._stateAfterDoctypePublicIdentifier(cp);
        break;
      }
      case State.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: {
        this._stateBetweenDoctypePublicAndSystemIdentifiers(cp);
        break;
      }
      case State.AFTER_DOCTYPE_SYSTEM_KEYWORD: {
        this._stateAfterDoctypeSystemKeyword(cp);
        break;
      }
      case State.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER: {
        this._stateBeforeDoctypeSystemIdentifier(cp);
        break;
      }
      case State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED: {
        this._stateDoctypeSystemIdentifierDoubleQuoted(cp);
        break;
      }
      case State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: {
        this._stateDoctypeSystemIdentifierSingleQuoted(cp);
        break;
      }
      case State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER: {
        this._stateAfterDoctypeSystemIdentifier(cp);
        break;
      }
      case State.BOGUS_DOCTYPE: {
        this._stateBogusDoctype(cp);
        break;
      }
      case State.CDATA_SECTION: {
        this._stateCdataSection(cp);
        break;
      }
      case State.CDATA_SECTION_BRACKET: {
        this._stateCdataSectionBracket(cp);
        break;
      }
      case State.CDATA_SECTION_END: {
        this._stateCdataSectionEnd(cp);
        break;
      }
      case State.CHARACTER_REFERENCE: {
        this._stateCharacterReference();
        break;
      }
      case State.AMBIGUOUS_AMPERSAND: {
        this._stateAmbiguousAmpersand(cp);
        break;
      }
      default: {
        throw new Error("Unknown state");
      }
    }
  }
  // State machine
  // Data state
  //------------------------------------------------------------------
  _stateData(cp) {
    switch (cp) {
      case CODE_POINTS.LESS_THAN_SIGN: {
        this.state = State.TAG_OPEN;
        break;
      }
      case CODE_POINTS.AMPERSAND: {
        this._startCharacterReference();
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        this._emitCodePoint(cp);
        break;
      }
      case CODE_POINTS.EOF: {
        this._emitEOFToken();
        break;
      }
      default: {
        this._emitCodePoint(cp);
      }
    }
  }
  //  RCDATA state
  //------------------------------------------------------------------
  _stateRcdata(cp) {
    switch (cp) {
      case CODE_POINTS.AMPERSAND: {
        this._startCharacterReference();
        break;
      }
      case CODE_POINTS.LESS_THAN_SIGN: {
        this.state = State.RCDATA_LESS_THAN_SIGN;
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        this._emitChars(REPLACEMENT_CHARACTER);
        break;
      }
      case CODE_POINTS.EOF: {
        this._emitEOFToken();
        break;
      }
      default: {
        this._emitCodePoint(cp);
      }
    }
  }
  // RAWTEXT state
  //------------------------------------------------------------------
  _stateRawtext(cp) {
    switch (cp) {
      case CODE_POINTS.LESS_THAN_SIGN: {
        this.state = State.RAWTEXT_LESS_THAN_SIGN;
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        this._emitChars(REPLACEMENT_CHARACTER);
        break;
      }
      case CODE_POINTS.EOF: {
        this._emitEOFToken();
        break;
      }
      default: {
        this._emitCodePoint(cp);
      }
    }
  }
  // Script data state
  //------------------------------------------------------------------
  _stateScriptData(cp) {
    switch (cp) {
      case CODE_POINTS.LESS_THAN_SIGN: {
        this.state = State.SCRIPT_DATA_LESS_THAN_SIGN;
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        this._emitChars(REPLACEMENT_CHARACTER);
        break;
      }
      case CODE_POINTS.EOF: {
        this._emitEOFToken();
        break;
      }
      default: {
        this._emitCodePoint(cp);
      }
    }
  }
  // PLAINTEXT state
  //------------------------------------------------------------------
  _statePlaintext(cp) {
    switch (cp) {
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        this._emitChars(REPLACEMENT_CHARACTER);
        break;
      }
      case CODE_POINTS.EOF: {
        this._emitEOFToken();
        break;
      }
      default: {
        this._emitCodePoint(cp);
      }
    }
  }
  // Tag open state
  //------------------------------------------------------------------
  _stateTagOpen(cp) {
    if (isAsciiLetter(cp)) {
      this._createStartTagToken();
      this.state = State.TAG_NAME;
      this._stateTagName(cp);
    } else
      switch (cp) {
        case CODE_POINTS.EXCLAMATION_MARK: {
          this.state = State.MARKUP_DECLARATION_OPEN;
          break;
        }
        case CODE_POINTS.SOLIDUS: {
          this.state = State.END_TAG_OPEN;
          break;
        }
        case CODE_POINTS.QUESTION_MARK: {
          this._err(ERR.unexpectedQuestionMarkInsteadOfTagName);
          this._createCommentToken(1);
          this.state = State.BOGUS_COMMENT;
          this._stateBogusComment(cp);
          break;
        }
        case CODE_POINTS.EOF: {
          this._err(ERR.eofBeforeTagName);
          this._emitChars("<");
          this._emitEOFToken();
          break;
        }
        default: {
          this._err(ERR.invalidFirstCharacterOfTagName);
          this._emitChars("<");
          this.state = State.DATA;
          this._stateData(cp);
        }
      }
  }
  // End tag open state
  //------------------------------------------------------------------
  _stateEndTagOpen(cp) {
    if (isAsciiLetter(cp)) {
      this._createEndTagToken();
      this.state = State.TAG_NAME;
      this._stateTagName(cp);
    } else
      switch (cp) {
        case CODE_POINTS.GREATER_THAN_SIGN: {
          this._err(ERR.missingEndTagName);
          this.state = State.DATA;
          break;
        }
        case CODE_POINTS.EOF: {
          this._err(ERR.eofBeforeTagName);
          this._emitChars("</");
          this._emitEOFToken();
          break;
        }
        default: {
          this._err(ERR.invalidFirstCharacterOfTagName);
          this._createCommentToken(2);
          this.state = State.BOGUS_COMMENT;
          this._stateBogusComment(cp);
        }
      }
  }
  // Tag name state
  //------------------------------------------------------------------
  _stateTagName(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        this.state = State.BEFORE_ATTRIBUTE_NAME;
        break;
      }
      case CODE_POINTS.SOLIDUS: {
        this.state = State.SELF_CLOSING_START_TAG;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this.state = State.DATA;
        this.emitCurrentTagToken();
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        token.tagName += REPLACEMENT_CHARACTER;
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInTag);
        this._emitEOFToken();
        break;
      }
      default: {
        token.tagName += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
      }
    }
  }
  // RCDATA less-than sign state
  //------------------------------------------------------------------
  _stateRcdataLessThanSign(cp) {
    if (cp === CODE_POINTS.SOLIDUS) {
      this.state = State.RCDATA_END_TAG_OPEN;
    } else {
      this._emitChars("<");
      this.state = State.RCDATA;
      this._stateRcdata(cp);
    }
  }
  // RCDATA end tag open state
  //------------------------------------------------------------------
  _stateRcdataEndTagOpen(cp) {
    if (isAsciiLetter(cp)) {
      this.state = State.RCDATA_END_TAG_NAME;
      this._stateRcdataEndTagName(cp);
    } else {
      this._emitChars("</");
      this.state = State.RCDATA;
      this._stateRcdata(cp);
    }
  }
  handleSpecialEndTag(_cp) {
    if (!this.preprocessor.startsWith(this.lastStartTagName, false)) {
      return !this._ensureHibernation();
    }
    this._createEndTagToken();
    const token = this.currentToken;
    token.tagName = this.lastStartTagName;
    const cp = this.preprocessor.peek(this.lastStartTagName.length);
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        this._advanceBy(this.lastStartTagName.length);
        this.state = State.BEFORE_ATTRIBUTE_NAME;
        return false;
      }
      case CODE_POINTS.SOLIDUS: {
        this._advanceBy(this.lastStartTagName.length);
        this.state = State.SELF_CLOSING_START_TAG;
        return false;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this._advanceBy(this.lastStartTagName.length);
        this.emitCurrentTagToken();
        this.state = State.DATA;
        return false;
      }
      default: {
        return !this._ensureHibernation();
      }
    }
  }
  // RCDATA end tag name state
  //------------------------------------------------------------------
  _stateRcdataEndTagName(cp) {
    if (this.handleSpecialEndTag(cp)) {
      this._emitChars("</");
      this.state = State.RCDATA;
      this._stateRcdata(cp);
    }
  }
  // RAWTEXT less-than sign state
  //------------------------------------------------------------------
  _stateRawtextLessThanSign(cp) {
    if (cp === CODE_POINTS.SOLIDUS) {
      this.state = State.RAWTEXT_END_TAG_OPEN;
    } else {
      this._emitChars("<");
      this.state = State.RAWTEXT;
      this._stateRawtext(cp);
    }
  }
  // RAWTEXT end tag open state
  //------------------------------------------------------------------
  _stateRawtextEndTagOpen(cp) {
    if (isAsciiLetter(cp)) {
      this.state = State.RAWTEXT_END_TAG_NAME;
      this._stateRawtextEndTagName(cp);
    } else {
      this._emitChars("</");
      this.state = State.RAWTEXT;
      this._stateRawtext(cp);
    }
  }
  // RAWTEXT end tag name state
  //------------------------------------------------------------------
  _stateRawtextEndTagName(cp) {
    if (this.handleSpecialEndTag(cp)) {
      this._emitChars("</");
      this.state = State.RAWTEXT;
      this._stateRawtext(cp);
    }
  }
  // Script data less-than sign state
  //------------------------------------------------------------------
  _stateScriptDataLessThanSign(cp) {
    switch (cp) {
      case CODE_POINTS.SOLIDUS: {
        this.state = State.SCRIPT_DATA_END_TAG_OPEN;
        break;
      }
      case CODE_POINTS.EXCLAMATION_MARK: {
        this.state = State.SCRIPT_DATA_ESCAPE_START;
        this._emitChars("<!");
        break;
      }
      default: {
        this._emitChars("<");
        this.state = State.SCRIPT_DATA;
        this._stateScriptData(cp);
      }
    }
  }
  // Script data end tag open state
  //------------------------------------------------------------------
  _stateScriptDataEndTagOpen(cp) {
    if (isAsciiLetter(cp)) {
      this.state = State.SCRIPT_DATA_END_TAG_NAME;
      this._stateScriptDataEndTagName(cp);
    } else {
      this._emitChars("</");
      this.state = State.SCRIPT_DATA;
      this._stateScriptData(cp);
    }
  }
  // Script data end tag name state
  //------------------------------------------------------------------
  _stateScriptDataEndTagName(cp) {
    if (this.handleSpecialEndTag(cp)) {
      this._emitChars("</");
      this.state = State.SCRIPT_DATA;
      this._stateScriptData(cp);
    }
  }
  // Script data escape start state
  //------------------------------------------------------------------
  _stateScriptDataEscapeStart(cp) {
    if (cp === CODE_POINTS.HYPHEN_MINUS) {
      this.state = State.SCRIPT_DATA_ESCAPE_START_DASH;
      this._emitChars("-");
    } else {
      this.state = State.SCRIPT_DATA;
      this._stateScriptData(cp);
    }
  }
  // Script data escape start dash state
  //------------------------------------------------------------------
  _stateScriptDataEscapeStartDash(cp) {
    if (cp === CODE_POINTS.HYPHEN_MINUS) {
      this.state = State.SCRIPT_DATA_ESCAPED_DASH_DASH;
      this._emitChars("-");
    } else {
      this.state = State.SCRIPT_DATA;
      this._stateScriptData(cp);
    }
  }
  // Script data escaped state
  //------------------------------------------------------------------
  _stateScriptDataEscaped(cp) {
    switch (cp) {
      case CODE_POINTS.HYPHEN_MINUS: {
        this.state = State.SCRIPT_DATA_ESCAPED_DASH;
        this._emitChars("-");
        break;
      }
      case CODE_POINTS.LESS_THAN_SIGN: {
        this.state = State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        this._emitChars(REPLACEMENT_CHARACTER);
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInScriptHtmlCommentLikeText);
        this._emitEOFToken();
        break;
      }
      default: {
        this._emitCodePoint(cp);
      }
    }
  }
  // Script data escaped dash state
  //------------------------------------------------------------------
  _stateScriptDataEscapedDash(cp) {
    switch (cp) {
      case CODE_POINTS.HYPHEN_MINUS: {
        this.state = State.SCRIPT_DATA_ESCAPED_DASH_DASH;
        this._emitChars("-");
        break;
      }
      case CODE_POINTS.LESS_THAN_SIGN: {
        this.state = State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        this.state = State.SCRIPT_DATA_ESCAPED;
        this._emitChars(REPLACEMENT_CHARACTER);
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInScriptHtmlCommentLikeText);
        this._emitEOFToken();
        break;
      }
      default: {
        this.state = State.SCRIPT_DATA_ESCAPED;
        this._emitCodePoint(cp);
      }
    }
  }
  // Script data escaped dash dash state
  //------------------------------------------------------------------
  _stateScriptDataEscapedDashDash(cp) {
    switch (cp) {
      case CODE_POINTS.HYPHEN_MINUS: {
        this._emitChars("-");
        break;
      }
      case CODE_POINTS.LESS_THAN_SIGN: {
        this.state = State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this.state = State.SCRIPT_DATA;
        this._emitChars(">");
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        this.state = State.SCRIPT_DATA_ESCAPED;
        this._emitChars(REPLACEMENT_CHARACTER);
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInScriptHtmlCommentLikeText);
        this._emitEOFToken();
        break;
      }
      default: {
        this.state = State.SCRIPT_DATA_ESCAPED;
        this._emitCodePoint(cp);
      }
    }
  }
  // Script data escaped less-than sign state
  //------------------------------------------------------------------
  _stateScriptDataEscapedLessThanSign(cp) {
    if (cp === CODE_POINTS.SOLIDUS) {
      this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN;
    } else if (isAsciiLetter(cp)) {
      this._emitChars("<");
      this.state = State.SCRIPT_DATA_DOUBLE_ESCAPE_START;
      this._stateScriptDataDoubleEscapeStart(cp);
    } else {
      this._emitChars("<");
      this.state = State.SCRIPT_DATA_ESCAPED;
      this._stateScriptDataEscaped(cp);
    }
  }
  // Script data escaped end tag open state
  //------------------------------------------------------------------
  _stateScriptDataEscapedEndTagOpen(cp) {
    if (isAsciiLetter(cp)) {
      this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_NAME;
      this._stateScriptDataEscapedEndTagName(cp);
    } else {
      this._emitChars("</");
      this.state = State.SCRIPT_DATA_ESCAPED;
      this._stateScriptDataEscaped(cp);
    }
  }
  // Script data escaped end tag name state
  //------------------------------------------------------------------
  _stateScriptDataEscapedEndTagName(cp) {
    if (this.handleSpecialEndTag(cp)) {
      this._emitChars("</");
      this.state = State.SCRIPT_DATA_ESCAPED;
      this._stateScriptDataEscaped(cp);
    }
  }
  // Script data double escape start state
  //------------------------------------------------------------------
  _stateScriptDataDoubleEscapeStart(cp) {
    if (this.preprocessor.startsWith(SEQUENCES.SCRIPT, false) && isScriptDataDoubleEscapeSequenceEnd(this.preprocessor.peek(SEQUENCES.SCRIPT.length))) {
      this._emitCodePoint(cp);
      for (let i = 0; i < SEQUENCES.SCRIPT.length; i++) {
        this._emitCodePoint(this._consume());
      }
      this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
    } else if (!this._ensureHibernation()) {
      this.state = State.SCRIPT_DATA_ESCAPED;
      this._stateScriptDataEscaped(cp);
    }
  }
  // Script data double escaped state
  //------------------------------------------------------------------
  _stateScriptDataDoubleEscaped(cp) {
    switch (cp) {
      case CODE_POINTS.HYPHEN_MINUS: {
        this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH;
        this._emitChars("-");
        break;
      }
      case CODE_POINTS.LESS_THAN_SIGN: {
        this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN;
        this._emitChars("<");
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        this._emitChars(REPLACEMENT_CHARACTER);
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInScriptHtmlCommentLikeText);
        this._emitEOFToken();
        break;
      }
      default: {
        this._emitCodePoint(cp);
      }
    }
  }
  // Script data double escaped dash state
  //------------------------------------------------------------------
  _stateScriptDataDoubleEscapedDash(cp) {
    switch (cp) {
      case CODE_POINTS.HYPHEN_MINUS: {
        this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH;
        this._emitChars("-");
        break;
      }
      case CODE_POINTS.LESS_THAN_SIGN: {
        this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN;
        this._emitChars("<");
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
        this._emitChars(REPLACEMENT_CHARACTER);
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInScriptHtmlCommentLikeText);
        this._emitEOFToken();
        break;
      }
      default: {
        this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
        this._emitCodePoint(cp);
      }
    }
  }
  // Script data double escaped dash dash state
  //------------------------------------------------------------------
  _stateScriptDataDoubleEscapedDashDash(cp) {
    switch (cp) {
      case CODE_POINTS.HYPHEN_MINUS: {
        this._emitChars("-");
        break;
      }
      case CODE_POINTS.LESS_THAN_SIGN: {
        this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN;
        this._emitChars("<");
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this.state = State.SCRIPT_DATA;
        this._emitChars(">");
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
        this._emitChars(REPLACEMENT_CHARACTER);
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInScriptHtmlCommentLikeText);
        this._emitEOFToken();
        break;
      }
      default: {
        this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
        this._emitCodePoint(cp);
      }
    }
  }
  // Script data double escaped less-than sign state
  //------------------------------------------------------------------
  _stateScriptDataDoubleEscapedLessThanSign(cp) {
    if (cp === CODE_POINTS.SOLIDUS) {
      this.state = State.SCRIPT_DATA_DOUBLE_ESCAPE_END;
      this._emitChars("/");
    } else {
      this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
      this._stateScriptDataDoubleEscaped(cp);
    }
  }
  // Script data double escape end state
  //------------------------------------------------------------------
  _stateScriptDataDoubleEscapeEnd(cp) {
    if (this.preprocessor.startsWith(SEQUENCES.SCRIPT, false) && isScriptDataDoubleEscapeSequenceEnd(this.preprocessor.peek(SEQUENCES.SCRIPT.length))) {
      this._emitCodePoint(cp);
      for (let i = 0; i < SEQUENCES.SCRIPT.length; i++) {
        this._emitCodePoint(this._consume());
      }
      this.state = State.SCRIPT_DATA_ESCAPED;
    } else if (!this._ensureHibernation()) {
      this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
      this._stateScriptDataDoubleEscaped(cp);
    }
  }
  // Before attribute name state
  //------------------------------------------------------------------
  _stateBeforeAttributeName(cp) {
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        break;
      }
      case CODE_POINTS.SOLIDUS:
      case CODE_POINTS.GREATER_THAN_SIGN:
      case CODE_POINTS.EOF: {
        this.state = State.AFTER_ATTRIBUTE_NAME;
        this._stateAfterAttributeName(cp);
        break;
      }
      case CODE_POINTS.EQUALS_SIGN: {
        this._err(ERR.unexpectedEqualsSignBeforeAttributeName);
        this._createAttr("=");
        this.state = State.ATTRIBUTE_NAME;
        break;
      }
      default: {
        this._createAttr("");
        this.state = State.ATTRIBUTE_NAME;
        this._stateAttributeName(cp);
      }
    }
  }
  // Attribute name state
  //------------------------------------------------------------------
  _stateAttributeName(cp) {
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED:
      case CODE_POINTS.SOLIDUS:
      case CODE_POINTS.GREATER_THAN_SIGN:
      case CODE_POINTS.EOF: {
        this._leaveAttrName();
        this.state = State.AFTER_ATTRIBUTE_NAME;
        this._stateAfterAttributeName(cp);
        break;
      }
      case CODE_POINTS.EQUALS_SIGN: {
        this._leaveAttrName();
        this.state = State.BEFORE_ATTRIBUTE_VALUE;
        break;
      }
      case CODE_POINTS.QUOTATION_MARK:
      case CODE_POINTS.APOSTROPHE:
      case CODE_POINTS.LESS_THAN_SIGN: {
        this._err(ERR.unexpectedCharacterInAttributeName);
        this.currentAttr.name += String.fromCodePoint(cp);
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        this.currentAttr.name += REPLACEMENT_CHARACTER;
        break;
      }
      default: {
        this.currentAttr.name += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
      }
    }
  }
  // After attribute name state
  //------------------------------------------------------------------
  _stateAfterAttributeName(cp) {
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        break;
      }
      case CODE_POINTS.SOLIDUS: {
        this.state = State.SELF_CLOSING_START_TAG;
        break;
      }
      case CODE_POINTS.EQUALS_SIGN: {
        this.state = State.BEFORE_ATTRIBUTE_VALUE;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this.state = State.DATA;
        this.emitCurrentTagToken();
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInTag);
        this._emitEOFToken();
        break;
      }
      default: {
        this._createAttr("");
        this.state = State.ATTRIBUTE_NAME;
        this._stateAttributeName(cp);
      }
    }
  }
  // Before attribute value state
  //------------------------------------------------------------------
  _stateBeforeAttributeValue(cp) {
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        break;
      }
      case CODE_POINTS.QUOTATION_MARK: {
        this.state = State.ATTRIBUTE_VALUE_DOUBLE_QUOTED;
        break;
      }
      case CODE_POINTS.APOSTROPHE: {
        this.state = State.ATTRIBUTE_VALUE_SINGLE_QUOTED;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this._err(ERR.missingAttributeValue);
        this.state = State.DATA;
        this.emitCurrentTagToken();
        break;
      }
      default: {
        this.state = State.ATTRIBUTE_VALUE_UNQUOTED;
        this._stateAttributeValueUnquoted(cp);
      }
    }
  }
  // Attribute value (double-quoted) state
  //------------------------------------------------------------------
  _stateAttributeValueDoubleQuoted(cp) {
    switch (cp) {
      case CODE_POINTS.QUOTATION_MARK: {
        this.state = State.AFTER_ATTRIBUTE_VALUE_QUOTED;
        break;
      }
      case CODE_POINTS.AMPERSAND: {
        this._startCharacterReference();
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        this.currentAttr.value += REPLACEMENT_CHARACTER;
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInTag);
        this._emitEOFToken();
        break;
      }
      default: {
        this.currentAttr.value += String.fromCodePoint(cp);
      }
    }
  }
  // Attribute value (single-quoted) state
  //------------------------------------------------------------------
  _stateAttributeValueSingleQuoted(cp) {
    switch (cp) {
      case CODE_POINTS.APOSTROPHE: {
        this.state = State.AFTER_ATTRIBUTE_VALUE_QUOTED;
        break;
      }
      case CODE_POINTS.AMPERSAND: {
        this._startCharacterReference();
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        this.currentAttr.value += REPLACEMENT_CHARACTER;
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInTag);
        this._emitEOFToken();
        break;
      }
      default: {
        this.currentAttr.value += String.fromCodePoint(cp);
      }
    }
  }
  // Attribute value (unquoted) state
  //------------------------------------------------------------------
  _stateAttributeValueUnquoted(cp) {
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        this._leaveAttrValue();
        this.state = State.BEFORE_ATTRIBUTE_NAME;
        break;
      }
      case CODE_POINTS.AMPERSAND: {
        this._startCharacterReference();
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this._leaveAttrValue();
        this.state = State.DATA;
        this.emitCurrentTagToken();
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        this.currentAttr.value += REPLACEMENT_CHARACTER;
        break;
      }
      case CODE_POINTS.QUOTATION_MARK:
      case CODE_POINTS.APOSTROPHE:
      case CODE_POINTS.LESS_THAN_SIGN:
      case CODE_POINTS.EQUALS_SIGN:
      case CODE_POINTS.GRAVE_ACCENT: {
        this._err(ERR.unexpectedCharacterInUnquotedAttributeValue);
        this.currentAttr.value += String.fromCodePoint(cp);
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInTag);
        this._emitEOFToken();
        break;
      }
      default: {
        this.currentAttr.value += String.fromCodePoint(cp);
      }
    }
  }
  // After attribute value (quoted) state
  //------------------------------------------------------------------
  _stateAfterAttributeValueQuoted(cp) {
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        this._leaveAttrValue();
        this.state = State.BEFORE_ATTRIBUTE_NAME;
        break;
      }
      case CODE_POINTS.SOLIDUS: {
        this._leaveAttrValue();
        this.state = State.SELF_CLOSING_START_TAG;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this._leaveAttrValue();
        this.state = State.DATA;
        this.emitCurrentTagToken();
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInTag);
        this._emitEOFToken();
        break;
      }
      default: {
        this._err(ERR.missingWhitespaceBetweenAttributes);
        this.state = State.BEFORE_ATTRIBUTE_NAME;
        this._stateBeforeAttributeName(cp);
      }
    }
  }
  // Self-closing start tag state
  //------------------------------------------------------------------
  _stateSelfClosingStartTag(cp) {
    switch (cp) {
      case CODE_POINTS.GREATER_THAN_SIGN: {
        const token = this.currentToken;
        token.selfClosing = true;
        this.state = State.DATA;
        this.emitCurrentTagToken();
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInTag);
        this._emitEOFToken();
        break;
      }
      default: {
        this._err(ERR.unexpectedSolidusInTag);
        this.state = State.BEFORE_ATTRIBUTE_NAME;
        this._stateBeforeAttributeName(cp);
      }
    }
  }
  // Bogus comment state
  //------------------------------------------------------------------
  _stateBogusComment(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this.state = State.DATA;
        this.emitCurrentComment(token);
        break;
      }
      case CODE_POINTS.EOF: {
        this.emitCurrentComment(token);
        this._emitEOFToken();
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        token.data += REPLACEMENT_CHARACTER;
        break;
      }
      default: {
        token.data += String.fromCodePoint(cp);
      }
    }
  }
  // Markup declaration open state
  //------------------------------------------------------------------
  _stateMarkupDeclarationOpen(cp) {
    if (this._consumeSequenceIfMatch(SEQUENCES.DASH_DASH, true)) {
      this._createCommentToken(SEQUENCES.DASH_DASH.length + 1);
      this.state = State.COMMENT_START;
    } else if (this._consumeSequenceIfMatch(SEQUENCES.DOCTYPE, false)) {
      this.currentLocation = this.getCurrentLocation(SEQUENCES.DOCTYPE.length + 1);
      this.state = State.DOCTYPE;
    } else if (this._consumeSequenceIfMatch(SEQUENCES.CDATA_START, true)) {
      if (this.inForeignNode) {
        this.state = State.CDATA_SECTION;
      } else {
        this._err(ERR.cdataInHtmlContent);
        this._createCommentToken(SEQUENCES.CDATA_START.length + 1);
        this.currentToken.data = "[CDATA[";
        this.state = State.BOGUS_COMMENT;
      }
    } else if (!this._ensureHibernation()) {
      this._err(ERR.incorrectlyOpenedComment);
      this._createCommentToken(2);
      this.state = State.BOGUS_COMMENT;
      this._stateBogusComment(cp);
    }
  }
  // Comment start state
  //------------------------------------------------------------------
  _stateCommentStart(cp) {
    switch (cp) {
      case CODE_POINTS.HYPHEN_MINUS: {
        this.state = State.COMMENT_START_DASH;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this._err(ERR.abruptClosingOfEmptyComment);
        this.state = State.DATA;
        const token = this.currentToken;
        this.emitCurrentComment(token);
        break;
      }
      default: {
        this.state = State.COMMENT;
        this._stateComment(cp);
      }
    }
  }
  // Comment start dash state
  //------------------------------------------------------------------
  _stateCommentStartDash(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.HYPHEN_MINUS: {
        this.state = State.COMMENT_END;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this._err(ERR.abruptClosingOfEmptyComment);
        this.state = State.DATA;
        this.emitCurrentComment(token);
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInComment);
        this.emitCurrentComment(token);
        this._emitEOFToken();
        break;
      }
      default: {
        token.data += "-";
        this.state = State.COMMENT;
        this._stateComment(cp);
      }
    }
  }
  // Comment state
  //------------------------------------------------------------------
  _stateComment(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.HYPHEN_MINUS: {
        this.state = State.COMMENT_END_DASH;
        break;
      }
      case CODE_POINTS.LESS_THAN_SIGN: {
        token.data += "<";
        this.state = State.COMMENT_LESS_THAN_SIGN;
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        token.data += REPLACEMENT_CHARACTER;
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInComment);
        this.emitCurrentComment(token);
        this._emitEOFToken();
        break;
      }
      default: {
        token.data += String.fromCodePoint(cp);
      }
    }
  }
  // Comment less-than sign state
  //------------------------------------------------------------------
  _stateCommentLessThanSign(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.EXCLAMATION_MARK: {
        token.data += "!";
        this.state = State.COMMENT_LESS_THAN_SIGN_BANG;
        break;
      }
      case CODE_POINTS.LESS_THAN_SIGN: {
        token.data += "<";
        break;
      }
      default: {
        this.state = State.COMMENT;
        this._stateComment(cp);
      }
    }
  }
  // Comment less-than sign bang state
  //------------------------------------------------------------------
  _stateCommentLessThanSignBang(cp) {
    if (cp === CODE_POINTS.HYPHEN_MINUS) {
      this.state = State.COMMENT_LESS_THAN_SIGN_BANG_DASH;
    } else {
      this.state = State.COMMENT;
      this._stateComment(cp);
    }
  }
  // Comment less-than sign bang dash state
  //------------------------------------------------------------------
  _stateCommentLessThanSignBangDash(cp) {
    if (cp === CODE_POINTS.HYPHEN_MINUS) {
      this.state = State.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH;
    } else {
      this.state = State.COMMENT_END_DASH;
      this._stateCommentEndDash(cp);
    }
  }
  // Comment less-than sign bang dash dash state
  //------------------------------------------------------------------
  _stateCommentLessThanSignBangDashDash(cp) {
    if (cp !== CODE_POINTS.GREATER_THAN_SIGN && cp !== CODE_POINTS.EOF) {
      this._err(ERR.nestedComment);
    }
    this.state = State.COMMENT_END;
    this._stateCommentEnd(cp);
  }
  // Comment end dash state
  //------------------------------------------------------------------
  _stateCommentEndDash(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.HYPHEN_MINUS: {
        this.state = State.COMMENT_END;
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInComment);
        this.emitCurrentComment(token);
        this._emitEOFToken();
        break;
      }
      default: {
        token.data += "-";
        this.state = State.COMMENT;
        this._stateComment(cp);
      }
    }
  }
  // Comment end state
  //------------------------------------------------------------------
  _stateCommentEnd(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this.state = State.DATA;
        this.emitCurrentComment(token);
        break;
      }
      case CODE_POINTS.EXCLAMATION_MARK: {
        this.state = State.COMMENT_END_BANG;
        break;
      }
      case CODE_POINTS.HYPHEN_MINUS: {
        token.data += "-";
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInComment);
        this.emitCurrentComment(token);
        this._emitEOFToken();
        break;
      }
      default: {
        token.data += "--";
        this.state = State.COMMENT;
        this._stateComment(cp);
      }
    }
  }
  // Comment end bang state
  //------------------------------------------------------------------
  _stateCommentEndBang(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.HYPHEN_MINUS: {
        token.data += "--!";
        this.state = State.COMMENT_END_DASH;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this._err(ERR.incorrectlyClosedComment);
        this.state = State.DATA;
        this.emitCurrentComment(token);
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInComment);
        this.emitCurrentComment(token);
        this._emitEOFToken();
        break;
      }
      default: {
        token.data += "--!";
        this.state = State.COMMENT;
        this._stateComment(cp);
      }
    }
  }
  // DOCTYPE state
  //------------------------------------------------------------------
  _stateDoctype(cp) {
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        this.state = State.BEFORE_DOCTYPE_NAME;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this.state = State.BEFORE_DOCTYPE_NAME;
        this._stateBeforeDoctypeName(cp);
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInDoctype);
        this._createDoctypeToken(null);
        const token = this.currentToken;
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this._emitEOFToken();
        break;
      }
      default: {
        this._err(ERR.missingWhitespaceBeforeDoctypeName);
        this.state = State.BEFORE_DOCTYPE_NAME;
        this._stateBeforeDoctypeName(cp);
      }
    }
  }
  // Before DOCTYPE name state
  //------------------------------------------------------------------
  _stateBeforeDoctypeName(cp) {
    if (isAsciiUpper(cp)) {
      this._createDoctypeToken(String.fromCharCode(toAsciiLower(cp)));
      this.state = State.DOCTYPE_NAME;
    } else
      switch (cp) {
        case CODE_POINTS.SPACE:
        case CODE_POINTS.LINE_FEED:
        case CODE_POINTS.TABULATION:
        case CODE_POINTS.FORM_FEED: {
          break;
        }
        case CODE_POINTS.NULL: {
          this._err(ERR.unexpectedNullCharacter);
          this._createDoctypeToken(REPLACEMENT_CHARACTER);
          this.state = State.DOCTYPE_NAME;
          break;
        }
        case CODE_POINTS.GREATER_THAN_SIGN: {
          this._err(ERR.missingDoctypeName);
          this._createDoctypeToken(null);
          const token = this.currentToken;
          token.forceQuirks = true;
          this.emitCurrentDoctype(token);
          this.state = State.DATA;
          break;
        }
        case CODE_POINTS.EOF: {
          this._err(ERR.eofInDoctype);
          this._createDoctypeToken(null);
          const token = this.currentToken;
          token.forceQuirks = true;
          this.emitCurrentDoctype(token);
          this._emitEOFToken();
          break;
        }
        default: {
          this._createDoctypeToken(String.fromCodePoint(cp));
          this.state = State.DOCTYPE_NAME;
        }
      }
  }
  // DOCTYPE name state
  //------------------------------------------------------------------
  _stateDoctypeName(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        this.state = State.AFTER_DOCTYPE_NAME;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this.state = State.DATA;
        this.emitCurrentDoctype(token);
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        token.name += REPLACEMENT_CHARACTER;
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInDoctype);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this._emitEOFToken();
        break;
      }
      default: {
        token.name += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
      }
    }
  }
  // After DOCTYPE name state
  //------------------------------------------------------------------
  _stateAfterDoctypeName(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this.state = State.DATA;
        this.emitCurrentDoctype(token);
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInDoctype);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this._emitEOFToken();
        break;
      }
      default: {
        if (this._consumeSequenceIfMatch(SEQUENCES.PUBLIC, false)) {
          this.state = State.AFTER_DOCTYPE_PUBLIC_KEYWORD;
        } else if (this._consumeSequenceIfMatch(SEQUENCES.SYSTEM, false)) {
          this.state = State.AFTER_DOCTYPE_SYSTEM_KEYWORD;
        } else if (!this._ensureHibernation()) {
          this._err(ERR.invalidCharacterSequenceAfterDoctypeName);
          token.forceQuirks = true;
          this.state = State.BOGUS_DOCTYPE;
          this._stateBogusDoctype(cp);
        }
      }
    }
  }
  // After DOCTYPE public keyword state
  //------------------------------------------------------------------
  _stateAfterDoctypePublicKeyword(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        this.state = State.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;
        break;
      }
      case CODE_POINTS.QUOTATION_MARK: {
        this._err(ERR.missingWhitespaceAfterDoctypePublicKeyword);
        token.publicId = "";
        this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;
        break;
      }
      case CODE_POINTS.APOSTROPHE: {
        this._err(ERR.missingWhitespaceAfterDoctypePublicKeyword);
        token.publicId = "";
        this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this._err(ERR.missingDoctypePublicIdentifier);
        token.forceQuirks = true;
        this.state = State.DATA;
        this.emitCurrentDoctype(token);
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInDoctype);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this._emitEOFToken();
        break;
      }
      default: {
        this._err(ERR.missingQuoteBeforeDoctypePublicIdentifier);
        token.forceQuirks = true;
        this.state = State.BOGUS_DOCTYPE;
        this._stateBogusDoctype(cp);
      }
    }
  }
  // Before DOCTYPE public identifier state
  //------------------------------------------------------------------
  _stateBeforeDoctypePublicIdentifier(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        break;
      }
      case CODE_POINTS.QUOTATION_MARK: {
        token.publicId = "";
        this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;
        break;
      }
      case CODE_POINTS.APOSTROPHE: {
        token.publicId = "";
        this.state = State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this._err(ERR.missingDoctypePublicIdentifier);
        token.forceQuirks = true;
        this.state = State.DATA;
        this.emitCurrentDoctype(token);
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInDoctype);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this._emitEOFToken();
        break;
      }
      default: {
        this._err(ERR.missingQuoteBeforeDoctypePublicIdentifier);
        token.forceQuirks = true;
        this.state = State.BOGUS_DOCTYPE;
        this._stateBogusDoctype(cp);
      }
    }
  }
  // DOCTYPE public identifier (double-quoted) state
  //------------------------------------------------------------------
  _stateDoctypePublicIdentifierDoubleQuoted(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.QUOTATION_MARK: {
        this.state = State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        token.publicId += REPLACEMENT_CHARACTER;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this._err(ERR.abruptDoctypePublicIdentifier);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this.state = State.DATA;
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInDoctype);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this._emitEOFToken();
        break;
      }
      default: {
        token.publicId += String.fromCodePoint(cp);
      }
    }
  }
  // DOCTYPE public identifier (single-quoted) state
  //------------------------------------------------------------------
  _stateDoctypePublicIdentifierSingleQuoted(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.APOSTROPHE: {
        this.state = State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        token.publicId += REPLACEMENT_CHARACTER;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this._err(ERR.abruptDoctypePublicIdentifier);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this.state = State.DATA;
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInDoctype);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this._emitEOFToken();
        break;
      }
      default: {
        token.publicId += String.fromCodePoint(cp);
      }
    }
  }
  // After DOCTYPE public identifier state
  //------------------------------------------------------------------
  _stateAfterDoctypePublicIdentifier(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        this.state = State.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this.state = State.DATA;
        this.emitCurrentDoctype(token);
        break;
      }
      case CODE_POINTS.QUOTATION_MARK: {
        this._err(ERR.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers);
        token.systemId = "";
        this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
        break;
      }
      case CODE_POINTS.APOSTROPHE: {
        this._err(ERR.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers);
        token.systemId = "";
        this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInDoctype);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this._emitEOFToken();
        break;
      }
      default: {
        this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
        token.forceQuirks = true;
        this.state = State.BOGUS_DOCTYPE;
        this._stateBogusDoctype(cp);
      }
    }
  }
  // Between DOCTYPE public and system identifiers state
  //------------------------------------------------------------------
  _stateBetweenDoctypePublicAndSystemIdentifiers(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this.emitCurrentDoctype(token);
        this.state = State.DATA;
        break;
      }
      case CODE_POINTS.QUOTATION_MARK: {
        token.systemId = "";
        this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
        break;
      }
      case CODE_POINTS.APOSTROPHE: {
        token.systemId = "";
        this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInDoctype);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this._emitEOFToken();
        break;
      }
      default: {
        this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
        token.forceQuirks = true;
        this.state = State.BOGUS_DOCTYPE;
        this._stateBogusDoctype(cp);
      }
    }
  }
  // After DOCTYPE system keyword state
  //------------------------------------------------------------------
  _stateAfterDoctypeSystemKeyword(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        this.state = State.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;
        break;
      }
      case CODE_POINTS.QUOTATION_MARK: {
        this._err(ERR.missingWhitespaceAfterDoctypeSystemKeyword);
        token.systemId = "";
        this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
        break;
      }
      case CODE_POINTS.APOSTROPHE: {
        this._err(ERR.missingWhitespaceAfterDoctypeSystemKeyword);
        token.systemId = "";
        this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this._err(ERR.missingDoctypeSystemIdentifier);
        token.forceQuirks = true;
        this.state = State.DATA;
        this.emitCurrentDoctype(token);
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInDoctype);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this._emitEOFToken();
        break;
      }
      default: {
        this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
        token.forceQuirks = true;
        this.state = State.BOGUS_DOCTYPE;
        this._stateBogusDoctype(cp);
      }
    }
  }
  // Before DOCTYPE system identifier state
  //------------------------------------------------------------------
  _stateBeforeDoctypeSystemIdentifier(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        break;
      }
      case CODE_POINTS.QUOTATION_MARK: {
        token.systemId = "";
        this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;
        break;
      }
      case CODE_POINTS.APOSTROPHE: {
        token.systemId = "";
        this.state = State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this._err(ERR.missingDoctypeSystemIdentifier);
        token.forceQuirks = true;
        this.state = State.DATA;
        this.emitCurrentDoctype(token);
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInDoctype);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this._emitEOFToken();
        break;
      }
      default: {
        this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
        token.forceQuirks = true;
        this.state = State.BOGUS_DOCTYPE;
        this._stateBogusDoctype(cp);
      }
    }
  }
  // DOCTYPE system identifier (double-quoted) state
  //------------------------------------------------------------------
  _stateDoctypeSystemIdentifierDoubleQuoted(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.QUOTATION_MARK: {
        this.state = State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        token.systemId += REPLACEMENT_CHARACTER;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this._err(ERR.abruptDoctypeSystemIdentifier);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this.state = State.DATA;
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInDoctype);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this._emitEOFToken();
        break;
      }
      default: {
        token.systemId += String.fromCodePoint(cp);
      }
    }
  }
  // DOCTYPE system identifier (single-quoted) state
  //------------------------------------------------------------------
  _stateDoctypeSystemIdentifierSingleQuoted(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.APOSTROPHE: {
        this.state = State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        token.systemId += REPLACEMENT_CHARACTER;
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this._err(ERR.abruptDoctypeSystemIdentifier);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this.state = State.DATA;
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInDoctype);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this._emitEOFToken();
        break;
      }
      default: {
        token.systemId += String.fromCodePoint(cp);
      }
    }
  }
  // After DOCTYPE system identifier state
  //------------------------------------------------------------------
  _stateAfterDoctypeSystemIdentifier(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.SPACE:
      case CODE_POINTS.LINE_FEED:
      case CODE_POINTS.TABULATION:
      case CODE_POINTS.FORM_FEED: {
        break;
      }
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this.emitCurrentDoctype(token);
        this.state = State.DATA;
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInDoctype);
        token.forceQuirks = true;
        this.emitCurrentDoctype(token);
        this._emitEOFToken();
        break;
      }
      default: {
        this._err(ERR.unexpectedCharacterAfterDoctypeSystemIdentifier);
        this.state = State.BOGUS_DOCTYPE;
        this._stateBogusDoctype(cp);
      }
    }
  }
  // Bogus DOCTYPE state
  //------------------------------------------------------------------
  _stateBogusDoctype(cp) {
    const token = this.currentToken;
    switch (cp) {
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this.emitCurrentDoctype(token);
        this.state = State.DATA;
        break;
      }
      case CODE_POINTS.NULL: {
        this._err(ERR.unexpectedNullCharacter);
        break;
      }
      case CODE_POINTS.EOF: {
        this.emitCurrentDoctype(token);
        this._emitEOFToken();
        break;
      }
      default:
    }
  }
  // CDATA section state
  //------------------------------------------------------------------
  _stateCdataSection(cp) {
    switch (cp) {
      case CODE_POINTS.RIGHT_SQUARE_BRACKET: {
        this.state = State.CDATA_SECTION_BRACKET;
        break;
      }
      case CODE_POINTS.EOF: {
        this._err(ERR.eofInCdata);
        this._emitEOFToken();
        break;
      }
      default: {
        this._emitCodePoint(cp);
      }
    }
  }
  // CDATA section bracket state
  //------------------------------------------------------------------
  _stateCdataSectionBracket(cp) {
    if (cp === CODE_POINTS.RIGHT_SQUARE_BRACKET) {
      this.state = State.CDATA_SECTION_END;
    } else {
      this._emitChars("]");
      this.state = State.CDATA_SECTION;
      this._stateCdataSection(cp);
    }
  }
  // CDATA section end state
  //------------------------------------------------------------------
  _stateCdataSectionEnd(cp) {
    switch (cp) {
      case CODE_POINTS.GREATER_THAN_SIGN: {
        this.state = State.DATA;
        break;
      }
      case CODE_POINTS.RIGHT_SQUARE_BRACKET: {
        this._emitChars("]");
        break;
      }
      default: {
        this._emitChars("]]");
        this.state = State.CDATA_SECTION;
        this._stateCdataSection(cp);
      }
    }
  }
  // Character reference state
  //------------------------------------------------------------------
  _stateCharacterReference() {
    let length = this.entityDecoder.write(this.preprocessor.html, this.preprocessor.pos);
    if (length < 0) {
      if (this.preprocessor.lastChunkWritten) {
        length = this.entityDecoder.end();
      } else {
        this.active = false;
        this.preprocessor.pos = this.preprocessor.html.length - 1;
        this.consumedAfterSnapshot = 0;
        this.preprocessor.endOfChunkHit = true;
        return;
      }
    }
    if (length === 0) {
      this.preprocessor.pos = this.entityStartPos;
      this._flushCodePointConsumedAsCharacterReference(CODE_POINTS.AMPERSAND);
      this.state = !this._isCharacterReferenceInAttribute() && isAsciiAlphaNumeric2(this.preprocessor.peek(1)) ? State.AMBIGUOUS_AMPERSAND : this.returnState;
    } else {
      this.state = this.returnState;
    }
  }
  // Ambiguos ampersand state
  //------------------------------------------------------------------
  _stateAmbiguousAmpersand(cp) {
    if (isAsciiAlphaNumeric2(cp)) {
      this._flushCodePointConsumedAsCharacterReference(cp);
    } else {
      if (cp === CODE_POINTS.SEMICOLON) {
        this._err(ERR.unknownNamedCharacterReference);
      }
      this.state = this.returnState;
      this._callState(cp);
    }
  }
};

// node_modules/parse5/dist/parser/open-element-stack.js
var IMPLICIT_END_TAG_REQUIRED = /* @__PURE__ */ new Set([TAG_ID.DD, TAG_ID.DT, TAG_ID.LI, TAG_ID.OPTGROUP, TAG_ID.OPTION, TAG_ID.P, TAG_ID.RB, TAG_ID.RP, TAG_ID.RT, TAG_ID.RTC]);
var IMPLICIT_END_TAG_REQUIRED_THOROUGHLY = /* @__PURE__ */ new Set([
  ...IMPLICIT_END_TAG_REQUIRED,
  TAG_ID.CAPTION,
  TAG_ID.COLGROUP,
  TAG_ID.TBODY,
  TAG_ID.TD,
  TAG_ID.TFOOT,
  TAG_ID.TH,
  TAG_ID.THEAD,
  TAG_ID.TR
]);
var SCOPING_ELEMENTS_HTML = /* @__PURE__ */ new Set([
  TAG_ID.APPLET,
  TAG_ID.CAPTION,
  TAG_ID.HTML,
  TAG_ID.MARQUEE,
  TAG_ID.OBJECT,
  TAG_ID.TABLE,
  TAG_ID.TD,
  TAG_ID.TEMPLATE,
  TAG_ID.TH
]);
var SCOPING_ELEMENTS_HTML_LIST = /* @__PURE__ */ new Set([...SCOPING_ELEMENTS_HTML, TAG_ID.OL, TAG_ID.UL]);
var SCOPING_ELEMENTS_HTML_BUTTON = /* @__PURE__ */ new Set([...SCOPING_ELEMENTS_HTML, TAG_ID.BUTTON]);
var SCOPING_ELEMENTS_MATHML = /* @__PURE__ */ new Set([TAG_ID.ANNOTATION_XML, TAG_ID.MI, TAG_ID.MN, TAG_ID.MO, TAG_ID.MS, TAG_ID.MTEXT]);
var SCOPING_ELEMENTS_SVG = /* @__PURE__ */ new Set([TAG_ID.DESC, TAG_ID.FOREIGN_OBJECT, TAG_ID.TITLE]);
var TABLE_ROW_CONTEXT = /* @__PURE__ */ new Set([TAG_ID.TR, TAG_ID.TEMPLATE, TAG_ID.HTML]);
var TABLE_BODY_CONTEXT = /* @__PURE__ */ new Set([TAG_ID.TBODY, TAG_ID.TFOOT, TAG_ID.THEAD, TAG_ID.TEMPLATE, TAG_ID.HTML]);
var TABLE_CONTEXT = /* @__PURE__ */ new Set([TAG_ID.TABLE, TAG_ID.TEMPLATE, TAG_ID.HTML]);
var TABLE_CELLS = /* @__PURE__ */ new Set([TAG_ID.TD, TAG_ID.TH]);
var OpenElementStack = class {
  get currentTmplContentOrNode() {
    return this._isInTemplate() ? this.treeAdapter.getTemplateContent(this.current) : this.current;
  }
  constructor(document2, treeAdapter, handler) {
    this.treeAdapter = treeAdapter;
    this.handler = handler;
    this.items = [];
    this.tagIDs = [];
    this.stackTop = -1;
    this.tmplCount = 0;
    this.currentTagId = TAG_ID.UNKNOWN;
    this.current = document2;
  }
  //Index of element
  _indexOf(element) {
    return this.items.lastIndexOf(element, this.stackTop);
  }
  //Update current element
  _isInTemplate() {
    return this.currentTagId === TAG_ID.TEMPLATE && this.treeAdapter.getNamespaceURI(this.current) === NS.HTML;
  }
  _updateCurrentElement() {
    this.current = this.items[this.stackTop];
    this.currentTagId = this.tagIDs[this.stackTop];
  }
  //Mutations
  push(element, tagID) {
    this.stackTop++;
    this.items[this.stackTop] = element;
    this.current = element;
    this.tagIDs[this.stackTop] = tagID;
    this.currentTagId = tagID;
    if (this._isInTemplate()) {
      this.tmplCount++;
    }
    this.handler.onItemPush(element, tagID, true);
  }
  pop() {
    const popped = this.current;
    if (this.tmplCount > 0 && this._isInTemplate()) {
      this.tmplCount--;
    }
    this.stackTop--;
    this._updateCurrentElement();
    this.handler.onItemPop(popped, true);
  }
  replace(oldElement, newElement) {
    const idx = this._indexOf(oldElement);
    this.items[idx] = newElement;
    if (idx === this.stackTop) {
      this.current = newElement;
    }
  }
  insertAfter(referenceElement, newElement, newElementID) {
    const insertionIdx = this._indexOf(referenceElement) + 1;
    this.items.splice(insertionIdx, 0, newElement);
    this.tagIDs.splice(insertionIdx, 0, newElementID);
    this.stackTop++;
    if (insertionIdx === this.stackTop) {
      this._updateCurrentElement();
    }
    this.handler.onItemPush(this.current, this.currentTagId, insertionIdx === this.stackTop);
  }
  popUntilTagNamePopped(tagName) {
    let targetIdx = this.stackTop + 1;
    do {
      targetIdx = this.tagIDs.lastIndexOf(tagName, targetIdx - 1);
    } while (targetIdx > 0 && this.treeAdapter.getNamespaceURI(this.items[targetIdx]) !== NS.HTML);
    this.shortenToLength(targetIdx < 0 ? 0 : targetIdx);
  }
  shortenToLength(idx) {
    while (this.stackTop >= idx) {
      const popped = this.current;
      if (this.tmplCount > 0 && this._isInTemplate()) {
        this.tmplCount -= 1;
      }
      this.stackTop--;
      this._updateCurrentElement();
      this.handler.onItemPop(popped, this.stackTop < idx);
    }
  }
  popUntilElementPopped(element) {
    const idx = this._indexOf(element);
    this.shortenToLength(idx < 0 ? 0 : idx);
  }
  popUntilPopped(tagNames, targetNS) {
    const idx = this._indexOfTagNames(tagNames, targetNS);
    this.shortenToLength(idx < 0 ? 0 : idx);
  }
  popUntilNumberedHeaderPopped() {
    this.popUntilPopped(NUMBERED_HEADERS, NS.HTML);
  }
  popUntilTableCellPopped() {
    this.popUntilPopped(TABLE_CELLS, NS.HTML);
  }
  popAllUpToHtmlElement() {
    this.tmplCount = 0;
    this.shortenToLength(1);
  }
  _indexOfTagNames(tagNames, namespace) {
    for (let i = this.stackTop; i >= 0; i--) {
      if (tagNames.has(this.tagIDs[i]) && this.treeAdapter.getNamespaceURI(this.items[i]) === namespace) {
        return i;
      }
    }
    return -1;
  }
  clearBackTo(tagNames, targetNS) {
    const idx = this._indexOfTagNames(tagNames, targetNS);
    this.shortenToLength(idx + 1);
  }
  clearBackToTableContext() {
    this.clearBackTo(TABLE_CONTEXT, NS.HTML);
  }
  clearBackToTableBodyContext() {
    this.clearBackTo(TABLE_BODY_CONTEXT, NS.HTML);
  }
  clearBackToTableRowContext() {
    this.clearBackTo(TABLE_ROW_CONTEXT, NS.HTML);
  }
  remove(element) {
    const idx = this._indexOf(element);
    if (idx >= 0) {
      if (idx === this.stackTop) {
        this.pop();
      } else {
        this.items.splice(idx, 1);
        this.tagIDs.splice(idx, 1);
        this.stackTop--;
        this._updateCurrentElement();
        this.handler.onItemPop(element, false);
      }
    }
  }
  //Search
  tryPeekProperlyNestedBodyElement() {
    return this.stackTop >= 1 && this.tagIDs[1] === TAG_ID.BODY ? this.items[1] : null;
  }
  contains(element) {
    return this._indexOf(element) > -1;
  }
  getCommonAncestor(element) {
    const elementIdx = this._indexOf(element) - 1;
    return elementIdx >= 0 ? this.items[elementIdx] : null;
  }
  isRootHtmlElementCurrent() {
    return this.stackTop === 0 && this.tagIDs[0] === TAG_ID.HTML;
  }
  //Element in scope
  hasInDynamicScope(tagName, htmlScope) {
    for (let i = this.stackTop; i >= 0; i--) {
      const tn = this.tagIDs[i];
      switch (this.treeAdapter.getNamespaceURI(this.items[i])) {
        case NS.HTML: {
          if (tn === tagName)
            return true;
          if (htmlScope.has(tn))
            return false;
          break;
        }
        case NS.SVG: {
          if (SCOPING_ELEMENTS_SVG.has(tn))
            return false;
          break;
        }
        case NS.MATHML: {
          if (SCOPING_ELEMENTS_MATHML.has(tn))
            return false;
          break;
        }
      }
    }
    return true;
  }
  hasInScope(tagName) {
    return this.hasInDynamicScope(tagName, SCOPING_ELEMENTS_HTML);
  }
  hasInListItemScope(tagName) {
    return this.hasInDynamicScope(tagName, SCOPING_ELEMENTS_HTML_LIST);
  }
  hasInButtonScope(tagName) {
    return this.hasInDynamicScope(tagName, SCOPING_ELEMENTS_HTML_BUTTON);
  }
  hasNumberedHeaderInScope() {
    for (let i = this.stackTop; i >= 0; i--) {
      const tn = this.tagIDs[i];
      switch (this.treeAdapter.getNamespaceURI(this.items[i])) {
        case NS.HTML: {
          if (NUMBERED_HEADERS.has(tn))
            return true;
          if (SCOPING_ELEMENTS_HTML.has(tn))
            return false;
          break;
        }
        case NS.SVG: {
          if (SCOPING_ELEMENTS_SVG.has(tn))
            return false;
          break;
        }
        case NS.MATHML: {
          if (SCOPING_ELEMENTS_MATHML.has(tn))
            return false;
          break;
        }
      }
    }
    return true;
  }
  hasInTableScope(tagName) {
    for (let i = this.stackTop; i >= 0; i--) {
      if (this.treeAdapter.getNamespaceURI(this.items[i]) !== NS.HTML) {
        continue;
      }
      switch (this.tagIDs[i]) {
        case tagName: {
          return true;
        }
        case TAG_ID.TABLE:
        case TAG_ID.HTML: {
          return false;
        }
      }
    }
    return true;
  }
  hasTableBodyContextInTableScope() {
    for (let i = this.stackTop; i >= 0; i--) {
      if (this.treeAdapter.getNamespaceURI(this.items[i]) !== NS.HTML) {
        continue;
      }
      switch (this.tagIDs[i]) {
        case TAG_ID.TBODY:
        case TAG_ID.THEAD:
        case TAG_ID.TFOOT: {
          return true;
        }
        case TAG_ID.TABLE:
        case TAG_ID.HTML: {
          return false;
        }
      }
    }
    return true;
  }
  hasInSelectScope(tagName) {
    for (let i = this.stackTop; i >= 0; i--) {
      if (this.treeAdapter.getNamespaceURI(this.items[i]) !== NS.HTML) {
        continue;
      }
      switch (this.tagIDs[i]) {
        case tagName: {
          return true;
        }
        case TAG_ID.OPTION:
        case TAG_ID.OPTGROUP: {
          break;
        }
        default: {
          return false;
        }
      }
    }
    return true;
  }
  //Implied end tags
  generateImpliedEndTags() {
    while (IMPLICIT_END_TAG_REQUIRED.has(this.currentTagId)) {
      this.pop();
    }
  }
  generateImpliedEndTagsThoroughly() {
    while (IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId)) {
      this.pop();
    }
  }
  generateImpliedEndTagsWithExclusion(exclusionId) {
    while (this.currentTagId !== exclusionId && IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId)) {
      this.pop();
    }
  }
};

// node_modules/parse5/dist/parser/formatting-element-list.js
var NOAH_ARK_CAPACITY = 3;
var EntryType;
(function(EntryType2) {
  EntryType2[EntryType2["Marker"] = 0] = "Marker";
  EntryType2[EntryType2["Element"] = 1] = "Element";
})(EntryType || (EntryType = {}));
var MARKER = { type: EntryType.Marker };
var FormattingElementList = class {
  constructor(treeAdapter) {
    this.treeAdapter = treeAdapter;
    this.entries = [];
    this.bookmark = null;
  }
  //Noah Ark's condition
  //OPTIMIZATION: at first we try to find possible candidates for exclusion using
  //lightweight heuristics without thorough attributes check.
  _getNoahArkConditionCandidates(newElement, neAttrs) {
    const candidates = [];
    const neAttrsLength = neAttrs.length;
    const neTagName = this.treeAdapter.getTagName(newElement);
    const neNamespaceURI = this.treeAdapter.getNamespaceURI(newElement);
    for (let i = 0; i < this.entries.length; i++) {
      const entry = this.entries[i];
      if (entry.type === EntryType.Marker) {
        break;
      }
      const { element } = entry;
      if (this.treeAdapter.getTagName(element) === neTagName && this.treeAdapter.getNamespaceURI(element) === neNamespaceURI) {
        const elementAttrs = this.treeAdapter.getAttrList(element);
        if (elementAttrs.length === neAttrsLength) {
          candidates.push({ idx: i, attrs: elementAttrs });
        }
      }
    }
    return candidates;
  }
  _ensureNoahArkCondition(newElement) {
    if (this.entries.length < NOAH_ARK_CAPACITY)
      return;
    const neAttrs = this.treeAdapter.getAttrList(newElement);
    const candidates = this._getNoahArkConditionCandidates(newElement, neAttrs);
    if (candidates.length < NOAH_ARK_CAPACITY)
      return;
    const neAttrsMap = new Map(neAttrs.map((neAttr) => [neAttr.name, neAttr.value]));
    let validCandidates = 0;
    for (let i = 0; i < candidates.length; i++) {
      const candidate = candidates[i];
      if (candidate.attrs.every((cAttr) => neAttrsMap.get(cAttr.name) === cAttr.value)) {
        validCandidates += 1;
        if (validCandidates >= NOAH_ARK_CAPACITY) {
          this.entries.splice(candidate.idx, 1);
        }
      }
    }
  }
  //Mutations
  insertMarker() {
    this.entries.unshift(MARKER);
  }
  pushElement(element, token) {
    this._ensureNoahArkCondition(element);
    this.entries.unshift({
      type: EntryType.Element,
      element,
      token
    });
  }
  insertElementAfterBookmark(element, token) {
    const bookmarkIdx = this.entries.indexOf(this.bookmark);
    this.entries.splice(bookmarkIdx, 0, {
      type: EntryType.Element,
      element,
      token
    });
  }
  removeEntry(entry) {
    const entryIndex = this.entries.indexOf(entry);
    if (entryIndex >= 0) {
      this.entries.splice(entryIndex, 1);
    }
  }
  /**
   * Clears the list of formatting elements up to the last marker.
   *
   * @see https://html.spec.whatwg.org/multipage/parsing.html#clear-the-list-of-active-formatting-elements-up-to-the-last-marker
   */
  clearToLastMarker() {
    const markerIdx = this.entries.indexOf(MARKER);
    if (markerIdx >= 0) {
      this.entries.splice(0, markerIdx + 1);
    } else {
      this.entries.length = 0;
    }
  }
  //Search
  getElementEntryInScopeWithTagName(tagName) {
    const entry = this.entries.find((entry2) => entry2.type === EntryType.Marker || this.treeAdapter.getTagName(entry2.element) === tagName);
    return entry && entry.type === EntryType.Element ? entry : null;
  }
  getElementEntry(element) {
    return this.entries.find((entry) => entry.type === EntryType.Element && entry.element === element);
  }
};

// node_modules/parse5/dist/tree-adapters/default.js
var defaultTreeAdapter = {
  //Node construction
  createDocument() {
    return {
      nodeName: "#document",
      mode: DOCUMENT_MODE.NO_QUIRKS,
      childNodes: []
    };
  },
  createDocumentFragment() {
    return {
      nodeName: "#document-fragment",
      childNodes: []
    };
  },
  createElement(tagName, namespaceURI, attrs) {
    return {
      nodeName: tagName,
      tagName,
      attrs,
      namespaceURI,
      childNodes: [],
      parentNode: null
    };
  },
  createCommentNode(data) {
    return {
      nodeName: "#comment",
      data,
      parentNode: null
    };
  },
  createTextNode(value) {
    return {
      nodeName: "#text",
      value,
      parentNode: null
    };
  },
  //Tree mutation
  appendChild(parentNode, newNode) {
    parentNode.childNodes.push(newNode);
    newNode.parentNode = parentNode;
  },
  insertBefore(parentNode, newNode, referenceNode) {
    const insertionIdx = parentNode.childNodes.indexOf(referenceNode);
    parentNode.childNodes.splice(insertionIdx, 0, newNode);
    newNode.parentNode = parentNode;
  },
  setTemplateContent(templateElement, contentElement) {
    templateElement.content = contentElement;
  },
  getTemplateContent(templateElement) {
    return templateElement.content;
  },
  setDocumentType(document2, name, publicId, systemId) {
    const doctypeNode = document2.childNodes.find((node) => node.nodeName === "#documentType");
    if (doctypeNode) {
      doctypeNode.name = name;
      doctypeNode.publicId = publicId;
      doctypeNode.systemId = systemId;
    } else {
      const node = {
        nodeName: "#documentType",
        name,
        publicId,
        systemId,
        parentNode: null
      };
      defaultTreeAdapter.appendChild(document2, node);
    }
  },
  setDocumentMode(document2, mode) {
    document2.mode = mode;
  },
  getDocumentMode(document2) {
    return document2.mode;
  },
  detachNode(node) {
    if (node.parentNode) {
      const idx = node.parentNode.childNodes.indexOf(node);
      node.parentNode.childNodes.splice(idx, 1);
      node.parentNode = null;
    }
  },
  insertText(parentNode, text) {
    if (parentNode.childNodes.length > 0) {
      const prevNode = parentNode.childNodes[parentNode.childNodes.length - 1];
      if (defaultTreeAdapter.isTextNode(prevNode)) {
        prevNode.value += text;
        return;
      }
    }
    defaultTreeAdapter.appendChild(parentNode, defaultTreeAdapter.createTextNode(text));
  },
  insertTextBefore(parentNode, text, referenceNode) {
    const prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1];
    if (prevNode && defaultTreeAdapter.isTextNode(prevNode)) {
      prevNode.value += text;
    } else {
      defaultTreeAdapter.insertBefore(parentNode, defaultTreeAdapter.createTextNode(text), referenceNode);
    }
  },
  adoptAttributes(recipient, attrs) {
    const recipientAttrsMap = new Set(recipient.attrs.map((attr) => attr.name));
    for (let j = 0; j < attrs.length; j++) {
      if (!recipientAttrsMap.has(attrs[j].name)) {
        recipient.attrs.push(attrs[j]);
      }
    }
  },
  //Tree traversing
  getFirstChild(node) {
    return node.childNodes[0];
  },
  getChildNodes(node) {
    return node.childNodes;
  },
  getParentNode(node) {
    return node.parentNode;
  },
  getAttrList(element) {
    return element.attrs;
  },
  //Node data
  getTagName(element) {
    return element.tagName;
  },
  getNamespaceURI(element) {
    return element.namespaceURI;
  },
  getTextNodeContent(textNode) {
    return textNode.value;
  },
  getCommentNodeContent(commentNode) {
    return commentNode.data;
  },
  getDocumentTypeNodeName(doctypeNode) {
    return doctypeNode.name;
  },
  getDocumentTypeNodePublicId(doctypeNode) {
    return doctypeNode.publicId;
  },
  getDocumentTypeNodeSystemId(doctypeNode) {
    return doctypeNode.systemId;
  },
  //Node types
  isTextNode(node) {
    return node.nodeName === "#text";
  },
  isCommentNode(node) {
    return node.nodeName === "#comment";
  },
  isDocumentTypeNode(node) {
    return node.nodeName === "#documentType";
  },
  isElementNode(node) {
    return Object.prototype.hasOwnProperty.call(node, "tagName");
  },
  // Source code location
  setNodeSourceCodeLocation(node, location2) {
    node.sourceCodeLocation = location2;
  },
  getNodeSourceCodeLocation(node) {
    return node.sourceCodeLocation;
  },
  updateNodeSourceCodeLocation(node, endLocation) {
    node.sourceCodeLocation = { ...node.sourceCodeLocation, ...endLocation };
  }
};

// node_modules/parse5/dist/common/doctype.js
var VALID_DOCTYPE_NAME = "html";
var VALID_SYSTEM_ID = "about:legacy-compat";
var QUIRKS_MODE_SYSTEM_ID = "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd";
var QUIRKS_MODE_PUBLIC_ID_PREFIXES = [
  "+//silmaril//dtd html pro v0r11 19970101//",
  "-//as//dtd html 3.0 aswedit + extensions//",
  "-//advasoft ltd//dtd html 3.0 aswedit + extensions//",
  "-//ietf//dtd html 2.0 level 1//",
  "-//ietf//dtd html 2.0 level 2//",
  "-//ietf//dtd html 2.0 strict level 1//",
  "-//ietf//dtd html 2.0 strict level 2//",
  "-//ietf//dtd html 2.0 strict//",
  "-//ietf//dtd html 2.0//",
  "-//ietf//dtd html 2.1e//",
  "-//ietf//dtd html 3.0//",
  "-//ietf//dtd html 3.2 final//",
  "-//ietf//dtd html 3.2//",
  "-//ietf//dtd html 3//",
  "-//ietf//dtd html level 0//",
  "-//ietf//dtd html level 1//",
  "-//ietf//dtd html level 2//",
  "-//ietf//dtd html level 3//",
  "-//ietf//dtd html strict level 0//",
  "-//ietf//dtd html strict level 1//",
  "-//ietf//dtd html strict level 2//",
  "-//ietf//dtd html strict level 3//",
  "-//ietf//dtd html strict//",
  "-//ietf//dtd html//",
  "-//metrius//dtd metrius presentational//",
  "-//microsoft//dtd internet explorer 2.0 html strict//",
  "-//microsoft//dtd internet explorer 2.0 html//",
  "-//microsoft//dtd internet explorer 2.0 tables//",
  "-//microsoft//dtd internet explorer 3.0 html strict//",
  "-//microsoft//dtd internet explorer 3.0 html//",
  "-//microsoft//dtd internet explorer 3.0 tables//",
  "-//netscape comm. corp.//dtd html//",
  "-//netscape comm. corp.//dtd strict html//",
  "-//o'reilly and associates//dtd html 2.0//",
  "-//o'reilly and associates//dtd html extended 1.0//",
  "-//o'reilly and associates//dtd html extended relaxed 1.0//",
  "-//sq//dtd html 2.0 hotmetal + extensions//",
  "-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//",
  "-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//",
  "-//spyglass//dtd html 2.0 extended//",
  "-//sun microsystems corp.//dtd hotjava html//",
  "-//sun microsystems corp.//dtd hotjava strict html//",
  "-//w3c//dtd html 3 1995-03-24//",
  "-//w3c//dtd html 3.2 draft//",
  "-//w3c//dtd html 3.2 final//",
  "-//w3c//dtd html 3.2//",
  "-//w3c//dtd html 3.2s draft//",
  "-//w3c//dtd html 4.0 frameset//",
  "-//w3c//dtd html 4.0 transitional//",
  "-//w3c//dtd html experimental 19960712//",
  "-//w3c//dtd html experimental 970421//",
  "-//w3c//dtd w3 html//",
  "-//w3o//dtd w3 html 3.0//",
  "-//webtechs//dtd mozilla html 2.0//",
  "-//webtechs//dtd mozilla html//"
];
var QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES = [
  ...QUIRKS_MODE_PUBLIC_ID_PREFIXES,
  "-//w3c//dtd html 4.01 frameset//",
  "-//w3c//dtd html 4.01 transitional//"
];
var QUIRKS_MODE_PUBLIC_IDS = /* @__PURE__ */ new Set([
  "-//w3o//dtd w3 html strict 3.0//en//",
  "-/w3c/dtd html 4.0 transitional/en",
  "html"
]);
var LIMITED_QUIRKS_PUBLIC_ID_PREFIXES = ["-//w3c//dtd xhtml 1.0 frameset//", "-//w3c//dtd xhtml 1.0 transitional//"];
var LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES = [
  ...LIMITED_QUIRKS_PUBLIC_ID_PREFIXES,
  "-//w3c//dtd html 4.01 frameset//",
  "-//w3c//dtd html 4.01 transitional//"
];
function hasPrefix(publicId, prefixes) {
  return prefixes.some((prefix) => publicId.startsWith(prefix));
}
function isConforming(token) {
  return token.name === VALID_DOCTYPE_NAME && token.publicId === null && (token.systemId === null || token.systemId === VALID_SYSTEM_ID);
}
function getDocumentMode(token) {
  if (token.name !== VALID_DOCTYPE_NAME) {
    return DOCUMENT_MODE.QUIRKS;
  }
  const { systemId } = token;
  if (systemId && systemId.toLowerCase() === QUIRKS_MODE_SYSTEM_ID) {
    return DOCUMENT_MODE.QUIRKS;
  }
  let { publicId } = token;
  if (publicId !== null) {
    publicId = publicId.toLowerCase();
    if (QUIRKS_MODE_PUBLIC_IDS.has(publicId)) {
      return DOCUMENT_MODE.QUIRKS;
    }
    let prefixes = systemId === null ? QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES : QUIRKS_MODE_PUBLIC_ID_PREFIXES;
    if (hasPrefix(publicId, prefixes)) {
      return DOCUMENT_MODE.QUIRKS;
    }
    prefixes = systemId === null ? LIMITED_QUIRKS_PUBLIC_ID_PREFIXES : LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES;
    if (hasPrefix(publicId, prefixes)) {
      return DOCUMENT_MODE.LIMITED_QUIRKS;
    }
  }
  return DOCUMENT_MODE.NO_QUIRKS;
}

// node_modules/parse5/dist/common/foreign-content.js
var foreign_content_exports = {};
__export(foreign_content_exports, {
  SVG_TAG_NAMES_ADJUSTMENT_MAP: () => SVG_TAG_NAMES_ADJUSTMENT_MAP,
  adjustTokenMathMLAttrs: () => adjustTokenMathMLAttrs,
  adjustTokenSVGAttrs: () => adjustTokenSVGAttrs,
  adjustTokenSVGTagName: () => adjustTokenSVGTagName,
  adjustTokenXMLAttrs: () => adjustTokenXMLAttrs,
  causesExit: () => causesExit,
  isIntegrationPoint: () => isIntegrationPoint
});
var MIME_TYPES = {
  TEXT_HTML: "text/html",
  APPLICATION_XML: "application/xhtml+xml"
};
var DEFINITION_URL_ATTR = "definitionurl";
var ADJUSTED_DEFINITION_URL_ATTR = "definitionURL";
var SVG_ATTRS_ADJUSTMENT_MAP = new Map([
  "attributeName",
  "attributeType",
  "baseFrequency",
  "baseProfile",
  "calcMode",
  "clipPathUnits",
  "diffuseConstant",
  "edgeMode",
  "filterUnits",
  "glyphRef",
  "gradientTransform",
  "gradientUnits",
  "kernelMatrix",
  "kernelUnitLength",
  "keyPoints",
  "keySplines",
  "keyTimes",
  "lengthAdjust",
  "limitingConeAngle",
  "markerHeight",
  "markerUnits",
  "markerWidth",
  "maskContentUnits",
  "maskUnits",
  "numOctaves",
  "pathLength",
  "patternContentUnits",
  "patternTransform",
  "patternUnits",
  "pointsAtX",
  "pointsAtY",
  "pointsAtZ",
  "preserveAlpha",
  "preserveAspectRatio",
  "primitiveUnits",
  "refX",
  "refY",
  "repeatCount",
  "repeatDur",
  "requiredExtensions",
  "requiredFeatures",
  "specularConstant",
  "specularExponent",
  "spreadMethod",
  "startOffset",
  "stdDeviation",
  "stitchTiles",
  "surfaceScale",
  "systemLanguage",
  "tableValues",
  "targetX",
  "targetY",
  "textLength",
  "viewBox",
  "viewTarget",
  "xChannelSelector",
  "yChannelSelector",
  "zoomAndPan"
].map((attr) => [attr.toLowerCase(), attr]));
var XML_ATTRS_ADJUSTMENT_MAP = /* @__PURE__ */ new Map([
  ["xlink:actuate", { prefix: "xlink", name: "actuate", namespace: NS.XLINK }],
  ["xlink:arcrole", { prefix: "xlink", name: "arcrole", namespace: NS.XLINK }],
  ["xlink:href", { prefix: "xlink", name: "href", namespace: NS.XLINK }],
  ["xlink:role", { prefix: "xlink", name: "role", namespace: NS.XLINK }],
  ["xlink:show", { prefix: "xlink", name: "show", namespace: NS.XLINK }],
  ["xlink:title", { prefix: "xlink", name: "title", namespace: NS.XLINK }],
  ["xlink:type", { prefix: "xlink", name: "type", namespace: NS.XLINK }],
  ["xml:lang", { prefix: "xml", name: "lang", namespace: NS.XML }],
  ["xml:space", { prefix: "xml", name: "space", namespace: NS.XML }],
  ["xmlns", { prefix: "", name: "xmlns", namespace: NS.XMLNS }],
  ["xmlns:xlink", { prefix: "xmlns", name: "xlink", namespace: NS.XMLNS }]
]);
var SVG_TAG_NAMES_ADJUSTMENT_MAP = new Map([
  "altGlyph",
  "altGlyphDef",
  "altGlyphItem",
  "animateColor",
  "animateMotion",
  "animateTransform",
  "clipPath",
  "feBlend",
  "feColorMatrix",
  "feComponentTransfer",
  "feComposite",
  "feConvolveMatrix",
  "feDiffuseLighting",
  "feDisplacementMap",
  "feDistantLight",
  "feFlood",
  "feFuncA",
  "feFuncB",
  "feFuncG",
  "feFuncR",
  "feGaussianBlur",
  "feImage",
  "feMerge",
  "feMergeNode",
  "feMorphology",
  "feOffset",
  "fePointLight",
  "feSpecularLighting",
  "feSpotLight",
  "feTile",
  "feTurbulence",
  "foreignObject",
  "glyphRef",
  "linearGradient",
  "radialGradient",
  "textPath"
].map((tn) => [tn.toLowerCase(), tn]));
var EXITS_FOREIGN_CONTENT = /* @__PURE__ */ new Set([
  TAG_ID.B,
  TAG_ID.BIG,
  TAG_ID.BLOCKQUOTE,
  TAG_ID.BODY,
  TAG_ID.BR,
  TAG_ID.CENTER,
  TAG_ID.CODE,
  TAG_ID.DD,
  TAG_ID.DIV,
  TAG_ID.DL,
  TAG_ID.DT,
  TAG_ID.EM,
  TAG_ID.EMBED,
  TAG_ID.H1,
  TAG_ID.H2,
  TAG_ID.H3,
  TAG_ID.H4,
  TAG_ID.H5,
  TAG_ID.H6,
  TAG_ID.HEAD,
  TAG_ID.HR,
  TAG_ID.I,
  TAG_ID.IMG,
  TAG_ID.LI,
  TAG_ID.LISTING,
  TAG_ID.MENU,
  TAG_ID.META,
  TAG_ID.NOBR,
  TAG_ID.OL,
  TAG_ID.P,
  TAG_ID.PRE,
  TAG_ID.RUBY,
  TAG_ID.S,
  TAG_ID.SMALL,
  TAG_ID.SPAN,
  TAG_ID.STRONG,
  TAG_ID.STRIKE,
  TAG_ID.SUB,
  TAG_ID.SUP,
  TAG_ID.TABLE,
  TAG_ID.TT,
  TAG_ID.U,
  TAG_ID.UL,
  TAG_ID.VAR
]);
function causesExit(startTagToken) {
  const tn = startTagToken.tagID;
  const isFontWithAttrs = tn === TAG_ID.FONT && startTagToken.attrs.some(({ name }) => name === ATTRS.COLOR || name === ATTRS.SIZE || name === ATTRS.FACE);
  return isFontWithAttrs || EXITS_FOREIGN_CONTENT.has(tn);
}
function adjustTokenMathMLAttrs(token) {
  for (let i = 0; i < token.attrs.length; i++) {
    if (token.attrs[i].name === DEFINITION_URL_ATTR) {
      token.attrs[i].name = ADJUSTED_DEFINITION_URL_ATTR;
      break;
    }
  }
}
function adjustTokenSVGAttrs(token) {
  for (let i = 0; i < token.attrs.length; i++) {
    const adjustedAttrName = SVG_ATTRS_ADJUSTMENT_MAP.get(token.attrs[i].name);
    if (adjustedAttrName != null) {
      token.attrs[i].name = adjustedAttrName;
    }
  }
}
function adjustTokenXMLAttrs(token) {
  for (let i = 0; i < token.attrs.length; i++) {
    const adjustedAttrEntry = XML_ATTRS_ADJUSTMENT_MAP.get(token.attrs[i].name);
    if (adjustedAttrEntry) {
      token.attrs[i].prefix = adjustedAttrEntry.prefix;
      token.attrs[i].name = adjustedAttrEntry.name;
      token.attrs[i].namespace = adjustedAttrEntry.namespace;
    }
  }
}
function adjustTokenSVGTagName(token) {
  const adjustedTagName = SVG_TAG_NAMES_ADJUSTMENT_MAP.get(token.tagName);
  if (adjustedTagName != null) {
    token.tagName = adjustedTagName;
    token.tagID = getTagID(token.tagName);
  }
}
function isMathMLTextIntegrationPoint(tn, ns) {
  return ns === NS.MATHML && (tn === TAG_ID.MI || tn === TAG_ID.MO || tn === TAG_ID.MN || tn === TAG_ID.MS || tn === TAG_ID.MTEXT);
}
function isHtmlIntegrationPoint(tn, ns, attrs) {
  if (ns === NS.MATHML && tn === TAG_ID.ANNOTATION_XML) {
    for (let i = 0; i < attrs.length; i++) {
      if (attrs[i].name === ATTRS.ENCODING) {
        const value = attrs[i].value.toLowerCase();
        return value === MIME_TYPES.TEXT_HTML || value === MIME_TYPES.APPLICATION_XML;
      }
    }
  }
  return ns === NS.SVG && (tn === TAG_ID.FOREIGN_OBJECT || tn === TAG_ID.DESC || tn === TAG_ID.TITLE);
}
function isIntegrationPoint(tn, ns, attrs, foreignNS) {
  return (!foreignNS || foreignNS === NS.HTML) && isHtmlIntegrationPoint(tn, ns, attrs) || (!foreignNS || foreignNS === NS.MATHML) && isMathMLTextIntegrationPoint(tn, ns);
}

// node_modules/parse5/dist/parser/index.js
var HIDDEN_INPUT_TYPE = "hidden";
var AA_OUTER_LOOP_ITER = 8;
var AA_INNER_LOOP_ITER = 3;
var InsertionMode;
(function(InsertionMode2) {
  InsertionMode2[InsertionMode2["INITIAL"] = 0] = "INITIAL";
  InsertionMode2[InsertionMode2["BEFORE_HTML"] = 1] = "BEFORE_HTML";
  InsertionMode2[InsertionMode2["BEFORE_HEAD"] = 2] = "BEFORE_HEAD";
  InsertionMode2[InsertionMode2["IN_HEAD"] = 3] = "IN_HEAD";
  InsertionMode2[InsertionMode2["IN_HEAD_NO_SCRIPT"] = 4] = "IN_HEAD_NO_SCRIPT";
  InsertionMode2[InsertionMode2["AFTER_HEAD"] = 5] = "AFTER_HEAD";
  InsertionMode2[InsertionMode2["IN_BODY"] = 6] = "IN_BODY";
  InsertionMode2[InsertionMode2["TEXT"] = 7] = "TEXT";
  InsertionMode2[InsertionMode2["IN_TABLE"] = 8] = "IN_TABLE";
  InsertionMode2[InsertionMode2["IN_TABLE_TEXT"] = 9] = "IN_TABLE_TEXT";
  InsertionMode2[InsertionMode2["IN_CAPTION"] = 10] = "IN_CAPTION";
  InsertionMode2[InsertionMode2["IN_COLUMN_GROUP"] = 11] = "IN_COLUMN_GROUP";
  InsertionMode2[InsertionMode2["IN_TABLE_BODY"] = 12] = "IN_TABLE_BODY";
  InsertionMode2[InsertionMode2["IN_ROW"] = 13] = "IN_ROW";
  InsertionMode2[InsertionMode2["IN_CELL"] = 14] = "IN_CELL";
  InsertionMode2[InsertionMode2["IN_SELECT"] = 15] = "IN_SELECT";
  InsertionMode2[InsertionMode2["IN_SELECT_IN_TABLE"] = 16] = "IN_SELECT_IN_TABLE";
  InsertionMode2[InsertionMode2["IN_TEMPLATE"] = 17] = "IN_TEMPLATE";
  InsertionMode2[InsertionMode2["AFTER_BODY"] = 18] = "AFTER_BODY";
  InsertionMode2[InsertionMode2["IN_FRAMESET"] = 19] = "IN_FRAMESET";
  InsertionMode2[InsertionMode2["AFTER_FRAMESET"] = 20] = "AFTER_FRAMESET";
  InsertionMode2[InsertionMode2["AFTER_AFTER_BODY"] = 21] = "AFTER_AFTER_BODY";
  InsertionMode2[InsertionMode2["AFTER_AFTER_FRAMESET"] = 22] = "AFTER_AFTER_FRAMESET";
})(InsertionMode || (InsertionMode = {}));
var BASE_LOC = {
  startLine: -1,
  startCol: -1,
  startOffset: -1,
  endLine: -1,
  endCol: -1,
  endOffset: -1
};
var TABLE_STRUCTURE_TAGS = /* @__PURE__ */ new Set([TAG_ID.TABLE, TAG_ID.TBODY, TAG_ID.TFOOT, TAG_ID.THEAD, TAG_ID.TR]);
var defaultParserOptions = {
  scriptingEnabled: true,
  sourceCodeLocationInfo: false,
  treeAdapter: defaultTreeAdapter,
  onParseError: null
};
var Parser = class {
  constructor(options, document2, fragmentContext = null, scriptHandler = null) {
    this.fragmentContext = fragmentContext;
    this.scriptHandler = scriptHandler;
    this.currentToken = null;
    this.stopped = false;
    this.insertionMode = InsertionMode.INITIAL;
    this.originalInsertionMode = InsertionMode.INITIAL;
    this.headElement = null;
    this.formElement = null;
    this.currentNotInHTML = false;
    this.tmplInsertionModeStack = [];
    this.pendingCharacterTokens = [];
    this.hasNonWhitespacePendingCharacterToken = false;
    this.framesetOk = true;
    this.skipNextNewLine = false;
    this.fosterParentingEnabled = false;
    this.options = {
      ...defaultParserOptions,
      ...options
    };
    this.treeAdapter = this.options.treeAdapter;
    this.onParseError = this.options.onParseError;
    if (this.onParseError) {
      this.options.sourceCodeLocationInfo = true;
    }
    this.document = document2 !== null && document2 !== void 0 ? document2 : this.treeAdapter.createDocument();
    this.tokenizer = new Tokenizer(this.options, this);
    this.activeFormattingElements = new FormattingElementList(this.treeAdapter);
    this.fragmentContextID = fragmentContext ? getTagID(this.treeAdapter.getTagName(fragmentContext)) : TAG_ID.UNKNOWN;
    this._setContextModes(fragmentContext !== null && fragmentContext !== void 0 ? fragmentContext : this.document, this.fragmentContextID);
    this.openElements = new OpenElementStack(this.document, this.treeAdapter, this);
  }
  // API
  static parse(html, options) {
    const parser = new this(options);
    parser.tokenizer.write(html, true);
    return parser.document;
  }
  static getFragmentParser(fragmentContext, options) {
    const opts = {
      ...defaultParserOptions,
      ...options
    };
    fragmentContext !== null && fragmentContext !== void 0 ? fragmentContext : fragmentContext = opts.treeAdapter.createElement(TAG_NAMES.TEMPLATE, NS.HTML, []);
    const documentMock = opts.treeAdapter.createElement("documentmock", NS.HTML, []);
    const parser = new this(opts, documentMock, fragmentContext);
    if (parser.fragmentContextID === TAG_ID.TEMPLATE) {
      parser.tmplInsertionModeStack.unshift(InsertionMode.IN_TEMPLATE);
    }
    parser._initTokenizerForFragmentParsing();
    parser._insertFakeRootElement();
    parser._resetInsertionMode();
    parser._findFormInFragmentContext();
    return parser;
  }
  getFragment() {
    const rootElement = this.treeAdapter.getFirstChild(this.document);
    const fragment = this.treeAdapter.createDocumentFragment();
    this._adoptNodes(rootElement, fragment);
    return fragment;
  }
  //Errors
  /** @internal */
  _err(token, code, beforeToken) {
    var _a2;
    if (!this.onParseError)
      return;
    const loc = (_a2 = token.location) !== null && _a2 !== void 0 ? _a2 : BASE_LOC;
    const err2 = {
      code,
      startLine: loc.startLine,
      startCol: loc.startCol,
      startOffset: loc.startOffset,
      endLine: beforeToken ? loc.startLine : loc.endLine,
      endCol: beforeToken ? loc.startCol : loc.endCol,
      endOffset: beforeToken ? loc.startOffset : loc.endOffset
    };
    this.onParseError(err2);
  }
  //Stack events
  /** @internal */
  onItemPush(node, tid, isTop) {
    var _a2, _b;
    (_b = (_a2 = this.treeAdapter).onItemPush) === null || _b === void 0 ? void 0 : _b.call(_a2, node);
    if (isTop && this.openElements.stackTop > 0)
      this._setContextModes(node, tid);
  }
  /** @internal */
  onItemPop(node, isTop) {
    var _a2, _b;
    if (this.options.sourceCodeLocationInfo) {
      this._setEndLocation(node, this.currentToken);
    }
    (_b = (_a2 = this.treeAdapter).onItemPop) === null || _b === void 0 ? void 0 : _b.call(_a2, node, this.openElements.current);
    if (isTop) {
      let current;
      let currentTagId;
      if (this.openElements.stackTop === 0 && this.fragmentContext) {
        current = this.fragmentContext;
        currentTagId = this.fragmentContextID;
      } else {
        ({ current, currentTagId } = this.openElements);
      }
      this._setContextModes(current, currentTagId);
    }
  }
  _setContextModes(current, tid) {
    const isHTML = current === this.document || this.treeAdapter.getNamespaceURI(current) === NS.HTML;
    this.currentNotInHTML = !isHTML;
    this.tokenizer.inForeignNode = !isHTML && !this._isIntegrationPoint(tid, current);
  }
  /** @protected */
  _switchToTextParsing(currentToken, nextTokenizerState) {
    this._insertElement(currentToken, NS.HTML);
    this.tokenizer.state = nextTokenizerState;
    this.originalInsertionMode = this.insertionMode;
    this.insertionMode = InsertionMode.TEXT;
  }
  switchToPlaintextParsing() {
    this.insertionMode = InsertionMode.TEXT;
    this.originalInsertionMode = InsertionMode.IN_BODY;
    this.tokenizer.state = TokenizerMode.PLAINTEXT;
  }
  //Fragment parsing
  /** @protected */
  _getAdjustedCurrentElement() {
    return this.openElements.stackTop === 0 && this.fragmentContext ? this.fragmentContext : this.openElements.current;
  }
  /** @protected */
  _findFormInFragmentContext() {
    let node = this.fragmentContext;
    while (node) {
      if (this.treeAdapter.getTagName(node) === TAG_NAMES.FORM) {
        this.formElement = node;
        break;
      }
      node = this.treeAdapter.getParentNode(node);
    }
  }
  _initTokenizerForFragmentParsing() {
    if (!this.fragmentContext || this.treeAdapter.getNamespaceURI(this.fragmentContext) !== NS.HTML) {
      return;
    }
    switch (this.fragmentContextID) {
      case TAG_ID.TITLE:
      case TAG_ID.TEXTAREA: {
        this.tokenizer.state = TokenizerMode.RCDATA;
        break;
      }
      case TAG_ID.STYLE:
      case TAG_ID.XMP:
      case TAG_ID.IFRAME:
      case TAG_ID.NOEMBED:
      case TAG_ID.NOFRAMES:
      case TAG_ID.NOSCRIPT: {
        this.tokenizer.state = TokenizerMode.RAWTEXT;
        break;
      }
      case TAG_ID.SCRIPT: {
        this.tokenizer.state = TokenizerMode.SCRIPT_DATA;
        break;
      }
      case TAG_ID.PLAINTEXT: {
        this.tokenizer.state = TokenizerMode.PLAINTEXT;
        break;
      }
      default:
    }
  }
  //Tree mutation
  /** @protected */
  _setDocumentType(token) {
    const name = token.name || "";
    const publicId = token.publicId || "";
    const systemId = token.systemId || "";
    this.treeAdapter.setDocumentType(this.document, name, publicId, systemId);
    if (token.location) {
      const documentChildren = this.treeAdapter.getChildNodes(this.document);
      const docTypeNode = documentChildren.find((node) => this.treeAdapter.isDocumentTypeNode(node));
      if (docTypeNode) {
        this.treeAdapter.setNodeSourceCodeLocation(docTypeNode, token.location);
      }
    }
  }
  /** @protected */
  _attachElementToTree(element, location2) {
    if (this.options.sourceCodeLocationInfo) {
      const loc = location2 && {
        ...location2,
        startTag: location2
      };
      this.treeAdapter.setNodeSourceCodeLocation(element, loc);
    }
    if (this._shouldFosterParentOnInsertion()) {
      this._fosterParentElement(element);
    } else {
      const parent = this.openElements.currentTmplContentOrNode;
      this.treeAdapter.appendChild(parent, element);
    }
  }
  /**
   * For self-closing tags. Add an element to the tree, but skip adding it
   * to the stack.
   */
  /** @protected */
  _appendElement(token, namespaceURI) {
    const element = this.treeAdapter.createElement(token.tagName, namespaceURI, token.attrs);
    this._attachElementToTree(element, token.location);
  }
  /** @protected */
  _insertElement(token, namespaceURI) {
    const element = this.treeAdapter.createElement(token.tagName, namespaceURI, token.attrs);
    this._attachElementToTree(element, token.location);
    this.openElements.push(element, token.tagID);
  }
  /** @protected */
  _insertFakeElement(tagName, tagID) {
    const element = this.treeAdapter.createElement(tagName, NS.HTML, []);
    this._attachElementToTree(element, null);
    this.openElements.push(element, tagID);
  }
  /** @protected */
  _insertTemplate(token) {
    const tmpl = this.treeAdapter.createElement(token.tagName, NS.HTML, token.attrs);
    const content = this.treeAdapter.createDocumentFragment();
    this.treeAdapter.setTemplateContent(tmpl, content);
    this._attachElementToTree(tmpl, token.location);
    this.openElements.push(tmpl, token.tagID);
    if (this.options.sourceCodeLocationInfo)
      this.treeAdapter.setNodeSourceCodeLocation(content, null);
  }
  /** @protected */
  _insertFakeRootElement() {
    const element = this.treeAdapter.createElement(TAG_NAMES.HTML, NS.HTML, []);
    if (this.options.sourceCodeLocationInfo)
      this.treeAdapter.setNodeSourceCodeLocation(element, null);
    this.treeAdapter.appendChild(this.openElements.current, element);
    this.openElements.push(element, TAG_ID.HTML);
  }
  /** @protected */
  _appendCommentNode(token, parent) {
    const commentNode = this.treeAdapter.createCommentNode(token.data);
    this.treeAdapter.appendChild(parent, commentNode);
    if (this.options.sourceCodeLocationInfo) {
      this.treeAdapter.setNodeSourceCodeLocation(commentNode, token.location);
    }
  }
  /** @protected */
  _insertCharacters(token) {
    let parent;
    let beforeElement;
    if (this._shouldFosterParentOnInsertion()) {
      ({ parent, beforeElement } = this._findFosterParentingLocation());
      if (beforeElement) {
        this.treeAdapter.insertTextBefore(parent, token.chars, beforeElement);
      } else {
        this.treeAdapter.insertText(parent, token.chars);
      }
    } else {
      parent = this.openElements.currentTmplContentOrNode;
      this.treeAdapter.insertText(parent, token.chars);
    }
    if (!token.location)
      return;
    const siblings = this.treeAdapter.getChildNodes(parent);
    const textNodeIdx = beforeElement ? siblings.lastIndexOf(beforeElement) : siblings.length;
    const textNode = siblings[textNodeIdx - 1];
    const tnLoc = this.treeAdapter.getNodeSourceCodeLocation(textNode);
    if (tnLoc) {
      const { endLine, endCol, endOffset } = token.location;
      this.treeAdapter.updateNodeSourceCodeLocation(textNode, { endLine, endCol, endOffset });
    } else if (this.options.sourceCodeLocationInfo) {
      this.treeAdapter.setNodeSourceCodeLocation(textNode, token.location);
    }
  }
  /** @protected */
  _adoptNodes(donor, recipient) {
    for (let child = this.treeAdapter.getFirstChild(donor); child; child = this.treeAdapter.getFirstChild(donor)) {
      this.treeAdapter.detachNode(child);
      this.treeAdapter.appendChild(recipient, child);
    }
  }
  /** @protected */
  _setEndLocation(element, closingToken) {
    if (this.treeAdapter.getNodeSourceCodeLocation(element) && closingToken.location) {
      const ctLoc = closingToken.location;
      const tn = this.treeAdapter.getTagName(element);
      const endLoc = (
        // NOTE: For cases like <p> <p> </p> - First 'p' closes without a closing
        // tag and for cases like <td> <p> </td> - 'p' closes without a closing tag.
        closingToken.type === TokenType.END_TAG && tn === closingToken.tagName ? {
          endTag: { ...ctLoc },
          endLine: ctLoc.endLine,
          endCol: ctLoc.endCol,
          endOffset: ctLoc.endOffset
        } : {
          endLine: ctLoc.startLine,
          endCol: ctLoc.startCol,
          endOffset: ctLoc.startOffset
        }
      );
      this.treeAdapter.updateNodeSourceCodeLocation(element, endLoc);
    }
  }
  //Token processing
  shouldProcessStartTagTokenInForeignContent(token) {
    if (!this.currentNotInHTML)
      return false;
    let current;
    let currentTagId;
    if (this.openElements.stackTop === 0 && this.fragmentContext) {
      current = this.fragmentContext;
      currentTagId = this.fragmentContextID;
    } else {
      ({ current, currentTagId } = this.openElements);
    }
    if (token.tagID === TAG_ID.SVG && this.treeAdapter.getTagName(current) === TAG_NAMES.ANNOTATION_XML && this.treeAdapter.getNamespaceURI(current) === NS.MATHML) {
      return false;
    }
    return (
      // Check that `current` is not an integration point for HTML or MathML elements.
      this.tokenizer.inForeignNode || // If it _is_ an integration point, then we might have to check that it is not an HTML
      // integration point.
      (token.tagID === TAG_ID.MGLYPH || token.tagID === TAG_ID.MALIGNMARK) && !this._isIntegrationPoint(currentTagId, current, NS.HTML)
    );
  }
  /** @protected */
  _processToken(token) {
    switch (token.type) {
      case TokenType.CHARACTER: {
        this.onCharacter(token);
        break;
      }
      case TokenType.NULL_CHARACTER: {
        this.onNullCharacter(token);
        break;
      }
      case TokenType.COMMENT: {
        this.onComment(token);
        break;
      }
      case TokenType.DOCTYPE: {
        this.onDoctype(token);
        break;
      }
      case TokenType.START_TAG: {
        this._processStartTag(token);
        break;
      }
      case TokenType.END_TAG: {
        this.onEndTag(token);
        break;
      }
      case TokenType.EOF: {
        this.onEof(token);
        break;
      }
      case TokenType.WHITESPACE_CHARACTER: {
        this.onWhitespaceCharacter(token);
        break;
      }
    }
  }
  //Integration points
  /** @protected */
  _isIntegrationPoint(tid, element, foreignNS) {
    const ns = this.treeAdapter.getNamespaceURI(element);
    const attrs = this.treeAdapter.getAttrList(element);
    return isIntegrationPoint(tid, ns, attrs, foreignNS);
  }
  //Active formatting elements reconstruction
  /** @protected */
  _reconstructActiveFormattingElements() {
    const listLength = this.activeFormattingElements.entries.length;
    if (listLength) {
      const endIndex = this.activeFormattingElements.entries.findIndex((entry) => entry.type === EntryType.Marker || this.openElements.contains(entry.element));
      const unopenIdx = endIndex < 0 ? listLength - 1 : endIndex - 1;
      for (let i = unopenIdx; i >= 0; i--) {
        const entry = this.activeFormattingElements.entries[i];
        this._insertElement(entry.token, this.treeAdapter.getNamespaceURI(entry.element));
        entry.element = this.openElements.current;
      }
    }
  }
  //Close elements
  /** @protected */
  _closeTableCell() {
    this.openElements.generateImpliedEndTags();
    this.openElements.popUntilTableCellPopped();
    this.activeFormattingElements.clearToLastMarker();
    this.insertionMode = InsertionMode.IN_ROW;
  }
  /** @protected */
  _closePElement() {
    this.openElements.generateImpliedEndTagsWithExclusion(TAG_ID.P);
    this.openElements.popUntilTagNamePopped(TAG_ID.P);
  }
  //Insertion modes
  /** @protected */
  _resetInsertionMode() {
    for (let i = this.openElements.stackTop; i >= 0; i--) {
      switch (i === 0 && this.fragmentContext ? this.fragmentContextID : this.openElements.tagIDs[i]) {
        case TAG_ID.TR: {
          this.insertionMode = InsertionMode.IN_ROW;
          return;
        }
        case TAG_ID.TBODY:
        case TAG_ID.THEAD:
        case TAG_ID.TFOOT: {
          this.insertionMode = InsertionMode.IN_TABLE_BODY;
          return;
        }
        case TAG_ID.CAPTION: {
          this.insertionMode = InsertionMode.IN_CAPTION;
          return;
        }
        case TAG_ID.COLGROUP: {
          this.insertionMode = InsertionMode.IN_COLUMN_GROUP;
          return;
        }
        case TAG_ID.TABLE: {
          this.insertionMode = InsertionMode.IN_TABLE;
          return;
        }
        case TAG_ID.BODY: {
          this.insertionMode = InsertionMode.IN_BODY;
          return;
        }
        case TAG_ID.FRAMESET: {
          this.insertionMode = InsertionMode.IN_FRAMESET;
          return;
        }
        case TAG_ID.SELECT: {
          this._resetInsertionModeForSelect(i);
          return;
        }
        case TAG_ID.TEMPLATE: {
          this.insertionMode = this.tmplInsertionModeStack[0];
          return;
        }
        case TAG_ID.HTML: {
          this.insertionMode = this.headElement ? InsertionMode.AFTER_HEAD : InsertionMode.BEFORE_HEAD;
          return;
        }
        case TAG_ID.TD:
        case TAG_ID.TH: {
          if (i > 0) {
            this.insertionMode = InsertionMode.IN_CELL;
            return;
          }
          break;
        }
        case TAG_ID.HEAD: {
          if (i > 0) {
            this.insertionMode = InsertionMode.IN_HEAD;
            return;
          }
          break;
        }
      }
    }
    this.insertionMode = InsertionMode.IN_BODY;
  }
  /** @protected */
  _resetInsertionModeForSelect(selectIdx) {
    if (selectIdx > 0) {
      for (let i = selectIdx - 1; i > 0; i--) {
        const tn = this.openElements.tagIDs[i];
        if (tn === TAG_ID.TEMPLATE) {
          break;
        } else if (tn === TAG_ID.TABLE) {
          this.insertionMode = InsertionMode.IN_SELECT_IN_TABLE;
          return;
        }
      }
    }
    this.insertionMode = InsertionMode.IN_SELECT;
  }
  //Foster parenting
  /** @protected */
  _isElementCausesFosterParenting(tn) {
    return TABLE_STRUCTURE_TAGS.has(tn);
  }
  /** @protected */
  _shouldFosterParentOnInsertion() {
    return this.fosterParentingEnabled && this._isElementCausesFosterParenting(this.openElements.currentTagId);
  }
  /** @protected */
  _findFosterParentingLocation() {
    for (let i = this.openElements.stackTop; i >= 0; i--) {
      const openElement = this.openElements.items[i];
      switch (this.openElements.tagIDs[i]) {
        case TAG_ID.TEMPLATE: {
          if (this.treeAdapter.getNamespaceURI(openElement) === NS.HTML) {
            return { parent: this.treeAdapter.getTemplateContent(openElement), beforeElement: null };
          }
          break;
        }
        case TAG_ID.TABLE: {
          const parent = this.treeAdapter.getParentNode(openElement);
          if (parent) {
            return { parent, beforeElement: openElement };
          }
          return { parent: this.openElements.items[i - 1], beforeElement: null };
        }
        default:
      }
    }
    return { parent: this.openElements.items[0], beforeElement: null };
  }
  /** @protected */
  _fosterParentElement(element) {
    const location2 = this._findFosterParentingLocation();
    if (location2.beforeElement) {
      this.treeAdapter.insertBefore(location2.parent, element, location2.beforeElement);
    } else {
      this.treeAdapter.appendChild(location2.parent, element);
    }
  }
  //Special elements
  /** @protected */
  _isSpecialElement(element, id) {
    const ns = this.treeAdapter.getNamespaceURI(element);
    return SPECIAL_ELEMENTS[ns].has(id);
  }
  /** @internal */
  onCharacter(token) {
    this.skipNextNewLine = false;
    if (this.tokenizer.inForeignNode) {
      characterInForeignContent(this, token);
      return;
    }
    switch (this.insertionMode) {
      case InsertionMode.INITIAL: {
        tokenInInitialMode(this, token);
        break;
      }
      case InsertionMode.BEFORE_HTML: {
        tokenBeforeHtml(this, token);
        break;
      }
      case InsertionMode.BEFORE_HEAD: {
        tokenBeforeHead(this, token);
        break;
      }
      case InsertionMode.IN_HEAD: {
        tokenInHead(this, token);
        break;
      }
      case InsertionMode.IN_HEAD_NO_SCRIPT: {
        tokenInHeadNoScript(this, token);
        break;
      }
      case InsertionMode.AFTER_HEAD: {
        tokenAfterHead(this, token);
        break;
      }
      case InsertionMode.IN_BODY:
      case InsertionMode.IN_CAPTION:
      case InsertionMode.IN_CELL:
      case InsertionMode.IN_TEMPLATE: {
        characterInBody(this, token);
        break;
      }
      case InsertionMode.TEXT:
      case InsertionMode.IN_SELECT:
      case InsertionMode.IN_SELECT_IN_TABLE: {
        this._insertCharacters(token);
        break;
      }
      case InsertionMode.IN_TABLE:
      case InsertionMode.IN_TABLE_BODY:
      case InsertionMode.IN_ROW: {
        characterInTable(this, token);
        break;
      }
      case InsertionMode.IN_TABLE_TEXT: {
        characterInTableText(this, token);
        break;
      }
      case InsertionMode.IN_COLUMN_GROUP: {
        tokenInColumnGroup(this, token);
        break;
      }
      case InsertionMode.AFTER_BODY: {
        tokenAfterBody(this, token);
        break;
      }
      case InsertionMode.AFTER_AFTER_BODY: {
        tokenAfterAfterBody(this, token);
        break;
      }
      default:
    }
  }
  /** @internal */
  onNullCharacter(token) {
    this.skipNextNewLine = false;
    if (this.tokenizer.inForeignNode) {
      nullCharacterInForeignContent(this, token);
      return;
    }
    switch (this.insertionMode) {
      case InsertionMode.INITIAL: {
        tokenInInitialMode(this, token);
        break;
      }
      case InsertionMode.BEFORE_HTML: {
        tokenBeforeHtml(this, token);
        break;
      }
      case InsertionMode.BEFORE_HEAD: {
        tokenBeforeHead(this, token);
        break;
      }
      case InsertionMode.IN_HEAD: {
        tokenInHead(this, token);
        break;
      }
      case InsertionMode.IN_HEAD_NO_SCRIPT: {
        tokenInHeadNoScript(this, token);
        break;
      }
      case InsertionMode.AFTER_HEAD: {
        tokenAfterHead(this, token);
        break;
      }
      case InsertionMode.TEXT: {
        this._insertCharacters(token);
        break;
      }
      case InsertionMode.IN_TABLE:
      case InsertionMode.IN_TABLE_BODY:
      case InsertionMode.IN_ROW: {
        characterInTable(this, token);
        break;
      }
      case InsertionMode.IN_COLUMN_GROUP: {
        tokenInColumnGroup(this, token);
        break;
      }
      case InsertionMode.AFTER_BODY: {
        tokenAfterBody(this, token);
        break;
      }
      case InsertionMode.AFTER_AFTER_BODY: {
        tokenAfterAfterBody(this, token);
        break;
      }
      default:
    }
  }
  /** @internal */
  onComment(token) {
    this.skipNextNewLine = false;
    if (this.currentNotInHTML) {
      appendComment(this, token);
      return;
    }
    switch (this.insertionMode) {
      case InsertionMode.INITIAL:
      case InsertionMode.BEFORE_HTML:
      case InsertionMode.BEFORE_HEAD:
      case InsertionMode.IN_HEAD:
      case InsertionMode.IN_HEAD_NO_SCRIPT:
      case InsertionMode.AFTER_HEAD:
      case InsertionMode.IN_BODY:
      case InsertionMode.IN_TABLE:
      case InsertionMode.IN_CAPTION:
      case InsertionMode.IN_COLUMN_GROUP:
      case InsertionMode.IN_TABLE_BODY:
      case InsertionMode.IN_ROW:
      case InsertionMode.IN_CELL:
      case InsertionMode.IN_SELECT:
      case InsertionMode.IN_SELECT_IN_TABLE:
      case InsertionMode.IN_TEMPLATE:
      case InsertionMode.IN_FRAMESET:
      case InsertionMode.AFTER_FRAMESET: {
        appendComment(this, token);
        break;
      }
      case InsertionMode.IN_TABLE_TEXT: {
        tokenInTableText(this, token);
        break;
      }
      case InsertionMode.AFTER_BODY: {
        appendCommentToRootHtmlElement(this, token);
        break;
      }
      case InsertionMode.AFTER_AFTER_BODY:
      case InsertionMode.AFTER_AFTER_FRAMESET: {
        appendCommentToDocument(this, token);
        break;
      }
      default:
    }
  }
  /** @internal */
  onDoctype(token) {
    this.skipNextNewLine = false;
    switch (this.insertionMode) {
      case InsertionMode.INITIAL: {
        doctypeInInitialMode(this, token);
        break;
      }
      case InsertionMode.BEFORE_HEAD:
      case InsertionMode.IN_HEAD:
      case InsertionMode.IN_HEAD_NO_SCRIPT:
      case InsertionMode.AFTER_HEAD: {
        this._err(token, ERR.misplacedDoctype);
        break;
      }
      case InsertionMode.IN_TABLE_TEXT: {
        tokenInTableText(this, token);
        break;
      }
      default:
    }
  }
  /** @internal */
  onStartTag(token) {
    this.skipNextNewLine = false;
    this.currentToken = token;
    this._processStartTag(token);
    if (token.selfClosing && !token.ackSelfClosing) {
      this._err(token, ERR.nonVoidHtmlElementStartTagWithTrailingSolidus);
    }
  }
  /**
   * Processes a given start tag.
   *
   * `onStartTag` checks if a self-closing tag was recognized. When a token
   * is moved inbetween multiple insertion modes, this check for self-closing
   * could lead to false positives. To avoid this, `_processStartTag` is used
   * for nested calls.
   *
   * @param token The token to process.
   * @protected
   */
  _processStartTag(token) {
    if (this.shouldProcessStartTagTokenInForeignContent(token)) {
      startTagInForeignContent(this, token);
    } else {
      this._startTagOutsideForeignContent(token);
    }
  }
  /** @protected */
  _startTagOutsideForeignContent(token) {
    switch (this.insertionMode) {
      case InsertionMode.INITIAL: {
        tokenInInitialMode(this, token);
        break;
      }
      case InsertionMode.BEFORE_HTML: {
        startTagBeforeHtml(this, token);
        break;
      }
      case InsertionMode.BEFORE_HEAD: {
        startTagBeforeHead(this, token);
        break;
      }
      case InsertionMode.IN_HEAD: {
        startTagInHead(this, token);
        break;
      }
      case InsertionMode.IN_HEAD_NO_SCRIPT: {
        startTagInHeadNoScript(this, token);
        break;
      }
      case InsertionMode.AFTER_HEAD: {
        startTagAfterHead(this, token);
        break;
      }
      case InsertionMode.IN_BODY: {
        startTagInBody(this, token);
        break;
      }
      case InsertionMode.IN_TABLE: {
        startTagInTable(this, token);
        break;
      }
      case InsertionMode.IN_TABLE_TEXT: {
        tokenInTableText(this, token);
        break;
      }
      case InsertionMode.IN_CAPTION: {
        startTagInCaption(this, token);
        break;
      }
      case InsertionMode.IN_COLUMN_GROUP: {
        startTagInColumnGroup(this, token);
        break;
      }
      case InsertionMode.IN_TABLE_BODY: {
        startTagInTableBody(this, token);
        break;
      }
      case InsertionMode.IN_ROW: {
        startTagInRow(this, token);
        break;
      }
      case InsertionMode.IN_CELL: {
        startTagInCell(this, token);
        break;
      }
      case InsertionMode.IN_SELECT: {
        startTagInSelect(this, token);
        break;
      }
      case InsertionMode.IN_SELECT_IN_TABLE: {
        startTagInSelectInTable(this, token);
        break;
      }
      case InsertionMode.IN_TEMPLATE: {
        startTagInTemplate(this, token);
        break;
      }
      case InsertionMode.AFTER_BODY: {
        startTagAfterBody(this, token);
        break;
      }
      case InsertionMode.IN_FRAMESET: {
        startTagInFrameset(this, token);
        break;
      }
      case InsertionMode.AFTER_FRAMESET: {
        startTagAfterFrameset(this, token);
        break;
      }
      case InsertionMode.AFTER_AFTER_BODY: {
        startTagAfterAfterBody(this, token);
        break;
      }
      case InsertionMode.AFTER_AFTER_FRAMESET: {
        startTagAfterAfterFrameset(this, token);
        break;
      }
      default:
    }
  }
  /** @internal */
  onEndTag(token) {
    this.skipNextNewLine = false;
    this.currentToken = token;
    if (this.currentNotInHTML) {
      endTagInForeignContent(this, token);
    } else {
      this._endTagOutsideForeignContent(token);
    }
  }
  /** @protected */
  _endTagOutsideForeignContent(token) {
    switch (this.insertionMode) {
      case InsertionMode.INITIAL: {
        tokenInInitialMode(this, token);
        break;
      }
      case InsertionMode.BEFORE_HTML: {
        endTagBeforeHtml(this, token);
        break;
      }
      case InsertionMode.BEFORE_HEAD: {
        endTagBeforeHead(this, token);
        break;
      }
      case InsertionMode.IN_HEAD: {
        endTagInHead(this, token);
        break;
      }
      case InsertionMode.IN_HEAD_NO_SCRIPT: {
        endTagInHeadNoScript(this, token);
        break;
      }
      case InsertionMode.AFTER_HEAD: {
        endTagAfterHead(this, token);
        break;
      }
      case InsertionMode.IN_BODY: {
        endTagInBody(this, token);
        break;
      }
      case InsertionMode.TEXT: {
        endTagInText(this, token);
        break;
      }
      case InsertionMode.IN_TABLE: {
        endTagInTable(this, token);
        break;
      }
      case InsertionMode.IN_TABLE_TEXT: {
        tokenInTableText(this, token);
        break;
      }
      case InsertionMode.IN_CAPTION: {
        endTagInCaption(this, token);
        break;
      }
      case InsertionMode.IN_COLUMN_GROUP: {
        endTagInColumnGroup(this, token);
        break;
      }
      case InsertionMode.IN_TABLE_BODY: {
        endTagInTableBody(this, token);
        break;
      }
      case InsertionMode.IN_ROW: {
        endTagInRow(this, token);
        break;
      }
      case InsertionMode.IN_CELL: {
        endTagInCell(this, token);
        break;
      }
      case InsertionMode.IN_SELECT: {
        endTagInSelect(this, token);
        break;
      }
      case InsertionMode.IN_SELECT_IN_TABLE: {
        endTagInSelectInTable(this, token);
        break;
      }
      case InsertionMode.IN_TEMPLATE: {
        endTagInTemplate(this, token);
        break;
      }
      case InsertionMode.AFTER_BODY: {
        endTagAfterBody(this, token);
        break;
      }
      case InsertionMode.IN_FRAMESET: {
        endTagInFrameset(this, token);
        break;
      }
      case InsertionMode.AFTER_FRAMESET: {
        endTagAfterFrameset(this, token);
        break;
      }
      case InsertionMode.AFTER_AFTER_BODY: {
        tokenAfterAfterBody(this, token);
        break;
      }
      default:
    }
  }
  /** @internal */
  onEof(token) {
    switch (this.insertionMode) {
      case InsertionMode.INITIAL: {
        tokenInInitialMode(this, token);
        break;
      }
      case InsertionMode.BEFORE_HTML: {
        tokenBeforeHtml(this, token);
        break;
      }
      case InsertionMode.BEFORE_HEAD: {
        tokenBeforeHead(this, token);
        break;
      }
      case InsertionMode.IN_HEAD: {
        tokenInHead(this, token);
        break;
      }
      case InsertionMode.IN_HEAD_NO_SCRIPT: {
        tokenInHeadNoScript(this, token);
        break;
      }
      case InsertionMode.AFTER_HEAD: {
        tokenAfterHead(this, token);
        break;
      }
      case InsertionMode.IN_BODY:
      case InsertionMode.IN_TABLE:
      case InsertionMode.IN_CAPTION:
      case InsertionMode.IN_COLUMN_GROUP:
      case InsertionMode.IN_TABLE_BODY:
      case InsertionMode.IN_ROW:
      case InsertionMode.IN_CELL:
      case InsertionMode.IN_SELECT:
      case InsertionMode.IN_SELECT_IN_TABLE: {
        eofInBody(this, token);
        break;
      }
      case InsertionMode.TEXT: {
        eofInText(this, token);
        break;
      }
      case InsertionMode.IN_TABLE_TEXT: {
        tokenInTableText(this, token);
        break;
      }
      case InsertionMode.IN_TEMPLATE: {
        eofInTemplate(this, token);
        break;
      }
      case InsertionMode.AFTER_BODY:
      case InsertionMode.IN_FRAMESET:
      case InsertionMode.AFTER_FRAMESET:
      case InsertionMode.AFTER_AFTER_BODY:
      case InsertionMode.AFTER_AFTER_FRAMESET: {
        stopParsing(this, token);
        break;
      }
      default:
    }
  }
  /** @internal */
  onWhitespaceCharacter(token) {
    if (this.skipNextNewLine) {
      this.skipNextNewLine = false;
      if (token.chars.charCodeAt(0) === CODE_POINTS.LINE_FEED) {
        if (token.chars.length === 1) {
          return;
        }
        token.chars = token.chars.substr(1);
      }
    }
    if (this.tokenizer.inForeignNode) {
      this._insertCharacters(token);
      return;
    }
    switch (this.insertionMode) {
      case InsertionMode.IN_HEAD:
      case InsertionMode.IN_HEAD_NO_SCRIPT:
      case InsertionMode.AFTER_HEAD:
      case InsertionMode.TEXT:
      case InsertionMode.IN_COLUMN_GROUP:
      case InsertionMode.IN_SELECT:
      case InsertionMode.IN_SELECT_IN_TABLE:
      case InsertionMode.IN_FRAMESET:
      case InsertionMode.AFTER_FRAMESET: {
        this._insertCharacters(token);
        break;
      }
      case InsertionMode.IN_BODY:
      case InsertionMode.IN_CAPTION:
      case InsertionMode.IN_CELL:
      case InsertionMode.IN_TEMPLATE:
      case InsertionMode.AFTER_BODY:
      case InsertionMode.AFTER_AFTER_BODY:
      case InsertionMode.AFTER_AFTER_FRAMESET: {
        whitespaceCharacterInBody(this, token);
        break;
      }
      case InsertionMode.IN_TABLE:
      case InsertionMode.IN_TABLE_BODY:
      case InsertionMode.IN_ROW: {
        characterInTable(this, token);
        break;
      }
      case InsertionMode.IN_TABLE_TEXT: {
        whitespaceCharacterInTableText(this, token);
        break;
      }
      default:
    }
  }
};
function aaObtainFormattingElementEntry(p, token) {
  let formattingElementEntry = p.activeFormattingElements.getElementEntryInScopeWithTagName(token.tagName);
  if (formattingElementEntry) {
    if (!p.openElements.contains(formattingElementEntry.element)) {
      p.activeFormattingElements.removeEntry(formattingElementEntry);
      formattingElementEntry = null;
    } else if (!p.openElements.hasInScope(token.tagID)) {
      formattingElementEntry = null;
    }
  } else {
    genericEndTagInBody(p, token);
  }
  return formattingElementEntry;
}
function aaObtainFurthestBlock(p, formattingElementEntry) {
  let furthestBlock = null;
  let idx = p.openElements.stackTop;
  for (; idx >= 0; idx--) {
    const element = p.openElements.items[idx];
    if (element === formattingElementEntry.element) {
      break;
    }
    if (p._isSpecialElement(element, p.openElements.tagIDs[idx])) {
      furthestBlock = element;
    }
  }
  if (!furthestBlock) {
    p.openElements.shortenToLength(idx < 0 ? 0 : idx);
    p.activeFormattingElements.removeEntry(formattingElementEntry);
  }
  return furthestBlock;
}
function aaInnerLoop(p, furthestBlock, formattingElement) {
  let lastElement = furthestBlock;
  let nextElement = p.openElements.getCommonAncestor(furthestBlock);
  for (let i = 0, element = nextElement; element !== formattingElement; i++, element = nextElement) {
    nextElement = p.openElements.getCommonAncestor(element);
    const elementEntry = p.activeFormattingElements.getElementEntry(element);
    const counterOverflow = elementEntry && i >= AA_INNER_LOOP_ITER;
    const shouldRemoveFromOpenElements = !elementEntry || counterOverflow;
    if (shouldRemoveFromOpenElements) {
      if (counterOverflow) {
        p.activeFormattingElements.removeEntry(elementEntry);
      }
      p.openElements.remove(element);
    } else {
      element = aaRecreateElementFromEntry(p, elementEntry);
      if (lastElement === furthestBlock) {
        p.activeFormattingElements.bookmark = elementEntry;
      }
      p.treeAdapter.detachNode(lastElement);
      p.treeAdapter.appendChild(element, lastElement);
      lastElement = element;
    }
  }
  return lastElement;
}
function aaRecreateElementFromEntry(p, elementEntry) {
  const ns = p.treeAdapter.getNamespaceURI(elementEntry.element);
  const newElement = p.treeAdapter.createElement(elementEntry.token.tagName, ns, elementEntry.token.attrs);
  p.openElements.replace(elementEntry.element, newElement);
  elementEntry.element = newElement;
  return newElement;
}
function aaInsertLastNodeInCommonAncestor(p, commonAncestor, lastElement) {
  const tn = p.treeAdapter.getTagName(commonAncestor);
  const tid = getTagID(tn);
  if (p._isElementCausesFosterParenting(tid)) {
    p._fosterParentElement(lastElement);
  } else {
    const ns = p.treeAdapter.getNamespaceURI(commonAncestor);
    if (tid === TAG_ID.TEMPLATE && ns === NS.HTML) {
      commonAncestor = p.treeAdapter.getTemplateContent(commonAncestor);
    }
    p.treeAdapter.appendChild(commonAncestor, lastElement);
  }
}
function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {
  const ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element);
  const { token } = formattingElementEntry;
  const newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);
  p._adoptNodes(furthestBlock, newElement);
  p.treeAdapter.appendChild(furthestBlock, newElement);
  p.activeFormattingElements.insertElementAfterBookmark(newElement, token);
  p.activeFormattingElements.removeEntry(formattingElementEntry);
  p.openElements.remove(formattingElementEntry.element);
  p.openElements.insertAfter(furthestBlock, newElement, token.tagID);
}
function callAdoptionAgency(p, token) {
  for (let i = 0; i < AA_OUTER_LOOP_ITER; i++) {
    const formattingElementEntry = aaObtainFormattingElementEntry(p, token);
    if (!formattingElementEntry) {
      break;
    }
    const furthestBlock = aaObtainFurthestBlock(p, formattingElementEntry);
    if (!furthestBlock) {
      break;
    }
    p.activeFormattingElements.bookmark = formattingElementEntry;
    const lastElement = aaInnerLoop(p, furthestBlock, formattingElementEntry.element);
    const commonAncestor = p.openElements.getCommonAncestor(formattingElementEntry.element);
    p.treeAdapter.detachNode(lastElement);
    if (commonAncestor)
      aaInsertLastNodeInCommonAncestor(p, commonAncestor, lastElement);
    aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry);
  }
}
function appendComment(p, token) {
  p._appendCommentNode(token, p.openElements.currentTmplContentOrNode);
}
function appendCommentToRootHtmlElement(p, token) {
  p._appendCommentNode(token, p.openElements.items[0]);
}
function appendCommentToDocument(p, token) {
  p._appendCommentNode(token, p.document);
}
function stopParsing(p, token) {
  p.stopped = true;
  if (token.location) {
    const target = p.fragmentContext ? 0 : 2;
    for (let i = p.openElements.stackTop; i >= target; i--) {
      p._setEndLocation(p.openElements.items[i], token);
    }
    if (!p.fragmentContext && p.openElements.stackTop >= 0) {
      const htmlElement = p.openElements.items[0];
      const htmlLocation = p.treeAdapter.getNodeSourceCodeLocation(htmlElement);
      if (htmlLocation && !htmlLocation.endTag) {
        p._setEndLocation(htmlElement, token);
        if (p.openElements.stackTop >= 1) {
          const bodyElement = p.openElements.items[1];
          const bodyLocation = p.treeAdapter.getNodeSourceCodeLocation(bodyElement);
          if (bodyLocation && !bodyLocation.endTag) {
            p._setEndLocation(bodyElement, token);
          }
        }
      }
    }
  }
}
function doctypeInInitialMode(p, token) {
  p._setDocumentType(token);
  const mode = token.forceQuirks ? DOCUMENT_MODE.QUIRKS : getDocumentMode(token);
  if (!isConforming(token)) {
    p._err(token, ERR.nonConformingDoctype);
  }
  p.treeAdapter.setDocumentMode(p.document, mode);
  p.insertionMode = InsertionMode.BEFORE_HTML;
}
function tokenInInitialMode(p, token) {
  p._err(token, ERR.missingDoctype, true);
  p.treeAdapter.setDocumentMode(p.document, DOCUMENT_MODE.QUIRKS);
  p.insertionMode = InsertionMode.BEFORE_HTML;
  p._processToken(token);
}
function startTagBeforeHtml(p, token) {
  if (token.tagID === TAG_ID.HTML) {
    p._insertElement(token, NS.HTML);
    p.insertionMode = InsertionMode.BEFORE_HEAD;
  } else {
    tokenBeforeHtml(p, token);
  }
}
function endTagBeforeHtml(p, token) {
  const tn = token.tagID;
  if (tn === TAG_ID.HTML || tn === TAG_ID.HEAD || tn === TAG_ID.BODY || tn === TAG_ID.BR) {
    tokenBeforeHtml(p, token);
  }
}
function tokenBeforeHtml(p, token) {
  p._insertFakeRootElement();
  p.insertionMode = InsertionMode.BEFORE_HEAD;
  p._processToken(token);
}
function startTagBeforeHead(p, token) {
  switch (token.tagID) {
    case TAG_ID.HTML: {
      startTagInBody(p, token);
      break;
    }
    case TAG_ID.HEAD: {
      p._insertElement(token, NS.HTML);
      p.headElement = p.openElements.current;
      p.insertionMode = InsertionMode.IN_HEAD;
      break;
    }
    default: {
      tokenBeforeHead(p, token);
    }
  }
}
function endTagBeforeHead(p, token) {
  const tn = token.tagID;
  if (tn === TAG_ID.HEAD || tn === TAG_ID.BODY || tn === TAG_ID.HTML || tn === TAG_ID.BR) {
    tokenBeforeHead(p, token);
  } else {
    p._err(token, ERR.endTagWithoutMatchingOpenElement);
  }
}
function tokenBeforeHead(p, token) {
  p._insertFakeElement(TAG_NAMES.HEAD, TAG_ID.HEAD);
  p.headElement = p.openElements.current;
  p.insertionMode = InsertionMode.IN_HEAD;
  p._processToken(token);
}
function startTagInHead(p, token) {
  switch (token.tagID) {
    case TAG_ID.HTML: {
      startTagInBody(p, token);
      break;
    }
    case TAG_ID.BASE:
    case TAG_ID.BASEFONT:
    case TAG_ID.BGSOUND:
    case TAG_ID.LINK:
    case TAG_ID.META: {
      p._appendElement(token, NS.HTML);
      token.ackSelfClosing = true;
      break;
    }
    case TAG_ID.TITLE: {
      p._switchToTextParsing(token, TokenizerMode.RCDATA);
      break;
    }
    case TAG_ID.NOSCRIPT: {
      if (p.options.scriptingEnabled) {
        p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
      } else {
        p._insertElement(token, NS.HTML);
        p.insertionMode = InsertionMode.IN_HEAD_NO_SCRIPT;
      }
      break;
    }
    case TAG_ID.NOFRAMES:
    case TAG_ID.STYLE: {
      p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
      break;
    }
    case TAG_ID.SCRIPT: {
      p._switchToTextParsing(token, TokenizerMode.SCRIPT_DATA);
      break;
    }
    case TAG_ID.TEMPLATE: {
      p._insertTemplate(token);
      p.activeFormattingElements.insertMarker();
      p.framesetOk = false;
      p.insertionMode = InsertionMode.IN_TEMPLATE;
      p.tmplInsertionModeStack.unshift(InsertionMode.IN_TEMPLATE);
      break;
    }
    case TAG_ID.HEAD: {
      p._err(token, ERR.misplacedStartTagForHeadElement);
      break;
    }
    default: {
      tokenInHead(p, token);
    }
  }
}
function endTagInHead(p, token) {
  switch (token.tagID) {
    case TAG_ID.HEAD: {
      p.openElements.pop();
      p.insertionMode = InsertionMode.AFTER_HEAD;
      break;
    }
    case TAG_ID.BODY:
    case TAG_ID.BR:
    case TAG_ID.HTML: {
      tokenInHead(p, token);
      break;
    }
    case TAG_ID.TEMPLATE: {
      templateEndTagInHead(p, token);
      break;
    }
    default: {
      p._err(token, ERR.endTagWithoutMatchingOpenElement);
    }
  }
}
function templateEndTagInHead(p, token) {
  if (p.openElements.tmplCount > 0) {
    p.openElements.generateImpliedEndTagsThoroughly();
    if (p.openElements.currentTagId !== TAG_ID.TEMPLATE) {
      p._err(token, ERR.closingOfElementWithOpenChildElements);
    }
    p.openElements.popUntilTagNamePopped(TAG_ID.TEMPLATE);
    p.activeFormattingElements.clearToLastMarker();
    p.tmplInsertionModeStack.shift();
    p._resetInsertionMode();
  } else {
    p._err(token, ERR.endTagWithoutMatchingOpenElement);
  }
}
function tokenInHead(p, token) {
  p.openElements.pop();
  p.insertionMode = InsertionMode.AFTER_HEAD;
  p._processToken(token);
}
function startTagInHeadNoScript(p, token) {
  switch (token.tagID) {
    case TAG_ID.HTML: {
      startTagInBody(p, token);
      break;
    }
    case TAG_ID.BASEFONT:
    case TAG_ID.BGSOUND:
    case TAG_ID.HEAD:
    case TAG_ID.LINK:
    case TAG_ID.META:
    case TAG_ID.NOFRAMES:
    case TAG_ID.STYLE: {
      startTagInHead(p, token);
      break;
    }
    case TAG_ID.NOSCRIPT: {
      p._err(token, ERR.nestedNoscriptInHead);
      break;
    }
    default: {
      tokenInHeadNoScript(p, token);
    }
  }
}
function endTagInHeadNoScript(p, token) {
  switch (token.tagID) {
    case TAG_ID.NOSCRIPT: {
      p.openElements.pop();
      p.insertionMode = InsertionMode.IN_HEAD;
      break;
    }
    case TAG_ID.BR: {
      tokenInHeadNoScript(p, token);
      break;
    }
    default: {
      p._err(token, ERR.endTagWithoutMatchingOpenElement);
    }
  }
}
function tokenInHeadNoScript(p, token) {
  const errCode = token.type === TokenType.EOF ? ERR.openElementsLeftAfterEof : ERR.disallowedContentInNoscriptInHead;
  p._err(token, errCode);
  p.openElements.pop();
  p.insertionMode = InsertionMode.IN_HEAD;
  p._processToken(token);
}
function startTagAfterHead(p, token) {
  switch (token.tagID) {
    case TAG_ID.HTML: {
      startTagInBody(p, token);
      break;
    }
    case TAG_ID.BODY: {
      p._insertElement(token, NS.HTML);
      p.framesetOk = false;
      p.insertionMode = InsertionMode.IN_BODY;
      break;
    }
    case TAG_ID.FRAMESET: {
      p._insertElement(token, NS.HTML);
      p.insertionMode = InsertionMode.IN_FRAMESET;
      break;
    }
    case TAG_ID.BASE:
    case TAG_ID.BASEFONT:
    case TAG_ID.BGSOUND:
    case TAG_ID.LINK:
    case TAG_ID.META:
    case TAG_ID.NOFRAMES:
    case TAG_ID.SCRIPT:
    case TAG_ID.STYLE:
    case TAG_ID.TEMPLATE:
    case TAG_ID.TITLE: {
      p._err(token, ERR.abandonedHeadElementChild);
      p.openElements.push(p.headElement, TAG_ID.HEAD);
      startTagInHead(p, token);
      p.openElements.remove(p.headElement);
      break;
    }
    case TAG_ID.HEAD: {
      p._err(token, ERR.misplacedStartTagForHeadElement);
      break;
    }
    default: {
      tokenAfterHead(p, token);
    }
  }
}
function endTagAfterHead(p, token) {
  switch (token.tagID) {
    case TAG_ID.BODY:
    case TAG_ID.HTML:
    case TAG_ID.BR: {
      tokenAfterHead(p, token);
      break;
    }
    case TAG_ID.TEMPLATE: {
      templateEndTagInHead(p, token);
      break;
    }
    default: {
      p._err(token, ERR.endTagWithoutMatchingOpenElement);
    }
  }
}
function tokenAfterHead(p, token) {
  p._insertFakeElement(TAG_NAMES.BODY, TAG_ID.BODY);
  p.insertionMode = InsertionMode.IN_BODY;
  modeInBody(p, token);
}
function modeInBody(p, token) {
  switch (token.type) {
    case TokenType.CHARACTER: {
      characterInBody(p, token);
      break;
    }
    case TokenType.WHITESPACE_CHARACTER: {
      whitespaceCharacterInBody(p, token);
      break;
    }
    case TokenType.COMMENT: {
      appendComment(p, token);
      break;
    }
    case TokenType.START_TAG: {
      startTagInBody(p, token);
      break;
    }
    case TokenType.END_TAG: {
      endTagInBody(p, token);
      break;
    }
    case TokenType.EOF: {
      eofInBody(p, token);
      break;
    }
    default:
  }
}
function whitespaceCharacterInBody(p, token) {
  p._reconstructActiveFormattingElements();
  p._insertCharacters(token);
}
function characterInBody(p, token) {
  p._reconstructActiveFormattingElements();
  p._insertCharacters(token);
  p.framesetOk = false;
}
function htmlStartTagInBody(p, token) {
  if (p.openElements.tmplCount === 0) {
    p.treeAdapter.adoptAttributes(p.openElements.items[0], token.attrs);
  }
}
function bodyStartTagInBody(p, token) {
  const bodyElement = p.openElements.tryPeekProperlyNestedBodyElement();
  if (bodyElement && p.openElements.tmplCount === 0) {
    p.framesetOk = false;
    p.treeAdapter.adoptAttributes(bodyElement, token.attrs);
  }
}
function framesetStartTagInBody(p, token) {
  const bodyElement = p.openElements.tryPeekProperlyNestedBodyElement();
  if (p.framesetOk && bodyElement) {
    p.treeAdapter.detachNode(bodyElement);
    p.openElements.popAllUpToHtmlElement();
    p._insertElement(token, NS.HTML);
    p.insertionMode = InsertionMode.IN_FRAMESET;
  }
}
function addressStartTagInBody(p, token) {
  if (p.openElements.hasInButtonScope(TAG_ID.P)) {
    p._closePElement();
  }
  p._insertElement(token, NS.HTML);
}
function numberedHeaderStartTagInBody(p, token) {
  if (p.openElements.hasInButtonScope(TAG_ID.P)) {
    p._closePElement();
  }
  if (NUMBERED_HEADERS.has(p.openElements.currentTagId)) {
    p.openElements.pop();
  }
  p._insertElement(token, NS.HTML);
}
function preStartTagInBody(p, token) {
  if (p.openElements.hasInButtonScope(TAG_ID.P)) {
    p._closePElement();
  }
  p._insertElement(token, NS.HTML);
  p.skipNextNewLine = true;
  p.framesetOk = false;
}
function formStartTagInBody(p, token) {
  const inTemplate = p.openElements.tmplCount > 0;
  if (!p.formElement || inTemplate) {
    if (p.openElements.hasInButtonScope(TAG_ID.P)) {
      p._closePElement();
    }
    p._insertElement(token, NS.HTML);
    if (!inTemplate) {
      p.formElement = p.openElements.current;
    }
  }
}
function listItemStartTagInBody(p, token) {
  p.framesetOk = false;
  const tn = token.tagID;
  for (let i = p.openElements.stackTop; i >= 0; i--) {
    const elementId = p.openElements.tagIDs[i];
    if (tn === TAG_ID.LI && elementId === TAG_ID.LI || (tn === TAG_ID.DD || tn === TAG_ID.DT) && (elementId === TAG_ID.DD || elementId === TAG_ID.DT)) {
      p.openElements.generateImpliedEndTagsWithExclusion(elementId);
      p.openElements.popUntilTagNamePopped(elementId);
      break;
    }
    if (elementId !== TAG_ID.ADDRESS && elementId !== TAG_ID.DIV && elementId !== TAG_ID.P && p._isSpecialElement(p.openElements.items[i], elementId)) {
      break;
    }
  }
  if (p.openElements.hasInButtonScope(TAG_ID.P)) {
    p._closePElement();
  }
  p._insertElement(token, NS.HTML);
}
function plaintextStartTagInBody(p, token) {
  if (p.openElements.hasInButtonScope(TAG_ID.P)) {
    p._closePElement();
  }
  p._insertElement(token, NS.HTML);
  p.tokenizer.state = TokenizerMode.PLAINTEXT;
}
function buttonStartTagInBody(p, token) {
  if (p.openElements.hasInScope(TAG_ID.BUTTON)) {
    p.openElements.generateImpliedEndTags();
    p.openElements.popUntilTagNamePopped(TAG_ID.BUTTON);
  }
  p._reconstructActiveFormattingElements();
  p._insertElement(token, NS.HTML);
  p.framesetOk = false;
}
function aStartTagInBody(p, token) {
  const activeElementEntry = p.activeFormattingElements.getElementEntryInScopeWithTagName(TAG_NAMES.A);
  if (activeElementEntry) {
    callAdoptionAgency(p, token);
    p.openElements.remove(activeElementEntry.element);
    p.activeFormattingElements.removeEntry(activeElementEntry);
  }
  p._reconstructActiveFormattingElements();
  p._insertElement(token, NS.HTML);
  p.activeFormattingElements.pushElement(p.openElements.current, token);
}
function bStartTagInBody(p, token) {
  p._reconstructActiveFormattingElements();
  p._insertElement(token, NS.HTML);
  p.activeFormattingElements.pushElement(p.openElements.current, token);
}
function nobrStartTagInBody(p, token) {
  p._reconstructActiveFormattingElements();
  if (p.openElements.hasInScope(TAG_ID.NOBR)) {
    callAdoptionAgency(p, token);
    p._reconstructActiveFormattingElements();
  }
  p._insertElement(token, NS.HTML);
  p.activeFormattingElements.pushElement(p.openElements.current, token);
}
function appletStartTagInBody(p, token) {
  p._reconstructActiveFormattingElements();
  p._insertElement(token, NS.HTML);
  p.activeFormattingElements.insertMarker();
  p.framesetOk = false;
}
function tableStartTagInBody(p, token) {
  if (p.treeAdapter.getDocumentMode(p.document) !== DOCUMENT_MODE.QUIRKS && p.openElements.hasInButtonScope(TAG_ID.P)) {
    p._closePElement();
  }
  p._insertElement(token, NS.HTML);
  p.framesetOk = false;
  p.insertionMode = InsertionMode.IN_TABLE;
}
function areaStartTagInBody(p, token) {
  p._reconstructActiveFormattingElements();
  p._appendElement(token, NS.HTML);
  p.framesetOk = false;
  token.ackSelfClosing = true;
}
function isHiddenInput(token) {
  const inputType = getTokenAttr(token, ATTRS.TYPE);
  return inputType != null && inputType.toLowerCase() === HIDDEN_INPUT_TYPE;
}
function inputStartTagInBody(p, token) {
  p._reconstructActiveFormattingElements();
  p._appendElement(token, NS.HTML);
  if (!isHiddenInput(token)) {
    p.framesetOk = false;
  }
  token.ackSelfClosing = true;
}
function paramStartTagInBody(p, token) {
  p._appendElement(token, NS.HTML);
  token.ackSelfClosing = true;
}
function hrStartTagInBody(p, token) {
  if (p.openElements.hasInButtonScope(TAG_ID.P)) {
    p._closePElement();
  }
  p._appendElement(token, NS.HTML);
  p.framesetOk = false;
  token.ackSelfClosing = true;
}
function imageStartTagInBody(p, token) {
  token.tagName = TAG_NAMES.IMG;
  token.tagID = TAG_ID.IMG;
  areaStartTagInBody(p, token);
}
function textareaStartTagInBody(p, token) {
  p._insertElement(token, NS.HTML);
  p.skipNextNewLine = true;
  p.tokenizer.state = TokenizerMode.RCDATA;
  p.originalInsertionMode = p.insertionMode;
  p.framesetOk = false;
  p.insertionMode = InsertionMode.TEXT;
}
function xmpStartTagInBody(p, token) {
  if (p.openElements.hasInButtonScope(TAG_ID.P)) {
    p._closePElement();
  }
  p._reconstructActiveFormattingElements();
  p.framesetOk = false;
  p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
}
function iframeStartTagInBody(p, token) {
  p.framesetOk = false;
  p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
}
function rawTextStartTagInBody(p, token) {
  p._switchToTextParsing(token, TokenizerMode.RAWTEXT);
}
function selectStartTagInBody(p, token) {
  p._reconstructActiveFormattingElements();
  p._insertElement(token, NS.HTML);
  p.framesetOk = false;
  p.insertionMode = p.insertionMode === InsertionMode.IN_TABLE || p.insertionMode === InsertionMode.IN_CAPTION || p.insertionMode === InsertionMode.IN_TABLE_BODY || p.insertionMode === InsertionMode.IN_ROW || p.insertionMode === InsertionMode.IN_CELL ? InsertionMode.IN_SELECT_IN_TABLE : InsertionMode.IN_SELECT;
}
function optgroupStartTagInBody(p, token) {
  if (p.openElements.currentTagId === TAG_ID.OPTION) {
    p.openElements.pop();
  }
  p._reconstructActiveFormattingElements();
  p._insertElement(token, NS.HTML);
}
function rbStartTagInBody(p, token) {
  if (p.openElements.hasInScope(TAG_ID.RUBY)) {
    p.openElements.generateImpliedEndTags();
  }
  p._insertElement(token, NS.HTML);
}
function rtStartTagInBody(p, token) {
  if (p.openElements.hasInScope(TAG_ID.RUBY)) {
    p.openElements.generateImpliedEndTagsWithExclusion(TAG_ID.RTC);
  }
  p._insertElement(token, NS.HTML);
}
function mathStartTagInBody(p, token) {
  p._reconstructActiveFormattingElements();
  adjustTokenMathMLAttrs(token);
  adjustTokenXMLAttrs(token);
  if (token.selfClosing) {
    p._appendElement(token, NS.MATHML);
  } else {
    p._insertElement(token, NS.MATHML);
  }
  token.ackSelfClosing = true;
}
function svgStartTagInBody(p, token) {
  p._reconstructActiveFormattingElements();
  adjustTokenSVGAttrs(token);
  adjustTokenXMLAttrs(token);
  if (token.selfClosing) {
    p._appendElement(token, NS.SVG);
  } else {
    p._insertElement(token, NS.SVG);
  }
  token.ackSelfClosing = true;
}
function genericStartTagInBody(p, token) {
  p._reconstructActiveFormattingElements();
  p._insertElement(token, NS.HTML);
}
function startTagInBody(p, token) {
  switch (token.tagID) {
    case TAG_ID.I:
    case TAG_ID.S:
    case TAG_ID.B:
    case TAG_ID.U:
    case TAG_ID.EM:
    case TAG_ID.TT:
    case TAG_ID.BIG:
    case TAG_ID.CODE:
    case TAG_ID.FONT:
    case TAG_ID.SMALL:
    case TAG_ID.STRIKE:
    case TAG_ID.STRONG: {
      bStartTagInBody(p, token);
      break;
    }
    case TAG_ID.A: {
      aStartTagInBody(p, token);
      break;
    }
    case TAG_ID.H1:
    case TAG_ID.H2:
    case TAG_ID.H3:
    case TAG_ID.H4:
    case TAG_ID.H5:
    case TAG_ID.H6: {
      numberedHeaderStartTagInBody(p, token);
      break;
    }
    case TAG_ID.P:
    case TAG_ID.DL:
    case TAG_ID.OL:
    case TAG_ID.UL:
    case TAG_ID.DIV:
    case TAG_ID.DIR:
    case TAG_ID.NAV:
    case TAG_ID.MAIN:
    case TAG_ID.MENU:
    case TAG_ID.ASIDE:
    case TAG_ID.CENTER:
    case TAG_ID.FIGURE:
    case TAG_ID.FOOTER:
    case TAG_ID.HEADER:
    case TAG_ID.HGROUP:
    case TAG_ID.DIALOG:
    case TAG_ID.DETAILS:
    case TAG_ID.ADDRESS:
    case TAG_ID.ARTICLE:
    case TAG_ID.SEARCH:
    case TAG_ID.SECTION:
    case TAG_ID.SUMMARY:
    case TAG_ID.FIELDSET:
    case TAG_ID.BLOCKQUOTE:
    case TAG_ID.FIGCAPTION: {
      addressStartTagInBody(p, token);
      break;
    }
    case TAG_ID.LI:
    case TAG_ID.DD:
    case TAG_ID.DT: {
      listItemStartTagInBody(p, token);
      break;
    }
    case TAG_ID.BR:
    case TAG_ID.IMG:
    case TAG_ID.WBR:
    case TAG_ID.AREA:
    case TAG_ID.EMBED:
    case TAG_ID.KEYGEN: {
      areaStartTagInBody(p, token);
      break;
    }
    case TAG_ID.HR: {
      hrStartTagInBody(p, token);
      break;
    }
    case TAG_ID.RB:
    case TAG_ID.RTC: {
      rbStartTagInBody(p, token);
      break;
    }
    case TAG_ID.RT:
    case TAG_ID.RP: {
      rtStartTagInBody(p, token);
      break;
    }
    case TAG_ID.PRE:
    case TAG_ID.LISTING: {
      preStartTagInBody(p, token);
      break;
    }
    case TAG_ID.XMP: {
      xmpStartTagInBody(p, token);
      break;
    }
    case TAG_ID.SVG: {
      svgStartTagInBody(p, token);
      break;
    }
    case TAG_ID.HTML: {
      htmlStartTagInBody(p, token);
      break;
    }
    case TAG_ID.BASE:
    case TAG_ID.LINK:
    case TAG_ID.META:
    case TAG_ID.STYLE:
    case TAG_ID.TITLE:
    case TAG_ID.SCRIPT:
    case TAG_ID.BGSOUND:
    case TAG_ID.BASEFONT:
    case TAG_ID.TEMPLATE: {
      startTagInHead(p, token);
      break;
    }
    case TAG_ID.BODY: {
      bodyStartTagInBody(p, token);
      break;
    }
    case TAG_ID.FORM: {
      formStartTagInBody(p, token);
      break;
    }
    case TAG_ID.NOBR: {
      nobrStartTagInBody(p, token);
      break;
    }
    case TAG_ID.MATH: {
      mathStartTagInBody(p, token);
      break;
    }
    case TAG_ID.TABLE: {
      tableStartTagInBody(p, token);
      break;
    }
    case TAG_ID.INPUT: {
      inputStartTagInBody(p, token);
      break;
    }
    case TAG_ID.PARAM:
    case TAG_ID.TRACK:
    case TAG_ID.SOURCE: {
      paramStartTagInBody(p, token);
      break;
    }
    case TAG_ID.IMAGE: {
      imageStartTagInBody(p, token);
      break;
    }
    case TAG_ID.BUTTON: {
      buttonStartTagInBody(p, token);
      break;
    }
    case TAG_ID.APPLET:
    case TAG_ID.OBJECT:
    case TAG_ID.MARQUEE: {
      appletStartTagInBody(p, token);
      break;
    }
    case TAG_ID.IFRAME: {
      iframeStartTagInBody(p, token);
      break;
    }
    case TAG_ID.SELECT: {
      selectStartTagInBody(p, token);
      break;
    }
    case TAG_ID.OPTION:
    case TAG_ID.OPTGROUP: {
      optgroupStartTagInBody(p, token);
      break;
    }
    case TAG_ID.NOEMBED:
    case TAG_ID.NOFRAMES: {
      rawTextStartTagInBody(p, token);
      break;
    }
    case TAG_ID.FRAMESET: {
      framesetStartTagInBody(p, token);
      break;
    }
    case TAG_ID.TEXTAREA: {
      textareaStartTagInBody(p, token);
      break;
    }
    case TAG_ID.NOSCRIPT: {
      if (p.options.scriptingEnabled) {
        rawTextStartTagInBody(p, token);
      } else {
        genericStartTagInBody(p, token);
      }
      break;
    }
    case TAG_ID.PLAINTEXT: {
      plaintextStartTagInBody(p, token);
      break;
    }
    case TAG_ID.COL:
    case TAG_ID.TH:
    case TAG_ID.TD:
    case TAG_ID.TR:
    case TAG_ID.HEAD:
    case TAG_ID.FRAME:
    case TAG_ID.TBODY:
    case TAG_ID.TFOOT:
    case TAG_ID.THEAD:
    case TAG_ID.CAPTION:
    case TAG_ID.COLGROUP: {
      break;
    }
    default: {
      genericStartTagInBody(p, token);
    }
  }
}
function bodyEndTagInBody(p, token) {
  if (p.openElements.hasInScope(TAG_ID.BODY)) {
    p.insertionMode = InsertionMode.AFTER_BODY;
    if (p.options.sourceCodeLocationInfo) {
      const bodyElement = p.openElements.tryPeekProperlyNestedBodyElement();
      if (bodyElement) {
        p._setEndLocation(bodyElement, token);
      }
    }
  }
}
function htmlEndTagInBody(p, token) {
  if (p.openElements.hasInScope(TAG_ID.BODY)) {
    p.insertionMode = InsertionMode.AFTER_BODY;
    endTagAfterBody(p, token);
  }
}
function addressEndTagInBody(p, token) {
  const tn = token.tagID;
  if (p.openElements.hasInScope(tn)) {
    p.openElements.generateImpliedEndTags();
    p.openElements.popUntilTagNamePopped(tn);
  }
}
function formEndTagInBody(p) {
  const inTemplate = p.openElements.tmplCount > 0;
  const { formElement } = p;
  if (!inTemplate) {
    p.formElement = null;
  }
  if ((formElement || inTemplate) && p.openElements.hasInScope(TAG_ID.FORM)) {
    p.openElements.generateImpliedEndTags();
    if (inTemplate) {
      p.openElements.popUntilTagNamePopped(TAG_ID.FORM);
    } else if (formElement) {
      p.openElements.remove(formElement);
    }
  }
}
function pEndTagInBody(p) {
  if (!p.openElements.hasInButtonScope(TAG_ID.P)) {
    p._insertFakeElement(TAG_NAMES.P, TAG_ID.P);
  }
  p._closePElement();
}
function liEndTagInBody(p) {
  if (p.openElements.hasInListItemScope(TAG_ID.LI)) {
    p.openElements.generateImpliedEndTagsWithExclusion(TAG_ID.LI);
    p.openElements.popUntilTagNamePopped(TAG_ID.LI);
  }
}
function ddEndTagInBody(p, token) {
  const tn = token.tagID;
  if (p.openElements.hasInScope(tn)) {
    p.openElements.generateImpliedEndTagsWithExclusion(tn);
    p.openElements.popUntilTagNamePopped(tn);
  }
}
function numberedHeaderEndTagInBody(p) {
  if (p.openElements.hasNumberedHeaderInScope()) {
    p.openElements.generateImpliedEndTags();
    p.openElements.popUntilNumberedHeaderPopped();
  }
}
function appletEndTagInBody(p, token) {
  const tn = token.tagID;
  if (p.openElements.hasInScope(tn)) {
    p.openElements.generateImpliedEndTags();
    p.openElements.popUntilTagNamePopped(tn);
    p.activeFormattingElements.clearToLastMarker();
  }
}
function brEndTagInBody(p) {
  p._reconstructActiveFormattingElements();
  p._insertFakeElement(TAG_NAMES.BR, TAG_ID.BR);
  p.openElements.pop();
  p.framesetOk = false;
}
function genericEndTagInBody(p, token) {
  const tn = token.tagName;
  const tid = token.tagID;
  for (let i = p.openElements.stackTop; i > 0; i--) {
    const element = p.openElements.items[i];
    const elementId = p.openElements.tagIDs[i];
    if (tid === elementId && (tid !== TAG_ID.UNKNOWN || p.treeAdapter.getTagName(element) === tn)) {
      p.openElements.generateImpliedEndTagsWithExclusion(tid);
      if (p.openElements.stackTop >= i)
        p.openElements.shortenToLength(i);
      break;
    }
    if (p._isSpecialElement(element, elementId)) {
      break;
    }
  }
}
function endTagInBody(p, token) {
  switch (token.tagID) {
    case TAG_ID.A:
    case TAG_ID.B:
    case TAG_ID.I:
    case TAG_ID.S:
    case TAG_ID.U:
    case TAG_ID.EM:
    case TAG_ID.TT:
    case TAG_ID.BIG:
    case TAG_ID.CODE:
    case TAG_ID.FONT:
    case TAG_ID.NOBR:
    case TAG_ID.SMALL:
    case TAG_ID.STRIKE:
    case TAG_ID.STRONG: {
      callAdoptionAgency(p, token);
      break;
    }
    case TAG_ID.P: {
      pEndTagInBody(p);
      break;
    }
    case TAG_ID.DL:
    case TAG_ID.UL:
    case TAG_ID.OL:
    case TAG_ID.DIR:
    case TAG_ID.DIV:
    case TAG_ID.NAV:
    case TAG_ID.PRE:
    case TAG_ID.MAIN:
    case TAG_ID.MENU:
    case TAG_ID.ASIDE:
    case TAG_ID.BUTTON:
    case TAG_ID.CENTER:
    case TAG_ID.FIGURE:
    case TAG_ID.FOOTER:
    case TAG_ID.HEADER:
    case TAG_ID.HGROUP:
    case TAG_ID.DIALOG:
    case TAG_ID.ADDRESS:
    case TAG_ID.ARTICLE:
    case TAG_ID.DETAILS:
    case TAG_ID.SEARCH:
    case TAG_ID.SECTION:
    case TAG_ID.SUMMARY:
    case TAG_ID.LISTING:
    case TAG_ID.FIELDSET:
    case TAG_ID.BLOCKQUOTE:
    case TAG_ID.FIGCAPTION: {
      addressEndTagInBody(p, token);
      break;
    }
    case TAG_ID.LI: {
      liEndTagInBody(p);
      break;
    }
    case TAG_ID.DD:
    case TAG_ID.DT: {
      ddEndTagInBody(p, token);
      break;
    }
    case TAG_ID.H1:
    case TAG_ID.H2:
    case TAG_ID.H3:
    case TAG_ID.H4:
    case TAG_ID.H5:
    case TAG_ID.H6: {
      numberedHeaderEndTagInBody(p);
      break;
    }
    case TAG_ID.BR: {
      brEndTagInBody(p);
      break;
    }
    case TAG_ID.BODY: {
      bodyEndTagInBody(p, token);
      break;
    }
    case TAG_ID.HTML: {
      htmlEndTagInBody(p, token);
      break;
    }
    case TAG_ID.FORM: {
      formEndTagInBody(p);
      break;
    }
    case TAG_ID.APPLET:
    case TAG_ID.OBJECT:
    case TAG_ID.MARQUEE: {
      appletEndTagInBody(p, token);
      break;
    }
    case TAG_ID.TEMPLATE: {
      templateEndTagInHead(p, token);
      break;
    }
    default: {
      genericEndTagInBody(p, token);
    }
  }
}
function eofInBody(p, token) {
  if (p.tmplInsertionModeStack.length > 0) {
    eofInTemplate(p, token);
  } else {
    stopParsing(p, token);
  }
}
function endTagInText(p, token) {
  var _a2;
  if (token.tagID === TAG_ID.SCRIPT) {
    (_a2 = p.scriptHandler) === null || _a2 === void 0 ? void 0 : _a2.call(p, p.openElements.current);
  }
  p.openElements.pop();
  p.insertionMode = p.originalInsertionMode;
}
function eofInText(p, token) {
  p._err(token, ERR.eofInElementThatCanContainOnlyText);
  p.openElements.pop();
  p.insertionMode = p.originalInsertionMode;
  p.onEof(token);
}
function characterInTable(p, token) {
  if (TABLE_STRUCTURE_TAGS.has(p.openElements.currentTagId)) {
    p.pendingCharacterTokens.length = 0;
    p.hasNonWhitespacePendingCharacterToken = false;
    p.originalInsertionMode = p.insertionMode;
    p.insertionMode = InsertionMode.IN_TABLE_TEXT;
    switch (token.type) {
      case TokenType.CHARACTER: {
        characterInTableText(p, token);
        break;
      }
      case TokenType.WHITESPACE_CHARACTER: {
        whitespaceCharacterInTableText(p, token);
        break;
      }
    }
  } else {
    tokenInTable(p, token);
  }
}
function captionStartTagInTable(p, token) {
  p.openElements.clearBackToTableContext();
  p.activeFormattingElements.insertMarker();
  p._insertElement(token, NS.HTML);
  p.insertionMode = InsertionMode.IN_CAPTION;
}
function colgroupStartTagInTable(p, token) {
  p.openElements.clearBackToTableContext();
  p._insertElement(token, NS.HTML);
  p.insertionMode = InsertionMode.IN_COLUMN_GROUP;
}
function colStartTagInTable(p, token) {
  p.openElements.clearBackToTableContext();
  p._insertFakeElement(TAG_NAMES.COLGROUP, TAG_ID.COLGROUP);
  p.insertionMode = InsertionMode.IN_COLUMN_GROUP;
  startTagInColumnGroup(p, token);
}
function tbodyStartTagInTable(p, token) {
  p.openElements.clearBackToTableContext();
  p._insertElement(token, NS.HTML);
  p.insertionMode = InsertionMode.IN_TABLE_BODY;
}
function tdStartTagInTable(p, token) {
  p.openElements.clearBackToTableContext();
  p._insertFakeElement(TAG_NAMES.TBODY, TAG_ID.TBODY);
  p.insertionMode = InsertionMode.IN_TABLE_BODY;
  startTagInTableBody(p, token);
}
function tableStartTagInTable(p, token) {
  if (p.openElements.hasInTableScope(TAG_ID.TABLE)) {
    p.openElements.popUntilTagNamePopped(TAG_ID.TABLE);
    p._resetInsertionMode();
    p._processStartTag(token);
  }
}
function inputStartTagInTable(p, token) {
  if (isHiddenInput(token)) {
    p._appendElement(token, NS.HTML);
  } else {
    tokenInTable(p, token);
  }
  token.ackSelfClosing = true;
}
function formStartTagInTable(p, token) {
  if (!p.formElement && p.openElements.tmplCount === 0) {
    p._insertElement(token, NS.HTML);
    p.formElement = p.openElements.current;
    p.openElements.pop();
  }
}
function startTagInTable(p, token) {
  switch (token.tagID) {
    case TAG_ID.TD:
    case TAG_ID.TH:
    case TAG_ID.TR: {
      tdStartTagInTable(p, token);
      break;
    }
    case TAG_ID.STYLE:
    case TAG_ID.SCRIPT:
    case TAG_ID.TEMPLATE: {
      startTagInHead(p, token);
      break;
    }
    case TAG_ID.COL: {
      colStartTagInTable(p, token);
      break;
    }
    case TAG_ID.FORM: {
      formStartTagInTable(p, token);
      break;
    }
    case TAG_ID.TABLE: {
      tableStartTagInTable(p, token);
      break;
    }
    case TAG_ID.TBODY:
    case TAG_ID.TFOOT:
    case TAG_ID.THEAD: {
      tbodyStartTagInTable(p, token);
      break;
    }
    case TAG_ID.INPUT: {
      inputStartTagInTable(p, token);
      break;
    }
    case TAG_ID.CAPTION: {
      captionStartTagInTable(p, token);
      break;
    }
    case TAG_ID.COLGROUP: {
      colgroupStartTagInTable(p, token);
      break;
    }
    default: {
      tokenInTable(p, token);
    }
  }
}
function endTagInTable(p, token) {
  switch (token.tagID) {
    case TAG_ID.TABLE: {
      if (p.openElements.hasInTableScope(TAG_ID.TABLE)) {
        p.openElements.popUntilTagNamePopped(TAG_ID.TABLE);
        p._resetInsertionMode();
      }
      break;
    }
    case TAG_ID.TEMPLATE: {
      templateEndTagInHead(p, token);
      break;
    }
    case TAG_ID.BODY:
    case TAG_ID.CAPTION:
    case TAG_ID.COL:
    case TAG_ID.COLGROUP:
    case TAG_ID.HTML:
    case TAG_ID.TBODY:
    case TAG_ID.TD:
    case TAG_ID.TFOOT:
    case TAG_ID.TH:
    case TAG_ID.THEAD:
    case TAG_ID.TR: {
      break;
    }
    default: {
      tokenInTable(p, token);
    }
  }
}
function tokenInTable(p, token) {
  const savedFosterParentingState = p.fosterParentingEnabled;
  p.fosterParentingEnabled = true;
  modeInBody(p, token);
  p.fosterParentingEnabled = savedFosterParentingState;
}
function whitespaceCharacterInTableText(p, token) {
  p.pendingCharacterTokens.push(token);
}
function characterInTableText(p, token) {
  p.pendingCharacterTokens.push(token);
  p.hasNonWhitespacePendingCharacterToken = true;
}
function tokenInTableText(p, token) {
  let i = 0;
  if (p.hasNonWhitespacePendingCharacterToken) {
    for (; i < p.pendingCharacterTokens.length; i++) {
      tokenInTable(p, p.pendingCharacterTokens[i]);
    }
  } else {
    for (; i < p.pendingCharacterTokens.length; i++) {
      p._insertCharacters(p.pendingCharacterTokens[i]);
    }
  }
  p.insertionMode = p.originalInsertionMode;
  p._processToken(token);
}
var TABLE_VOID_ELEMENTS = /* @__PURE__ */ new Set([TAG_ID.CAPTION, TAG_ID.COL, TAG_ID.COLGROUP, TAG_ID.TBODY, TAG_ID.TD, TAG_ID.TFOOT, TAG_ID.TH, TAG_ID.THEAD, TAG_ID.TR]);
function startTagInCaption(p, token) {
  const tn = token.tagID;
  if (TABLE_VOID_ELEMENTS.has(tn)) {
    if (p.openElements.hasInTableScope(TAG_ID.CAPTION)) {
      p.openElements.generateImpliedEndTags();
      p.openElements.popUntilTagNamePopped(TAG_ID.CAPTION);
      p.activeFormattingElements.clearToLastMarker();
      p.insertionMode = InsertionMode.IN_TABLE;
      startTagInTable(p, token);
    }
  } else {
    startTagInBody(p, token);
  }
}
function endTagInCaption(p, token) {
  const tn = token.tagID;
  switch (tn) {
    case TAG_ID.CAPTION:
    case TAG_ID.TABLE: {
      if (p.openElements.hasInTableScope(TAG_ID.CAPTION)) {
        p.openElements.generateImpliedEndTags();
        p.openElements.popUntilTagNamePopped(TAG_ID.CAPTION);
        p.activeFormattingElements.clearToLastMarker();
        p.insertionMode = InsertionMode.IN_TABLE;
        if (tn === TAG_ID.TABLE) {
          endTagInTable(p, token);
        }
      }
      break;
    }
    case TAG_ID.BODY:
    case TAG_ID.COL:
    case TAG_ID.COLGROUP:
    case TAG_ID.HTML:
    case TAG_ID.TBODY:
    case TAG_ID.TD:
    case TAG_ID.TFOOT:
    case TAG_ID.TH:
    case TAG_ID.THEAD:
    case TAG_ID.TR: {
      break;
    }
    default: {
      endTagInBody(p, token);
    }
  }
}
function startTagInColumnGroup(p, token) {
  switch (token.tagID) {
    case TAG_ID.HTML: {
      startTagInBody(p, token);
      break;
    }
    case TAG_ID.COL: {
      p._appendElement(token, NS.HTML);
      token.ackSelfClosing = true;
      break;
    }
    case TAG_ID.TEMPLATE: {
      startTagInHead(p, token);
      break;
    }
    default: {
      tokenInColumnGroup(p, token);
    }
  }
}
function endTagInColumnGroup(p, token) {
  switch (token.tagID) {
    case TAG_ID.COLGROUP: {
      if (p.openElements.currentTagId === TAG_ID.COLGROUP) {
        p.openElements.pop();
        p.insertionMode = InsertionMode.IN_TABLE;
      }
      break;
    }
    case TAG_ID.TEMPLATE: {
      templateEndTagInHead(p, token);
      break;
    }
    case TAG_ID.COL: {
      break;
    }
    default: {
      tokenInColumnGroup(p, token);
    }
  }
}
function tokenInColumnGroup(p, token) {
  if (p.openElements.currentTagId === TAG_ID.COLGROUP) {
    p.openElements.pop();
    p.insertionMode = InsertionMode.IN_TABLE;
    p._processToken(token);
  }
}
function startTagInTableBody(p, token) {
  switch (token.tagID) {
    case TAG_ID.TR: {
      p.openElements.clearBackToTableBodyContext();
      p._insertElement(token, NS.HTML);
      p.insertionMode = InsertionMode.IN_ROW;
      break;
    }
    case TAG_ID.TH:
    case TAG_ID.TD: {
      p.openElements.clearBackToTableBodyContext();
      p._insertFakeElement(TAG_NAMES.TR, TAG_ID.TR);
      p.insertionMode = InsertionMode.IN_ROW;
      startTagInRow(p, token);
      break;
    }
    case TAG_ID.CAPTION:
    case TAG_ID.COL:
    case TAG_ID.COLGROUP:
    case TAG_ID.TBODY:
    case TAG_ID.TFOOT:
    case TAG_ID.THEAD: {
      if (p.openElements.hasTableBodyContextInTableScope()) {
        p.openElements.clearBackToTableBodyContext();
        p.openElements.pop();
        p.insertionMode = InsertionMode.IN_TABLE;
        startTagInTable(p, token);
      }
      break;
    }
    default: {
      startTagInTable(p, token);
    }
  }
}
function endTagInTableBody(p, token) {
  const tn = token.tagID;
  switch (token.tagID) {
    case TAG_ID.TBODY:
    case TAG_ID.TFOOT:
    case TAG_ID.THEAD: {
      if (p.openElements.hasInTableScope(tn)) {
        p.openElements.clearBackToTableBodyContext();
        p.openElements.pop();
        p.insertionMode = InsertionMode.IN_TABLE;
      }
      break;
    }
    case TAG_ID.TABLE: {
      if (p.openElements.hasTableBodyContextInTableScope()) {
        p.openElements.clearBackToTableBodyContext();
        p.openElements.pop();
        p.insertionMode = InsertionMode.IN_TABLE;
        endTagInTable(p, token);
      }
      break;
    }
    case TAG_ID.BODY:
    case TAG_ID.CAPTION:
    case TAG_ID.COL:
    case TAG_ID.COLGROUP:
    case TAG_ID.HTML:
    case TAG_ID.TD:
    case TAG_ID.TH:
    case TAG_ID.TR: {
      break;
    }
    default: {
      endTagInTable(p, token);
    }
  }
}
function startTagInRow(p, token) {
  switch (token.tagID) {
    case TAG_ID.TH:
    case TAG_ID.TD: {
      p.openElements.clearBackToTableRowContext();
      p._insertElement(token, NS.HTML);
      p.insertionMode = InsertionMode.IN_CELL;
      p.activeFormattingElements.insertMarker();
      break;
    }
    case TAG_ID.CAPTION:
    case TAG_ID.COL:
    case TAG_ID.COLGROUP:
    case TAG_ID.TBODY:
    case TAG_ID.TFOOT:
    case TAG_ID.THEAD:
    case TAG_ID.TR: {
      if (p.openElements.hasInTableScope(TAG_ID.TR)) {
        p.openElements.clearBackToTableRowContext();
        p.openElements.pop();
        p.insertionMode = InsertionMode.IN_TABLE_BODY;
        startTagInTableBody(p, token);
      }
      break;
    }
    default: {
      startTagInTable(p, token);
    }
  }
}
function endTagInRow(p, token) {
  switch (token.tagID) {
    case TAG_ID.TR: {
      if (p.openElements.hasInTableScope(TAG_ID.TR)) {
        p.openElements.clearBackToTableRowContext();
        p.openElements.pop();
        p.insertionMode = InsertionMode.IN_TABLE_BODY;
      }
      break;
    }
    case TAG_ID.TABLE: {
      if (p.openElements.hasInTableScope(TAG_ID.TR)) {
        p.openElements.clearBackToTableRowContext();
        p.openElements.pop();
        p.insertionMode = InsertionMode.IN_TABLE_BODY;
        endTagInTableBody(p, token);
      }
      break;
    }
    case TAG_ID.TBODY:
    case TAG_ID.TFOOT:
    case TAG_ID.THEAD: {
      if (p.openElements.hasInTableScope(token.tagID) || p.openElements.hasInTableScope(TAG_ID.TR)) {
        p.openElements.clearBackToTableRowContext();
        p.openElements.pop();
        p.insertionMode = InsertionMode.IN_TABLE_BODY;
        endTagInTableBody(p, token);
      }
      break;
    }
    case TAG_ID.BODY:
    case TAG_ID.CAPTION:
    case TAG_ID.COL:
    case TAG_ID.COLGROUP:
    case TAG_ID.HTML:
    case TAG_ID.TD:
    case TAG_ID.TH: {
      break;
    }
    default: {
      endTagInTable(p, token);
    }
  }
}
function startTagInCell(p, token) {
  const tn = token.tagID;
  if (TABLE_VOID_ELEMENTS.has(tn)) {
    if (p.openElements.hasInTableScope(TAG_ID.TD) || p.openElements.hasInTableScope(TAG_ID.TH)) {
      p._closeTableCell();
      startTagInRow(p, token);
    }
  } else {
    startTagInBody(p, token);
  }
}
function endTagInCell(p, token) {
  const tn = token.tagID;
  switch (tn) {
    case TAG_ID.TD:
    case TAG_ID.TH: {
      if (p.openElements.hasInTableScope(tn)) {
        p.openElements.generateImpliedEndTags();
        p.openElements.popUntilTagNamePopped(tn);
        p.activeFormattingElements.clearToLastMarker();
        p.insertionMode = InsertionMode.IN_ROW;
      }
      break;
    }
    case TAG_ID.TABLE:
    case TAG_ID.TBODY:
    case TAG_ID.TFOOT:
    case TAG_ID.THEAD:
    case TAG_ID.TR: {
      if (p.openElements.hasInTableScope(tn)) {
        p._closeTableCell();
        endTagInRow(p, token);
      }
      break;
    }
    case TAG_ID.BODY:
    case TAG_ID.CAPTION:
    case TAG_ID.COL:
    case TAG_ID.COLGROUP:
    case TAG_ID.HTML: {
      break;
    }
    default: {
      endTagInBody(p, token);
    }
  }
}
function startTagInSelect(p, token) {
  switch (token.tagID) {
    case TAG_ID.HTML: {
      startTagInBody(p, token);
      break;
    }
    case TAG_ID.OPTION: {
      if (p.openElements.currentTagId === TAG_ID.OPTION) {
        p.openElements.pop();
      }
      p._insertElement(token, NS.HTML);
      break;
    }
    case TAG_ID.OPTGROUP: {
      if (p.openElements.currentTagId === TAG_ID.OPTION) {
        p.openElements.pop();
      }
      if (p.openElements.currentTagId === TAG_ID.OPTGROUP) {
        p.openElements.pop();
      }
      p._insertElement(token, NS.HTML);
      break;
    }
    case TAG_ID.HR: {
      if (p.openElements.currentTagId === TAG_ID.OPTION) {
        p.openElements.pop();
      }
      if (p.openElements.currentTagId === TAG_ID.OPTGROUP) {
        p.openElements.pop();
      }
      p._appendElement(token, NS.HTML);
      token.ackSelfClosing = true;
      break;
    }
    case TAG_ID.INPUT:
    case TAG_ID.KEYGEN:
    case TAG_ID.TEXTAREA:
    case TAG_ID.SELECT: {
      if (p.openElements.hasInSelectScope(TAG_ID.SELECT)) {
        p.openElements.popUntilTagNamePopped(TAG_ID.SELECT);
        p._resetInsertionMode();
        if (token.tagID !== TAG_ID.SELECT) {
          p._processStartTag(token);
        }
      }
      break;
    }
    case TAG_ID.SCRIPT:
    case TAG_ID.TEMPLATE: {
      startTagInHead(p, token);
      break;
    }
    default:
  }
}
function endTagInSelect(p, token) {
  switch (token.tagID) {
    case TAG_ID.OPTGROUP: {
      if (p.openElements.stackTop > 0 && p.openElements.currentTagId === TAG_ID.OPTION && p.openElements.tagIDs[p.openElements.stackTop - 1] === TAG_ID.OPTGROUP) {
        p.openElements.pop();
      }
      if (p.openElements.currentTagId === TAG_ID.OPTGROUP) {
        p.openElements.pop();
      }
      break;
    }
    case TAG_ID.OPTION: {
      if (p.openElements.currentTagId === TAG_ID.OPTION) {
        p.openElements.pop();
      }
      break;
    }
    case TAG_ID.SELECT: {
      if (p.openElements.hasInSelectScope(TAG_ID.SELECT)) {
        p.openElements.popUntilTagNamePopped(TAG_ID.SELECT);
        p._resetInsertionMode();
      }
      break;
    }
    case TAG_ID.TEMPLATE: {
      templateEndTagInHead(p, token);
      break;
    }
    default:
  }
}
function startTagInSelectInTable(p, token) {
  const tn = token.tagID;
  if (tn === TAG_ID.CAPTION || tn === TAG_ID.TABLE || tn === TAG_ID.TBODY || tn === TAG_ID.TFOOT || tn === TAG_ID.THEAD || tn === TAG_ID.TR || tn === TAG_ID.TD || tn === TAG_ID.TH) {
    p.openElements.popUntilTagNamePopped(TAG_ID.SELECT);
    p._resetInsertionMode();
    p._processStartTag(token);
  } else {
    startTagInSelect(p, token);
  }
}
function endTagInSelectInTable(p, token) {
  const tn = token.tagID;
  if (tn === TAG_ID.CAPTION || tn === TAG_ID.TABLE || tn === TAG_ID.TBODY || tn === TAG_ID.TFOOT || tn === TAG_ID.THEAD || tn === TAG_ID.TR || tn === TAG_ID.TD || tn === TAG_ID.TH) {
    if (p.openElements.hasInTableScope(tn)) {
      p.openElements.popUntilTagNamePopped(TAG_ID.SELECT);
      p._resetInsertionMode();
      p.onEndTag(token);
    }
  } else {
    endTagInSelect(p, token);
  }
}
function startTagInTemplate(p, token) {
  switch (token.tagID) {
    // First, handle tags that can start without a mode change
    case TAG_ID.BASE:
    case TAG_ID.BASEFONT:
    case TAG_ID.BGSOUND:
    case TAG_ID.LINK:
    case TAG_ID.META:
    case TAG_ID.NOFRAMES:
    case TAG_ID.SCRIPT:
    case TAG_ID.STYLE:
    case TAG_ID.TEMPLATE:
    case TAG_ID.TITLE: {
      startTagInHead(p, token);
      break;
    }
    // Re-process the token in the appropriate mode
    case TAG_ID.CAPTION:
    case TAG_ID.COLGROUP:
    case TAG_ID.TBODY:
    case TAG_ID.TFOOT:
    case TAG_ID.THEAD: {
      p.tmplInsertionModeStack[0] = InsertionMode.IN_TABLE;
      p.insertionMode = InsertionMode.IN_TABLE;
      startTagInTable(p, token);
      break;
    }
    case TAG_ID.COL: {
      p.tmplInsertionModeStack[0] = InsertionMode.IN_COLUMN_GROUP;
      p.insertionMode = InsertionMode.IN_COLUMN_GROUP;
      startTagInColumnGroup(p, token);
      break;
    }
    case TAG_ID.TR: {
      p.tmplInsertionModeStack[0] = InsertionMode.IN_TABLE_BODY;
      p.insertionMode = InsertionMode.IN_TABLE_BODY;
      startTagInTableBody(p, token);
      break;
    }
    case TAG_ID.TD:
    case TAG_ID.TH: {
      p.tmplInsertionModeStack[0] = InsertionMode.IN_ROW;
      p.insertionMode = InsertionMode.IN_ROW;
      startTagInRow(p, token);
      break;
    }
    default: {
      p.tmplInsertionModeStack[0] = InsertionMode.IN_BODY;
      p.insertionMode = InsertionMode.IN_BODY;
      startTagInBody(p, token);
    }
  }
}
function endTagInTemplate(p, token) {
  if (token.tagID === TAG_ID.TEMPLATE) {
    templateEndTagInHead(p, token);
  }
}
function eofInTemplate(p, token) {
  if (p.openElements.tmplCount > 0) {
    p.openElements.popUntilTagNamePopped(TAG_ID.TEMPLATE);
    p.activeFormattingElements.clearToLastMarker();
    p.tmplInsertionModeStack.shift();
    p._resetInsertionMode();
    p.onEof(token);
  } else {
    stopParsing(p, token);
  }
}
function startTagAfterBody(p, token) {
  if (token.tagID === TAG_ID.HTML) {
    startTagInBody(p, token);
  } else {
    tokenAfterBody(p, token);
  }
}
function endTagAfterBody(p, token) {
  var _a2;
  if (token.tagID === TAG_ID.HTML) {
    if (!p.fragmentContext) {
      p.insertionMode = InsertionMode.AFTER_AFTER_BODY;
    }
    if (p.options.sourceCodeLocationInfo && p.openElements.tagIDs[0] === TAG_ID.HTML) {
      p._setEndLocation(p.openElements.items[0], token);
      const bodyElement = p.openElements.items[1];
      if (bodyElement && !((_a2 = p.treeAdapter.getNodeSourceCodeLocation(bodyElement)) === null || _a2 === void 0 ? void 0 : _a2.endTag)) {
        p._setEndLocation(bodyElement, token);
      }
    }
  } else {
    tokenAfterBody(p, token);
  }
}
function tokenAfterBody(p, token) {
  p.insertionMode = InsertionMode.IN_BODY;
  modeInBody(p, token);
}
function startTagInFrameset(p, token) {
  switch (token.tagID) {
    case TAG_ID.HTML: {
      startTagInBody(p, token);
      break;
    }
    case TAG_ID.FRAMESET: {
      p._insertElement(token, NS.HTML);
      break;
    }
    case TAG_ID.FRAME: {
      p._appendElement(token, NS.HTML);
      token.ackSelfClosing = true;
      break;
    }
    case TAG_ID.NOFRAMES: {
      startTagInHead(p, token);
      break;
    }
    default:
  }
}
function endTagInFrameset(p, token) {
  if (token.tagID === TAG_ID.FRAMESET && !p.openElements.isRootHtmlElementCurrent()) {
    p.openElements.pop();
    if (!p.fragmentContext && p.openElements.currentTagId !== TAG_ID.FRAMESET) {
      p.insertionMode = InsertionMode.AFTER_FRAMESET;
    }
  }
}
function startTagAfterFrameset(p, token) {
  switch (token.tagID) {
    case TAG_ID.HTML: {
      startTagInBody(p, token);
      break;
    }
    case TAG_ID.NOFRAMES: {
      startTagInHead(p, token);
      break;
    }
    default:
  }
}
function endTagAfterFrameset(p, token) {
  if (token.tagID === TAG_ID.HTML) {
    p.insertionMode = InsertionMode.AFTER_AFTER_FRAMESET;
  }
}
function startTagAfterAfterBody(p, token) {
  if (token.tagID === TAG_ID.HTML) {
    startTagInBody(p, token);
  } else {
    tokenAfterAfterBody(p, token);
  }
}
function tokenAfterAfterBody(p, token) {
  p.insertionMode = InsertionMode.IN_BODY;
  modeInBody(p, token);
}
function startTagAfterAfterFrameset(p, token) {
  switch (token.tagID) {
    case TAG_ID.HTML: {
      startTagInBody(p, token);
      break;
    }
    case TAG_ID.NOFRAMES: {
      startTagInHead(p, token);
      break;
    }
    default:
  }
}
function nullCharacterInForeignContent(p, token) {
  token.chars = REPLACEMENT_CHARACTER;
  p._insertCharacters(token);
}
function characterInForeignContent(p, token) {
  p._insertCharacters(token);
  p.framesetOk = false;
}
function popUntilHtmlOrIntegrationPoint(p) {
  while (p.treeAdapter.getNamespaceURI(p.openElements.current) !== NS.HTML && !p._isIntegrationPoint(p.openElements.currentTagId, p.openElements.current)) {
    p.openElements.pop();
  }
}
function startTagInForeignContent(p, token) {
  if (causesExit(token)) {
    popUntilHtmlOrIntegrationPoint(p);
    p._startTagOutsideForeignContent(token);
  } else {
    const current = p._getAdjustedCurrentElement();
    const currentNs = p.treeAdapter.getNamespaceURI(current);
    if (currentNs === NS.MATHML) {
      adjustTokenMathMLAttrs(token);
    } else if (currentNs === NS.SVG) {
      adjustTokenSVGTagName(token);
      adjustTokenSVGAttrs(token);
    }
    adjustTokenXMLAttrs(token);
    if (token.selfClosing) {
      p._appendElement(token, currentNs);
    } else {
      p._insertElement(token, currentNs);
    }
    token.ackSelfClosing = true;
  }
}
function endTagInForeignContent(p, token) {
  if (token.tagID === TAG_ID.P || token.tagID === TAG_ID.BR) {
    popUntilHtmlOrIntegrationPoint(p);
    p._endTagOutsideForeignContent(token);
    return;
  }
  for (let i = p.openElements.stackTop; i > 0; i--) {
    const element = p.openElements.items[i];
    if (p.treeAdapter.getNamespaceURI(element) === NS.HTML) {
      p._endTagOutsideForeignContent(token);
      break;
    }
    const tagName = p.treeAdapter.getTagName(element);
    if (tagName.toLowerCase() === token.tagName) {
      token.tagName = tagName;
      p.openElements.shortenToLength(i);
      break;
    }
  }
}

// node_modules/entities/lib/esm/escape.js
var xmlCodeMap = /* @__PURE__ */ new Map([
  [34, "&quot;"],
  [38, "&amp;"],
  [39, "&apos;"],
  [60, "&lt;"],
  [62, "&gt;"]
]);
var getCodePoint = (
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
  String.prototype.codePointAt != null ? (str, index) => str.codePointAt(index) : (
    // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
    (c, index) => (c.charCodeAt(index) & 64512) === 55296 ? (c.charCodeAt(index) - 55296) * 1024 + c.charCodeAt(index + 1) - 56320 + 65536 : c.charCodeAt(index)
  )
);
function getEscaper(regex, map2) {
  return function escape2(data) {
    let match2;
    let lastIdx = 0;
    let result = "";
    while (match2 = regex.exec(data)) {
      if (lastIdx !== match2.index) {
        result += data.substring(lastIdx, match2.index);
      }
      result += map2.get(match2[0].charCodeAt(0));
      lastIdx = match2.index + 1;
    }
    return result + data.substring(lastIdx);
  };
}
var escapeUTF8 = getEscaper(/[&<>'"]/g, xmlCodeMap);
var escapeAttribute = getEscaper(/["&\u00A0]/g, /* @__PURE__ */ new Map([
  [34, "&quot;"],
  [38, "&amp;"],
  [160, "&nbsp;"]
]));
var escapeText = getEscaper(/[&<>\u00A0]/g, /* @__PURE__ */ new Map([
  [38, "&amp;"],
  [60, "&lt;"],
  [62, "&gt;"],
  [160, "&nbsp;"]
]));

// node_modules/parse5/dist/serializer/index.js
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
  TAG_NAMES.AREA,
  TAG_NAMES.BASE,
  TAG_NAMES.BASEFONT,
  TAG_NAMES.BGSOUND,
  TAG_NAMES.BR,
  TAG_NAMES.COL,
  TAG_NAMES.EMBED,
  TAG_NAMES.FRAME,
  TAG_NAMES.HR,
  TAG_NAMES.IMG,
  TAG_NAMES.INPUT,
  TAG_NAMES.KEYGEN,
  TAG_NAMES.LINK,
  TAG_NAMES.META,
  TAG_NAMES.PARAM,
  TAG_NAMES.SOURCE,
  TAG_NAMES.TRACK,
  TAG_NAMES.WBR
]);

// node_modules/parse5/dist/index.js
function parse(html, options) {
  return Parser.parse(html, options);
}
function parseFragment(fragmentContext, html, options) {
  if (typeof fragmentContext === "string") {
    options = html;
    html = fragmentContext;
    fragmentContext = null;
  }
  const parser = Parser.getFragmentParser(fragmentContext, options);
  parser.tokenizer.write(html, true);
  return parser.getFragment();
}

// src/mock-doc/parse-util.ts
var docParser = /* @__PURE__ */ new WeakMap();
function parseDocumentUtil(ownerDocument, html) {
  const doc = parse(html.trim(), getParser(ownerDocument));
  doc.documentElement = doc.firstElementChild;
  doc.head = doc.documentElement.firstElementChild;
  doc.body = doc.head.nextElementSibling;
  return doc;
}
function parseFragmentUtil(ownerDocument, html) {
  if (typeof html === "string") {
    html = html.trim();
  } else {
    html = "";
  }
  const frag = parseFragment(html, getParser(ownerDocument));
  return frag;
}
function getParser(ownerDocument) {
  let parseOptions = docParser.get(ownerDocument);
  if (parseOptions != null) {
    return parseOptions;
  }
  const treeAdapter = {
    createDocument() {
      const doc = ownerDocument.createElement("#document" /* DOCUMENT_NODE */);
      doc["x-mode"] = "no-quirks";
      return doc;
    },
    setNodeSourceCodeLocation(node, location2) {
      node.sourceCodeLocation = location2;
    },
    getNodeSourceCodeLocation(node) {
      return node.sourceCodeLocation;
    },
    createDocumentFragment() {
      return ownerDocument.createDocumentFragment();
    },
    createElement(tagName, namespaceURI, attrs) {
      const elm = ownerDocument.createElementNS(namespaceURI, tagName);
      for (let i = 0; i < attrs.length; i++) {
        const attr = attrs[i];
        if (attr.namespace == null || attr.namespace === "http://www.w3.org/1999/xhtml") {
          elm.setAttribute(attr.name, attr.value);
        } else {
          elm.setAttributeNS(attr.namespace, attr.name, attr.value);
        }
      }
      return elm;
    },
    createCommentNode(data) {
      return ownerDocument.createComment(data);
    },
    appendChild(parentNode, newNode) {
      parentNode.appendChild(newNode);
    },
    insertBefore(parentNode, newNode, referenceNode) {
      parentNode.insertBefore(newNode, referenceNode);
    },
    setTemplateContent(templateElement, contentElement) {
      templateElement.content = contentElement;
    },
    getTemplateContent(templateElement) {
      return templateElement.content;
    },
    setDocumentType(doc, name, publicId, systemId) {
      let doctypeNode = doc.childNodes.find((n) => n.nodeType === 10 /* DOCUMENT_TYPE_NODE */);
      if (doctypeNode == null) {
        doctypeNode = ownerDocument.createDocumentTypeNode();
        doc.insertBefore(doctypeNode, doc.firstChild);
      }
      doctypeNode.nodeValue = "!DOCTYPE";
      doctypeNode["x-name"] = name;
      doctypeNode["x-publicId"] = publicId;
      doctypeNode["x-systemId"] = systemId;
    },
    setDocumentMode(doc, mode) {
      doc["x-mode"] = mode;
    },
    getDocumentMode(doc) {
      return doc["x-mode"];
    },
    detachNode(node) {
      node.remove();
    },
    insertText(parentNode, text) {
      const lastChild = parentNode.lastChild;
      if (lastChild != null && lastChild.nodeType === 3 /* TEXT_NODE */) {
        lastChild.nodeValue += text;
      } else {
        parentNode.appendChild(ownerDocument.createTextNode(text));
      }
    },
    insertTextBefore(parentNode, text, referenceNode) {
      const prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1];
      if (prevNode != null && prevNode.nodeType === 3 /* TEXT_NODE */) {
        prevNode.nodeValue += text;
      } else {
        parentNode.insertBefore(ownerDocument.createTextNode(text), referenceNode);
      }
    },
    adoptAttributes(recipient, attrs) {
      for (let i = 0; i < attrs.length; i++) {
        const attr = attrs[i];
        if (recipient.hasAttributeNS(attr.namespace, attr.name) === false) {
          recipient.setAttributeNS(attr.namespace, attr.name, attr.value);
        }
      }
    },
    getFirstChild(node) {
      return node.childNodes[0];
    },
    getChildNodes(node) {
      return node.childNodes;
    },
    getParentNode(node) {
      return node.parentNode;
    },
    getAttrList(element) {
      const attrs = element.attributes.__items.map((attr) => {
        return {
          name: attr.name,
          value: attr.value,
          namespace: attr.namespaceURI,
          prefix: null
        };
      });
      return attrs;
    },
    getTagName(element) {
      if (element.namespaceURI === "http://www.w3.org/1999/xhtml") {
        return element.nodeName.toLowerCase();
      } else {
        return element.nodeName;
      }
    },
    getNamespaceURI(element) {
      return element.namespaceURI;
    },
    getTextNodeContent(textNode) {
      return textNode.nodeValue;
    },
    getCommentNodeContent(commentNode) {
      return commentNode.nodeValue;
    },
    getDocumentTypeNodeName(doctypeNode) {
      return doctypeNode["x-name"];
    },
    getDocumentTypeNodePublicId(doctypeNode) {
      return doctypeNode["x-publicId"];
    },
    getDocumentTypeNodeSystemId(doctypeNode) {
      return doctypeNode["x-systemId"];
    },
    // @ts-ignore - a `MockNode` will never be assignable to a `TreeAdapterTypeMap['text']`. As a result, we cannot
    // complete this function signature
    isTextNode(node) {
      return node.nodeType === 3 /* TEXT_NODE */;
    },
    // @ts-ignore - a `MockNode` will never be assignable to a `TreeAdapterTypeMap['comment']`. As a result, we cannot
    // complete this function signature (which requires its return type to be a type predicate)
    isCommentNode(node) {
      return node.nodeType === 8 /* COMMENT_NODE */;
    },
    // @ts-ignore - a `MockNode` will never be assignable to a `TreeAdapterTypeMap['document']`. As a result, we cannot
    // complete this function signature (which requires its return type to be a type predicate)
    isDocumentTypeNode(node) {
      return node.nodeType === 10 /* DOCUMENT_TYPE_NODE */;
    },
    // @ts-ignore - a `MockNode` will never be assignable to a `TreeAdapterTypeMap['element']`. As a result, we cannot
    // complete this function signature (which requires its return type to be a type predicate)
    isElementNode(node) {
      return node.nodeType === 1 /* ELEMENT_NODE */;
    }
  };
  parseOptions = {
    treeAdapter
  };
  docParser.set(ownerDocument, parseOptions);
  return parseOptions;
}

// src/mock-doc/third-party/jquery.ts
var jquery_default = (
  /*!
  * jQuery JavaScript Library v4.0.0-pre+9352011a7.dirty +selector
  * https://jquery.com/
  *
  * Copyright OpenJS Foundation and other contributors
  * Released under the MIT license
  * https://jquery.org/license
  *
  * Date: 2023-12-11T17:55Z
  */
  (function(global2, factory) {
    "use strict";
    if (true) {
      return factory(global2, true);
    } else {
      factory(global2);
    }
  })({
    document: {
      createElement() {
        return {};
      },
      nodeType: 9,
      documentElement: {
        nodeType: 1,
        nodeName: "HTML"
      }
    }
  }, function(window2, noGlobal) {
    "use strict";
    if (!window2.document) {
      throw new Error("jQuery requires a window with a document");
    }
    var arr = [];
    var getProto = Object.getPrototypeOf;
    var slice = arr.slice;
    var flat = arr.flat ? function(array) {
      return arr.flat.call(array);
    } : function(array) {
      return arr.concat.apply([], array);
    };
    var push = arr.push;
    var indexOf = arr.indexOf;
    var class2type = {};
    var toString = class2type.toString;
    var hasOwn = class2type.hasOwnProperty;
    var fnToString = hasOwn.toString;
    var ObjectFunctionString = fnToString.call(Object);
    var support = {};
    function toType(obj) {
      if (obj == null) {
        return obj + "";
      }
      return typeof obj === "object" ? class2type[toString.call(obj)] || "object" : typeof obj;
    }
    function isWindow(obj) {
      return obj != null && obj === obj.window;
    }
    function isArrayLike(obj) {
      var length = !!obj && obj.length, type = toType(obj);
      if (typeof obj === "function" || isWindow(obj)) {
        return false;
      }
      return type === "array" || length === 0 || typeof length === "number" && length > 0 && length - 1 in obj;
    }
    var document2 = window2.document;
    var preservedScriptAttributes = {
      type: true,
      src: true,
      nonce: true,
      noModule: true
    };
    function DOMEval(code, node, doc) {
      doc = doc || document2;
      var i2, script = doc.createElement("script");
      script.text = code;
      if (node) {
        for (i2 in preservedScriptAttributes) {
          if (node[i2]) {
            script[i2] = node[i2];
          }
        }
      }
      doc.head.appendChild(script).parentNode.removeChild(script);
    }
    const jQuery = {};
    var version = "4.0.0-pre+9352011a7.dirty +selector", rhtmlSuffix = /HTML$/i, jQueryOrig = function(selector, context) {
      return new jQuery.fn.init(selector, context);
    };
    jQuery.fn = jQuery.prototype = {
      // The current version of jQuery being used
      jquery: version,
      constructor: jQuery,
      // The default length of a jQuery object is 0
      length: 0,
      toArray: function() {
        return slice.call(this);
      },
      // Get the Nth element in the matched element set OR
      // Get the whole matched element set as a clean array
      get: function(num) {
        if (num == null) {
          return slice.call(this);
        }
        return num < 0 ? this[num + this.length] : this[num];
      },
      // Take an array of elements and push it onto the stack
      // (returning the new matched element set)
      pushStack: function(elems) {
        var ret = jQuery.merge(this.constructor(), elems);
        ret.prevObject = this;
        return ret;
      },
      // Execute a callback for every element in the matched set.
      each: function(callback) {
        return jQuery.each(this, callback);
      },
      map: function(callback) {
        return this.pushStack(jQuery.map(this, function(elem, i2) {
          return callback.call(elem, i2, elem);
        }));
      },
      slice: function() {
        return this.pushStack(slice.apply(this, arguments));
      },
      first: function() {
        return this.eq(0);
      },
      last: function() {
        return this.eq(-1);
      },
      even: function() {
        return this.pushStack(jQuery.grep(this, function(_elem, i2) {
          return (i2 + 1) % 2;
        }));
      },
      odd: function() {
        return this.pushStack(jQuery.grep(this, function(_elem, i2) {
          return i2 % 2;
        }));
      },
      eq: function(i2) {
        var len = this.length, j = +i2 + (i2 < 0 ? len : 0);
        return this.pushStack(j >= 0 && j < len ? [this[j]] : []);
      },
      end: function() {
        return this.prevObject || this.constructor();
      }
    };
    jQuery.extend = jQuery.fn.extend = function() {
      var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i2 = 1, length = arguments.length, deep = false;
      if (typeof target === "boolean") {
        deep = target;
        target = arguments[i2] || {};
        i2++;
      }
      if (typeof target !== "object" && typeof target !== "function") {
        target = {};
      }
      if (i2 === length) {
        target = this;
        i2--;
      }
      for (; i2 < length; i2++) {
        if ((options = arguments[i2]) != null) {
          for (name in options) {
            copy = options[name];
            if (name === "__proto__" || target === copy) {
              continue;
            }
            if (deep && copy && (jQuery.isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) {
              src = target[name];
              if (copyIsArray && !Array.isArray(src)) {
                clone = [];
              } else if (!copyIsArray && !jQuery.isPlainObject(src)) {
                clone = {};
              } else {
                clone = src;
              }
              copyIsArray = false;
              target[name] = jQuery.extend(deep, clone, copy);
            } else if (copy !== void 0) {
              target[name] = copy;
            }
          }
        }
      }
      return target;
    };
    jQuery.extend({
      // Unique for each copy of jQuery on the page
      expando: "jQuery" + (version + Math.random()).replace(/\D/g, ""),
      // Assume jQuery is ready without the ready module
      isReady: true,
      error: function(msg) {
        throw new Error(msg);
      },
      noop: function() {
      },
      isPlainObject: function(obj) {
        var proto, Ctor;
        if (!obj || toString.call(obj) !== "[object Object]") {
          return false;
        }
        proto = getProto(obj);
        if (!proto) {
          return true;
        }
        Ctor = hasOwn.call(proto, "constructor") && proto.constructor;
        return typeof Ctor === "function" && fnToString.call(Ctor) === ObjectFunctionString;
      },
      isEmptyObject: function(obj) {
        var name;
        for (name in obj) {
          return false;
        }
        return true;
      },
      // Evaluates a script in a provided context; falls back to the global one
      // if not specified.
      globalEval: function(code, options, doc) {
        DOMEval(code, { nonce: options && options.nonce }, doc);
      },
      each: function(obj, callback) {
        var length, i2 = 0;
        if (isArrayLike(obj)) {
          length = obj.length;
          for (; i2 < length; i2++) {
            if (callback.call(obj[i2], i2, obj[i2]) === false) {
              break;
            }
          }
        } else {
          for (i2 in obj) {
            if (callback.call(obj[i2], i2, obj[i2]) === false) {
              break;
            }
          }
        }
        return obj;
      },
      // Retrieve the text value of an array of DOM nodes
      text: function(elem) {
        var node, ret = "", i2 = 0, nodeType = elem.nodeType;
        if (!nodeType) {
          while (node = elem[i2++]) {
            ret += jQuery.text(node);
          }
        }
        if (nodeType === 1 || nodeType === 11) {
          return elem.textContent;
        }
        if (nodeType === 9) {
          return elem.documentElement.textContent;
        }
        if (nodeType === 3 || nodeType === 4) {
          return elem.nodeValue;
        }
        return ret;
      },
      // results is for internal usage only
      makeArray: function(arr2, results) {
        var ret = results || [];
        if (arr2 != null) {
          if (isArrayLike(Object(arr2))) {
            jQuery.merge(
              ret,
              typeof arr2 === "string" ? [arr2] : arr2
            );
          } else {
            push.call(ret, arr2);
          }
        }
        return ret;
      },
      inArray: function(elem, arr2, i2) {
        return arr2 == null ? -1 : indexOf.call(arr2, elem, i2);
      },
      isXMLDoc: function(elem) {
        var namespace = elem && elem.namespaceURI, docElem = elem && (elem.ownerDocument || elem).documentElement;
        return !rhtmlSuffix.test(namespace || docElem && docElem.nodeName || "HTML");
      },
      // Note: an element does not contain itself
      contains: function(a, b) {
        var bup = b && b.parentNode;
        return a === bup || !!(bup && bup.nodeType === 1 && // Support: IE 9 - 11+
        // IE doesn't have `contains` on SVG.
        (a.contains ? a.contains(bup) : a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16));
      },
      merge: function(first, second) {
        var len = +second.length, j = 0, i2 = first.length;
        for (; j < len; j++) {
          first[i2++] = second[j];
        }
        first.length = i2;
        return first;
      },
      grep: function(elems, callback, invert) {
        var callbackInverse, matches3 = [], i2 = 0, length = elems.length, callbackExpect = !invert;
        for (; i2 < length; i2++) {
          callbackInverse = !callback(elems[i2], i2);
          if (callbackInverse !== callbackExpect) {
            matches3.push(elems[i2]);
          }
        }
        return matches3;
      },
      // arg is for internal usage only
      map: function(elems, callback, arg) {
        var length, value, i2 = 0, ret = [];
        if (isArrayLike(elems)) {
          length = elems.length;
          for (; i2 < length; i2++) {
            value = callback(elems[i2], i2, arg);
            if (value != null) {
              ret.push(value);
            }
          }
        } else {
          for (i2 in elems) {
            value = callback(elems[i2], i2, arg);
            if (value != null) {
              ret.push(value);
            }
          }
        }
        return flat(ret);
      },
      // A global GUID counter for objects
      guid: 1,
      // jQuery.support is not used in Core but other projects attach their
      // properties to it so it needs to exist.
      support
    });
    if (typeof Symbol === "function") {
      jQuery.fn[Symbol.iterator] = arr[Symbol.iterator];
    }
    jQuery.each(
      "Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),
      function(_i, name) {
        class2type["[object " + name + "]"] = name.toLowerCase();
      }
    );
    function nodeName(elem, name) {
      return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
    }
    var pop = arr.pop;
    var whitespace = "[\\x20\\t\\r\\n\\f]";
    var isIE = document2.documentMode;
    try {
      document2.querySelector(":has(*,:jqfake)");
      support.cssHas = false;
    } catch (e) {
      support.cssHas = true;
    }
    var rbuggyQSA = [];
    if (isIE) {
      rbuggyQSA.push(
        // Support: IE 9 - 11+
        // IE's :disabled selector does not pick up the children of disabled fieldsets
        ":enabled",
        ":disabled",
        // Support: IE 11+
        // IE 11 doesn't find elements on a `[name='']` query in some cases.
        // Adding a temporary attribute to the document before the selection works
        // around the issue.
        "\\[" + whitespace + "*name" + whitespace + "*=" + whitespace + `*(?:''|"")`
      );
    }
    if (!support.cssHas) {
      rbuggyQSA.push(":has");
    }
    rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join("|"));
    var rtrimCSS = new RegExp(
      "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$",
      "g"
    );
    var identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+";
    var booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped";
    var rleadingCombinator = new RegExp("^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*");
    var rdescend = new RegExp(whitespace + "|>");
    var rsibling = /[+~]/;
    var documentElement = document2.documentElement;
    var matches2 = documentElement.matches || documentElement.msMatchesSelector;
    function createCache() {
      var keys = [];
      function cache(key, value) {
        if (keys.push(key + " ") > jQuery.expr.cacheLength) {
          delete cache[keys.shift()];
        }
        return cache[key + " "] = value;
      }
      return cache;
    }
    function testContext(context) {
      return context && typeof context.getElementsByTagName !== "undefined" && context;
    }
    var attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + // Operator (capture 2)
    "*([*^$|!~]?=)" + whitespace + // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
    `*(?:'((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)"|(` + identifier + "))|)" + whitespace + "*\\]";
    var pseudos = ":(" + identifier + `)(?:\\((('((?:\\\\.|[^\\\\'])*)'|"((?:\\\\.|[^\\\\"])*)")|((?:\\\\.|[^\\\\()[\\]]|` + attributes + ")*)|.*)\\)|)";
    var filterMatchExpr = {
      ID: new RegExp("^#(" + identifier + ")"),
      CLASS: new RegExp("^\\.(" + identifier + ")"),
      TAG: new RegExp("^(" + identifier + "|[*])"),
      ATTR: new RegExp("^" + attributes),
      PSEUDO: new RegExp("^" + pseudos),
      CHILD: new RegExp(
        "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)",
        "i"
      )
    };
    var rpseudo = new RegExp(pseudos);
    var runescape = new RegExp("\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g"), funescape = function(escape2, nonHex) {
      var high = "0x" + escape2.slice(1) - 65536;
      if (nonHex) {
        return nonHex;
      }
      return high < 0 ? String.fromCharCode(high + 65536) : String.fromCharCode(high >> 10 | 55296, high & 1023 | 56320);
    };
    function unescapeSelector(sel) {
      return sel.replace(runescape, funescape);
    }
    function selectorError(msg) {
      jQuery.error("Syntax error, unrecognized expression: " + msg);
    }
    var rcomma = new RegExp("^" + whitespace + "*," + whitespace + "*");
    var tokenCache = createCache();
    function tokenize(selector, parseOnly) {
      var matched, match2, tokens, type, soFar, groups, preFilters, cached = tokenCache[selector + " "];
      if (cached) {
        return parseOnly ? 0 : cached.slice(0);
      }
      soFar = selector;
      groups = [];
      preFilters = jQuery.expr.preFilter;
      while (soFar) {
        if (!matched || (match2 = rcomma.exec(soFar))) {
          if (match2) {
            soFar = soFar.slice(match2[0].length) || soFar;
          }
          groups.push(tokens = []);
        }
        matched = false;
        if (match2 = rleadingCombinator.exec(soFar)) {
          matched = match2.shift();
          tokens.push({
            value: matched,
            // Cast descendant combinators to space
            type: match2[0].replace(rtrimCSS, " ")
          });
          soFar = soFar.slice(matched.length);
        }
        for (type in filterMatchExpr) {
          if ((match2 = jQuery.expr.match[type].exec(soFar)) && (!preFilters[type] || (match2 = preFilters[type](match2)))) {
            matched = match2.shift();
            tokens.push({
              value: matched,
              type,
              matches: match2
            });
            soFar = soFar.slice(matched.length);
          }
        }
        if (!matched) {
          break;
        }
      }
      if (parseOnly) {
        return soFar.length;
      }
      return soFar ? selectorError(selector) : (
        // Cache the tokens
        tokenCache(selector, groups).slice(0)
      );
    }
    var preFilter = {
      ATTR: function(match2) {
        match2[1] = unescapeSelector(match2[1]);
        match2[3] = unescapeSelector(match2[3] || match2[4] || match2[5] || "");
        if (match2[2] === "~=") {
          match2[3] = " " + match2[3] + " ";
        }
        return match2.slice(0, 4);
      },
      CHILD: function(match2) {
        match2[1] = match2[1].toLowerCase();
        if (match2[1].slice(0, 3) === "nth") {
          if (!match2[3]) {
            selectorError(match2[0]);
          }
          match2[4] = +(match2[4] ? match2[5] + (match2[6] || 1) : 2 * (match2[3] === "even" || match2[3] === "odd"));
          match2[5] = +(match2[7] + match2[8] || match2[3] === "odd");
        } else if (match2[3]) {
          selectorError(match2[0]);
        }
        return match2;
      },
      PSEUDO: function(match2) {
        var excess, unquoted = !match2[6] && match2[2];
        if (filterMatchExpr.CHILD.test(match2[0])) {
          return null;
        }
        if (match2[3]) {
          match2[2] = match2[4] || match2[5] || "";
        } else if (unquoted && rpseudo.test(unquoted) && // Get excess from tokenize (recursively)
        (excess = tokenize(unquoted, true)) && // advance to the next closing parenthesis
        (excess = unquoted.indexOf(")", unquoted.length - excess) - unquoted.length)) {
          match2[0] = match2[0].slice(0, excess);
          match2[2] = unquoted.slice(0, excess);
        }
        return match2.slice(0, 3);
      }
    };
    function toSelector(tokens) {
      var i2 = 0, len = tokens.length, selector = "";
      for (; i2 < len; i2++) {
        selector += tokens[i2].value;
      }
      return selector;
    }
    var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;
    function fcssescape(ch, asCodePoint) {
      if (asCodePoint) {
        if (ch === "\0") {
          return "\uFFFD";
        }
        return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16) + " ";
      }
      return "\\" + ch;
    }
    jQuery.escapeSelector = function(sel) {
      return (sel + "").replace(rcssescape, fcssescape);
    };
    var sort = arr.sort;
    var splice = arr.splice;
    var hasDuplicate;
    function sortOrder(a, b) {
      if (a === b) {
        hasDuplicate = true;
        return 0;
      }
      var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
      if (compare) {
        return compare;
      }
      compare = (a.ownerDocument || a) == (b.ownerDocument || b) ? a.compareDocumentPosition(b) : (
        // Otherwise we know they are disconnected
        1
      );
      if (compare & 1) {
        if (a == document2 || a.ownerDocument == document2 && jQuery.contains(document2, a)) {
          return -1;
        }
        if (b == document2 || b.ownerDocument == document2 && jQuery.contains(document2, b)) {
          return 1;
        }
        return 0;
      }
      return compare & 4 ? -1 : 1;
    }
    jQuery.uniqueSort = function(results) {
      var elem, duplicates = [], j = 0, i2 = 0;
      hasDuplicate = false;
      sort.call(results, sortOrder);
      if (hasDuplicate) {
        while (elem = results[i2++]) {
          if (elem === results[i2]) {
            j = duplicates.push(i2);
          }
        }
        while (j--) {
          splice.call(results, duplicates[j], 1);
        }
      }
      return results;
    };
    jQuery.fn.uniqueSort = function() {
      return this.pushStack(jQuery.uniqueSort(slice.apply(this)));
    };
    var i, outermostContext, document$1, documentElement$1, documentIsHTML, dirruns = 0, done = 0, classCache = createCache(), compilerCache = createCache(), nonnativeSelectorCache = createCache(), rwhitespace = new RegExp(whitespace + "+", "g"), ridentifier = new RegExp("^" + identifier + "$"), matchExpr = jQuery.extend({
      bool: new RegExp("^(?:" + booleans + ")$", "i"),
      // For use in libraries implementing .is()
      // We use this for POS matching in `select`
      needsContext: new RegExp("^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i")
    }, filterMatchExpr), rinputs = /^(?:input|select|textarea|button)$/i, rheader = /^h\d$/i, rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, unloadHandler = function() {
      setDocument();
    }, inDisabledFieldset = addCombinator(
      function(elem) {
        return elem.disabled === true && nodeName(elem, "fieldset");
      },
      { dir: "parentNode", next: "legend" }
    );
    function find(selector, context, results, seed) {
      var m, i2, elem, nid, match2, groups, newSelector, newContext = context && context.ownerDocument, nodeType = context ? context.nodeType : 9;
      results = results || [];
      if (typeof selector !== "string" || !selector || nodeType !== 1 && nodeType !== 9 && nodeType !== 11) {
        return results;
      }
      if (false) {
        setDocument(context);
        context = context || document$1;
        if (documentIsHTML) {
          if (nodeType !== 11 && (match2 = rquickExpr.exec(selector))) {
            if (m = match2[1]) {
              if (nodeType === 9) {
                if (elem = context.getElementById(m)) {
                  push.call(results, elem);
                }
                return results;
              } else {
                if (newContext && (elem = newContext.getElementById(m)) && jQuery.contains(context, elem)) {
                  push.call(results, elem);
                  return results;
                }
              }
            } else if (match2[2]) {
              push.apply(results, context.getElementsByTagName(selector));
              return results;
            } else if ((m = match2[3]) && context.getElementsByClassName) {
              push.apply(results, context.getElementsByClassName(m));
              return results;
            }
          }
          if (!nonnativeSelectorCache[selector + " "] && (!rbuggyQSA || !rbuggyQSA.test(selector))) {
            newSelector = selector;
            newContext = context;
            if (nodeType === 1 && (rdescend.test(selector) || rleadingCombinator.test(selector))) {
              newContext = rsibling.test(selector) && testContext(context.parentNode) || context;
              if (newContext != context || isIE) {
                if (nid = context.getAttribute("id")) {
                  nid = jQuery.escapeSelector(nid);
                } else {
                  context.setAttribute("id", nid = jQuery.expando);
                }
              }
              groups = tokenize(selector);
              i2 = groups.length;
              while (i2--) {
                groups[i2] = (nid ? "#" + nid : ":scope") + " " + toSelector(groups[i2]);
              }
              newSelector = groups.join(",");
            }
            try {
              push.apply(
                results,
                newContext.querySelectorAll(newSelector)
              );
              return results;
            } catch (qsaError) {
              nonnativeSelectorCache(selector, true);
            } finally {
              if (nid === jQuery.expando) {
                context.removeAttribute("id");
              }
            }
          }
        }
      }
      return select(selector.replace(rtrimCSS, "$1"), context, results, seed);
    }
    function markFunction(fn) {
      fn[jQuery.expando] = true;
      return fn;
    }
    function createInputPseudo(type) {
      return function(elem) {
        return nodeName(elem, "input") && elem.type === type;
      };
    }
    function createButtonPseudo(type) {
      return function(elem) {
        return (nodeName(elem, "input") || nodeName(elem, "button")) && elem.type === type;
      };
    }
    function createDisabledPseudo(disabled) {
      return function(elem) {
        if ("form" in elem) {
          if (elem.parentNode && elem.disabled === false) {
            if ("label" in elem) {
              if ("label" in elem.parentNode) {
                return elem.parentNode.disabled === disabled;
              } else {
                return elem.disabled === disabled;
              }
            }
            return elem.isDisabled === disabled || // Where there is no isDisabled, check manually
            elem.isDisabled !== !disabled && inDisabledFieldset(elem) === disabled;
          }
          return elem.disabled === disabled;
        } else if ("label" in elem) {
          return elem.disabled === disabled;
        }
        return false;
      };
    }
    function createPositionalPseudo(fn) {
      return markFunction(function(argument) {
        argument = +argument;
        return markFunction(function(seed, matches3) {
          var j, matchIndexes = fn([], seed.length, argument), i2 = matchIndexes.length;
          while (i2--) {
            if (seed[j = matchIndexes[i2]]) {
              seed[j] = !(matches3[j] = seed[j]);
            }
          }
        });
      });
    }
    function setDocument(node) {
      var subWindow, doc = node ? node.ownerDocument || node : document2;
      if (doc == document$1 || doc.nodeType !== 9) {
        return;
      }
      document$1 = doc;
      documentElement$1 = document$1.documentElement;
      documentIsHTML = !jQuery.isXMLDoc(document$1);
      if (isIE && document2 != document$1 && (subWindow = document$1.defaultView) && subWindow.top !== subWindow) {
        subWindow.addEventListener("unload", unloadHandler);
      }
    }
    find.matches = function(expr, elements) {
      return find(expr, null, null, elements);
    };
    find.matchesSelector = function(elem, expr) {
      setDocument(elem);
      if (documentIsHTML && !nonnativeSelectorCache[expr + " "] && (!rbuggyQSA || !rbuggyQSA.test(expr))) {
        try {
          return matches2.call(elem, expr);
        } catch (e) {
          nonnativeSelectorCache(expr, true);
        }
      }
      return find(expr, document$1, null, [elem]).length > 0;
    };
    jQuery.expr = {
      // Can be adjusted by the user
      cacheLength: 50,
      createPseudo: markFunction,
      match: matchExpr,
      find: {
        ID: function(id, context) {
          if (typeof context.getElementById !== "undefined" && documentIsHTML) {
            var elem = context.getElementById(id);
            return elem ? [elem] : [];
          }
        },
        TAG: function(tag, context) {
          if (typeof context.getElementsByTagName !== "undefined") {
            return context.getElementsByTagName(tag);
          } else {
            return context.querySelectorAll(tag);
          }
        },
        CLASS: function(className, context) {
          if (typeof context.getElementsByClassName !== "undefined" && documentIsHTML) {
            return context.getElementsByClassName(className);
          }
        }
      },
      relative: {
        ">": { dir: "parentNode", first: true },
        " ": { dir: "parentNode" },
        "+": { dir: "previousSibling", first: true },
        "~": { dir: "previousSibling" }
      },
      preFilter,
      filter: {
        ID: function(id) {
          var attrId = unescapeSelector(id);
          return function(elem) {
            return elem.getAttribute("id") === attrId;
          };
        },
        TAG: function(nodeNameSelector) {
          var expectedNodeName = unescapeSelector(nodeNameSelector).toLowerCase();
          return nodeNameSelector === "*" ? function() {
            return true;
          } : function(elem) {
            return nodeName(elem, expectedNodeName);
          };
        },
        CLASS: function(className) {
          var pattern = classCache[className + " "];
          return pattern || (pattern = new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)")) && classCache(className, function(elem) {
            return pattern.test(
              typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || ""
            );
          });
        },
        ATTR: function(name, operator, check) {
          return function(elem) {
            var result = elem.getAttribute(name);
            if (result == null) {
              return operator === "!=";
            }
            if (!operator) {
              return true;
            }
            result += "";
            if (operator === "=") {
              return result === check;
            }
            if (operator === "!=") {
              return result !== check;
            }
            if (operator === "^=") {
              return check && result.indexOf(check) === 0;
            }
            if (operator === "*=") {
              return check && result.indexOf(check) > -1;
            }
            if (operator === "$=") {
              return check && result.slice(-check.length) === check;
            }
            if (operator === "~=") {
              return (" " + result.replace(rwhitespace, " ") + " ").indexOf(check) > -1;
            }
            if (operator === "|=") {
              return result === check || result.slice(0, check.length + 1) === check + "-";
            }
            return false;
          };
        },
        CHILD: function(type, what, _argument, first, last) {
          var simple = type.slice(0, 3) !== "nth", forward = type.slice(-4) !== "last", ofType = what === "of-type";
          return first === 1 && last === 0 ? (
            // Shortcut for :nth-*(n)
            function(elem) {
              return !!elem.parentNode;
            }
          ) : function(elem, _context, xml) {
            var cache, outerCache, node, nodeIndex, start, dir = simple !== forward ? "nextSibling" : "previousSibling", parent = elem.parentNode, name = ofType && elem.nodeName.toLowerCase(), useCache = !xml && !ofType, diff = false;
            if (parent) {
              if (simple) {
                while (dir) {
                  node = elem;
                  while (node = node[dir]) {
                    if (ofType ? nodeName(node, name) : node.nodeType === 1) {
                      return false;
                    }
                  }
                  start = dir = type === "only" && !start && "nextSibling";
                }
                return true;
              }
              start = [forward ? parent.firstChild : parent.lastChild];
              if (forward && useCache) {
                outerCache = parent[jQuery.expando] || (parent[jQuery.expando] = {});
                cache = outerCache[type] || [];
                nodeIndex = cache[0] === dirruns && cache[1];
                diff = nodeIndex && cache[2];
                node = nodeIndex && parent.childNodes[nodeIndex];
                while (node = ++nodeIndex && node && node[dir] || // Fallback to seeking `elem` from the start
                (diff = nodeIndex = 0) || start.pop()) {
                  if (node.nodeType === 1 && ++diff && node === elem) {
                    outerCache[type] = [dirruns, nodeIndex, diff];
                    break;
                  }
                }
              } else {
                if (useCache) {
                  outerCache = elem[jQuery.expando] || (elem[jQuery.expando] = {});
                  cache = outerCache[type] || [];
                  nodeIndex = cache[0] === dirruns && cache[1];
                  diff = nodeIndex;
                }
                if (diff === false) {
                  while (node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop()) {
                    if ((ofType ? nodeName(node, name) : node.nodeType === 1) && ++diff) {
                      if (useCache) {
                        outerCache = node[jQuery.expando] || (node[jQuery.expando] = {});
                        outerCache[type] = [dirruns, diff];
                      }
                      if (node === elem) {
                        break;
                      }
                    }
                  }
                }
              }
              diff -= last;
              return diff === first || diff % first === 0 && diff / first >= 0;
            }
          };
        },
        PSEUDO: function(pseudo, argument) {
          var fn = jQuery.expr.pseudos[pseudo] || jQuery.expr.setFilters[pseudo.toLowerCase()] || selectorError("unsupported pseudo: " + pseudo);
          if (fn[jQuery.expando]) {
            return fn(argument);
          }
          return fn;
        }
      },
      pseudos: {
        // Potentially complex pseudos
        not: markFunction(function(selector) {
          var input = [], results = [], matcher = compile(selector.replace(rtrimCSS, "$1"));
          return matcher[jQuery.expando] ? markFunction(function(seed, matches3, _context, xml) {
            var elem, unmatched = matcher(seed, null, xml, []), i2 = seed.length;
            while (i2--) {
              if (elem = unmatched[i2]) {
                seed[i2] = !(matches3[i2] = elem);
              }
            }
          }) : function(elem, _context, xml) {
            input[0] = elem;
            matcher(input, null, xml, results);
            input[0] = null;
            return !results.pop();
          };
        }),
        has: markFunction(function(selector) {
          return function(elem) {
            return find(selector, elem).length > 0;
          };
        }),
        contains: markFunction(function(text) {
          text = unescapeSelector(text);
          return function(elem) {
            return (elem.textContent || jQuery.text(elem)).indexOf(text) > -1;
          };
        }),
        // "Whether an element is represented by a :lang() selector
        // is based solely on the element's language value
        // being equal to the identifier C,
        // or beginning with the identifier C immediately followed by "-".
        // The matching of C against the element's language value is performed case-insensitively.
        // The identifier C does not have to be a valid language name."
        // https://www.w3.org/TR/selectors/#lang-pseudo
        lang: markFunction(function(lang) {
          if (!ridentifier.test(lang || "")) {
            selectorError("unsupported lang: " + lang);
          }
          lang = unescapeSelector(lang).toLowerCase();
          return function(elem) {
            var elemLang;
            do {
              if (elemLang = documentIsHTML ? elem.lang : elem.getAttribute("xml:lang") || elem.getAttribute("lang")) {
                elemLang = elemLang.toLowerCase();
                return elemLang === lang || elemLang.indexOf(lang + "-") === 0;
              }
            } while ((elem = elem.parentNode) && elem.nodeType === 1);
            return false;
          };
        }),
        // Miscellaneous
        target: function(elem) {
          var hash = window2.location && window2.location.hash;
          return hash && hash.slice(1) === elem.id;
        },
        root: function(elem) {
          return elem === documentElement$1;
        },
        focus: function(elem) {
          return elem === document$1.activeElement && document$1.hasFocus() && !!(elem.type || elem.href || ~elem.tabIndex);
        },
        // Boolean properties
        enabled: createDisabledPseudo(false),
        disabled: createDisabledPseudo(true),
        checked: function(elem) {
          return nodeName(elem, "input") && !!elem.checked || nodeName(elem, "option") && !!elem.selected;
        },
        selected: function(elem) {
          if (isIE && elem.parentNode) {
            elem.parentNode.selectedIndex;
          }
          return elem.selected === true;
        },
        // Contents
        empty: function(elem) {
          for (elem = elem.firstChild; elem; elem = elem.nextSibling) {
            if (elem.nodeType < 6) {
              return false;
            }
          }
          return true;
        },
        parent: function(elem) {
          return !jQuery.expr.pseudos.empty(elem);
        },
        // Element/input types
        header: function(elem) {
          return rheader.test(elem.nodeName);
        },
        input: function(elem) {
          return rinputs.test(elem.nodeName);
        },
        button: function(elem) {
          return nodeName(elem, "input") && elem.type === "button" || nodeName(elem, "button");
        },
        text: function(elem) {
          return nodeName(elem, "input") && elem.type === "text";
        },
        // Position-in-collection
        first: createPositionalPseudo(function() {
          return [0];
        }),
        last: createPositionalPseudo(function(_matchIndexes, length) {
          return [length - 1];
        }),
        eq: createPositionalPseudo(function(_matchIndexes, length, argument) {
          return [argument < 0 ? argument + length : argument];
        }),
        even: createPositionalPseudo(function(matchIndexes, length) {
          var i2 = 0;
          for (; i2 < length; i2 += 2) {
            matchIndexes.push(i2);
          }
          return matchIndexes;
        }),
        odd: createPositionalPseudo(function(matchIndexes, length) {
          var i2 = 1;
          for (; i2 < length; i2 += 2) {
            matchIndexes.push(i2);
          }
          return matchIndexes;
        }),
        lt: createPositionalPseudo(function(matchIndexes, length, argument) {
          var i2;
          if (argument < 0) {
            i2 = argument + length;
          } else if (argument > length) {
            i2 = length;
          } else {
            i2 = argument;
          }
          for (; --i2 >= 0; ) {
            matchIndexes.push(i2);
          }
          return matchIndexes;
        }),
        gt: createPositionalPseudo(function(matchIndexes, length, argument) {
          var i2 = argument < 0 ? argument + length : argument;
          for (; ++i2 < length; ) {
            matchIndexes.push(i2);
          }
          return matchIndexes;
        })
      }
    };
    jQuery.expr.pseudos.nth = jQuery.expr.pseudos.eq;
    for (i in { radio: true, checkbox: true, file: true, password: true, image: true }) {
      jQuery.expr.pseudos[i] = createInputPseudo(i);
    }
    for (i in { submit: true, reset: true }) {
      jQuery.expr.pseudos[i] = createButtonPseudo(i);
    }
    function setFilters() {
    }
    setFilters.prototype = jQuery.expr.filters = jQuery.expr.pseudos;
    jQuery.expr.setFilters = new setFilters();
    function addCombinator(matcher, combinator, base) {
      var dir = combinator.dir, skip = combinator.next, key = skip || dir, checkNonElements = base && key === "parentNode", doneName = done++;
      return combinator.first ? (
        // Check against closest ancestor/preceding element
        function(elem, context, xml) {
          while (elem = elem[dir]) {
            if (elem.nodeType === 1 || checkNonElements) {
              return matcher(elem, context, xml);
            }
          }
          return false;
        }
      ) : (
        // Check against all ancestor/preceding elements
        function(elem, context, xml) {
          var oldCache, outerCache, newCache = [dirruns, doneName];
          if (xml) {
            while (elem = elem[dir]) {
              if (elem.nodeType === 1 || checkNonElements) {
                if (matcher(elem, context, xml)) {
                  return true;
                }
              }
            }
          } else {
            while (elem = elem[dir]) {
              if (elem.nodeType === 1 || checkNonElements) {
                outerCache = elem[jQuery.expando] || (elem[jQuery.expando] = {});
                if (skip && nodeName(elem, skip)) {
                  elem = elem[dir] || elem;
                } else if ((oldCache = outerCache[key]) && oldCache[0] === dirruns && oldCache[1] === doneName) {
                  return newCache[2] = oldCache[2];
                } else {
                  outerCache[key] = newCache;
                  if (newCache[2] = matcher(elem, context, xml)) {
                    return true;
                  }
                }
              }
            }
          }
          return false;
        }
      );
    }
    function elementMatcher(matchers) {
      return matchers.length > 1 ? function(elem, context, xml) {
        var i2 = matchers.length;
        while (i2--) {
          if (!matchers[i2](elem, context, xml)) {
            return false;
          }
        }
        return true;
      } : matchers[0];
    }
    function multipleContexts(selector, contexts, results) {
      var i2 = 0, len = contexts.length;
      for (; i2 < len; i2++) {
        find(selector, contexts[i2], results);
      }
      return results;
    }
    function condense(unmatched, map2, filter2, context, xml) {
      var elem, newUnmatched = [], i2 = 0, len = unmatched.length, mapped = map2 != null;
      for (; i2 < len; i2++) {
        if (elem = unmatched[i2]) {
          if (!filter2 || filter2(elem, context, xml)) {
            newUnmatched.push(elem);
            if (mapped) {
              map2.push(i2);
            }
          }
        }
      }
      return newUnmatched;
    }
    function setMatcher(preFilter2, selector, matcher, postFilter, postFinder, postSelector) {
      if (postFilter && !postFilter[jQuery.expando]) {
        postFilter = setMatcher(postFilter);
      }
      if (postFinder && !postFinder[jQuery.expando]) {
        postFinder = setMatcher(postFinder, postSelector);
      }
      return markFunction(function(seed, results, context, xml) {
        var temp, i2, elem, matcherOut, preMap = [], postMap = [], preexisting = results.length, elems = seed || multipleContexts(
          selector || "*",
          context.nodeType ? [context] : context,
          []
        ), matcherIn = preFilter2 && (seed || !selector) ? condense(elems, preMap, preFilter2, context, xml) : elems;
        if (matcher) {
          matcherOut = postFinder || (seed ? preFilter2 : preexisting || postFilter) ? (
            // ...intermediate processing is necessary
            []
          ) : (
            // ...otherwise use results directly
            results
          );
          matcher(matcherIn, matcherOut, context, xml);
        } else {
          matcherOut = matcherIn;
        }
        if (postFilter) {
          temp = condense(matcherOut, postMap);
          postFilter(temp, [], context, xml);
          i2 = temp.length;
          while (i2--) {
            if (elem = temp[i2]) {
              matcherOut[postMap[i2]] = !(matcherIn[postMap[i2]] = elem);
            }
          }
        }
        if (seed) {
          if (postFinder || preFilter2) {
            if (postFinder) {
              temp = [];
              i2 = matcherOut.length;
              while (i2--) {
                if (elem = matcherOut[i2]) {
                  temp.push(matcherIn[i2] = elem);
                }
              }
              postFinder(null, matcherOut = [], temp, xml);
            }
            i2 = matcherOut.length;
            while (i2--) {
              if ((elem = matcherOut[i2]) && (temp = postFinder ? indexOf.call(seed, elem) : preMap[i2]) > -1) {
                seed[temp] = !(results[temp] = elem);
              }
            }
          }
        } else {
          matcherOut = condense(
            matcherOut === results ? matcherOut.splice(preexisting, matcherOut.length) : matcherOut
          );
          if (postFinder) {
            postFinder(null, results, matcherOut, xml);
          } else {
            push.apply(results, matcherOut);
          }
        }
      });
    }
    function matcherFromTokens(tokens) {
      var checkContext, matcher, j, len = tokens.length, leadingRelative = jQuery.expr.relative[tokens[0].type], implicitRelative = leadingRelative || jQuery.expr.relative[" "], i2 = leadingRelative ? 1 : 0, matchContext = addCombinator(function(elem) {
        return elem === checkContext;
      }, implicitRelative, true), matchAnyContext = addCombinator(function(elem) {
        return indexOf.call(checkContext, elem) > -1;
      }, implicitRelative, true), matchers = [function(elem, context, xml) {
        var ret = !leadingRelative && (xml || context != outermostContext) || ((checkContext = context).nodeType ? matchContext(elem, context, xml) : matchAnyContext(elem, context, xml));
        checkContext = null;
        return ret;
      }];
      for (; i2 < len; i2++) {
        if (matcher = jQuery.expr.relative[tokens[i2].type]) {
          matchers = [addCombinator(elementMatcher(matchers), matcher)];
        } else {
          matcher = jQuery.expr.filter[tokens[i2].type].apply(null, tokens[i2].matches);
          if (matcher[jQuery.expando]) {
            j = ++i2;
            for (; j < len; j++) {
              if (jQuery.expr.relative[tokens[j].type]) {
                break;
              }
            }
            return setMatcher(
              i2 > 1 && elementMatcher(matchers),
              i2 > 1 && toSelector(
                // If the preceding token was a descendant combinator, insert an implicit any-element `*`
                tokens.slice(0, i2 - 1).concat({ value: tokens[i2 - 2].type === " " ? "*" : "" })
              ).replace(rtrimCSS, "$1"),
              matcher,
              i2 < j && matcherFromTokens(tokens.slice(i2, j)),
              j < len && matcherFromTokens(tokens = tokens.slice(j)),
              j < len && toSelector(tokens)
            );
          }
          matchers.push(matcher);
        }
      }
      return elementMatcher(matchers);
    }
    function matcherFromGroupMatchers(elementMatchers, setMatchers) {
      var bySet = setMatchers.length > 0, byElement = elementMatchers.length > 0, superMatcher = function(seed, context, xml, results, outermost) {
        var elem, j, matcher, matchedCount = 0, i2 = "0", unmatched = seed && [], setMatched = [], contextBackup = outermostContext, elems = seed || byElement && jQuery.expr.find.TAG("*", outermost), dirrunsUnique = dirruns += contextBackup == null ? 1 : Math.random() || 0.1;
        if (outermost) {
          outermostContext = context == document$1 || context || outermost;
        }
        for (; (elem = elems[i2]) != null; i2++) {
          if (byElement && elem) {
            j = 0;
            if (!context && elem.ownerDocument != document$1) {
              setDocument(elem);
              xml = !documentIsHTML;
            }
            while (matcher = elementMatchers[j++]) {
              if (matcher(elem, context || document$1, xml)) {
                push.call(results, elem);
                break;
              }
            }
            if (outermost) {
              dirruns = dirrunsUnique;
            }
          }
          if (bySet) {
            if (elem = !matcher && elem) {
              matchedCount--;
            }
            if (seed) {
              unmatched.push(elem);
            }
          }
        }
        matchedCount += i2;
        if (bySet && i2 !== matchedCount) {
          j = 0;
          while (matcher = setMatchers[j++]) {
            matcher(unmatched, setMatched, context, xml);
          }
          if (seed) {
            if (matchedCount > 0) {
              while (i2--) {
                if (!(unmatched[i2] || setMatched[i2])) {
                  setMatched[i2] = pop.call(results);
                }
              }
            }
            setMatched = condense(setMatched);
          }
          push.apply(results, setMatched);
          if (outermost && !seed && setMatched.length > 0 && matchedCount + setMatchers.length > 1) {
            jQuery.uniqueSort(results);
          }
        }
        if (outermost) {
          dirruns = dirrunsUnique;
          outermostContext = contextBackup;
        }
        return unmatched;
      };
      return bySet ? markFunction(superMatcher) : superMatcher;
    }
    function compile(selector, match2) {
      var i2, setMatchers = [], elementMatchers = [], cached = compilerCache[selector + " "];
      if (!cached) {
        if (!match2) {
          match2 = tokenize(selector);
        }
        i2 = match2.length;
        while (i2--) {
          cached = matcherFromTokens(match2[i2]);
          if (cached[jQuery.expando]) {
            setMatchers.push(cached);
          } else {
            elementMatchers.push(cached);
          }
        }
        cached = compilerCache(
          selector,
          matcherFromGroupMatchers(elementMatchers, setMatchers)
        );
        cached.selector = selector;
      }
      return cached;
    }
    function select(selector, context, results, seed) {
      var i2, tokens, token, type, find2, compiled = typeof selector === "function" && selector, match2 = !seed && tokenize(selector = compiled.selector || selector);
      results = results || [];
      if (match2.length === 1) {
        tokens = match2[0] = match2[0].slice(0);
        if (tokens.length > 2 && (token = tokens[0]).type === "ID" && context.nodeType === 9 && documentIsHTML && jQuery.expr.relative[tokens[1].type]) {
          context = (jQuery.expr.find.ID(
            unescapeSelector(token.matches[0]),
            context
          ) || [])[0];
          if (!context) {
            return results;
          } else if (compiled) {
            context = context.parentNode;
          }
          selector = selector.slice(tokens.shift().value.length);
        }
        i2 = matchExpr.needsContext.test(selector) ? 0 : tokens.length;
        while (i2--) {
          token = tokens[i2];
          if (jQuery.expr.relative[type = token.type]) {
            break;
          }
          if (find2 = jQuery.expr.find[type]) {
            if (seed = find2(
              unescapeSelector(token.matches[0]),
              rsibling.test(tokens[0].type) && testContext(context.parentNode) || context
            )) {
              tokens.splice(i2, 1);
              selector = seed.length && toSelector(tokens);
              if (!selector) {
                push.apply(results, seed);
                return results;
              }
              break;
            }
          }
        }
      }
      (compiled || compile(selector, match2))(
        seed,
        context,
        !documentIsHTML,
        results,
        !context || rsibling.test(selector) && testContext(context.parentNode) || context
      );
      return results;
    }
    setDocument();
    jQuery.find = find;
    find.compile = compile;
    find.select = select;
    find.setDocument = setDocument;
    find.tokenize = tokenize;
    return jQuery;
  })
);

// src/mock-doc/selector.ts
function matches(selector, elm) {
  try {
    const r = jquery_default.find(selector, void 0, void 0, [elm]);
    return r.length > 0;
  } catch (e) {
    updateSelectorError(selector, e);
    throw e;
  }
}
function selectOne(selector, elm) {
  try {
    const r = jquery_default.find(selector, elm, void 0, void 0);
    return r[0] || null;
  } catch (e) {
    updateSelectorError(selector, e);
    throw e;
  }
}
function selectAll(selector, elm) {
  try {
    return jquery_default.find(selector, elm, void 0, void 0);
  } catch (e) {
    updateSelectorError(selector, e);
    throw e;
  }
}
var PROBLEMATIC_SELECTORS = [":scope", ":where", ":is"];
function updateSelectorError(selector, e) {
  const selectorsPresent = PROBLEMATIC_SELECTORS.filter((s) => selector.includes(s));
  if (selectorsPresent.length > 0 && e.message) {
    e.message = `At present jQuery does not support the ${humanReadableList(selectorsPresent)} ${selectorsPresent.length === 1 ? "selector" : "selectors"}.
If you need this in your test, consider writing an end-to-end test instead.
` + e.message;
  }
}
function humanReadableList(items) {
  if (items.length <= 1) {
    return items.join("");
  }
  return `${items.slice(0, items.length - 1).join(", ")} and ${items[items.length - 1]}`;
}

// src/mock-doc/serialize-node.ts
function normalizeSerializationOptions(opts = {}) {
  return {
    ...opts,
    outerHtml: typeof opts.outerHtml !== "boolean" ? false : opts.outerHtml,
    ...opts.prettyHtml ? {
      indentSpaces: typeof opts.indentSpaces !== "number" ? 2 : opts.indentSpaces,
      newLines: typeof opts.newLines !== "boolean" ? true : opts.newLines
    } : {
      prettyHtml: false,
      indentSpaces: typeof opts.indentSpaces !== "number" ? 0 : opts.indentSpaces,
      newLines: typeof opts.newLines !== "boolean" ? false : opts.newLines
    },
    approximateLineWidth: typeof opts.approximateLineWidth !== "number" ? -1 : opts.approximateLineWidth,
    removeEmptyAttributes: typeof opts.removeEmptyAttributes !== "boolean" ? true : opts.removeEmptyAttributes,
    removeAttributeQuotes: typeof opts.removeAttributeQuotes !== "boolean" ? false : opts.removeAttributeQuotes,
    removeBooleanAttributeQuotes: typeof opts.removeBooleanAttributeQuotes !== "boolean" ? false : opts.removeBooleanAttributeQuotes,
    removeHtmlComments: typeof opts.removeHtmlComments !== "boolean" ? false : opts.removeHtmlComments,
    serializeShadowRoot: typeof opts.serializeShadowRoot === "undefined" ? "declarative-shadow-dom" : opts.serializeShadowRoot,
    fullDocument: typeof opts.fullDocument !== "boolean" ? true : opts.fullDocument
  };
}
function serializeNodeToHtml(elm, serializationOptions = {}) {
  const opts = normalizeSerializationOptions(serializationOptions);
  const output = {
    currentLineWidth: 0,
    indent: 0,
    isWithinBody: false,
    text: []
  };
  let renderedNode = "";
  const children = !opts.fullDocument && elm.body ? Array.from(elm.body.childNodes) : opts.outerHtml ? [elm] : Array.from(getChildNodes(elm));
  for (let i = 0, ii = children.length; i < ii; i++) {
    const child = children[i];
    const chunks = Array.from(streamToHtml(child, opts, output));
    renderedNode += chunks.join("");
  }
  return renderedNode.trim();
}
var shadowRootTag = "mock:shadow-root";
function* streamToHtml(node, opts, output) {
  var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
  const isShadowRoot = node.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */;
  if (node.nodeType === 1 /* ELEMENT_NODE */ || isShadowRoot) {
    const tagName = isShadowRoot ? shadowRootTag : getTagName(node);
    if (tagName === "body") {
      output.isWithinBody = true;
    }
    const ignoreTag = opts.excludeTags != null && opts.excludeTags.includes(tagName);
    if (ignoreTag === false) {
      const isWithinWhitespaceSensitiveNode = opts.newLines || ((_a2 = opts.indentSpaces) != null ? _a2 : 0) > 0 ? isWithinWhitespaceSensitive(node) : false;
      if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
        yield "\n";
        output.currentLineWidth = 0;
      }
      if (((_b = opts.indentSpaces) != null ? _b : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
        for (let i = 0; i < output.indent; i++) {
          yield " ";
        }
        output.currentLineWidth += output.indent;
      }
      const tag = tagName === shadowRootTag ? "template" : tagName;
      yield "<" + tag;
      output.currentLineWidth += tag.length + 1;
      if (tag === "template" && (!node.getAttribute || !node.getAttribute("shadowrootmode")) && /**
       * If the node is a shadow root, we want to add the `shadowrootmode` attribute
       */
      ("host" in node || node.nodeName.toLocaleLowerCase() === shadowRootTag)) {
        const mode = ` shadowrootmode="open"`;
        yield mode;
        output.currentLineWidth += mode.length;
        if (node.delegatesFocus) {
          const delegatesFocusAttr = " shadowrootdelegatesfocus";
          yield delegatesFocusAttr;
          output.currentLineWidth += delegatesFocusAttr.length;
        }
      }
      const attrsLength = node.attributes.length;
      const attributes = opts.prettyHtml && attrsLength > 1 ? cloneAttributes(node.attributes, true) : node.attributes;
      for (let i = 0; i < attrsLength; i++) {
        const attr = attributes.item(i);
        const attrName = attr.name;
        if (attrName === "style") {
          continue;
        }
        if (tag === "template" && isShadowRoot && (attrName === "shadowrootmode" || attrName === "shadowrootdelegatesfocus")) {
          continue;
        }
        let attrValue = attr.value;
        if (opts.removeEmptyAttributes && attrValue === "" && REMOVE_EMPTY_ATTR.has(attrName)) {
          continue;
        }
        const attrNamespaceURI = attr.namespaceURI;
        if (attrNamespaceURI == null) {
          output.currentLineWidth += attrName.length + 1;
          if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth > opts.approximateLineWidth) {
            yield "\n" + attrName;
            output.currentLineWidth = 0;
          } else {
            yield " " + attrName;
          }
        } else if (attrNamespaceURI === "http://www.w3.org/XML/1998/namespace") {
          yield " xml:" + attrName;
          output.currentLineWidth += attrName.length + 5;
        } else if (attrNamespaceURI === "http://www.w3.org/2000/xmlns/") {
          if (attrName !== "xmlns") {
            yield " xmlns:" + attrName;
            output.currentLineWidth += attrName.length + 7;
          } else {
            yield " " + attrName;
            output.currentLineWidth += attrName.length + 1;
          }
        } else if (attrNamespaceURI === XLINK_NS) {
          yield " xlink:" + attrName;
          output.currentLineWidth += attrName.length + 7;
        } else {
          yield " " + attrNamespaceURI + ":" + attrName;
          output.currentLineWidth += attrNamespaceURI.length + attrName.length + 2;
        }
        if (opts.prettyHtml && attrName === "class") {
          attrValue = attr.value = attrValue.split(" ").filter((t) => t !== "").sort().join(" ").trim();
        }
        if (attrValue === "") {
          if (attrName === "shadowrootdelegatesfocus") {
            continue;
          }
          if (opts.removeBooleanAttributeQuotes && BOOLEAN_ATTR.has(attrName)) {
            continue;
          }
          if (opts.removeEmptyAttributes && attrName.startsWith("data-")) {
            continue;
          }
        }
        if (opts.removeAttributeQuotes && CAN_REMOVE_ATTR_QUOTES.test(attrValue)) {
          yield "=" + escapeString(attrValue, true);
          output.currentLineWidth += attrValue.length + 1;
        } else {
          yield '="' + escapeString(attrValue, true) + '"';
          output.currentLineWidth += attrValue.length + 3;
        }
      }
      if (node.hasAttribute("style")) {
        const cssText = node.style.cssText;
        if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth + cssText.length + 10 > opts.approximateLineWidth) {
          yield `
style="${cssText}">`;
          output.currentLineWidth = 0;
        } else {
          yield ` style="${cssText}">`;
          output.currentLineWidth += cssText.length + 10;
        }
      } else {
        yield ">";
        output.currentLineWidth += 1;
      }
    }
    if (EMPTY_ELEMENTS.has(tagName) === false) {
      const shadowRoot = node.shadowRoot;
      if (shadowRoot != null && opts.serializeShadowRoot !== false) {
        output.indent = output.indent + ((_c = opts.indentSpaces) != null ? _c : 0);
        yield* streamToHtml(shadowRoot, opts, output);
        output.indent = output.indent - ((_d = opts.indentSpaces) != null ? _d : 0);
        const childNodes = getChildNodes(node);
        if (opts.newLines && (childNodes.length === 0 || childNodes.length === 1 && childNodes[0].nodeType === 3 /* TEXT_NODE */ && ((_e = childNodes[0].nodeValue) == null ? void 0 : _e.trim()) === "")) {
          yield "\n";
          output.currentLineWidth = 0;
          for (let i = 0; i < output.indent; i++) {
            yield " ";
          }
          output.currentLineWidth += output.indent;
        }
      }
      if (opts.excludeTagContent == null || opts.excludeTagContent.includes(tagName) === false) {
        const tag = tagName === shadowRootTag ? "template" : tagName;
        const childNodes = tagName === "template" ? node.content.childNodes : getChildNodes(node);
        const childNodeLength = childNodes.length;
        if (childNodeLength > 0) {
          if (childNodeLength === 1 && childNodes[0].nodeType === 3 /* TEXT_NODE */ && (typeof childNodes[0].nodeValue !== "string" || childNodes[0].nodeValue.trim() === "")) {
          } else {
            const isWithinWhitespaceSensitiveNode = opts.newLines || ((_f = opts.indentSpaces) != null ? _f : 0) > 0 ? isWithinWhitespaceSensitive(node) : false;
            if (!isWithinWhitespaceSensitiveNode && ((_g = opts.indentSpaces) != null ? _g : 0) > 0 && ignoreTag === false) {
              output.indent = output.indent + ((_h = opts.indentSpaces) != null ? _h : 0);
            }
            for (let i = 0; i < childNodeLength; i++) {
              const sId = node.attributes.getNamedItem(HYDRATE_ID);
              const isStencilDeclarativeShadowDOM = childNodes[i].nodeName.toLowerCase() === "template" && sId;
              if (isStencilDeclarativeShadowDOM) {
                yield `
${" ".repeat(output.indent)}<!--r.${sId.value}-->`;
                continue;
              }
              yield* streamToHtml(childNodes[i], opts, output);
            }
            if (ignoreTag === false) {
              if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
                yield "\n";
                output.currentLineWidth = 0;
              }
              if (((_i = opts.indentSpaces) != null ? _i : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
                output.indent = output.indent - ((_j = opts.indentSpaces) != null ? _j : 0);
                for (let i = 0; i < output.indent; i++) {
                  yield " ";
                }
                output.currentLineWidth += output.indent;
              }
            }
          }
        }
        if (ignoreTag === false) {
          yield "</" + tag + ">";
          output.currentLineWidth += tag.length + 3;
        }
      }
    }
    if (((_k = opts.approximateLineWidth) != null ? _k : 0) > 0 && STRUCTURE_ELEMENTS.has(tagName)) {
      yield "\n";
      output.currentLineWidth = 0;
    }
    if (tagName === "body") {
      output.isWithinBody = false;
    }
  } else if (node.nodeType === 3 /* TEXT_NODE */) {
    let textContent = node.nodeValue;
    if (typeof textContent === "string") {
      const trimmedTextContent = textContent.trim();
      if (trimmedTextContent === "") {
        if (isWithinWhitespaceSensitive(node)) {
          yield textContent;
          output.currentLineWidth += textContent.length;
        } else if (((_l = opts.approximateLineWidth) != null ? _l : 0) > 0 && !output.isWithinBody) {
        } else if (!opts.prettyHtml) {
          output.currentLineWidth += 1;
          if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth > opts.approximateLineWidth) {
            yield "\n";
            output.currentLineWidth = 0;
          } else {
            yield " ";
          }
        }
      } else {
        const isWithinWhitespaceSensitiveNode = opts.newLines || ((_m = opts.indentSpaces) != null ? _m : 0) > 0 || opts.prettyHtml ? isWithinWhitespaceSensitive(node) : false;
        if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
          yield "\n";
          output.currentLineWidth = 0;
        }
        if (((_n = opts.indentSpaces) != null ? _n : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
          for (let i = 0; i < output.indent; i++) {
            yield " ";
          }
          output.currentLineWidth += output.indent;
        }
        let textContentLength = textContent.length;
        if (textContentLength > 0) {
          const parentTagName = node.parentNode != null && node.parentNode.nodeType === 1 /* ELEMENT_NODE */ ? node.parentNode.nodeName : null;
          if (typeof parentTagName === "string" && NON_ESCAPABLE_CONTENT.has(parentTagName)) {
            if (isWithinWhitespaceSensitive(node)) {
              yield textContent;
            } else {
              yield trimmedTextContent;
              textContentLength = trimmedTextContent.length;
            }
            output.currentLineWidth += textContentLength;
          } else {
            if (opts.prettyHtml && !isWithinWhitespaceSensitiveNode) {
              yield escapeString(textContent.replace(/\s\s+/g, " ").trim(), false);
              output.currentLineWidth += textContentLength;
            } else {
              if (isWithinWhitespaceSensitive(node)) {
                output.currentLineWidth += textContentLength;
              } else {
                if (/\s/.test(textContent.charAt(0))) {
                  textContent = " " + textContent.trimLeft();
                }
                textContentLength = textContent.length;
                if (textContentLength > 1) {
                  if (/\s/.test(textContent.charAt(textContentLength - 1))) {
                    if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth + textContentLength > opts.approximateLineWidth) {
                      textContent = textContent.trimRight() + "\n";
                      output.currentLineWidth = 0;
                    } else {
                      textContent = textContent.trimRight() + " ";
                    }
                  }
                }
                output.currentLineWidth += textContentLength;
              }
              yield escapeString(textContent, false);
            }
          }
        }
      }
    }
  } else if (node.nodeType === 8 /* COMMENT_NODE */) {
    const nodeValue = node.nodeValue;
    const isHydrateAnnotation = (nodeValue == null ? void 0 : nodeValue.startsWith(CONTENT_REF_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(ORG_LOCATION_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(SLOT_NODE_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(TEXT_NODE_ID + "."));
    if (opts.removeHtmlComments && !isHydrateAnnotation) {
      return;
    }
    const isWithinWhitespaceSensitiveNode = opts.newLines || ((_o = opts.indentSpaces) != null ? _o : 0) > 0 ? isWithinWhitespaceSensitive(node) : false;
    if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
      yield "\n";
      output.currentLineWidth = 0;
    }
    if (((_p = opts.indentSpaces) != null ? _p : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
      for (let i = 0; i < output.indent; i++) {
        yield " ";
      }
      output.currentLineWidth += output.indent;
    }
    yield "<!--" + nodeValue + "-->";
    if (nodeValue) {
      output.currentLineWidth += nodeValue.length + 7;
    }
  } else if (node.nodeType === 10 /* DOCUMENT_TYPE_NODE */) {
    yield "<!doctype html>";
  }
}
var AMP_REGEX = /&/g;
var NBSP_REGEX = /\u00a0/g;
var DOUBLE_QUOTE_REGEX = /"/g;
var LT_REGEX = /</g;
var GT_REGEX = />/g;
var CAN_REMOVE_ATTR_QUOTES = /^[^ \t\n\f\r"'`=<>\/\\-]+$/;
function getTagName(element) {
  if (element.namespaceURI === "http://www.w3.org/1999/xhtml") {
    return element.nodeName.toLowerCase();
  } else {
    return element.nodeName;
  }
}
function escapeString(str, attrMode) {
  str = str.replace(AMP_REGEX, "&amp;").replace(NBSP_REGEX, "&nbsp;");
  if (attrMode) {
    return str.replace(DOUBLE_QUOTE_REGEX, "&quot;");
  }
  return str.replace(LT_REGEX, "&lt;").replace(GT_REGEX, "&gt;");
}
function isWithinWhitespaceSensitive(node) {
  let _node = node;
  while (_node == null ? void 0 : _node.nodeName) {
    if (WHITESPACE_SENSITIVE.has(_node.nodeName)) {
      return true;
    }
    _node = _node.parentNode;
  }
  return false;
}
function getChildNodes(node) {
  return node.__childNodes || node.childNodes;
}
var NON_ESCAPABLE_CONTENT = /* @__PURE__ */ new Set([
  "STYLE",
  "SCRIPT",
  "IFRAME",
  "NOSCRIPT",
  "XMP",
  "NOEMBED",
  "NOFRAMES",
  "PLAINTEXT"
]);
var WHITESPACE_SENSITIVE = /* @__PURE__ */ new Set([
  "CODE",
  "OUTPUT",
  "PLAINTEXT",
  "PRE",
  "SCRIPT",
  "TEMPLATE",
  "TEXTAREA"
]);
var EMPTY_ELEMENTS = /* @__PURE__ */ new Set([
  "area",
  "base",
  "basefont",
  "bgsound",
  "br",
  "col",
  "embed",
  "frame",
  "hr",
  "img",
  "input",
  "keygen",
  "link",
  "meta",
  "param",
  "source",
  "trace",
  "track",
  "wbr"
]);
var REMOVE_EMPTY_ATTR = /* @__PURE__ */ new Set(["class", "dir", "id", "lang", "name", "title"]);
var BOOLEAN_ATTR = /* @__PURE__ */ new Set([
  "allowfullscreen",
  "async",
  "autofocus",
  "autoplay",
  "checked",
  "compact",
  "controls",
  "declare",
  "default",
  "defaultchecked",
  "defaultmuted",
  "defaultselected",
  "defer",
  "disabled",
  "enabled",
  "formnovalidate",
  "hidden",
  "indeterminate",
  "inert",
  "ismap",
  "itemscope",
  "loop",
  "multiple",
  "muted",
  "nohref",
  "nomodule",
  "noresize",
  "noshade",
  "novalidate",
  "nowrap",
  "open",
  "pauseonexit",
  "readonly",
  "required",
  "reversed",
  "scoped",
  "seamless",
  "selected",
  "shadowrootdelegatesfocus",
  "sortable",
  "truespeed",
  "typemustmatch",
  "visible"
]);
var STRUCTURE_ELEMENTS = /* @__PURE__ */ new Set([
  "html",
  "body",
  "head",
  "iframe",
  "meta",
  "link",
  "base",
  "title",
  "script",
  "style"
]);

// src/mock-doc/token-list.ts
var MockTokenList = class {
  constructor(elm, attr) {
    this.elm = elm;
    this.attr = attr;
  }
  add(...tokens) {
    const items = getItems(this.elm, this.attr);
    let updated = false;
    tokens.forEach((token) => {
      token = String(token);
      validateToken(token);
      if (items.includes(token) === false) {
        items.push(token);
        updated = true;
      }
    });
    if (updated) {
      this.elm.setAttributeNS(null, this.attr, items.join(" "));
    }
  }
  remove(...tokens) {
    const items = getItems(this.elm, this.attr);
    let updated = false;
    tokens.forEach((token) => {
      token = String(token);
      validateToken(token);
      const index = items.indexOf(token);
      if (index > -1) {
        items.splice(index, 1);
        updated = true;
      }
    });
    if (updated) {
      this.elm.setAttributeNS(null, this.attr, items.filter((c) => c.length > 0).join(" "));
    }
  }
  contains(token) {
    token = String(token);
    return getItems(this.elm, this.attr).includes(token);
  }
  toggle(token) {
    token = String(token);
    if (this.contains(token) === true) {
      this.remove(token);
    } else {
      this.add(token);
    }
  }
  get length() {
    return getItems(this.elm, this.attr).length;
  }
  item(index) {
    return getItems(this.elm, this.attr)[index];
  }
  toString() {
    return getItems(this.elm, this.attr).join(" ");
  }
};
function validateToken(token) {
  if (token === "") {
    throw new Error("The token provided must not be empty.");
  }
  if (/\s/.test(token)) {
    throw new Error(`The token provided ('${token}') contains HTML space characters, which are not valid in tokens.`);
  }
}
function getItems(elm, attr) {
  const value = elm.getAttribute(attr);
  if (typeof value === "string" && value.length > 0) {
    return value.trim().split(" ").filter((c) => c.length > 0);
  }
  return [];
}

// src/mock-doc/node.ts
var MockNode2 = class {
  _nodeValue;
  nodeName;
  nodeType;
  ownerDocument;
  parentNode;
  _childNodes = [];
  constructor(ownerDocument, nodeType, nodeName, nodeValue) {
    this.ownerDocument = ownerDocument;
    this.nodeType = nodeType;
    this.nodeName = nodeName;
    this._nodeValue = nodeValue;
    this.parentNode = null;
  }
  get childNodes() {
    return this._childNodes;
  }
  set childNodes(value) {
    this._childNodes = value;
  }
  appendChild(newNode) {
    if (newNode.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */) {
      const nodes = newNode.childNodes.slice();
      for (const child of nodes) {
        this.appendChild(child);
      }
    } else {
      newNode.remove();
      newNode.parentNode = this;
      this.childNodes.push(newNode);
      connectNode(this.ownerDocument, newNode);
    }
    return newNode;
  }
  append(...items) {
    items.forEach((item) => {
      const isNode = typeof item === "object" && item !== null && "nodeType" in item;
      this.appendChild(isNode ? item : this.ownerDocument.createTextNode(String(item)));
    });
  }
  prepend(...items) {
    const firstChild = this.firstChild;
    items.forEach((item) => {
      const isNode = typeof item === "object" && item !== null && "nodeType" in item;
      if (firstChild) {
        this.insertBefore(isNode ? item : this.ownerDocument.createTextNode(String(item)), firstChild);
      }
    });
  }
  cloneNode(deep) {
    throw new Error(`invalid node type to clone: ${this.nodeType}, deep: ${deep}`);
  }
  compareDocumentPosition(_other) {
    return -1;
  }
  get firstChild() {
    return this.childNodes[0] || null;
  }
  insertBefore(newNode, referenceNode) {
    if (newNode.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */) {
      for (let i = 0, ii = newNode.childNodes.length; i < ii; i++) {
        insertBefore(this, newNode.childNodes[i], referenceNode);
      }
    } else {
      insertBefore(this, newNode, referenceNode);
    }
    return newNode;
  }
  get isConnected() {
    let node = this;
    while (node != null) {
      if (node.nodeType === 9 /* DOCUMENT_NODE */) {
        return true;
      }
      node = node.parentNode;
      if (node != null && node.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */) {
        node = node.host;
      }
    }
    return false;
  }
  isSameNode(node) {
    return this === node;
  }
  get lastChild() {
    return this.childNodes[this.childNodes.length - 1] || null;
  }
  get nextSibling() {
    if (this.parentNode != null) {
      const index = this.parentNode.childNodes.indexOf(this) + 1;
      return this.parentNode.childNodes[index] || null;
    }
    return null;
  }
  get nodeValue() {
    var _a2;
    return (_a2 = this._nodeValue) != null ? _a2 : "";
  }
  set nodeValue(value) {
    this._nodeValue = value;
  }
  get parentElement() {
    return this.parentNode || null;
  }
  set parentElement(value) {
    this.parentNode = value;
  }
  get previousSibling() {
    if (this.parentNode != null) {
      const index = this.parentNode.childNodes.indexOf(this) - 1;
      return this.parentNode.childNodes[index] || null;
    }
    return null;
  }
  contains(otherNode) {
    if (otherNode === this) {
      return true;
    }
    const childNodes = Array.from(this.childNodes);
    if (childNodes.includes(otherNode)) {
      return true;
    }
    return childNodes.some((node) => this.contains.bind(node)(otherNode));
  }
  removeChild(childNode) {
    const index = this.childNodes.indexOf(childNode);
    if (index > -1) {
      this.childNodes.splice(index, 1);
      if (this.nodeType === 1 /* ELEMENT_NODE */) {
        const wasConnected = this.isConnected;
        childNode.parentNode = null;
        if (wasConnected === true) {
          disconnectNode(childNode);
        }
      } else {
        childNode.parentNode = null;
      }
    } else {
      throw new Error(`node not found within childNodes during removeChild`);
    }
    return childNode;
  }
  remove() {
    if (this.parentNode != null) {
      this.__parentNode ? this.__parentNode.removeChild(this) : this.parentNode.removeChild(this);
    }
  }
  replaceChild(newChild, oldChild) {
    if (oldChild.parentNode === this) {
      this.insertBefore(newChild, oldChild);
      oldChild.remove();
      return newChild;
    }
    return null;
  }
  get textContent() {
    var _a2;
    return (_a2 = this._nodeValue) != null ? _a2 : "";
  }
  set textContent(value) {
    this._nodeValue = String(value);
  }
  addEventListener(type, handler) {
    addEventListener(this, type, handler);
  }
  removeEventListener(type, handler) {
    removeEventListener(this, type, handler);
  }
  dispatchEvent(ev) {
    return dispatchEvent(this, ev);
  }
};
__publicField(MockNode2, "ELEMENT_NODE", 1);
__publicField(MockNode2, "TEXT_NODE", 3);
__publicField(MockNode2, "PROCESSING_INSTRUCTION_NODE", 7);
__publicField(MockNode2, "COMMENT_NODE", 8);
__publicField(MockNode2, "DOCUMENT_NODE", 9);
__publicField(MockNode2, "DOCUMENT_TYPE_NODE", 10);
__publicField(MockNode2, "DOCUMENT_FRAGMENT_NODE", 11);
var MockNodeList = class {
  childNodes;
  length;
  ownerDocument;
  constructor(ownerDocument, childNodes, length) {
    this.ownerDocument = ownerDocument;
    this.childNodes = childNodes;
    this.length = length;
  }
};
var MockElement = class extends MockNode2 {
  __namespaceURI;
  __attributeMap;
  __shadowRoot;
  __style;
  attachInternals() {
    return new Proxy({}, {
      get: function(_target, prop, _receiver) {
        if ("process" in globalThis && globalThis.process.env.__STENCIL_SPEC_TESTS__) {
          console.error(
            `NOTE: Property ${String(prop)} was accessed on ElementInternals, but this property is not implemented.
  Testing components with ElementInternals is fully supported in e2e tests.`
          );
        }
      }
    });
  }
  constructor(ownerDocument, nodeName, namespaceURI = null) {
    super(ownerDocument, 1 /* ELEMENT_NODE */, typeof nodeName === "string" ? nodeName : null, null);
    this.__namespaceURI = namespaceURI;
    this.__shadowRoot = null;
    this.__attributeMap = null;
  }
  addEventListener(type, handler) {
    addEventListener(this, type, handler);
  }
  attachShadow(_opts) {
    var _a2;
    const shadowRoot = this.ownerDocument.createDocumentFragment();
    shadowRoot.delegatesFocus = (_a2 = _opts.delegatesFocus) != null ? _a2 : false;
    this.shadowRoot = shadowRoot;
    return shadowRoot;
  }
  blur() {
    if (isCurrentlyDispatching(this, "blur")) {
      return;
    }
    markAsDispatching(this, "blur");
    try {
      dispatchEvent(
        this,
        new MockFocusEvent("blur", { relatedTarget: null, bubbles: true, cancelable: true, composed: true })
      );
    } finally {
      unmarkAsDispatching(this, "blur");
    }
  }
  get localName() {
    if (!this.nodeName) {
      throw new Error(`Can't compute elements localName without nodeName`);
    }
    return this.nodeName.toLocaleLowerCase();
  }
  get namespaceURI() {
    return this.__namespaceURI;
  }
  get shadowRoot() {
    return this.__shadowRoot || null;
  }
  /**
   * Set shadow root for element
   * @param shadowRoot - ShadowRoot to set
   */
  set shadowRoot(shadowRoot) {
    if (shadowRoot != null) {
      shadowRoot.host = this;
      this.__shadowRoot = shadowRoot;
    } else {
      delete this.__shadowRoot;
    }
  }
  get attributes() {
    if (this.__attributeMap == null) {
      const attrMap = createAttributeProxy(false);
      this.__attributeMap = attrMap;
      return attrMap;
    }
    return this.__attributeMap;
  }
  set attributes(attrs) {
    this.__attributeMap = attrs;
  }
  get children() {
    return this.childNodes.filter((n) => n.nodeType === 1 /* ELEMENT_NODE */);
  }
  get childElementCount() {
    return this.childNodes.filter((n) => n.nodeType === 1 /* ELEMENT_NODE */).length;
  }
  get className() {
    return this.getAttributeNS(null, "class") || "";
  }
  set className(value) {
    this.setAttributeNS(null, "class", value);
  }
  get classList() {
    return new MockTokenList(this, "class");
  }
  get part() {
    return new MockTokenList(this, "part");
  }
  set part(value) {
    this.setAttributeNS(null, "part", String(value));
  }
  click() {
    dispatchEvent(this, new MockEvent("click", { bubbles: true, cancelable: true, composed: true }));
  }
  cloneNode(_deep) {
    return null;
  }
  closest(selector) {
    let elm = this;
    while (elm != null) {
      if (elm.matches(selector)) {
        return elm;
      }
      elm = elm.parentNode;
    }
    return null;
  }
  get dataset() {
    return dataset(this);
  }
  get dir() {
    return this.getAttributeNS(null, "dir") || "";
  }
  set dir(value) {
    this.setAttributeNS(null, "dir", value);
  }
  dispatchEvent(ev) {
    return dispatchEvent(this, ev);
  }
  get firstElementChild() {
    return this.children[0] || null;
  }
  focus(_options2) {
    dispatchEvent(
      this,
      new MockFocusEvent("focus", { relatedTarget: null, bubbles: true, cancelable: true, composed: true })
    );
  }
  getAttribute(attrName) {
    if (attrName === "style") {
      if (this.__style != null && this.__style.length > 0) {
        return this.style.cssText;
      }
      return null;
    }
    const attr = this.attributes.getNamedItem(attrName);
    if (attr != null) {
      return attr.value;
    }
    return null;
  }
  getAttributeNS(namespaceURI, attrName) {
    const attr = this.attributes.getNamedItemNS(namespaceURI, attrName);
    if (attr != null) {
      return attr.value;
    }
    return null;
  }
  getAttributeNode(attrName) {
    if (!this.hasAttribute(attrName)) {
      return null;
    }
    return new MockAttr(attrName, this.getAttribute(attrName));
  }
  getBoundingClientRect() {
    return { bottom: 0, height: 0, left: 0, right: 0, top: 0, width: 0, x: 0, y: 0 };
  }
  getRootNode(opts) {
    const isComposed = opts != null && opts.composed === true;
    let node = this;
    while (node.parentNode != null) {
      node = node.parentNode;
      if (isComposed === true && node.parentNode == null && node.host != null) {
        node = node.host;
      }
    }
    return node;
  }
  get draggable() {
    return this.getAttributeNS(null, "draggable") === "true";
  }
  set draggable(value) {
    this.setAttributeNS(null, "draggable", value);
  }
  hasChildNodes() {
    return this.childNodes.length > 0;
  }
  get id() {
    return this.getAttributeNS(null, "id") || "";
  }
  set id(value) {
    this.setAttributeNS(null, "id", value);
  }
  get innerHTML() {
    if (this.childNodes.length === 0) {
      return "";
    }
    return serializeNodeToHtml(this, {
      newLines: false,
      indentSpaces: 0
    });
  }
  set innerHTML(html) {
    var _a2;
    if (NON_ESCAPABLE_CONTENT.has((_a2 = this.nodeName) != null ? _a2 : "") === true) {
      setTextContent(this, html);
    } else {
      for (let i = this.childNodes.length - 1; i >= 0; i--) {
        this.removeChild(this.childNodes[i]);
      }
      if (typeof html === "string") {
        const frag = parseFragmentUtil(this.ownerDocument, html);
        while (frag.childNodes.length > 0) {
          this.appendChild(frag.childNodes[0]);
        }
      }
    }
  }
  get innerText() {
    const text = [];
    getTextContent(this.childNodes, text);
    return text.join("");
  }
  set innerText(value) {
    setTextContent(this, value);
  }
  insertAdjacentElement(position, elm) {
    if (position === "beforebegin" && this.parentNode) {
      insertBefore(this.parentNode, elm, this);
    } else if (position === "afterbegin") {
      this.prepend(elm);
    } else if (position === "beforeend") {
      this.appendChild(elm);
    } else if (position === "afterend" && this.parentNode) {
      insertBefore(this.parentNode, elm, this.nextSibling);
    }
    return elm;
  }
  insertAdjacentHTML(position, html) {
    const frag = parseFragmentUtil(this.ownerDocument, html);
    if (position === "beforebegin") {
      while (frag.childNodes.length > 0) {
        if (this.parentNode) {
          insertBefore(this.parentNode, frag.childNodes[0], this);
        }
      }
    } else if (position === "afterbegin") {
      while (frag.childNodes.length > 0) {
        this.prepend(frag.childNodes[frag.childNodes.length - 1]);
      }
    } else if (position === "beforeend") {
      while (frag.childNodes.length > 0) {
        this.appendChild(frag.childNodes[0]);
      }
    } else if (position === "afterend") {
      while (frag.childNodes.length > 0) {
        if (this.parentNode) {
          insertBefore(this.parentNode, frag.childNodes[frag.childNodes.length - 1], this.nextSibling);
        }
      }
    }
  }
  insertAdjacentText(position, text) {
    const elm = this.ownerDocument.createTextNode(text);
    if (position === "beforebegin" && this.parentNode) {
      insertBefore(this.parentNode, elm, this);
    } else if (position === "afterbegin") {
      this.prepend(elm);
    } else if (position === "beforeend") {
      this.appendChild(elm);
    } else if (position === "afterend" && this.parentNode) {
      insertBefore(this.parentNode, elm, this.nextSibling);
    }
  }
  hasAttribute(attrName) {
    if (attrName === "style") {
      return this.__style != null && this.__style.length > 0;
    }
    return this.getAttribute(attrName) !== null;
  }
  hasAttributeNS(namespaceURI, name) {
    return this.getAttributeNS(namespaceURI, name) !== null;
  }
  get hidden() {
    return this.hasAttributeNS(null, "hidden");
  }
  set hidden(isHidden) {
    if (isHidden === true) {
      this.setAttributeNS(null, "hidden", "");
    } else {
      this.removeAttributeNS(null, "hidden");
    }
  }
  get lang() {
    return this.getAttributeNS(null, "lang") || "";
  }
  set lang(value) {
    this.setAttributeNS(null, "lang", value);
  }
  get lastElementChild() {
    const children = this.children;
    return children[children.length - 1] || null;
  }
  matches(selector) {
    return matches(selector, this);
  }
  get nextElementSibling() {
    const parentElement = this.parentElement;
    if (parentElement != null && (parentElement.nodeType === 1 /* ELEMENT_NODE */ || parentElement.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */ || parentElement.nodeType === 9 /* DOCUMENT_NODE */)) {
      const children = parentElement.children;
      const index = children.indexOf(this) + 1;
      return parentElement.children[index] || null;
    }
    return null;
  }
  get outerHTML() {
    return serializeNodeToHtml(this, {
      newLines: false,
      outerHtml: true,
      indentSpaces: 0
    });
  }
  get previousElementSibling() {
    const parentElement = this.parentElement;
    if (parentElement != null && (parentElement.nodeType === 1 /* ELEMENT_NODE */ || parentElement.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */ || parentElement.nodeType === 9 /* DOCUMENT_NODE */)) {
      const children = parentElement.children;
      const index = children.indexOf(this) - 1;
      return parentElement.children[index] || null;
    }
    return null;
  }
  getElementsByClassName(classNames) {
    const classes = classNames.trim().split(" ").filter((c) => c.length > 0);
    const results = [];
    getElementsByClassName(this, classes, results);
    return results;
  }
  getElementsByTagName(tagName) {
    const results = [];
    getElementsByTagName(this, tagName.toLowerCase(), results);
    return results;
  }
  querySelector(selector) {
    return selectOne(selector, this);
  }
  querySelectorAll(selector) {
    return selectAll(selector, this);
  }
  removeAttribute(attrName) {
    if (attrName === "style") {
      delete this.__style;
    } else {
      const attr = this.attributes.getNamedItem(attrName);
      if (attr != null) {
        this.attributes.removeNamedItemNS(attr);
        if (checkAttributeChanged(this) === true) {
          attributeChanged(this, attrName, attr.value, null);
        }
      }
    }
  }
  removeAttributeNS(namespaceURI, attrName) {
    const attr = this.attributes.getNamedItemNS(namespaceURI, attrName);
    if (attr != null) {
      this.attributes.removeNamedItemNS(attr);
      if (checkAttributeChanged(this) === true) {
        attributeChanged(this, attrName, attr.value, null);
      }
    }
  }
  removeEventListener(type, handler) {
    removeEventListener(this, type, handler);
  }
  setAttribute(attrName, value) {
    if (attrName === "style") {
      this.style = value;
    } else {
      const attributes = this.attributes;
      let attr = attributes.getNamedItem(attrName);
      const checkAttrChanged = checkAttributeChanged(this);
      if (attr != null) {
        if (checkAttrChanged === true) {
          const oldValue = attr.value;
          attr.value = value;
          if (oldValue !== attr.value) {
            attributeChanged(this, attr.name, oldValue, attr.value);
          }
        } else {
          attr.value = value;
        }
      } else {
        if (attributes.caseInsensitive) {
          attrName = attrName.toLowerCase();
        }
        attr = new MockAttr(attrName, value);
        attributes.__items.push(attr);
        if (checkAttrChanged === true) {
          attributeChanged(this, attrName, null, attr.value);
        }
      }
    }
  }
  setAttributeNS(namespaceURI, attrName, value) {
    const attributes = this.attributes;
    let attr = attributes.getNamedItemNS(namespaceURI, attrName);
    const checkAttrChanged = checkAttributeChanged(this);
    if (attr != null) {
      if (checkAttrChanged === true) {
        const oldValue = attr.value;
        attr.value = value;
        if (oldValue !== attr.value) {
          attributeChanged(this, attr.name, oldValue, attr.value);
        }
      } else {
        attr.value = value;
      }
    } else {
      attr = new MockAttr(attrName, value, namespaceURI);
      attributes.__items.push(attr);
      if (checkAttrChanged === true) {
        attributeChanged(this, attrName, null, attr.value);
      }
    }
  }
  get style() {
    if (this.__style == null) {
      this.__style = createCSSStyleDeclaration();
    }
    return this.__style;
  }
  set style(val) {
    if (typeof val === "string") {
      if (this.__style == null) {
        this.__style = createCSSStyleDeclaration();
      }
      this.__style.cssText = val;
    } else {
      this.__style = val;
    }
  }
  get tabIndex() {
    return parseInt(this.getAttributeNS(null, "tabindex") || "-1", 10);
  }
  set tabIndex(value) {
    this.setAttributeNS(null, "tabindex", value);
  }
  get tagName() {
    var _a2;
    return (_a2 = this.nodeName) != null ? _a2 : "";
  }
  set tagName(value) {
    this.nodeName = value;
  }
  get textContent() {
    const text = [];
    getTextContent(this.childNodes, text);
    return text.join("");
  }
  set textContent(value) {
    setTextContent(this, value);
  }
  get title() {
    return this.getAttributeNS(null, "title") || "";
  }
  set title(value) {
    this.setAttributeNS(null, "title", value);
  }
  animate() {
  }
  onanimationstart() {
  }
  onanimationend() {
  }
  onanimationiteration() {
  }
  onabort() {
  }
  onauxclick() {
  }
  onbeforecopy() {
  }
  onbeforecut() {
  }
  onbeforepaste() {
  }
  onblur() {
  }
  oncancel() {
  }
  oncanplay() {
  }
  oncanplaythrough() {
  }
  onchange() {
  }
  onclick() {
  }
  onclose() {
  }
  oncontextmenu() {
  }
  oncopy() {
  }
  oncuechange() {
  }
  oncut() {
  }
  ondblclick() {
  }
  ondrag() {
  }
  ondragend() {
  }
  ondragenter() {
  }
  ondragleave() {
  }
  ondragover() {
  }
  ondragstart() {
  }
  ondrop() {
  }
  ondurationchange() {
  }
  onemptied() {
  }
  onended() {
  }
  onerror() {
  }
  onfocus() {
  }
  onfocusin() {
  }
  onfocusout() {
  }
  onformdata() {
  }
  onfullscreenchange() {
  }
  onfullscreenerror() {
  }
  ongotpointercapture() {
  }
  oninput() {
  }
  oninvalid() {
  }
  onkeydown() {
  }
  onkeypress() {
  }
  onkeyup() {
  }
  onload() {
  }
  onloadeddata() {
  }
  onloadedmetadata() {
  }
  onloadstart() {
  }
  onlostpointercapture() {
  }
  onmousedown() {
  }
  onmouseenter() {
  }
  onmouseleave() {
  }
  onmousemove() {
  }
  onmouseout() {
  }
  onmouseover() {
  }
  onmouseup() {
  }
  onmousewheel() {
  }
  onpaste() {
  }
  onpause() {
  }
  onplay() {
  }
  onplaying() {
  }
  onpointercancel() {
  }
  onpointerdown() {
  }
  onpointerenter() {
  }
  onpointerleave() {
  }
  onpointermove() {
  }
  onpointerout() {
  }
  onpointerover() {
  }
  onpointerup() {
  }
  onprogress() {
  }
  onratechange() {
  }
  onreset() {
  }
  onresize() {
  }
  onscroll() {
  }
  onsearch() {
  }
  onseeked() {
  }
  onseeking() {
  }
  onselect() {
  }
  onselectstart() {
  }
  onstalled() {
  }
  onsubmit() {
  }
  onsuspend() {
  }
  ontimeupdate() {
  }
  ontoggle() {
  }
  onvolumechange() {
  }
  onwaiting() {
  }
  onwebkitfullscreenchange() {
  }
  onwebkitfullscreenerror() {
  }
  onwheel() {
  }
  requestFullscreen() {
  }
  scrollBy() {
  }
  scrollTo() {
  }
  scrollIntoView() {
  }
  toString(opts) {
    return serializeNodeToHtml(this, opts);
  }
};
function getElementsByClassName(elm, classNames, foundElms) {
  const children = elm.children;
  for (let i = 0, ii = children.length; i < ii; i++) {
    const childElm = children[i];
    for (let j = 0, jj = classNames.length; j < jj; j++) {
      if (childElm.classList.contains(classNames[j])) {
        foundElms.push(childElm);
      }
    }
    getElementsByClassName(childElm, classNames, foundElms);
  }
}
function getElementsByTagName(elm, tagName, foundElms) {
  var _a2;
  const children = elm.children;
  for (let i = 0, ii = children.length; i < ii; i++) {
    const childElm = children[i];
    if (tagName === "*" || ((_a2 = childElm.nodeName) != null ? _a2 : "").toLowerCase() === tagName) {
      foundElms.push(childElm);
    }
    getElementsByTagName(childElm, tagName, foundElms);
  }
}
function resetElement(elm) {
  resetEventListeners(elm);
  delete elm.__attributeMap;
  delete elm.__shadowRoot;
  delete elm.__style;
}
function insertBefore(parentNode, newNode, referenceNode) {
  if (newNode !== referenceNode) {
    newNode.remove();
    newNode.parentNode = parentNode;
    newNode.ownerDocument = parentNode.ownerDocument;
    if (referenceNode != null) {
      const index = parentNode.childNodes.indexOf(referenceNode);
      if (index > -1) {
        parentNode.childNodes.splice(index, 0, newNode);
      } else {
        throw new Error(`referenceNode not found in parentNode.childNodes`);
      }
    } else {
      parentNode.childNodes.push(newNode);
    }
    connectNode(parentNode.ownerDocument, newNode);
  }
  return newNode;
}
var MockHTMLElement = class extends MockElement {
  __namespaceURI = "http://www.w3.org/1999/xhtml";
  constructor(ownerDocument, nodeName) {
    super(ownerDocument, typeof nodeName === "string" ? nodeName.toUpperCase() : null);
  }
  get tagName() {
    var _a2;
    return (_a2 = this.nodeName) != null ? _a2 : "";
  }
  set tagName(value) {
    this.nodeName = value;
  }
  /**
   * A node’s parent of type Element is known as its parent element.
   * If the node has a parent of a different type, its parent element
   * is null.
   * @returns MockElement
   */
  get parentElement() {
    if (this.nodeName === "HTML") {
      return null;
    }
    return super.parentElement;
  }
  get attributes() {
    if (this.__attributeMap == null) {
      const attrMap = createAttributeProxy(true);
      this.__attributeMap = attrMap;
      return attrMap;
    }
    return this.__attributeMap;
  }
  set attributes(attrs) {
    this.__attributeMap = attrs;
  }
};
var MockTextNode = class _MockTextNode extends MockNode2 {
  constructor(ownerDocument, text) {
    super(ownerDocument, 3 /* TEXT_NODE */, "#text" /* TEXT_NODE */, text);
  }
  cloneNode(_deep) {
    return new _MockTextNode(null, this.nodeValue);
  }
  get textContent() {
    return this.nodeValue;
  }
  set textContent(text) {
    this.nodeValue = text;
  }
  get data() {
    return this.nodeValue;
  }
  set data(text) {
    this.nodeValue = text;
  }
  get wholeText() {
    if (this.parentNode != null) {
      const text = [];
      for (let i = 0, ii = this.parentNode.childNodes.length; i < ii; i++) {
        const childNode = this.parentNode.childNodes[i];
        if (childNode.nodeType === 3 /* TEXT_NODE */) {
          text.push(childNode.nodeValue);
        }
      }
      return text.join("");
    }
    return this.nodeValue;
  }
};
function getTextContent(childNodes, text) {
  for (let i = 0, ii = childNodes.length; i < ii; i++) {
    const childNode = childNodes[i];
    if (childNode.nodeType === 3 /* TEXT_NODE */) {
      text.push(childNode.nodeValue);
    } else if (childNode.nodeType === 1 /* ELEMENT_NODE */) {
      getTextContent(childNode.childNodes, text);
    }
  }
}
function setTextContent(elm, text) {
  for (let i = elm.childNodes.length - 1; i >= 0; i--) {
    elm.removeChild(elm.childNodes[i]);
  }
  const textNode = new MockTextNode(elm.ownerDocument, text);
  elm.appendChild(textNode);
}
var currentlyDispatching = /* @__PURE__ */ new WeakMap();
function isCurrentlyDispatching(target, eventType) {
  const dispatchingEvents = currentlyDispatching.get(target);
  return dispatchingEvents != null && dispatchingEvents.has(eventType);
}
function markAsDispatching(target, eventType) {
  let dispatchingEvents = currentlyDispatching.get(target);
  if (dispatchingEvents == null) {
    dispatchingEvents = /* @__PURE__ */ new Set();
    currentlyDispatching.set(target, dispatchingEvents);
  }
  dispatchingEvents.add(eventType);
}
function unmarkAsDispatching(target, eventType) {
  const dispatchingEvents = currentlyDispatching.get(target);
  if (dispatchingEvents != null) {
    dispatchingEvents.delete(eventType);
    if (dispatchingEvents.size === 0) {
      currentlyDispatching.delete(target);
    }
  }
}

// src/mock-doc/comment-node.ts
var MockComment = class _MockComment extends MockNode2 {
  constructor(ownerDocument, data) {
    super(ownerDocument, 8 /* COMMENT_NODE */, "#comment" /* COMMENT_NODE */, data);
  }
  cloneNode(_deep) {
    return new _MockComment(null, this.nodeValue);
  }
  get textContent() {
    return this.nodeValue;
  }
  set textContent(text) {
    this.nodeValue = text;
  }
};

// src/mock-doc/document-fragment.ts
var MockDocumentFragment = class _MockDocumentFragment extends MockHTMLElement {
  constructor(ownerDocument) {
    super(ownerDocument, null);
    this.nodeName = "#document-fragment" /* DOCUMENT_FRAGMENT_NODE */;
    this.nodeType = 11 /* DOCUMENT_FRAGMENT_NODE */;
  }
  getElementById(id) {
    return getElementById(this, id);
  }
  get adoptedStyleSheets() {
    return [];
  }
  set adoptedStyleSheets(_adoptedStyleSheets) {
    throw new Error("Unimplemented");
  }
  cloneNode(deep) {
    const cloned = new _MockDocumentFragment(null);
    if (deep) {
      for (let i = 0, ii = this.childNodes.length; i < ii; i++) {
        const childNode = this.childNodes[i];
        if (childNode.nodeType === 1 /* ELEMENT_NODE */ || childNode.nodeType === 3 /* TEXT_NODE */ || childNode.nodeType === 8 /* COMMENT_NODE */) {
          const clonedChildNode = this.childNodes[i].cloneNode(true);
          cloned.appendChild(clonedChildNode);
        }
      }
    }
    return cloned;
  }
};

// src/mock-doc/document-type-node.ts
var MockDocumentTypeNode = class extends MockHTMLElement {
  constructor(ownerDocument) {
    super(ownerDocument, "!DOCTYPE");
    this.nodeType = 10 /* DOCUMENT_TYPE_NODE */;
    this.setAttribute("html", "");
  }
};

// src/mock-doc/css-style-sheet.ts
var MockCSSRule = class {
  constructor(parentStyleSheet) {
    this.parentStyleSheet = parentStyleSheet;
  }
  cssText = "";
  type = 0;
};
var MockCSSStyleSheet = class {
  ownerNode;
  type = "text/css";
  parentStyleSheet = null;
  cssRules = [];
  constructor(ownerNode) {
    this.ownerNode = ownerNode;
  }
  get rules() {
    return this.cssRules;
  }
  set rules(rules) {
    this.cssRules = rules;
  }
  deleteRule(index) {
    if (index >= 0 && index < this.cssRules.length) {
      this.cssRules.splice(index, 1);
      if (this.ownerNode) {
        updateStyleTextNode(this.ownerNode);
      }
    }
  }
  insertRule(rule, index = 0) {
    if (typeof index !== "number") {
      index = 0;
    }
    if (index < 0) {
      index = 0;
    }
    if (index > this.cssRules.length) {
      index = this.cssRules.length;
    }
    const cssRule = new MockCSSRule(this);
    cssRule.cssText = rule;
    this.cssRules.splice(index, 0, cssRule);
    if (this.ownerNode) {
      updateStyleTextNode(this.ownerNode);
    }
    return index;
  }
  replaceSync(cssText) {
    this.cssRules = [];
    const rules = cssText.split("}").map((rule) => rule.trim()).filter(Boolean).map((rule) => rule + "}");
    for (const rule of rules) {
      const cssRule = new MockCSSRule(this);
      cssRule.cssText = rule;
      this.cssRules.push(cssRule);
    }
    if (this.ownerNode) {
      updateStyleTextNode(this.ownerNode);
    }
  }
};
function getStyleElementText(styleElm) {
  const output = [];
  for (let i = 0; i < styleElm.childNodes.length; i++) {
    output.push(styleElm.childNodes[i].nodeValue);
  }
  return output.join("");
}
function setStyleElementText(styleElm, text) {
  const sheet = styleElm.sheet;
  sheet.cssRules.length = 0;
  sheet.insertRule(text);
  updateStyleTextNode(styleElm);
}
function updateStyleTextNode(styleElm) {
  const childNodeLen = styleElm.childNodes.length;
  if (childNodeLen > 1) {
    for (let i = childNodeLen - 1; i >= 1; i--) {
      styleElm.removeChild(styleElm.childNodes[i]);
    }
  } else if (childNodeLen < 1) {
    styleElm.appendChild(styleElm.ownerDocument.createTextNode(""));
  }
  const textNode = styleElm.childNodes[0];
  textNode.nodeValue = styleElm.sheet.cssRules.map((r) => r.cssText).join("\n");
}

// src/mock-doc/element.ts
function createElement(ownerDocument, tagName) {
  if (typeof tagName !== "string" || tagName === "" || !/^[a-z0-9-_:]+$/i.test(tagName)) {
    throw new Error(`The tag name provided (${tagName}) is not a valid name.`);
  }
  tagName = tagName.toLowerCase();
  switch (tagName) {
    case "a":
      return new MockAnchorElement(ownerDocument);
    case "base":
      return new MockBaseElement(ownerDocument);
    case "button":
      return new MockButtonElement(ownerDocument);
    case "canvas":
      return new MockCanvasElement(ownerDocument);
    case "form":
      return new MockFormElement(ownerDocument);
    case "img":
      return new MockImageElement(ownerDocument);
    case "input":
      return new MockInputElement(ownerDocument);
    case "label":
      return new MockLabelElement(ownerDocument);
    case "link":
      return new MockLinkElement(ownerDocument);
    case "meta":
      return new MockMetaElement(ownerDocument);
    case "script":
      return new MockScriptElement(ownerDocument);
    case "slot":
      return new MockSlotElement(ownerDocument);
    case "slot-fb":
      return new MockHTMLElement(ownerDocument, tagName);
    case "style":
      return new MockStyleElement(ownerDocument);
    case "template":
      return new MockTemplateElement(ownerDocument);
    case "title":
      return new MockTitleElement(ownerDocument);
    case "ul":
      return new MockUListElement(ownerDocument);
  }
  if (ownerDocument != null && tagName.includes("-")) {
    const win2 = ownerDocument.defaultView;
    if (win2 != null && win2.customElements != null) {
      return createCustomElement(win2.customElements, ownerDocument, tagName);
    }
  }
  return new MockHTMLElement(ownerDocument, tagName);
}
function createElementNS(ownerDocument, namespaceURI, tagName) {
  if (namespaceURI === "http://www.w3.org/1999/xhtml") {
    return createElement(ownerDocument, tagName);
  } else if (namespaceURI === "http://www.w3.org/2000/svg") {
    switch (tagName.toLowerCase()) {
      case "text":
      case "tspan":
      case "tref":
      case "altglyph":
      case "textpath":
        return new MockSVGTextContentElement(ownerDocument, tagName);
      case "circle":
      case "ellipse":
      case "image":
      case "line":
      case "path":
      case "polygon":
      case "polyline":
      case "rect":
      case "use":
        return new MockSVGGraphicsElement(ownerDocument, tagName);
      case "svg":
        return new MockSVGSVGElement(ownerDocument, tagName);
      default:
        return new MockSVGElement(ownerDocument, tagName);
    }
  } else {
    return new MockElement(ownerDocument, tagName, namespaceURI);
  }
}
var MockAnchorElement = class extends MockHTMLElement {
  constructor(ownerDocument) {
    super(ownerDocument, "a");
  }
  get href() {
    return fullUrl(this, "href");
  }
  set href(value) {
    this.setAttribute("href", value);
  }
  get pathname() {
    if (!this.href) {
      return "";
    }
    return new URL(this.href).pathname;
  }
};
var MockButtonElement = class extends MockHTMLElement {
  constructor(ownerDocument) {
    super(ownerDocument, "button");
  }
  get labels() {
    return getLabelsForElement(this);
  }
};
patchPropAttributes(
  MockButtonElement.prototype,
  {
    type: String
  },
  {
    type: "submit"
  }
);
Object.defineProperty(MockButtonElement.prototype, "form", {
  get() {
    return this.hasAttribute("form") ? this.getAttribute("form") : null;
  }
});
var MockImageElement = class extends MockHTMLElement {
  constructor(ownerDocument) {
    super(ownerDocument, "img");
  }
  get draggable() {
    return this.getAttributeNS(null, "draggable") !== "false";
  }
  set draggable(value) {
    this.setAttributeNS(null, "draggable", value);
  }
  get src() {
    return fullUrl(this, "src");
  }
  set src(value) {
    this.setAttribute("src", value);
  }
};
patchPropAttributes(MockImageElement.prototype, {
  height: Number,
  width: Number
});
var MockInputElement = class extends MockHTMLElement {
  constructor(ownerDocument) {
    super(ownerDocument, "input");
  }
  get list() {
    const listId = this.getAttribute("list");
    if (listId) {
      return this.ownerDocument.getElementById(listId);
    }
    return null;
  }
  get labels() {
    return getLabelsForElement(this);
  }
};
patchPropAttributes(
  MockInputElement.prototype,
  {
    accept: String,
    autocomplete: String,
    autofocus: Boolean,
    capture: String,
    checked: Boolean,
    disabled: Boolean,
    form: String,
    formaction: String,
    formenctype: String,
    formmethod: String,
    formnovalidate: String,
    formtarget: String,
    height: Number,
    inputmode: String,
    max: String,
    maxLength: Number,
    min: String,
    minLength: Number,
    multiple: Boolean,
    name: String,
    pattern: String,
    placeholder: String,
    required: Boolean,
    readOnly: Boolean,
    size: Number,
    spellCheck: Boolean,
    src: String,
    step: String,
    type: String,
    value: String,
    width: Number
  },
  {
    type: "text"
  }
);
var MockFormElement = class extends MockHTMLElement {
  constructor(ownerDocument) {
    super(ownerDocument, "form");
  }
};
patchPropAttributes(MockFormElement.prototype, {
  name: String
});
var MockLabelElement = class extends MockHTMLElement {
  constructor(ownerDocument) {
    super(ownerDocument, "label");
  }
  get htmlFor() {
    return this.getAttributeNS(null, "for") || "";
  }
  set htmlFor(value) {
    this.setAttributeNS(null, "for", value);
  }
  get control() {
    var _a2, _b;
    const forAttr = this.htmlFor;
    if (forAttr) {
      return (_b = (_a2 = this.ownerDocument) == null ? void 0 : _a2.getElementById(forAttr)) != null ? _b : null;
    }
    const labelableSelector = 'button, input:not([type="hidden"]), meter, output, progress, select, textarea';
    return this.querySelector(labelableSelector);
  }
};
var MockLinkElement = class extends MockHTMLElement {
  constructor(ownerDocument) {
    super(ownerDocument, "link");
  }
  get href() {
    return fullUrl(this, "href");
  }
  set href(value) {
    this.setAttribute("href", value);
  }
};
patchPropAttributes(MockLinkElement.prototype, {
  crossorigin: String,
  media: String,
  rel: String,
  type: String
});
var MockMetaElement = class extends MockHTMLElement {
  content;
  constructor(ownerDocument) {
    super(ownerDocument, "meta");
  }
};
patchPropAttributes(MockMetaElement.prototype, {
  charset: String,
  content: String,
  name: String
});
var MockScriptElement = class extends MockHTMLElement {
  constructor(ownerDocument) {
    super(ownerDocument, "script");
  }
  get src() {
    return fullUrl(this, "src");
  }
  set src(value) {
    this.setAttribute("src", value);
  }
};
patchPropAttributes(MockScriptElement.prototype, {
  type: String
});
var MockDOMMatrix = class _MockDOMMatrix {
  static fromMatrix() {
    return new _MockDOMMatrix();
  }
  a = 1;
  b = 0;
  c = 0;
  d = 1;
  e = 0;
  f = 0;
  m11 = 1;
  m12 = 0;
  m13 = 0;
  m14 = 0;
  m21 = 0;
  m22 = 1;
  m23 = 0;
  m24 = 0;
  m31 = 0;
  m32 = 0;
  m33 = 1;
  m34 = 0;
  m41 = 0;
  m42 = 0;
  m43 = 0;
  m44 = 1;
  is2D = true;
  isIdentity = true;
  inverse() {
    return new _MockDOMMatrix();
  }
  flipX() {
    return new _MockDOMMatrix();
  }
  flipY() {
    return new _MockDOMMatrix();
  }
  multiply() {
    return new _MockDOMMatrix();
  }
  rotate() {
    return new _MockDOMMatrix();
  }
  rotateAxisAngle() {
    return new _MockDOMMatrix();
  }
  rotateFromVector() {
    return new _MockDOMMatrix();
  }
  scale() {
    return new _MockDOMMatrix();
  }
  scaleNonUniform() {
    return new _MockDOMMatrix();
  }
  skewX() {
    return new _MockDOMMatrix();
  }
  skewY() {
    return new _MockDOMMatrix();
  }
  toJSON() {
  }
  toString() {
  }
  transformPoint() {
    return new MockDOMPoint();
  }
  translate() {
    return new _MockDOMMatrix();
  }
};
var MockDOMPoint = class {
  w = 1;
  x = 0;
  y = 0;
  z = 0;
  toJSON() {
  }
  matrixTransform() {
    return new MockDOMMatrix();
  }
};
var MockSVGRect = class {
  height = 10;
  width = 10;
  x = 0;
  y = 0;
};
var MockStyleElement = class extends MockHTMLElement {
  sheet;
  constructor(ownerDocument) {
    super(ownerDocument, "style");
    this.sheet = new MockCSSStyleSheet(this);
  }
  get innerHTML() {
    return getStyleElementText(this);
  }
  set innerHTML(value) {
    setStyleElementText(this, value);
  }
  get innerText() {
    return getStyleElementText(this);
  }
  set innerText(value) {
    setStyleElementText(this, value);
  }
  get textContent() {
    return getStyleElementText(this);
  }
  set textContent(value) {
    setStyleElementText(this, value);
  }
};
var MockSVGElement = class extends MockElement {
  __namespaceURI = "http://www.w3.org/2000/svg";
  // SVGElement properties and methods
  get ownerSVGElement() {
    return null;
  }
  get viewportElement() {
    return null;
  }
  onunload() {
  }
  // SVGGeometryElement properties and methods
  get pathLength() {
    return 0;
  }
  isPointInFill(_pt) {
    return false;
  }
  isPointInStroke(_pt) {
    return false;
  }
  getTotalLength() {
    return 0;
  }
};
var MockSVGGraphicsElement = class extends MockSVGElement {
  getBBox(_options2) {
    return new MockSVGRect();
  }
  getCTM() {
    return new MockDOMMatrix();
  }
  getScreenCTM() {
    return new MockDOMMatrix();
  }
};
var MockSVGSVGElement = class extends MockSVGGraphicsElement {
  createSVGPoint() {
    return new MockDOMPoint();
  }
};
var MockSVGTextContentElement = class extends MockSVGGraphicsElement {
  getComputedTextLength() {
    return 0;
  }
};
var MockBaseElement = class extends MockHTMLElement {
  constructor(ownerDocument) {
    super(ownerDocument, "base");
  }
  get href() {
    return fullUrl(this, "href");
  }
  set href(value) {
    this.setAttribute("href", value);
  }
};
var MockTemplateElement = class _MockTemplateElement extends MockHTMLElement {
  content;
  constructor(ownerDocument) {
    super(ownerDocument, "template");
    this.content = new MockDocumentFragment(ownerDocument);
  }
  get innerHTML() {
    return this.content.innerHTML;
  }
  set innerHTML(html) {
    this.content.innerHTML = html;
  }
  cloneNode(deep) {
    const cloned = new _MockTemplateElement(null);
    cloned.attributes = cloneAttributes(this.attributes);
    const styleCssText = this.getAttribute("style");
    if (styleCssText != null && styleCssText.length > 0) {
      cloned.setAttribute("style", styleCssText);
    }
    cloned.content = this.content.cloneNode(deep);
    if (deep) {
      for (let i = 0, ii = this.childNodes.length; i < ii; i++) {
        const clonedChildNode = this.childNodes[i].cloneNode(true);
        cloned.appendChild(clonedChildNode);
      }
    }
    return cloned;
  }
};
var MockTitleElement = class extends MockHTMLElement {
  constructor(ownerDocument) {
    super(ownerDocument, "title");
  }
  get text() {
    return this.textContent;
  }
  set text(value) {
    this.textContent = value;
  }
};
var MockUListElement = class extends MockHTMLElement {
  constructor(ownerDocument) {
    super(ownerDocument, "ul");
  }
};
var MockSlotElement = class _MockSlotElement extends MockHTMLElement {
  constructor(ownerDocument) {
    super(ownerDocument, "slot");
  }
  assignedNodes(opts) {
    let nodesToReturn = [];
    const ownerHost = this.getRootNode().host;
    if (!ownerHost) return nodesToReturn;
    if (ownerHost.childNodes.length) {
      if (this.name) {
        nodesToReturn = ownerHost.childNodes.filter(
          (n) => n.nodeType === 1 /* ELEMENT_NODE */ && n.getAttribute("slot") === this.name
        );
      } else {
        nodesToReturn = ownerHost.childNodes.filter(
          (n) => n.nodeType === 1 /* ELEMENT_NODE */ && !n.getAttribute("slot") || n.nodeType !== 1 /* ELEMENT_NODE */
        );
      }
      if (nodesToReturn.length) return nodesToReturn;
    }
    if (!(opts == null ? void 0 : opts.flatten)) return this.childNodes.filter((n) => !(n instanceof _MockSlotElement));
    return this.childNodes.reduce(
      (acc, node) => {
        if (node instanceof _MockSlotElement) {
          acc.push(...node.assignedNodes(opts));
        } else {
          acc.push(node);
        }
        return acc;
      },
      []
    );
  }
  assignedElements(opts) {
    let elesToReturn = [];
    const ownerHost = this.getRootNode().host;
    if (!ownerHost) return elesToReturn;
    if (ownerHost.children.length) {
      if (this.name) {
        elesToReturn = ownerHost.children.filter((n) => n.getAttribute("slot") == this.name);
      } else {
        elesToReturn = ownerHost.children.filter((n) => !n.getAttribute("slot"));
      }
      if (elesToReturn.length) return elesToReturn;
    }
    if (!(opts == null ? void 0 : opts.flatten)) return this.children.filter((n) => !(n instanceof _MockSlotElement));
    return this.children.reduce(
      (acc, node) => {
        if (node instanceof _MockSlotElement) {
          acc.push(...node.assignedElements(opts));
        } else {
          acc.push(node);
        }
        return acc;
      },
      []
    );
  }
};
patchPropAttributes(MockSlotElement.prototype, {
  name: String
});
var CanvasRenderingContext = class {
  context;
  contextAttributes;
  constructor(context, contextAttributes) {
    this.context = context;
    this.contextAttributes = contextAttributes;
  }
  fillRect() {
    return;
  }
  clearRect() {
  }
  getImageData(_, __, w, h2) {
    return {
      data: new Array(w * h2 * 4)
    };
  }
  toDataURL() {
    return "data:,";
  }
  putImageData() {
  }
  createImageData() {
    return {};
  }
  setTransform() {
  }
  drawImage() {
  }
  save() {
  }
  fillText() {
  }
  restore() {
  }
  beginPath() {
  }
  moveTo() {
  }
  lineTo() {
  }
  closePath() {
  }
  stroke() {
  }
  translate() {
  }
  scale() {
  }
  rotate() {
  }
  arc() {
  }
  fill() {
  }
  measureText() {
    return { width: 0 };
  }
  transform() {
  }
  rect() {
  }
  clip() {
  }
};
var MockCanvasElement = class extends MockHTMLElement {
  constructor(ownerDocument) {
    super(ownerDocument, "canvas");
  }
  getContext(context, contextAttributes) {
    return new CanvasRenderingContext(context, contextAttributes);
  }
};
function fullUrl(elm, attrName) {
  const val = elm.getAttribute(attrName) || "";
  if (elm.ownerDocument != null) {
    const win2 = elm.ownerDocument.defaultView;
    if (win2 != null) {
      const loc = win2.location;
      if (loc != null) {
        try {
          const url = new URL(val, loc.href);
          return url.href;
        } catch (e) {
        }
      }
    }
  }
  return val.replace(/\'|\"/g, "").trim();
}
function getLabelsForElement(elm) {
  const labels = [];
  const id = elm.id;
  const doc = elm.ownerDocument;
  if (doc) {
    if (id) {
      const allLabels = doc.getElementsByTagName("label");
      for (let i = 0; i < allLabels.length; i++) {
        const label = allLabels[i];
        if (label.htmlFor === id) {
          labels.push(label);
        }
      }
    }
    let parent = elm.parentNode;
    while (parent) {
      if (parent.nodeName === "LABEL" && !labels.includes(parent)) {
        labels.push(parent);
      }
      parent = parent.parentNode;
    }
  }
  return labels;
}
function patchPropAttributes(prototype, attrs, defaults2 = {}) {
  Object.keys(attrs).forEach((propName) => {
    const attr = attrs[propName];
    const defaultValue = defaults2[propName];
    if (attr === Boolean) {
      Object.defineProperty(prototype, propName, {
        get() {
          return this.hasAttribute(propName);
        },
        set(value) {
          if (value) {
            this.setAttribute(propName, "");
          } else {
            this.removeAttribute(propName);
          }
        }
      });
    } else if (attr === Number) {
      Object.defineProperty(prototype, propName, {
        get() {
          const value = this.getAttribute(propName);
          return value ? parseInt(value, 10) : defaultValue === void 0 ? 0 : defaultValue;
        },
        set(value) {
          this.setAttribute(propName, value);
        }
      });
    } else {
      Object.defineProperty(prototype, propName, {
        get() {
          return this.hasAttribute(propName) ? this.getAttribute(propName) : defaultValue || "";
        },
        set(value) {
          this.setAttribute(propName, value);
        }
      });
    }
  });
}
MockElement.prototype.cloneNode = function(deep) {
  const cloned = createElement(this.ownerDocument, this.nodeName);
  cloned.attributes = cloneAttributes(this.attributes);
  const styleCssText = this.getAttribute("style");
  if (styleCssText != null && styleCssText.length > 0) {
    cloned.setAttribute("style", styleCssText);
  }
  if (deep) {
    for (let i = 0, ii = this.childNodes.length; i < ii; i++) {
      const clonedChildNode = this.childNodes[i].cloneNode(true);
      cloned.appendChild(clonedChildNode);
    }
  }
  return cloned;
};

// src/mock-doc/parse-html.ts
var sharedDocument;
function parseHtmlToDocument(html, ownerDocument = null) {
  if (ownerDocument == null) {
    if (sharedDocument == null) {
      sharedDocument = new MockDocument();
    }
    ownerDocument = sharedDocument;
  }
  return parseDocumentUtil(ownerDocument, html);
}

// src/mock-doc/console.ts
var consoleNoop = () => {
};
function createConsole() {
  return {
    debug: consoleNoop,
    error: consoleNoop,
    info: consoleNoop,
    log: consoleNoop,
    warn: consoleNoop,
    dir: consoleNoop,
    dirxml: consoleNoop,
    table: consoleNoop,
    trace: consoleNoop,
    group: consoleNoop,
    groupCollapsed: consoleNoop,
    groupEnd: consoleNoop,
    clear: consoleNoop,
    count: consoleNoop,
    countReset: consoleNoop,
    assert: consoleNoop,
    profile: consoleNoop,
    profileEnd: consoleNoop,
    time: consoleNoop,
    timeLog: consoleNoop,
    timeEnd: consoleNoop,
    timeStamp: consoleNoop,
    context: consoleNoop,
    memory: consoleNoop
  };
}

// src/mock-doc/headers.ts
var MockHeaders = class {
  _values = [];
  constructor(init) {
    if (typeof init === "object") {
      if (typeof init[Symbol.iterator] === "function") {
        const kvs = [];
        for (const kv of init) {
          if (typeof kv[Symbol.iterator] === "function") {
            kvs.push([...kv]);
          }
        }
        for (const kv of kvs) {
          this.append(kv[0], kv[1]);
        }
      } else {
        for (const key in init) {
          this.append(key, init[key]);
        }
      }
    }
  }
  append(key, value) {
    this._values.push([key, value + ""]);
  }
  delete(key) {
    key = key.toLowerCase();
    for (let i = this._values.length - 1; i >= 0; i--) {
      if (this._values[i][0].toLowerCase() === key) {
        this._values.splice(i, 1);
      }
    }
  }
  entries() {
    const entries = [];
    for (const kv of this.keys()) {
      entries.push([kv, this.get(kv)]);
    }
    let index = -1;
    return {
      next() {
        index++;
        return {
          value: entries[index],
          done: !entries[index]
        };
      },
      [Symbol.iterator]() {
        return this;
      }
    };
  }
  forEach(cb) {
    for (const kv of this.entries()) {
      cb(kv[1], kv[0]);
    }
  }
  get(key) {
    const rtn = [];
    key = key.toLowerCase();
    for (const kv of this._values) {
      if (kv[0].toLowerCase() === key) {
        rtn.push(kv[1]);
      }
    }
    return rtn.length > 0 ? rtn.join(", ") : null;
  }
  has(key) {
    key = key.toLowerCase();
    for (const kv of this._values) {
      if (kv[0].toLowerCase() === key) {
        return true;
      }
    }
    return false;
  }
  keys() {
    const keys = [];
    for (const kv of this._values) {
      const key = kv[0].toLowerCase();
      if (!keys.includes(key)) {
        keys.push(key);
      }
    }
    let index = -1;
    return {
      next() {
        index++;
        return {
          value: keys[index],
          done: !keys[index]
        };
      },
      [Symbol.iterator]() {
        return this;
      }
    };
  }
  set(key, value) {
    for (const kv of this._values) {
      if (kv[0].toLowerCase() === key.toLowerCase()) {
        kv[1] = value + "";
        return;
      }
    }
    this.append(key, value);
  }
  values() {
    const values = this._values;
    let index = -1;
    return {
      next() {
        index++;
        const done = !values[index];
        return {
          value: done ? void 0 : values[index][1],
          done
        };
      },
      [Symbol.iterator]() {
        return this;
      }
    };
  }
  [Symbol.iterator]() {
    return this.entries();
  }
};

// src/mock-doc/parser.ts
var MockDOMParser = class {
  parseFromString(htmlToParse, mimeType) {
    if (mimeType !== "text/html") {
      console.error("XML parsing not implemented yet, continuing as html");
    }
    return parseHtmlToDocument(htmlToParse);
  }
};

// src/mock-doc/request-response.ts
var MockRequest = class _MockRequest {
  _method = "GET";
  _url = "/";
  bodyUsed = false;
  cache = "default";
  credentials = "same-origin";
  headers;
  integrity = "";
  keepalive = false;
  mode = "cors";
  redirect = "follow";
  referrer = "about:client";
  referrerPolicy = "";
  constructor(input, init = {}) {
    if (typeof input === "string") {
      this.url = input;
    } else if (input) {
      Object.assign(this, input);
      this.headers = new MockHeaders(input.headers);
    }
    Object.assign(this, init);
    if (init.headers) {
      this.headers = new MockHeaders(init.headers);
    }
    if (!this.headers) {
      this.headers = new MockHeaders();
    }
  }
  get url() {
    if (typeof this._url === "string") {
      return new URL(this._url, location.href).href;
    }
    return new URL("/", location.href).href;
  }
  set url(value) {
    this._url = value;
  }
  get method() {
    if (typeof this._method === "string") {
      return this._method.toUpperCase();
    }
    return "GET";
  }
  set method(value) {
    this._method = value;
  }
  clone() {
    const clone = { ...this };
    clone.headers = new MockHeaders(this.headers);
    return new _MockRequest(clone);
  }
};
var MockResponse = class _MockResponse {
  _body;
  headers;
  ok = true;
  status = 200;
  statusText = "";
  type = "default";
  url = "";
  constructor(body, init = {}) {
    this._body = body;
    if (init) {
      Object.assign(this, init);
    }
    this.headers = new MockHeaders(init.headers);
  }
  async json() {
    return JSON.parse(this._body);
  }
  async text() {
    return this._body;
  }
  clone() {
    const initClone = { ...this };
    initClone.headers = new MockHeaders(this.headers);
    return new _MockResponse(this._body, initClone);
  }
};

// src/mock-doc/global.ts
function patchWindow(winToBePatched) {
  const mockWin = new MockWindow(false);
  WINDOW_FUNCTIONS.forEach((fnName) => {
    if (typeof winToBePatched[fnName] !== "function") {
      winToBePatched[fnName] = mockWin[fnName].bind(mockWin);
    }
  });
  WINDOW_PROPS.forEach((propName) => {
    if (winToBePatched === void 0) {
      Object.defineProperty(winToBePatched, propName, {
        get() {
          return mockWin[propName];
        },
        set(val) {
          mockWin[propName] = val;
        },
        configurable: true,
        enumerable: true
      });
    }
  });
}
function addGlobalsToWindowPrototype(mockWinPrototype) {
  GLOBAL_CONSTRUCTORS.forEach(([cstrName, Cstr]) => {
    Object.defineProperty(mockWinPrototype, cstrName, {
      get() {
        return this["__" + cstrName] || Cstr;
      },
      set(cstr) {
        this["__" + cstrName] = cstr;
      },
      configurable: true,
      enumerable: true
    });
  });
}
var WINDOW_FUNCTIONS = [
  "addEventListener",
  "alert",
  "blur",
  "cancelAnimationFrame",
  "cancelIdleCallback",
  "clearInterval",
  "clearTimeout",
  "close",
  "confirm",
  "dispatchEvent",
  "focus",
  "getComputedStyle",
  "matchMedia",
  "open",
  "prompt",
  "removeEventListener",
  "requestAnimationFrame",
  "requestIdleCallback",
  "URL"
];
var WINDOW_PROPS = [
  "customElements",
  "devicePixelRatio",
  "document",
  "history",
  "innerHeight",
  "innerWidth",
  "localStorage",
  "location",
  "navigator",
  "pageXOffset",
  "pageYOffset",
  "performance",
  "screenLeft",
  "screenTop",
  "screenX",
  "screenY",
  "scrollX",
  "scrollY",
  "sessionStorage",
  "CSS",
  "CustomEvent",
  "Event",
  "Element",
  "HTMLElement",
  "Node",
  "NodeList",
  "FocusEvent",
  "KeyboardEvent",
  "MouseEvent",
  "CSSStyleSheet"
];
var GLOBAL_CONSTRUCTORS = [
  ["CSSStyleSheet", MockCSSStyleSheet],
  ["CustomEvent", MockCustomEvent],
  ["DocumentFragment", MockDocumentFragment],
  ["DOMParser", MockDOMParser],
  ["Event", MockEvent],
  ["FocusEvent", MockFocusEvent],
  ["Headers", MockHeaders],
  ["KeyboardEvent", MockKeyboardEvent],
  ["MouseEvent", MockMouseEvent],
  ["Request", MockRequest],
  ["Response", MockResponse],
  ["ShadowRoot", MockDocumentFragment],
  ["HTMLAnchorElement", MockAnchorElement],
  ["HTMLBaseElement", MockBaseElement],
  ["HTMLButtonElement", MockButtonElement],
  ["HTMLCanvasElement", MockCanvasElement],
  ["HTMLFormElement", MockFormElement],
  ["HTMLImageElement", MockImageElement],
  ["HTMLInputElement", MockInputElement],
  ["HTMLLinkElement", MockLinkElement],
  ["HTMLMetaElement", MockMetaElement],
  ["HTMLScriptElement", MockScriptElement],
  ["HTMLStyleElement", MockStyleElement],
  ["HTMLTemplateElement", MockTemplateElement],
  ["HTMLTitleElement", MockTitleElement],
  ["HTMLUListElement", MockUListElement]
];

// src/mock-doc/history.ts
var MockHistory = class {
  items = [];
  get length() {
    return this.items.length;
  }
  back() {
    this.go(-1);
  }
  forward() {
    this.go(1);
  }
  go(_value) {
  }
  pushState(_state, _title, _url) {
  }
  replaceState(_state, _title, _url) {
  }
};

// src/mock-doc/intersection-observer.ts
var MockIntersectionObserver = class {
  constructor() {
  }
  disconnect() {
  }
  observe() {
  }
  takeRecords() {
    return [];
  }
  unobserve() {
  }
};

// src/mock-doc/location.ts
var MockLocation = class {
  ancestorOrigins = null;
  protocol = "";
  host = "";
  hostname = "";
  port = "";
  pathname = "";
  search = "";
  hash = "";
  username = "";
  password = "";
  origin = "";
  _href = "";
  get href() {
    return this._href;
  }
  set href(value) {
    const url = new URL(value, "http://mockdoc.stenciljs.com");
    this._href = url.href;
    this.protocol = url.protocol;
    this.host = url.host;
    this.hostname = url.hostname;
    this.port = url.port;
    this.pathname = url.pathname;
    this.search = url.search;
    this.hash = url.hash;
    this.username = url.username;
    this.password = url.password;
    this.origin = url.origin;
  }
  assign(_url) {
  }
  reload(_forcedReload) {
  }
  replace(_url) {
  }
  toString() {
    return this.href;
  }
};

// src/mock-doc/navigator.ts
var MockNavigator = class {
  appCodeName = "MockNavigator";
  appName = "MockNavigator";
  appVersion = "MockNavigator";
  platform = "MockNavigator";
  userAgent = "MockNavigator";
};

// src/mock-doc/performance.ts
var MockPerformance = class {
  timeOrigin;
  eventCounts;
  constructor() {
    this.timeOrigin = Date.now();
    this.eventCounts = /* @__PURE__ */ new Map();
  }
  addEventListener() {
  }
  clearMarks() {
  }
  clearMeasures() {
  }
  clearResourceTimings() {
  }
  dispatchEvent() {
    return true;
  }
  getEntries() {
    return [];
  }
  getEntriesByName() {
    return [];
  }
  getEntriesByType() {
    return [];
  }
  // Stencil's implementation of `mark` is non-compliant with the `Performance` interface. Because Stencil will
  // instantiate an instance of this class and may attempt to assign it to a variable of type `Performance`, the return
  // type must match the `Performance` interface (rather than typing this function as returning `void` and ignoring the
  // associated errors returned by the type checker)
  // @ts-ignore
  mark() {
  }
  // Stencil's implementation of `measure` is non-compliant with the `Performance` interface. Because Stencil will
  // instantiate an instance of this class and may attempt to assign it to a variable of type `Performance`, the return
  // type must match the `Performance` interface (rather than typing this function as returning `void` and ignoring the
  // associated errors returned by the type checker)
  // @ts-ignore
  measure() {
  }
  get navigation() {
    return {};
  }
  now() {
    return Date.now() - this.timeOrigin;
  }
  get onresourcetimingbufferfull() {
    return null;
  }
  removeEventListener() {
  }
  setResourceTimingBufferSize() {
  }
  get timing() {
    return {};
  }
  toJSON() {
  }
};
function resetPerformance(perf) {
  if (perf != null) {
    try {
      perf.timeOrigin = Date.now();
    } catch (e) {
    }
  }
}

// src/mock-doc/resize-observer.ts
var MockResizeObserver = class {
  constructor() {
  }
  disconnect() {
  }
  observe() {
  }
  takeRecords() {
    return [];
  }
  unobserve() {
  }
};

// src/mock-doc/shadow-root.ts
var MockShadowRoot = class extends MockDocumentFragment {
  get activeElement() {
    return null;
  }
  get cloneable() {
    return false;
  }
  get delegatesFocus() {
    return false;
  }
  get fullscreenElement() {
    return null;
  }
  get host() {
    let parent = this.parentElement();
    while (parent) {
      if (parent.nodeType === 11) {
        return parent;
      }
      parent = parent.parentElement();
    }
    return null;
  }
  get mode() {
    return "open";
  }
  get pictureInPictureElement() {
    return null;
  }
  get pointerLockElement() {
    return null;
  }
  get serializable() {
    return false;
  }
  get slotAssignment() {
    return "named";
  }
  get styleSheets() {
    return [];
  }
};

// src/mock-doc/storage.ts
var MockStorage = class {
  items = /* @__PURE__ */ new Map();
  key(_value) {
  }
  getItem(key) {
    key = String(key);
    if (this.items.has(key)) {
      return this.items.get(key);
    }
    return null;
  }
  setItem(key, value) {
    if (value == null) {
      value = "null";
    }
    this.items.set(String(key), String(value));
  }
  removeItem(key) {
    this.items.delete(String(key));
  }
  clear() {
    this.items.clear();
  }
};

// src/mock-doc/window.ts
var nativeClearInterval = globalThis.clearInterval;
var nativeClearTimeout = globalThis.clearTimeout;
var nativeSetInterval = globalThis.setInterval;
var nativeSetTimeout = globalThis.setTimeout;
var nativeURL = globalThis.URL;
var nativeWindow = globalThis.window;
var MockWindow = class {
  __timeouts;
  __history;
  __elementCstr;
  __charDataCstr;
  __docTypeCstr;
  __docCstr;
  __docFragCstr;
  __domTokenListCstr;
  __nodeCstr;
  __nodeListCstr;
  __localStorage;
  __sessionStorage;
  __location;
  __navigator;
  __clearInterval;
  __clearTimeout;
  __setInterval;
  __setTimeout;
  __maxTimeout;
  __allowInterval;
  URL;
  console;
  customElements;
  document;
  performance;
  devicePixelRatio;
  innerHeight;
  innerWidth;
  pageXOffset;
  pageYOffset;
  screen;
  screenLeft;
  screenTop;
  screenX;
  screenY;
  scrollX;
  scrollY;
  constructor(html = null) {
    if (html !== false) {
      this.document = new MockDocument(html, this);
    } else {
      this.document = null;
    }
    this.performance = new MockPerformance();
    this.customElements = new MockCustomElementRegistry(this);
    this.console = createConsole();
    resetWindowDefaults(this);
    resetWindowDimensions(this);
  }
  addEventListener(type, handler) {
    addEventListener(this, type, handler);
  }
  alert(msg) {
    if (this.console) {
      this.console.debug(msg);
    } else {
      console.debug(msg);
    }
  }
  blur() {
  }
  cancelAnimationFrame(id) {
    this.__clearTimeout.call(nativeWindow || this, id);
  }
  cancelIdleCallback(id) {
    this.__clearTimeout.call(nativeWindow || this, id);
  }
  get CharacterData() {
    if (this.__charDataCstr == null) {
      const ownerDocument = this.document;
      this.__charDataCstr = class extends MockNode2 {
        constructor() {
          super(ownerDocument, 0, "test", "");
          throw new Error("Illegal constructor: cannot construct CharacterData");
        }
      };
    }
    return this.__charDataCstr;
  }
  set CharacterData(charDataCstr) {
    this.__charDataCstr = charDataCstr;
  }
  clearInterval(id) {
    this.__clearInterval.call(nativeWindow || this, id);
  }
  clearTimeout(id) {
    this.__clearTimeout.call(nativeWindow || this, id);
  }
  close() {
    resetWindow(this);
  }
  confirm() {
    return false;
  }
  get CSS() {
    return {
      supports: () => true
    };
  }
  get Document() {
    if (this.__docCstr == null) {
      const win2 = this;
      this.__docCstr = class extends MockDocument {
        constructor() {
          super(false, win2);
          throw new Error("Illegal constructor: cannot construct Document");
        }
      };
    }
    return this.__docCstr;
  }
  set Document(docCstr) {
    this.__docCstr = docCstr;
  }
  get DocumentFragment() {
    if (this.__docFragCstr == null) {
      const ownerDocument = this.document;
      this.__docFragCstr = class extends MockDocumentFragment {
        constructor() {
          super(ownerDocument);
          throw new Error("Illegal constructor: cannot construct DocumentFragment");
        }
      };
    }
    return this.__docFragCstr;
  }
  set DocumentFragment(docFragCstr) {
    this.__docFragCstr = docFragCstr;
  }
  get ShadowRoot() {
    return MockShadowRoot;
  }
  get DocumentType() {
    if (this.__docTypeCstr == null) {
      const ownerDocument = this.document;
      this.__docTypeCstr = class extends MockNode2 {
        constructor() {
          super(ownerDocument, 0, "test", "");
          throw new Error("Illegal constructor: cannot construct DocumentType");
        }
      };
    }
    return this.__docTypeCstr;
  }
  set DocumentType(docTypeCstr) {
    this.__docTypeCstr = docTypeCstr;
  }
  get DOMTokenList() {
    if (this.__domTokenListCstr == null) {
      this.__domTokenListCstr = class MockDOMTokenList {
      };
    }
    return this.__domTokenListCstr;
  }
  set DOMTokenList(domTokenListCstr) {
    this.__domTokenListCstr = domTokenListCstr;
  }
  dispatchEvent(ev) {
    return dispatchEvent(this, ev);
  }
  get Element() {
    return MockElement;
  }
  fetch(input, init) {
    if (typeof fetch === "function") {
      return fetch(input, init);
    }
    throw new Error(`fetch() not implemented`);
  }
  focus() {
  }
  getComputedStyle(_) {
    return {
      cssText: "",
      length: 0,
      parentRule: null,
      getPropertyPriority() {
        return null;
      },
      getPropertyValue() {
        return "";
      },
      item() {
        return null;
      },
      removeProperty() {
        return null;
      },
      setProperty() {
        return null;
      }
    };
  }
  get globalThis() {
    return this;
  }
  get history() {
    if (this.__history == null) {
      this.__history = new MockHistory();
    }
    return this.__history;
  }
  set history(hsty) {
    this.__history = hsty;
  }
  get JSON() {
    return JSON;
  }
  get HTMLElement() {
    return MockHTMLElement;
  }
  get SVGElement() {
    return MockSVGElement;
  }
  get IntersectionObserver() {
    return MockIntersectionObserver;
  }
  get ResizeObserver() {
    return MockResizeObserver;
  }
  get localStorage() {
    if (this.__localStorage == null) {
      this.__localStorage = new MockStorage();
    }
    return this.__localStorage;
  }
  set localStorage(locStorage) {
    this.__localStorage = locStorage;
  }
  get location() {
    if (this.__location == null) {
      this.__location = new MockLocation();
    }
    return this.__location;
  }
  set location(val) {
    if (typeof val === "string") {
      if (this.__location == null) {
        this.__location = new MockLocation();
      }
      this.__location.href = val;
    } else {
      this.__location = val;
    }
  }
  matchMedia(media) {
    return {
      media,
      matches: false,
      addListener: (_handler) => {
      },
      removeListener: (_handler) => {
      },
      addEventListener: (_type, _handler) => {
      },
      removeEventListener: (_type, _handler) => {
      },
      dispatchEvent: (_ev) => {
      },
      onchange: null
    };
  }
  get Node() {
    return MockNode2;
  }
  get NodeList() {
    if (this.__nodeListCstr == null) {
      const ownerDocument = this.document;
      this.__nodeListCstr = class extends MockNodeList {
        constructor() {
          super(ownerDocument, [], 0);
          throw new Error("Illegal constructor: cannot construct NodeList");
        }
      };
    }
    return this.__nodeListCstr;
  }
  get navigator() {
    if (this.__navigator == null) {
      this.__navigator = new MockNavigator();
    }
    return this.__navigator;
  }
  set navigator(nav) {
    this.__navigator = nav;
  }
  get parent() {
    return null;
  }
  prompt() {
    return "";
  }
  open() {
    return null;
  }
  get origin() {
    return this.location.origin;
  }
  removeEventListener(type, handler) {
    removeEventListener(this, type, handler);
  }
  requestAnimationFrame(callback) {
    return this.setTimeout(() => {
      callback(Date.now());
    }, 0);
  }
  requestIdleCallback(callback) {
    return this.setTimeout(() => {
      callback({
        didTimeout: false,
        timeRemaining: () => 0
      });
    }, 0);
  }
  scroll(_x, _y) {
  }
  scrollBy(_x, _y) {
  }
  scrollTo(_x, _y) {
  }
  get self() {
    return this;
  }
  get sessionStorage() {
    if (this.__sessionStorage == null) {
      this.__sessionStorage = new MockStorage();
    }
    return this.__sessionStorage;
  }
  set sessionStorage(locStorage) {
    this.__sessionStorage = locStorage;
  }
  setInterval(callback, ms, ...args) {
    if (this.__timeouts == null) {
      this.__timeouts = /* @__PURE__ */ new Set();
    }
    ms = Math.min(ms != null ? ms : 0, this.__maxTimeout);
    if (this.__allowInterval) {
      const intervalId = this.__setInterval(() => {
        if (this.__timeouts) {
          this.__timeouts.delete(intervalId);
          try {
            callback(...args);
          } catch (e) {
            if (this.console) {
              this.console.error(e);
            } else {
              console.error(e);
            }
          }
        }
      }, ms);
      if (this.__timeouts) {
        this.__timeouts.add(intervalId);
      }
      return intervalId;
    }
    const timeoutId = this.__setTimeout.call(
      nativeWindow || this,
      () => {
        if (this.__timeouts) {
          this.__timeouts.delete(timeoutId);
          try {
            callback(...args);
          } catch (e) {
            if (this.console) {
              this.console.error(e);
            } else {
              console.error(e);
            }
          }
        }
      },
      ms
    );
    if (this.__timeouts) {
      this.__timeouts.add(timeoutId);
    }
    return timeoutId;
  }
  setTimeout(callback, ms, ...args) {
    if (this.__timeouts == null) {
      this.__timeouts = /* @__PURE__ */ new Set();
    }
    ms = Math.min(ms != null ? ms : 0, this.__maxTimeout);
    const timeoutId = this.__setTimeout.call(
      nativeWindow || this,
      () => {
        if (this.__timeouts) {
          this.__timeouts.delete(timeoutId);
          try {
            callback(...args);
          } catch (e) {
            if (this.console) {
              this.console.error(e);
            } else {
              console.error(e);
            }
          }
        }
      },
      ms
    );
    if (this.__timeouts) {
      this.__timeouts.add(timeoutId);
    }
    return timeoutId;
  }
  get top() {
    return this;
  }
  get window() {
    return this;
  }
  onanimationstart() {
  }
  onanimationend() {
  }
  onanimationiteration() {
  }
  onabort() {
  }
  onauxclick() {
  }
  onbeforecopy() {
  }
  onbeforecut() {
  }
  onbeforepaste() {
  }
  onblur() {
  }
  oncancel() {
  }
  oncanplay() {
  }
  oncanplaythrough() {
  }
  onchange() {
  }
  onclick() {
  }
  onclose() {
  }
  oncontextmenu() {
  }
  oncopy() {
  }
  oncuechange() {
  }
  oncut() {
  }
  ondblclick() {
  }
  ondrag() {
  }
  ondragend() {
  }
  ondragenter() {
  }
  ondragleave() {
  }
  ondragover() {
  }
  ondragstart() {
  }
  ondrop() {
  }
  ondurationchange() {
  }
  onemptied() {
  }
  onended() {
  }
  onerror() {
  }
  onfocus() {
  }
  onfocusin() {
  }
  onfocusout() {
  }
  onformdata() {
  }
  onfullscreenchange() {
  }
  onfullscreenerror() {
  }
  ongotpointercapture() {
  }
  oninput() {
  }
  oninvalid() {
  }
  onkeydown() {
  }
  onkeypress() {
  }
  onkeyup() {
  }
  onload() {
  }
  onloadeddata() {
  }
  onloadedmetadata() {
  }
  onloadstart() {
  }
  onlostpointercapture() {
  }
  onmousedown() {
  }
  onmouseenter() {
  }
  onmouseleave() {
  }
  onmousemove() {
  }
  onmouseout() {
  }
  onmouseover() {
  }
  onmouseup() {
  }
  onmousewheel() {
  }
  onpaste() {
  }
  onpause() {
  }
  onplay() {
  }
  onplaying() {
  }
  onpointercancel() {
  }
  onpointerdown() {
  }
  onpointerenter() {
  }
  onpointerleave() {
  }
  onpointermove() {
  }
  onpointerout() {
  }
  onpointerover() {
  }
  onpointerup() {
  }
  onprogress() {
  }
  onratechange() {
  }
  onreset() {
  }
  onresize() {
  }
  onscroll() {
  }
  onsearch() {
  }
  onseeked() {
  }
  onseeking() {
  }
  onselect() {
  }
  onselectstart() {
  }
  onstalled() {
  }
  onsubmit() {
  }
  onsuspend() {
  }
  ontimeupdate() {
  }
  ontoggle() {
  }
  onvolumechange() {
  }
  onwaiting() {
  }
  onwebkitfullscreenchange() {
  }
  onwebkitfullscreenerror() {
  }
  onwheel() {
  }
};
addGlobalsToWindowPrototype(MockWindow.prototype);
function resetWindowDefaults(win2) {
  win2.__clearInterval = nativeClearInterval;
  win2.__clearTimeout = nativeClearTimeout;
  win2.__setInterval = nativeSetInterval;
  win2.__setTimeout = nativeSetTimeout;
  win2.__maxTimeout = 6e4;
  win2.__allowInterval = true;
  win2.URL = nativeURL;
}
function cloneWindow(srcWin, opts = {}) {
  if (srcWin == null) {
    return null;
  }
  const clonedWin = new MockWindow(false);
  if (!opts.customElementProxy) {
    srcWin.customElements = null;
  }
  if (srcWin.document != null) {
    const clonedDoc = new MockDocument(false, clonedWin);
    clonedWin.document = clonedDoc;
    clonedDoc.documentElement = srcWin.document.documentElement.cloneNode(true);
  } else {
    clonedWin.document = new MockDocument(null, clonedWin);
  }
  return clonedWin;
}
function constrainTimeouts(win2) {
  win2.__allowInterval = false;
  win2.__maxTimeout = 0;
}
function resetWindow(win2) {
  if (win2 != null) {
    if (win2.__timeouts) {
      win2.__timeouts.forEach((timeoutId) => {
        nativeClearInterval(timeoutId);
        nativeClearTimeout(timeoutId);
      });
      win2.__timeouts.clear();
    }
    if (win2.customElements && win2.customElements.clear) {
      win2.customElements.clear();
    }
    resetDocument(win2.document);
    resetPerformance(win2.performance);
    for (const key in win2) {
      if (win2.hasOwnProperty(key) && key !== "document" && key !== "performance" && key !== "customElements") {
        delete win2[key];
      }
    }
    resetWindowDefaults(win2);
    resetWindowDimensions(win2);
    resetEventListeners(win2);
    if (win2.document != null) {
      try {
        win2.document.defaultView = win2;
      } catch (e) {
      }
    }
    win2.fetch = null;
    win2.Headers = null;
    win2.Request = null;
    win2.Response = null;
    win2.FetchError = null;
  }
}
function resetWindowDimensions(win2) {
  try {
    win2.devicePixelRatio = 1;
    win2.innerHeight = 768;
    win2.innerWidth = 1366;
    win2.pageXOffset = 0;
    win2.pageYOffset = 0;
    win2.screenLeft = 0;
    win2.screenTop = 0;
    win2.screenX = 0;
    win2.screenY = 0;
    win2.scrollX = 0;
    win2.scrollY = 0;
    win2.screen = {
      availHeight: win2.innerHeight,
      availLeft: 0,
      availTop: 0,
      availWidth: win2.innerWidth,
      colorDepth: 24,
      height: win2.innerHeight,
      keepAwake: false,
      orientation: {
        angle: 0,
        type: "portrait-primary"
      },
      pixelDepth: 24,
      width: win2.innerWidth
    };
  } catch (e) {
  }
}

// src/mock-doc/document.ts
var MockDocument = class _MockDocument extends MockHTMLElement {
  defaultView;
  cookie;
  referrer;
  constructor(html = null, win2 = null) {
    super(null, null);
    this.nodeName = "#document" /* DOCUMENT_NODE */;
    this.nodeType = 9 /* DOCUMENT_NODE */;
    this.defaultView = win2;
    this.cookie = "";
    this.referrer = "";
    this.appendChild(this.createDocumentTypeNode());
    if (typeof html === "string") {
      const parsedDoc = parseDocumentUtil(this, html);
      const documentElement = parsedDoc.children.find((elm) => elm.nodeName === "HTML");
      if (documentElement != null) {
        this.appendChild(documentElement);
        setOwnerDocument(documentElement, this);
      }
    } else if (html !== false) {
      const documentElement = new MockHTMLElement(this, "html");
      this.appendChild(documentElement);
      documentElement.appendChild(new MockHTMLElement(this, "head"));
      documentElement.appendChild(new MockHTMLElement(this, "body"));
    }
  }
  get dir() {
    return this.documentElement.dir;
  }
  set dir(value) {
    this.documentElement.dir = value;
  }
  get localName() {
    throw new Error("Unimplemented");
  }
  get location() {
    if (this.defaultView != null) {
      return this.defaultView.location;
    }
    return null;
  }
  set location(val) {
    if (this.defaultView != null) {
      this.defaultView.location.href = val;
    }
  }
  get baseURI() {
    const baseNode = this.head.childNodes.find((node) => node.nodeName === "BASE");
    if (baseNode) {
      return baseNode.href;
    }
    return this.URL;
  }
  get URL() {
    return this.location.href;
  }
  get styleSheets() {
    return this.querySelectorAll("style");
  }
  get scripts() {
    return this.querySelectorAll("script");
  }
  get forms() {
    return this.querySelectorAll("form");
  }
  get images() {
    return this.querySelectorAll("img");
  }
  get scrollingElement() {
    return this.documentElement;
  }
  get documentElement() {
    for (let i = this.childNodes.length - 1; i >= 0; i--) {
      if (this.childNodes[i].nodeName === "HTML") {
        return this.childNodes[i];
      }
    }
    const documentElement = new MockHTMLElement(this, "html");
    this.appendChild(documentElement);
    return documentElement;
  }
  set documentElement(documentElement) {
    for (let i = this.childNodes.length - 1; i >= 0; i--) {
      if (this.childNodes[i].nodeType !== 10 /* DOCUMENT_TYPE_NODE */) {
        this.childNodes[i].remove();
      }
    }
    if (documentElement != null) {
      this.appendChild(documentElement);
      setOwnerDocument(documentElement, this);
    }
  }
  get head() {
    const documentElement = this.documentElement;
    for (let i = 0; i < documentElement.childNodes.length; i++) {
      if (documentElement.childNodes[i].nodeName === "HEAD") {
        return documentElement.childNodes[i];
      }
    }
    const head = new MockHTMLElement(this, "head");
    documentElement.insertBefore(head, documentElement.firstChild);
    return head;
  }
  set head(head) {
    const documentElement = this.documentElement;
    for (let i = documentElement.childNodes.length - 1; i >= 0; i--) {
      if (documentElement.childNodes[i].nodeName === "HEAD") {
        documentElement.childNodes[i].remove();
      }
    }
    if (head != null) {
      documentElement.insertBefore(head, documentElement.firstChild);
      setOwnerDocument(head, this);
    }
  }
  get body() {
    const documentElement = this.documentElement;
    for (let i = documentElement.childNodes.length - 1; i >= 0; i--) {
      if (documentElement.childNodes[i].nodeName === "BODY") {
        return documentElement.childNodes[i];
      }
    }
    const body = new MockHTMLElement(this, "body");
    documentElement.appendChild(body);
    return body;
  }
  set body(body) {
    const documentElement = this.documentElement;
    for (let i = documentElement.childNodes.length - 1; i >= 0; i--) {
      if (documentElement.childNodes[i].nodeName === "BODY") {
        documentElement.childNodes[i].remove();
      }
    }
    if (body != null) {
      documentElement.appendChild(body);
      setOwnerDocument(body, this);
    }
  }
  appendChild(newNode) {
    newNode.remove();
    newNode.parentNode = this;
    this.childNodes.push(newNode);
    return newNode;
  }
  createComment(data) {
    return new MockComment(this, data);
  }
  createAttribute(attrName) {
    return new MockAttr(attrName.toLowerCase(), "");
  }
  createAttributeNS(namespaceURI, attrName) {
    return new MockAttr(attrName, "", namespaceURI);
  }
  createElement(tagName) {
    if (tagName === "#document" /* DOCUMENT_NODE */) {
      const doc = new _MockDocument(false);
      doc.nodeName = tagName;
      doc.parentNode = null;
      return doc;
    }
    return createElement(this, tagName);
  }
  createElementNS(namespaceURI, tagName) {
    const elmNs = createElementNS(this, namespaceURI, tagName);
    return elmNs;
  }
  createTextNode(text) {
    return new MockTextNode(this, text);
  }
  createDocumentFragment() {
    return new MockDocumentFragment(this);
  }
  createDocumentTypeNode() {
    return new MockDocumentTypeNode(this);
  }
  getElementById(id) {
    return getElementById(this, id);
  }
  getElementsByName(elmName) {
    return getElementsByName(this, elmName.toLowerCase());
  }
  get title() {
    const title = this.head.childNodes.find((elm) => elm.nodeName === "TITLE");
    if (title != null && typeof title.textContent === "string") {
      return title.textContent.trim();
    }
    return "";
  }
  set title(value) {
    const head = this.head;
    let title = head.childNodes.find((elm) => elm.nodeName === "TITLE");
    if (title == null) {
      title = this.createElement("title");
      head.appendChild(title);
    }
    title.textContent = value;
  }
};
function resetDocument(doc) {
  if (doc != null) {
    resetEventListeners(doc);
    const documentElement = doc.documentElement;
    if (documentElement != null) {
      resetElement(documentElement);
      for (let i = 0, ii = documentElement.childNodes.length; i < ii; i++) {
        const childNode = documentElement.childNodes[i];
        resetElement(childNode);
        childNode.childNodes.length = 0;
      }
    }
    for (const key in doc) {
      if (doc.hasOwnProperty(key) && !DOC_KEY_KEEPERS.has(key)) {
        delete doc[key];
      }
    }
    try {
      doc.nodeName = "#document" /* DOCUMENT_NODE */;
    } catch (e) {
    }
    try {
      doc.nodeType = 9 /* DOCUMENT_NODE */;
    } catch (e) {
    }
    try {
      doc.cookie = "";
    } catch (e) {
    }
    try {
      doc.referrer = "";
    } catch (e) {
    }
  }
}
var DOC_KEY_KEEPERS = /* @__PURE__ */ new Set([
  "nodeName",
  "nodeType",
  "nodeValue",
  "ownerDocument",
  "parentNode",
  "childNodes",
  "_childNodes",
  "_shadowRoot"
]);
function getElementById(elm, id) {
  const children = elm.children;
  for (let i = 0, ii = children.length; i < ii; i++) {
    const childElm = children[i];
    if (childElm.id === id) {
      return childElm;
    }
    const childElmFound = getElementById(childElm, id);
    if (childElmFound != null) {
      return childElmFound;
    }
  }
  return null;
}
function getElementsByName(elm, elmName, foundElms = []) {
  const children = elm.children;
  for (let i = 0, ii = children.length; i < ii; i++) {
    const childElm = children[i];
    if (childElm.name && childElm.name.toLowerCase() === elmName) {
      foundElms.push(childElm);
    }
    getElementsByName(childElm, elmName, foundElms);
  }
  return foundElms;
}
function setOwnerDocument(elm, ownerDocument) {
  for (let i = 0, ii = elm.childNodes.length; i < ii; i++) {
    elm.childNodes[i].ownerDocument = ownerDocument;
    if (elm.childNodes[i].nodeType === 1 /* ELEMENT_NODE */) {
      setOwnerDocument(elm.childNodes[i], ownerDocument);
    }
  }
}

// src/hydrate/runner/create-window.ts
var templateWindows = /* @__PURE__ */ new Map();
function createWindowFromHtml(templateHtml, uniqueId) {
  let templateWindow = templateWindows.get(uniqueId);
  if (templateWindow == null) {
    templateWindow = new MockWindow(templateHtml);
    templateWindows.set(uniqueId, templateWindow);
  }
  const win2 = cloneWindow(templateWindow);
  return win2;
}
var Build = {
  isDev: BUILD.isDev ? true : false,
  isBrowser: true,
  isServer: false,
  isTesting: BUILD.isTesting ? true : false
};

// src/utils/constants.ts
var PrimitiveType = /* @__PURE__ */ ((PrimitiveType2) => {
  PrimitiveType2["Undefined"] = "undefined";
  PrimitiveType2["Null"] = "null";
  PrimitiveType2["String"] = "string";
  PrimitiveType2["Number"] = "number";
  PrimitiveType2["SpecialNumber"] = "number";
  PrimitiveType2["Boolean"] = "boolean";
  PrimitiveType2["BigInt"] = "bigint";
  return PrimitiveType2;
})(PrimitiveType || {});
var NonPrimitiveType = /* @__PURE__ */ ((NonPrimitiveType2) => {
  NonPrimitiveType2["Array"] = "array";
  NonPrimitiveType2["Date"] = "date";
  NonPrimitiveType2["Map"] = "map";
  NonPrimitiveType2["Object"] = "object";
  NonPrimitiveType2["RegularExpression"] = "regexp";
  NonPrimitiveType2["Set"] = "set";
  NonPrimitiveType2["Channel"] = "channel";
  NonPrimitiveType2["Symbol"] = "symbol";
  return NonPrimitiveType2;
})(NonPrimitiveType || {});
var TYPE_CONSTANT = "type";
var VALUE_CONSTANT = "value";
var SERIALIZED_PREFIX = "serialized:";
var STENCIL_DEV_MODE = BUILD.isTesting ? ["STENCIL:"] : [
  "%cstencil",
  "color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px"
];
var win = typeof window !== "undefined" ? window : {};
var H = win.HTMLElement || class {
};
var supportsShadow = BUILD.shadowDom;
var supportsConstructableStylesheets = BUILD.constructableCSS ? /* @__PURE__ */ (() => {
  try {
    if (!win.document.adoptedStyleSheets) {
      return false;
    }
    new CSSStyleSheet();
    return typeof new CSSStyleSheet().replaceSync === "function";
  } catch (e) {
  }
  return false;
})() : false;

// src/utils/helpers.ts
var isString = (v) => typeof v === "string";

// src/utils/shadow-css.ts
/**
 * @license
 * Copyright Google Inc. All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 *
 * This file is a port of shadowCSS from `webcomponents.js` to TypeScript.
 * https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js
 * https://github.com/angular/angular/blob/master/packages/compiler/src/shadow_css.ts
 */
var _polyfillHost = "-shadowcsshost";
var _polyfillSlotted = "-shadowcssslotted";
var _polyfillHostContext = "-shadowcsscontext";
var _parenSuffix = ")(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)";
var _cssColonHostRe = new RegExp("(" + _polyfillHost + _parenSuffix, "gim");
var _cssColonHostContextRe = new RegExp("(" + _polyfillHostContext + _parenSuffix, "gim");
var _cssColonSlottedRe = new RegExp("(" + _polyfillSlotted + _parenSuffix, "gim");
var _polyfillHostNoCombinator = _polyfillHost + "-no-combinator";

// src/runtime/mode.ts
var setMode = (handler) => modeResolutionChain.push(handler);

// src/utils/local-value.ts
var LocalValue = class _LocalValue {
  type;
  value;
  constructor(type, value) {
    if (type === "undefined" /* Undefined */ || type === "null" /* Null */) {
      this.type = type;
    } else {
      this.type = type;
      this.value = value;
    }
  }
  /**
   * Creates a new LocalValue object with a string value.
   *
   * @param {string} value - The string value to be stored in the LocalValue object.
   * @returns {LocalValue} - The created LocalValue object.
   */
  static createStringValue(value) {
    return new _LocalValue("string" /* String */, value);
  }
  /**
   * Creates a new LocalValue object with a number value.
   *
   * @param {number} value - The number value.
   * @returns {LocalValue} - The created LocalValue object.
   */
  static createNumberValue(value) {
    return new _LocalValue("number" /* Number */, value);
  }
  /**
   * Creates a new LocalValue object with a special number value.
   *
   * @param {number} value - The value of the special number.
   * @returns {LocalValue} - The created LocalValue object.
   */
  static createSpecialNumberValue(value) {
    if (Number.isNaN(value)) {
      return new _LocalValue("number" /* SpecialNumber */, "NaN");
    }
    if (Object.is(value, -0)) {
      return new _LocalValue("number" /* SpecialNumber */, "-0");
    }
    if (value === Infinity) {
      return new _LocalValue("number" /* SpecialNumber */, "Infinity");
    }
    if (value === -Infinity) {
      return new _LocalValue("number" /* SpecialNumber */, "-Infinity");
    }
    return new _LocalValue("number" /* SpecialNumber */, value);
  }
  /**
   * Creates a new LocalValue object with an undefined value.
   * @returns {LocalValue} - The created LocalValue object.
   */
  static createUndefinedValue() {
    return new _LocalValue("undefined" /* Undefined */);
  }
  /**
   * Creates a new LocalValue object with a null value.
   * @returns {LocalValue} - The created LocalValue object.
   */
  static createNullValue() {
    return new _LocalValue("null" /* Null */);
  }
  /**
   * Creates a new LocalValue object with a boolean value.
   *
   * @param {boolean} value - The boolean value.
   * @returns {LocalValue} - The created LocalValue object.
   */
  static createBooleanValue(value) {
    return new _LocalValue("boolean" /* Boolean */, value);
  }
  /**
   * Creates a new LocalValue object with a BigInt value.
   *
   * @param {BigInt} value - The BigInt value.
   * @returns {LocalValue} - The created LocalValue object.
   */
  static createBigIntValue(value) {
    return new _LocalValue("bigint" /* BigInt */, value.toString());
  }
  /**
   * Creates a new LocalValue object with an array.
   *
   * @param {Array} value - The array.
   * @returns {LocalValue} - The created LocalValue object.
   */
  static createArrayValue(value) {
    return new _LocalValue("array" /* Array */, value);
  }
  /**
   * Creates a new LocalValue object with date value.
   *
   * @param {string} value - The date.
   * @returns {LocalValue} - The created LocalValue object.
   */
  static createDateValue(value) {
    return new _LocalValue("date" /* Date */, value);
  }
  /**
   * Creates a new LocalValue object of map value.
   * @param {Map} map - The map.
   * @returns {LocalValue} - The created LocalValue object.
   */
  static createMapValue(map2) {
    const value = [];
    Array.from(map2.entries()).forEach(([key, val]) => {
      value.push([_LocalValue.getArgument(key), _LocalValue.getArgument(val)]);
    });
    return new _LocalValue("map" /* Map */, value);
  }
  /**
   * Creates a new LocalValue object from the passed object.
   *
   * @param object the object to create a LocalValue from
   * @returns {LocalValue} - The created LocalValue object.
   */
  static createObjectValue(object) {
    const value = [];
    Object.entries(object).forEach(([key, val]) => {
      value.push([key, _LocalValue.getArgument(val)]);
    });
    return new _LocalValue("object" /* Object */, value);
  }
  /**
   * Creates a new LocalValue object of regular expression value.
   *
   * @param {string} value - The value of the regular expression.
   * @returns {LocalValue} - The created LocalValue object.
   */
  static createRegularExpressionValue(value) {
    return new _LocalValue("regexp" /* RegularExpression */, value);
  }
  /**
   * Creates a new LocalValue object with the specified value.
   * @param {Set} value - The value to be set.
   * @returns {LocalValue} - The created LocalValue object.
   */
  static createSetValue(value) {
    return new _LocalValue("set" /* Set */, value);
  }
  /**
   * Creates a new LocalValue object with the given channel value
   *
   * @param {ChannelValue} value - The channel value.
   * @returns {LocalValue} - The created LocalValue object.
   */
  static createChannelValue(value) {
    return new _LocalValue("channel" /* Channel */, value);
  }
  /**
   * Creates a new LocalValue object with a Symbol value.
   *
   * @param {Symbol} symbol - The Symbol value
   * @returns {LocalValue} - The created LocalValue object
   */
  static createSymbolValue(symbol) {
    const description = symbol.description || "Symbol()";
    return new _LocalValue("symbol" /* Symbol */, description);
  }
  static getArgument(argument) {
    const type = typeof argument;
    switch (type) {
      case "string" /* String */:
        return _LocalValue.createStringValue(argument);
      case "number" /* Number */:
        if (Number.isNaN(argument) || Object.is(argument, -0) || !Number.isFinite(argument)) {
          return _LocalValue.createSpecialNumberValue(argument);
        }
        return _LocalValue.createNumberValue(argument);
      case "boolean" /* Boolean */:
        return _LocalValue.createBooleanValue(argument);
      case "bigint" /* BigInt */:
        return _LocalValue.createBigIntValue(argument);
      case "undefined" /* Undefined */:
        return _LocalValue.createUndefinedValue();
      case "symbol" /* Symbol */:
        return _LocalValue.createSymbolValue(argument);
      case "object" /* Object */:
        if (argument === null) {
          return _LocalValue.createNullValue();
        }
        if (argument instanceof Date) {
          return _LocalValue.createDateValue(argument);
        }
        if (argument instanceof Map) {
          const map2 = [];
          argument.forEach((value, key) => {
            const objectKey = typeof key === "string" ? key : _LocalValue.getArgument(key);
            const objectValue = _LocalValue.getArgument(value);
            map2.push([objectKey, objectValue]);
          });
          return _LocalValue.createMapValue(argument);
        }
        if (argument instanceof Set) {
          const set = [];
          argument.forEach((value) => {
            set.push(_LocalValue.getArgument(value));
          });
          return _LocalValue.createSetValue(set);
        }
        if (argument instanceof Array) {
          const arr = [];
          argument.forEach((value) => {
            arr.push(_LocalValue.getArgument(value));
          });
          return _LocalValue.createArrayValue(arr);
        }
        if (argument instanceof RegExp) {
          return _LocalValue.createRegularExpressionValue({
            pattern: argument.source,
            flags: argument.flags
          });
        }
        return _LocalValue.createObjectValue(argument);
    }
    throw new Error(`Unsupported type: ${type}`);
  }
  asMap() {
    return {
      [TYPE_CONSTANT]: this.type,
      ...!(this.type === "null" /* Null */ || this.type === "undefined" /* Undefined */) ? { [VALUE_CONSTANT]: this.value } : {}
    };
  }
};

// src/utils/remote-value.ts
var RemoteValue = class _RemoteValue {
  /**
   * Deserializes a LocalValue serialized object back to its original JavaScript representation
   *
   * @param serialized The serialized LocalValue object
   * @returns The original JavaScript value/object
   */
  static fromLocalValue(serialized) {
    const type = serialized[TYPE_CONSTANT];
    const value = VALUE_CONSTANT in serialized ? serialized[VALUE_CONSTANT] : void 0;
    switch (type) {
      case "string" /* String */:
        return value;
      case "boolean" /* Boolean */:
        return value;
      case "bigint" /* BigInt */:
        return BigInt(value);
      case "undefined" /* Undefined */:
        return void 0;
      case "null" /* Null */:
        return null;
      case "number" /* Number */:
        if (value === "NaN") return NaN;
        if (value === "-0") return -0;
        if (value === "Infinity") return Infinity;
        if (value === "-Infinity") return -Infinity;
        return value;
      case "array" /* Array */:
        return value.map((item) => _RemoteValue.fromLocalValue(item));
      case "date" /* Date */:
        return new Date(value);
      case "map" /* Map */:
        const map2 = /* @__PURE__ */ new Map();
        for (const [key, val] of value) {
          const deserializedKey = typeof key === "object" && key !== null ? _RemoteValue.fromLocalValue(key) : key;
          const deserializedValue = _RemoteValue.fromLocalValue(val);
          map2.set(deserializedKey, deserializedValue);
        }
        return map2;
      case "object" /* Object */:
        const obj = {};
        for (const [key, val] of value) {
          obj[key] = _RemoteValue.fromLocalValue(val);
        }
        return obj;
      case "regexp" /* RegularExpression */:
        const { pattern, flags } = value;
        return new RegExp(pattern, flags);
      case "set" /* Set */:
        const set = /* @__PURE__ */ new Set();
        for (const item of value) {
          set.add(_RemoteValue.fromLocalValue(item));
        }
        return set;
      case "symbol" /* Symbol */:
        return Symbol(value);
      default:
        throw new Error(`Unsupported type: ${type}`);
    }
  }
  /**
   * Utility method to deserialize multiple LocalValues at once
   *
   * @param serializedValues Array of serialized LocalValue objects
   * @returns Array of deserialized JavaScript values
   */
  static fromLocalValueArray(serializedValues) {
    return serializedValues.map((value) => _RemoteValue.fromLocalValue(value));
  }
  /**
   * Verifies if the given object matches the structure of a serialized LocalValue
   *
   * @param obj Object to verify
   * @returns boolean indicating if the object has LocalValue structure
   */
  static isLocalValueObject(obj) {
    if (typeof obj !== "object" || obj === null) {
      return false;
    }
    if (!obj.hasOwnProperty(TYPE_CONSTANT)) {
      return false;
    }
    const type = obj[TYPE_CONSTANT];
    const hasTypeProperty = Object.values({ ...PrimitiveType, ...NonPrimitiveType }).includes(type);
    if (!hasTypeProperty) {
      return false;
    }
    if (type !== "null" /* Null */ && type !== "undefined" /* Undefined */) {
      return obj.hasOwnProperty(VALUE_CONSTANT);
    }
    return true;
  }
};

// src/utils/serialize.ts
function serializeProperty(value) {
  if (["string", "boolean", "undefined"].includes(typeof value) || typeof value === "number" && value !== Infinity && value !== -Infinity && !isNaN(value)) {
    return value;
  }
  const arg = LocalValue.getArgument(value);
  return SERIALIZED_PREFIX + btoa(JSON.stringify(arg));
}
function deserializeProperty(value) {
  if (typeof value !== "string" || !value.startsWith(SERIALIZED_PREFIX)) {
    return value;
  }
  return RemoteValue.fromLocalValue(JSON.parse(atob(value.slice(SERIALIZED_PREFIX.length))));
}
var CAPTURE_EVENT_SUFFIX = "Capture";
var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
var baseClass = BUILD.lazyLoad ? class {
} : globalThis.HTMLElement || class {
};

// src/runtime/tag-transform.ts
var tagTransformer = void 0;
function transformTag(tag) {
  if (!tagTransformer) return tag;
  return tagTransformer(tag);
}
function setTagTransformer(transformer) {
  if (tagTransformer) {
    console.warn(`
      A tagTransformer has already been set. 
      Overwriting it may lead to error and unexpected results if your components have already been defined.
    `);
  }
  tagTransformer = transformer;
}
// Tag transform state object for factory closure
var $stencilTagTransform = { setTagTransformer: setTagTransformer, transformTag: transformTag };


// src/utils/message-utils.ts
var catchError = (diagnostics, err2, msg) => {
  const diagnostic = {
    level: "error",
    type: "build",
    header: "Build Error",
    messageText: "build error",
    lines: []
  };
  if (isString(msg)) {
    diagnostic.messageText = msg.length ? msg : "UNKNOWN ERROR";
  } else if (err2 != null) {
    if (err2.stack != null) {
      diagnostic.messageText = err2.stack.toString();
    } else {
      if (err2.message != null) {
        diagnostic.messageText = err2.message.length ? err2.message : "UNKNOWN ERROR";
      } else {
        diagnostic.messageText = err2.toString();
      }
    }
  }
  if (diagnostics != null && !shouldIgnoreError(diagnostic.messageText)) {
    diagnostics.push(diagnostic);
  }
  return diagnostic;
};
var hasError = (diagnostics) => {
  if (diagnostics == null || diagnostics.length === 0) {
    return false;
  }
  return diagnostics.some((d) => d.level === "error" && d.type !== "runtime");
};
var shouldIgnoreError = (msg) => {
  return msg === TASK_CANCELED_MSG;
};
var TASK_CANCELED_MSG = `task canceled`;

// node_modules/minimatch/dist/esm/index.js
var import_brace_expansion = __toESM(require_brace_expansion(), 1);

// node_modules/minimatch/dist/esm/assert-valid-pattern.js
var MAX_PATTERN_LENGTH = 1024 * 64;
var assertValidPattern = (pattern) => {
  if (typeof pattern !== "string") {
    throw new TypeError("invalid pattern");
  }
  if (pattern.length > MAX_PATTERN_LENGTH) {
    throw new TypeError("pattern is too long");
  }
};

// node_modules/minimatch/dist/esm/brace-expressions.js
var posixClasses = {
  "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
  "[:alpha:]": ["\\p{L}\\p{Nl}", true],
  "[:ascii:]": ["\\x00-\\x7f", false],
  "[:blank:]": ["\\p{Zs}\\t", true],
  "[:cntrl:]": ["\\p{Cc}", true],
  "[:digit:]": ["\\p{Nd}", true],
  "[:graph:]": ["\\p{Z}\\p{C}", true, true],
  "[:lower:]": ["\\p{Ll}", true],
  "[:print:]": ["\\p{C}", true],
  "[:punct:]": ["\\p{P}", true],
  "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
  "[:upper:]": ["\\p{Lu}", true],
  "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
  "[:xdigit:]": ["A-Fa-f0-9", false]
};
var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
var rangesToString = (ranges) => ranges.join("");
var parseClass = (glob, position) => {
  const pos = position;
  if (glob.charAt(pos) !== "[") {
    throw new Error("not in a brace expression");
  }
  const ranges = [];
  const negs = [];
  let i = pos + 1;
  let sawStart = false;
  let uflag = false;
  let escaping = false;
  let negate = false;
  let endPos = pos;
  let rangeStart = "";
  WHILE: while (i < glob.length) {
    const c = glob.charAt(i);
    if ((c === "!" || c === "^") && i === pos + 1) {
      negate = true;
      i++;
      continue;
    }
    if (c === "]" && sawStart && !escaping) {
      endPos = i + 1;
      break;
    }
    sawStart = true;
    if (c === "\\") {
      if (!escaping) {
        escaping = true;
        i++;
        continue;
      }
    }
    if (c === "[" && !escaping) {
      for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
        if (glob.startsWith(cls, i)) {
          if (rangeStart) {
            return ["$.", false, glob.length - pos, true];
          }
          i += cls.length;
          if (neg)
            negs.push(unip);
          else
            ranges.push(unip);
          uflag = uflag || u;
          continue WHILE;
        }
      }
    }
    escaping = false;
    if (rangeStart) {
      if (c > rangeStart) {
        ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
      } else if (c === rangeStart) {
        ranges.push(braceEscape(c));
      }
      rangeStart = "";
      i++;
      continue;
    }
    if (glob.startsWith("-]", i + 1)) {
      ranges.push(braceEscape(c + "-"));
      i += 2;
      continue;
    }
    if (glob.startsWith("-", i + 1)) {
      rangeStart = c;
      i += 2;
      continue;
    }
    ranges.push(braceEscape(c));
    i++;
  }
  if (endPos < i) {
    return ["", false, 0, false];
  }
  if (!ranges.length && !negs.length) {
    return ["$.", false, glob.length - pos, true];
  }
  if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
    const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
    return [regexpEscape(r), false, endPos - pos, false];
  }
  const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
  const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
  const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs;
  return [comb, uflag, endPos - pos, true];
};

// node_modules/minimatch/dist/esm/unescape.js
var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
  return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
};

// node_modules/minimatch/dist/esm/ast.js
var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
var isExtglobType = (c) => types.has(c);
var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
var startNoDot = "(?!\\.)";
var addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
var justDots = /* @__PURE__ */ new Set(["..", "."]);
var reSpecials = new Set("().*{}+?[]^$\\!");
var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
var qmark = "[^/]";
var star = qmark + "*?";
var starNoEmpty = qmark + "+?";
var _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, partsToRegExp_fn, parseGlob_fn;
var _AST = class _AST {
  constructor(type, parent, options = {}) {
    __privateAdd(this, _AST_instances);
    __publicField(this, "type");
    __privateAdd(this, _root);
    __privateAdd(this, _hasMagic);
    __privateAdd(this, _uflag, false);
    __privateAdd(this, _parts, []);
    __privateAdd(this, _parent);
    __privateAdd(this, _parentIndex);
    __privateAdd(this, _negs);
    __privateAdd(this, _filledNegs, false);
    __privateAdd(this, _options);
    __privateAdd(this, _toString);
    // set to true if it's an extglob with no children
    // (which really means one child of '')
    __privateAdd(this, _emptyExt, false);
    this.type = type;
    if (type)
      __privateSet(this, _hasMagic, true);
    __privateSet(this, _parent, parent);
    __privateSet(this, _root, __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _root) : this);
    __privateSet(this, _options, __privateGet(this, _root) === this ? options : __privateGet(__privateGet(this, _root), _options));
    __privateSet(this, _negs, __privateGet(this, _root) === this ? [] : __privateGet(__privateGet(this, _root), _negs));
    if (type === "!" && !__privateGet(__privateGet(this, _root), _filledNegs))
      __privateGet(this, _negs).push(this);
    __privateSet(this, _parentIndex, __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _parts).length : 0);
  }
  get hasMagic() {
    if (__privateGet(this, _hasMagic) !== void 0)
      return __privateGet(this, _hasMagic);
    for (const p of __privateGet(this, _parts)) {
      if (typeof p === "string")
        continue;
      if (p.type || p.hasMagic)
        return __privateSet(this, _hasMagic, true);
    }
    return __privateGet(this, _hasMagic);
  }
  // reconstructs the pattern
  toString() {
    if (__privateGet(this, _toString) !== void 0)
      return __privateGet(this, _toString);
    if (!this.type) {
      return __privateSet(this, _toString, __privateGet(this, _parts).map((p) => String(p)).join(""));
    } else {
      return __privateSet(this, _toString, this.type + "(" + __privateGet(this, _parts).map((p) => String(p)).join("|") + ")");
    }
  }
  push(...parts) {
    for (const p of parts) {
      if (p === "")
        continue;
      if (typeof p !== "string" && !(p instanceof _AST && __privateGet(p, _parent) === this)) {
        throw new Error("invalid part: " + p);
      }
      __privateGet(this, _parts).push(p);
    }
  }
  toJSON() {
    var _a2;
    const ret = this.type === null ? __privateGet(this, _parts).slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...__privateGet(this, _parts).map((p) => p.toJSON())];
    if (this.isStart() && !this.type)
      ret.unshift([]);
    if (this.isEnd() && (this === __privateGet(this, _root) || __privateGet(__privateGet(this, _root), _filledNegs) && ((_a2 = __privateGet(this, _parent)) == null ? void 0 : _a2.type) === "!")) {
      ret.push({});
    }
    return ret;
  }
  isStart() {
    var _a2;
    if (__privateGet(this, _root) === this)
      return true;
    if (!((_a2 = __privateGet(this, _parent)) == null ? void 0 : _a2.isStart()))
      return false;
    if (__privateGet(this, _parentIndex) === 0)
      return true;
    const p = __privateGet(this, _parent);
    for (let i = 0; i < __privateGet(this, _parentIndex); i++) {
      const pp = __privateGet(p, _parts)[i];
      if (!(pp instanceof _AST && pp.type === "!")) {
        return false;
      }
    }
    return true;
  }
  isEnd() {
    var _a2, _b, _c;
    if (__privateGet(this, _root) === this)
      return true;
    if (((_a2 = __privateGet(this, _parent)) == null ? void 0 : _a2.type) === "!")
      return true;
    if (!((_b = __privateGet(this, _parent)) == null ? void 0 : _b.isEnd()))
      return false;
    if (!this.type)
      return (_c = __privateGet(this, _parent)) == null ? void 0 : _c.isEnd();
    const pl = __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _parts).length : 0;
    return __privateGet(this, _parentIndex) === pl - 1;
  }
  copyIn(part) {
    if (typeof part === "string")
      this.push(part);
    else
      this.push(part.clone(this));
  }
  clone(parent) {
    const c = new _AST(this.type, parent);
    for (const p of __privateGet(this, _parts)) {
      c.copyIn(p);
    }
    return c;
  }
  static fromGlob(pattern, options = {}) {
    var _a2;
    const ast = new _AST(null, void 0, options);
    __privateMethod(_a2 = _AST, _AST_static, parseAST_fn).call(_a2, pattern, ast, 0, options);
    return ast;
  }
  // returns the regular expression if there's magic, or the unescaped
  // string if not.
  toMMPattern() {
    if (this !== __privateGet(this, _root))
      return __privateGet(this, _root).toMMPattern();
    const glob = this.toString();
    const [re, body, hasMagic, uflag] = this.toRegExpSource();
    const anyMagic = hasMagic || __privateGet(this, _hasMagic) || __privateGet(this, _options).nocase && !__privateGet(this, _options).nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase();
    if (!anyMagic) {
      return body;
    }
    const flags = (__privateGet(this, _options).nocase ? "i" : "") + (uflag ? "u" : "");
    return Object.assign(new RegExp(`^${re}$`, flags), {
      _src: re,
      _glob: glob
    });
  }
  get options() {
    return __privateGet(this, _options);
  }
  // returns the string match, the regexp source, whether there's magic
  // in the regexp (so a regular expression is required) and whether or
  // not the uflag is needed for the regular expression (for posix classes)
  // TODO: instead of injecting the start/end at this point, just return
  // the BODY of the regexp, along with the start/end portions suitable
  // for binding the start/end in either a joined full-path makeRe context
  // (where we bind to (^|/), or a standalone matchPart context (where
  // we bind to ^, and not /).  Otherwise slashes get duped!
  //
  // In part-matching mode, the start is:
  // - if not isStart: nothing
  // - if traversal possible, but not allowed: ^(?!\.\.?$)
  // - if dots allowed or not possible: ^
  // - if dots possible and not allowed: ^(?!\.)
  // end is:
  // - if not isEnd(): nothing
  // - else: $
  //
  // In full-path matching mode, we put the slash at the START of the
  // pattern, so start is:
  // - if first pattern: same as part-matching mode
  // - if not isStart(): nothing
  // - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
  // - if dots allowed or not possible: /
  // - if dots possible and not allowed: /(?!\.)
  // end is:
  // - if last pattern, same as part-matching mode
  // - else nothing
  //
  // Always put the (?:$|/) on negated tails, though, because that has to be
  // there to bind the end of the negated pattern portion, and it's easier to
  // just stick it in now rather than try to inject it later in the middle of
  // the pattern.
  //
  // We can just always return the same end, and leave it up to the caller
  // to know whether it's going to be used joined or in parts.
  // And, if the start is adjusted slightly, can do the same there:
  // - if not isStart: nothing
  // - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
  // - if dots allowed or not possible: (?:/|^)
  // - if dots possible and not allowed: (?:/|^)(?!\.)
  //
  // But it's better to have a simpler binding without a conditional, for
  // performance, so probably better to return both start options.
  //
  // Then the caller just ignores the end if it's not the first pattern,
  // and the start always gets applied.
  //
  // But that's always going to be $ if it's the ending pattern, or nothing,
  // so the caller can just attach $ at the end of the pattern when building.
  //
  // So the todo is:
  // - better detect what kind of start is needed
  // - return both flavors of starting pattern
  // - attach $ at the end of the pattern when creating the actual RegExp
  //
  // Ah, but wait, no, that all only applies to the root when the first pattern
  // is not an extglob. If the first pattern IS an extglob, then we need all
  // that dot prevention biz to live in the extglob portions, because eg
  // +(*|.x*) can match .xy but not .yx.
  //
  // So, return the two flavors if it's #root and the first child is not an
  // AST, otherwise leave it to the child AST to handle it, and there,
  // use the (?:^|/) style of start binding.
  //
  // Even simplified further:
  // - Since the start for a join is eg /(?!\.) and the start for a part
  // is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
  // or start or whatever) and prepend ^ or / at the Regexp construction.
  toRegExpSource(allowDot) {
    var _a2;
    const dot = allowDot != null ? allowDot : !!__privateGet(this, _options).dot;
    if (__privateGet(this, _root) === this)
      __privateMethod(this, _AST_instances, fillNegs_fn).call(this);
    if (!this.type) {
      const noEmpty = this.isStart() && this.isEnd();
      const src = __privateGet(this, _parts).map((p) => {
        var _a3;
        const [re, _, hasMagic, uflag] = typeof p === "string" ? __privateMethod(_a3 = _AST, _AST_static, parseGlob_fn).call(_a3, p, __privateGet(this, _hasMagic), noEmpty) : p.toRegExpSource(allowDot);
        __privateSet(this, _hasMagic, __privateGet(this, _hasMagic) || hasMagic);
        __privateSet(this, _uflag, __privateGet(this, _uflag) || uflag);
        return re;
      }).join("");
      let start2 = "";
      if (this.isStart()) {
        if (typeof __privateGet(this, _parts)[0] === "string") {
          const dotTravAllowed = __privateGet(this, _parts).length === 1 && justDots.has(__privateGet(this, _parts)[0]);
          if (!dotTravAllowed) {
            const aps = addPatternStart;
            const needNoTrav = (
              // dots are allowed, and the pattern starts with [ or .
              dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
              src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
              src.startsWith("\\.\\.") && aps.has(src.charAt(4))
            );
            const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
            start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
          }
        }
      }
      let end = "";
      if (this.isEnd() && __privateGet(__privateGet(this, _root), _filledNegs) && ((_a2 = __privateGet(this, _parent)) == null ? void 0 : _a2.type) === "!") {
        end = "(?:$|\\/)";
      }
      const final2 = start2 + src + end;
      return [
        final2,
        unescape(src),
        __privateSet(this, _hasMagic, !!__privateGet(this, _hasMagic)),
        __privateGet(this, _uflag)
      ];
    }
    const repeated = this.type === "*" || this.type === "+";
    const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
    let body = __privateMethod(this, _AST_instances, partsToRegExp_fn).call(this, dot);
    if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
      const s = this.toString();
      __privateSet(this, _parts, [s]);
      this.type = null;
      __privateSet(this, _hasMagic, void 0);
      return [s, unescape(this.toString()), false, false];
    }
    let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : __privateMethod(this, _AST_instances, partsToRegExp_fn).call(this, true);
    if (bodyDotAllowed === body) {
      bodyDotAllowed = "";
    }
    if (bodyDotAllowed) {
      body = `(?:${body})(?:${bodyDotAllowed})*?`;
    }
    let final = "";
    if (this.type === "!" && __privateGet(this, _emptyExt)) {
      final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
    } else {
      const close = this.type === "!" ? (
        // !() must match something,but !(x) can match ''
        "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star + ")"
      ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
      final = start + body + close;
    }
    return [
      final,
      unescape(body),
      __privateSet(this, _hasMagic, !!__privateGet(this, _hasMagic)),
      __privateGet(this, _uflag)
    ];
  }
};
_root = new WeakMap();
_hasMagic = new WeakMap();
_uflag = new WeakMap();
_parts = new WeakMap();
_parent = new WeakMap();
_parentIndex = new WeakMap();
_negs = new WeakMap();
_filledNegs = new WeakMap();
_options = new WeakMap();
_toString = new WeakMap();
_emptyExt = new WeakMap();
_AST_instances = new WeakSet();
fillNegs_fn = function() {
  if (this !== __privateGet(this, _root))
    throw new Error("should only call on root");
  if (__privateGet(this, _filledNegs))
    return this;
  this.toString();
  __privateSet(this, _filledNegs, true);
  let n;
  while (n = __privateGet(this, _negs).pop()) {
    if (n.type !== "!")
      continue;
    let p = n;
    let pp = __privateGet(p, _parent);
    while (pp) {
      for (let i = __privateGet(p, _parentIndex) + 1; !pp.type && i < __privateGet(pp, _parts).length; i++) {
        for (const part of __privateGet(n, _parts)) {
          if (typeof part === "string") {
            throw new Error("string part in extglob AST??");
          }
          part.copyIn(__privateGet(pp, _parts)[i]);
        }
      }
      p = pp;
      pp = __privateGet(p, _parent);
    }
  }
  return this;
};
_AST_static = new WeakSet();
parseAST_fn = function(str, ast, pos, opt) {
  var _a2, _b;
  let escaping = false;
  let inBrace = false;
  let braceStart = -1;
  let braceNeg = false;
  if (ast.type === null) {
    let i2 = pos;
    let acc2 = "";
    while (i2 < str.length) {
      const c = str.charAt(i2++);
      if (escaping || c === "\\") {
        escaping = !escaping;
        acc2 += c;
        continue;
      }
      if (inBrace) {
        if (i2 === braceStart + 1) {
          if (c === "^" || c === "!") {
            braceNeg = true;
          }
        } else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
          inBrace = false;
        }
        acc2 += c;
        continue;
      } else if (c === "[") {
        inBrace = true;
        braceStart = i2;
        braceNeg = false;
        acc2 += c;
        continue;
      }
      if (!opt.noext && isExtglobType(c) && str.charAt(i2) === "(") {
        ast.push(acc2);
        acc2 = "";
        const ext2 = new _AST(c, ast);
        i2 = __privateMethod(_a2 = _AST, _AST_static, parseAST_fn).call(_a2, str, ext2, i2, opt);
        ast.push(ext2);
        continue;
      }
      acc2 += c;
    }
    ast.push(acc2);
    return i2;
  }
  let i = pos + 1;
  let part = new _AST(null, ast);
  const parts = [];
  let acc = "";
  while (i < str.length) {
    const c = str.charAt(i++);
    if (escaping || c === "\\") {
      escaping = !escaping;
      acc += c;
      continue;
    }
    if (inBrace) {
      if (i === braceStart + 1) {
        if (c === "^" || c === "!") {
          braceNeg = true;
        }
      } else if (c === "]" && !(i === braceStart + 2 && braceNeg)) {
        inBrace = false;
      }
      acc += c;
      continue;
    } else if (c === "[") {
      inBrace = true;
      braceStart = i;
      braceNeg = false;
      acc += c;
      continue;
    }
    if (isExtglobType(c) && str.charAt(i) === "(") {
      part.push(acc);
      acc = "";
      const ext2 = new _AST(c, part);
      part.push(ext2);
      i = __privateMethod(_b = _AST, _AST_static, parseAST_fn).call(_b, str, ext2, i, opt);
      continue;
    }
    if (c === "|") {
      part.push(acc);
      acc = "";
      parts.push(part);
      part = new _AST(null, ast);
      continue;
    }
    if (c === ")") {
      if (acc === "" && __privateGet(ast, _parts).length === 0) {
        __privateSet(ast, _emptyExt, true);
      }
      part.push(acc);
      acc = "";
      ast.push(...parts, part);
      return i;
    }
    acc += c;
  }
  ast.type = null;
  __privateSet(ast, _hasMagic, void 0);
  __privateSet(ast, _parts, [str.substring(pos - 1)]);
  return i;
};
partsToRegExp_fn = function(dot) {
  return __privateGet(this, _parts).map((p) => {
    if (typeof p === "string") {
      throw new Error("string type in extglob ast??");
    }
    const [re, _, _hasMagic2, uflag] = p.toRegExpSource(dot);
    __privateSet(this, _uflag, __privateGet(this, _uflag) || uflag);
    return re;
  }).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
};
parseGlob_fn = function(glob, hasMagic, noEmpty = false) {
  let escaping = false;
  let re = "";
  let uflag = false;
  for (let i = 0; i < glob.length; i++) {
    const c = glob.charAt(i);
    if (escaping) {
      escaping = false;
      re += (reSpecials.has(c) ? "\\" : "") + c;
      continue;
    }
    if (c === "\\") {
      if (i === glob.length - 1) {
        re += "\\\\";
      } else {
        escaping = true;
      }
      continue;
    }
    if (c === "[") {
      const [src, needUflag, consumed, magic] = parseClass(glob, i);
      if (consumed) {
        re += src;
        uflag = uflag || needUflag;
        i += consumed - 1;
        hasMagic = hasMagic || magic;
        continue;
      }
    }
    if (c === "*") {
      if (noEmpty && glob === "*")
        re += starNoEmpty;
      else
        re += star;
      hasMagic = true;
      continue;
    }
    if (c === "?") {
      re += qmark;
      hasMagic = true;
      continue;
    }
    re += regExpEscape(c);
  }
  return [re, unescape(glob), !!hasMagic, uflag];
};
__privateAdd(_AST, _AST_static);
var AST = _AST;

// node_modules/minimatch/dist/esm/escape.js
var escape = (s, { windowsPathsNoEscape = false } = {}) => {
  return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
};

// node_modules/minimatch/dist/esm/index.js
var minimatch = (p, pattern, options = {}) => {
  assertValidPattern(pattern);
  if (!options.nocomment && pattern.charAt(0) === "#") {
    return false;
  }
  return new Minimatch(pattern, options).match(p);
};
var starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
var starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2);
var starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2);
var starDotExtTestNocase = (ext2) => {
  ext2 = ext2.toLowerCase();
  return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2);
};
var starDotExtTestNocaseDot = (ext2) => {
  ext2 = ext2.toLowerCase();
  return (f) => f.toLowerCase().endsWith(ext2);
};
var starDotStarRE = /^\*+\.\*+$/;
var starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
var starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
var dotStarRE = /^\.\*+$/;
var dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
var starRE = /^\*+$/;
var starTest = (f) => f.length !== 0 && !f.startsWith(".");
var starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
var qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
var qmarksTestNocase = ([$0, ext2 = ""]) => {
  const noext = qmarksTestNoExt([$0]);
  if (!ext2)
    return noext;
  ext2 = ext2.toLowerCase();
  return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
};
var qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
  const noext = qmarksTestNoExtDot([$0]);
  if (!ext2)
    return noext;
  ext2 = ext2.toLowerCase();
  return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
};
var qmarksTestDot = ([$0, ext2 = ""]) => {
  const noext = qmarksTestNoExtDot([$0]);
  return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
};
var qmarksTest = ([$0, ext2 = ""]) => {
  const noext = qmarksTestNoExt([$0]);
  return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
};
var qmarksTestNoExt = ([$0]) => {
  const len = $0.length;
  return (f) => f.length === len && !f.startsWith(".");
};
var qmarksTestNoExtDot = ([$0]) => {
  const len = $0.length;
  return (f) => f.length === len && f !== "." && f !== "..";
};
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
var path = {
  win32: { sep: "\\" },
  posix: { sep: "/" }
};
var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
minimatch.sep = sep;
var GLOBSTAR = Symbol("globstar **");
minimatch.GLOBSTAR = GLOBSTAR;
var qmark2 = "[^/]";
var star2 = qmark2 + "*?";
var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
minimatch.filter = filter;
var ext = (a, b = {}) => Object.assign({}, a, b);
var defaults = (def) => {
  if (!def || typeof def !== "object" || !Object.keys(def).length) {
    return minimatch;
  }
  const orig = minimatch;
  const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
  return Object.assign(m, {
    Minimatch: class Minimatch extends orig.Minimatch {
      constructor(pattern, options = {}) {
        super(pattern, ext(def, options));
      }
      static defaults(options) {
        return orig.defaults(ext(def, options)).Minimatch;
      }
    },
    AST: class AST extends orig.AST {
      /* c8 ignore start */
      constructor(type, parent, options = {}) {
        super(type, parent, ext(def, options));
      }
      /* c8 ignore stop */
      static fromGlob(pattern, options = {}) {
        return orig.AST.fromGlob(pattern, ext(def, options));
      }
    },
    unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
    escape: (s, options = {}) => orig.escape(s, ext(def, options)),
    filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
    defaults: (options) => orig.defaults(ext(def, options)),
    makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
    braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
    match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
    sep: orig.sep,
    GLOBSTAR
  });
};
minimatch.defaults = defaults;
var braceExpand = (pattern, options = {}) => {
  assertValidPattern(pattern);
  if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
    return [pattern];
  }
  return (0, import_brace_expansion.default)(pattern);
};
minimatch.braceExpand = braceExpand;
var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
minimatch.makeRe = makeRe;
var match = (list, pattern, options = {}) => {
  const mm = new Minimatch(pattern, options);
  list = list.filter((f) => mm.match(f));
  if (mm.options.nonull && !list.length) {
    list.push(pattern);
  }
  return list;
};
minimatch.match = match;
var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
var Minimatch = class {
  options;
  set;
  pattern;
  windowsPathsNoEscape;
  nonegate;
  negate;
  comment;
  empty;
  preserveMultipleSlashes;
  partial;
  globSet;
  globParts;
  nocase;
  isWindows;
  platform;
  windowsNoMagicRoot;
  regexp;
  constructor(pattern, options = {}) {
    assertValidPattern(pattern);
    options = options || {};
    this.options = options;
    this.pattern = pattern;
    this.platform = options.platform || defaultPlatform;
    this.isWindows = this.platform === "win32";
    this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
    if (this.windowsPathsNoEscape) {
      this.pattern = this.pattern.replace(/\\/g, "/");
    }
    this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
    this.regexp = null;
    this.negate = false;
    this.nonegate = !!options.nonegate;
    this.comment = false;
    this.empty = false;
    this.partial = !!options.partial;
    this.nocase = !!this.options.nocase;
    this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
    this.globSet = [];
    this.globParts = [];
    this.set = [];
    this.make();
  }
  hasMagic() {
    if (this.options.magicalBraces && this.set.length > 1) {
      return true;
    }
    for (const pattern of this.set) {
      for (const part of pattern) {
        if (typeof part !== "string")
          return true;
      }
    }
    return false;
  }
  debug(..._) {
  }
  make() {
    const pattern = this.pattern;
    const options = this.options;
    if (!options.nocomment && pattern.charAt(0) === "#") {
      this.comment = true;
      return;
    }
    if (!pattern) {
      this.empty = true;
      return;
    }
    this.parseNegate();
    this.globSet = [...new Set(this.braceExpand())];
    if (options.debug) {
      this.debug = (...args) => console.error(...args);
    }
    this.debug(this.pattern, this.globSet);
    const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
    this.globParts = this.preprocess(rawGlobParts);
    this.debug(this.pattern, this.globParts);
    let set = this.globParts.map((s, _, __) => {
      if (this.isWindows && this.windowsNoMagicRoot) {
        const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
        const isDrive = /^[a-z]:/i.test(s[0]);
        if (isUNC) {
          return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
        } else if (isDrive) {
          return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
        }
      }
      return s.map((ss) => this.parse(ss));
    });
    this.debug(this.pattern, set);
    this.set = set.filter((s) => s.indexOf(false) === -1);
    if (this.isWindows) {
      for (let i = 0; i < this.set.length; i++) {
        const p = this.set[i];
        if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) {
          p[2] = "?";
        }
      }
    }
    this.debug(this.pattern, this.set);
  }
  // various transforms to equivalent pattern sets that are
  // faster to process in a filesystem walk.  The goal is to
  // eliminate what we can, and push all ** patterns as far
  // to the right as possible, even if it increases the number
  // of patterns that we have to process.
  preprocess(globParts) {
    if (this.options.noglobstar) {
      for (let i = 0; i < globParts.length; i++) {
        for (let j = 0; j < globParts[i].length; j++) {
          if (globParts[i][j] === "**") {
            globParts[i][j] = "*";
          }
        }
      }
    }
    const { optimizationLevel = 1 } = this.options;
    if (optimizationLevel >= 2) {
      globParts = this.firstPhasePreProcess(globParts);
      globParts = this.secondPhasePreProcess(globParts);
    } else if (optimizationLevel >= 1) {
      globParts = this.levelOneOptimize(globParts);
    } else {
      globParts = this.adjascentGlobstarOptimize(globParts);
    }
    return globParts;
  }
  // just get rid of adjascent ** portions
  adjascentGlobstarOptimize(globParts) {
    return globParts.map((parts) => {
      let gs = -1;
      while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
        let i = gs;
        while (parts[i + 1] === "**") {
          i++;
        }
        if (i !== gs) {
          parts.splice(gs, i - gs);
        }
      }
      return parts;
    });
  }
  // get rid of adjascent ** and resolve .. portions
  levelOneOptimize(globParts) {
    return globParts.map((parts) => {
      parts = parts.reduce((set, part) => {
        const prev = set[set.length - 1];
        if (part === "**" && prev === "**") {
          return set;
        }
        if (part === "..") {
          if (prev && prev !== ".." && prev !== "." && prev !== "**") {
            set.pop();
            return set;
          }
        }
        set.push(part);
        return set;
      }, []);
      return parts.length === 0 ? [""] : parts;
    });
  }
  levelTwoFileOptimize(parts) {
    if (!Array.isArray(parts)) {
      parts = this.slashSplit(parts);
    }
    let didSomething = false;
    do {
      didSomething = false;
      if (!this.preserveMultipleSlashes) {
        for (let i = 1; i < parts.length - 1; i++) {
          const p = parts[i];
          if (i === 1 && p === "" && parts[0] === "")
            continue;
          if (p === "." || p === "") {
            didSomething = true;
            parts.splice(i, 1);
            i--;
          }
        }
        if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
          didSomething = true;
          parts.pop();
        }
      }
      let dd = 0;
      while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
        const p = parts[dd - 1];
        if (p && p !== "." && p !== ".." && p !== "**") {
          didSomething = true;
          parts.splice(dd - 1, 2);
          dd -= 2;
        }
      }
    } while (didSomething);
    return parts.length === 0 ? [""] : parts;
  }
  // First phase: single-pattern processing
  // <pre> is 1 or more portions
  // <rest> is 1 or more portions
  // <p> is any portion other than ., .., '', or **
  // <e> is . or ''
  //
  // **/.. is *brutal* for filesystem walking performance, because
  // it effectively resets the recursive walk each time it occurs,
  // and ** cannot be reduced out by a .. pattern part like a regexp
  // or most strings (other than .., ., and '') can be.
  //
  // <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
  // <pre>/<e>/<rest> -> <pre>/<rest>
  // <pre>/<p>/../<rest> -> <pre>/<rest>
  // **/**/<rest> -> **/<rest>
  //
  // **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
  // this WOULD be allowed if ** did follow symlinks, or * didn't
  firstPhasePreProcess(globParts) {
    let didSomething = false;
    do {
      didSomething = false;
      for (let parts of globParts) {
        let gs = -1;
        while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
          let gss = gs;
          while (parts[gss + 1] === "**") {
            gss++;
          }
          if (gss > gs) {
            parts.splice(gs + 1, gss - gs);
          }
          let next = parts[gs + 1];
          const p = parts[gs + 2];
          const p2 = parts[gs + 3];
          if (next !== "..")
            continue;
          if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
            continue;
          }
          didSomething = true;
          parts.splice(gs, 1);
          const other = parts.slice(0);
          other[gs] = "**";
          globParts.push(other);
          gs--;
        }
        if (!this.preserveMultipleSlashes) {
          for (let i = 1; i < parts.length - 1; i++) {
            const p = parts[i];
            if (i === 1 && p === "" && parts[0] === "")
              continue;
            if (p === "." || p === "") {
              didSomething = true;
              parts.splice(i, 1);
              i--;
            }
          }
          if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
            didSomething = true;
            parts.pop();
          }
        }
        let dd = 0;
        while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
          const p = parts[dd - 1];
          if (p && p !== "." && p !== ".." && p !== "**") {
            didSomething = true;
            const needDot = dd === 1 && parts[dd + 1] === "**";
            const splin = needDot ? ["."] : [];
            parts.splice(dd - 1, 2, ...splin);
            if (parts.length === 0)
              parts.push("");
            dd -= 2;
          }
        }
      }
    } while (didSomething);
    return globParts;
  }
  // second phase: multi-pattern dedupes
  // {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
  // {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
  // {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
  //
  // {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
  // ^-- not valid because ** doens't follow symlinks
  secondPhasePreProcess(globParts) {
    for (let i = 0; i < globParts.length - 1; i++) {
      for (let j = i + 1; j < globParts.length; j++) {
        const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
        if (!matched)
          continue;
        globParts[i] = matched;
        globParts[j] = [];
      }
    }
    return globParts.filter((gs) => gs.length);
  }
  partsMatch(a, b, emptyGSMatch = false) {
    let ai = 0;
    let bi = 0;
    let result = [];
    let which = "";
    while (ai < a.length && bi < b.length) {
      if (a[ai] === b[bi]) {
        result.push(which === "b" ? b[bi] : a[ai]);
        ai++;
        bi++;
      } else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
        result.push(a[ai]);
        ai++;
      } else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
        result.push(b[bi]);
        bi++;
      } else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
        if (which === "b")
          return false;
        which = "a";
        result.push(a[ai]);
        ai++;
        bi++;
      } else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
        if (which === "a")
          return false;
        which = "b";
        result.push(b[bi]);
        ai++;
        bi++;
      } else {
        return false;
      }
    }
    return a.length === b.length && result;
  }
  parseNegate() {
    if (this.nonegate)
      return;
    const pattern = this.pattern;
    let negate = false;
    let negateOffset = 0;
    for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++) {
      negate = !negate;
      negateOffset++;
    }
    if (negateOffset)
      this.pattern = pattern.slice(negateOffset);
    this.negate = negate;
  }
  // set partial to true to test if, for example,
  // "/a/b" matches the start of "/*/b/*/d"
  // Partial means, if you run out of file before you run
  // out of pattern, then that's fine, as long as all
  // the parts match.
  matchOne(file, pattern, partial = false) {
    const options = this.options;
    if (this.isWindows) {
      const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
      const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
      const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
      const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
      const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
      const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
      if (typeof fdi === "number" && typeof pdi === "number") {
        const [fd, pd] = [file[fdi], pattern[pdi]];
        if (fd.toLowerCase() === pd.toLowerCase()) {
          pattern[pdi] = fd;
          if (pdi > fdi) {
            pattern = pattern.slice(pdi);
          } else if (fdi > pdi) {
            file = file.slice(fdi);
          }
        }
      }
    }
    const { optimizationLevel = 1 } = this.options;
    if (optimizationLevel >= 2) {
      file = this.levelTwoFileOptimize(file);
    }
    this.debug("matchOne", this, { file, pattern });
    this.debug("matchOne", file.length, pattern.length);
    for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
      this.debug("matchOne loop");
      var p = pattern[pi];
      var f = file[fi];
      this.debug(pattern, p, f);
      if (p === false) {
        return false;
      }
      if (p === GLOBSTAR) {
        this.debug("GLOBSTAR", [pattern, p, f]);
        var fr = fi;
        var pr = pi + 1;
        if (pr === pl) {
          this.debug("** at the end");
          for (; fi < fl; fi++) {
            if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
              return false;
          }
          return true;
        }
        while (fr < fl) {
          var swallowee = file[fr];
          this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
          if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
            this.debug("globstar found match!", fr, fl, swallowee);
            return true;
          } else {
            if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
              this.debug("dot detected!", file, fr, pattern, pr);
              break;
            }
            this.debug("globstar swallow a segment, and continue");
            fr++;
          }
        }
        if (partial) {
          this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
          if (fr === fl) {
            return true;
          }
        }
        return false;
      }
      let hit;
      if (typeof p === "string") {
        hit = f === p;
        this.debug("string match", p, f, hit);
      } else {
        hit = p.test(f);
        this.debug("pattern match", p, f, hit);
      }
      if (!hit)
        return false;
    }
    if (fi === fl && pi === pl) {
      return true;
    } else if (fi === fl) {
      return partial;
    } else if (pi === pl) {
      return fi === fl - 1 && file[fi] === "";
    } else {
      throw new Error("wtf?");
    }
  }
  braceExpand() {
    return braceExpand(this.pattern, this.options);
  }
  parse(pattern) {
    assertValidPattern(pattern);
    const options = this.options;
    if (pattern === "**")
      return GLOBSTAR;
    if (pattern === "")
      return "";
    let m;
    let fastTest = null;
    if (m = pattern.match(starRE)) {
      fastTest = options.dot ? starTestDot : starTest;
    } else if (m = pattern.match(starDotExtRE)) {
      fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
    } else if (m = pattern.match(qmarksRE)) {
      fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
    } else if (m = pattern.match(starDotStarRE)) {
      fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
    } else if (m = pattern.match(dotStarRE)) {
      fastTest = dotStarTest;
    }
    const re = AST.fromGlob(pattern, this.options).toMMPattern();
    if (fastTest && typeof re === "object") {
      Reflect.defineProperty(re, "test", { value: fastTest });
    }
    return re;
  }
  makeRe() {
    if (this.regexp || this.regexp === false)
      return this.regexp;
    const set = this.set;
    if (!set.length) {
      this.regexp = false;
      return this.regexp;
    }
    const options = this.options;
    const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
    const flags = new Set(options.nocase ? ["i"] : []);
    let re = set.map((pattern) => {
      const pp = pattern.map((p) => {
        if (p instanceof RegExp) {
          for (const f of p.flags.split(""))
            flags.add(f);
        }
        return typeof p === "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
      });
      pp.forEach((p, i) => {
        const next = pp[i + 1];
        const prev = pp[i - 1];
        if (p !== GLOBSTAR || prev === GLOBSTAR) {
          return;
        }
        if (prev === void 0) {
          if (next !== void 0 && next !== GLOBSTAR) {
            pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
          } else {
            pp[i] = twoStar;
          }
        } else if (next === void 0) {
          pp[i - 1] = prev + "(?:\\/|" + twoStar + ")?";
        } else if (next !== GLOBSTAR) {
          pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
          pp[i + 1] = GLOBSTAR;
        }
      });
      return pp.filter((p) => p !== GLOBSTAR).join("/");
    }).join("|");
    const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
    re = "^" + open + re + close + "$";
    if (this.negate)
      re = "^(?!" + re + ").+$";
    try {
      this.regexp = new RegExp(re, [...flags].join(""));
    } catch (ex) {
      this.regexp = false;
    }
    return this.regexp;
  }
  slashSplit(p) {
    if (this.preserveMultipleSlashes) {
      return p.split("/");
    } else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
      return ["", ...p.split(/\/+/)];
    } else {
      return p.split(/\/+/);
    }
  }
  match(f, partial = this.partial) {
    this.debug("match", f, this.pattern);
    if (this.comment) {
      return false;
    }
    if (this.empty) {
      return f === "";
    }
    if (f === "/" && partial) {
      return true;
    }
    const options = this.options;
    if (this.isWindows) {
      f = f.split("\\").join("/");
    }
    const ff = this.slashSplit(f);
    this.debug(this.pattern, "split", ff);
    const set = this.set;
    this.debug(this.pattern, "set", set);
    let filename = ff[ff.length - 1];
    if (!filename) {
      for (let i = ff.length - 2; !filename && i >= 0; i--) {
        filename = ff[i];
      }
    }
    for (let i = 0; i < set.length; i++) {
      const pattern = set[i];
      let file = ff;
      if (options.matchBase && pattern.length === 1) {
        file = [filename];
      }
      const hit = this.matchOne(file, pattern, partial);
      if (hit) {
        if (options.flipNegate) {
          return true;
        }
        return !this.negate;
      }
    }
    if (options.flipNegate) {
      return false;
    }
    return this.negate;
  }
  static defaults(def) {
    return minimatch.defaults(def).Minimatch;
  }
};
minimatch.AST = AST;
minimatch.Minimatch = Minimatch;
minimatch.escape = escape;
minimatch.unescape = unescape;

// src/utils/result.ts
var result_exports = {};
__export(result_exports, {
  err: () => err,
  map: () => map,
  ok: () => ok,
  unwrap: () => unwrap,
  unwrapErr: () => unwrapErr
});
var ok = (value) => ({
  isOk: true,
  isErr: false,
  value
});
var err = (value) => ({
  isOk: false,
  isErr: true,
  value
});
function map(result, fn) {
  if (result.isOk) {
    const val = fn(result.value);
    if (val instanceof Promise) {
      return val.then((newVal) => ok(newVal));
    } else {
      return ok(val);
    }
  }
  if (result.isErr) {
    const value = result.value;
    return err(value);
  }
  throw "should never get here";
}
var unwrap = (result) => {
  if (result.isOk) {
    return result.value;
  } else {
    throw result.value;
  }
};
var unwrapErr = (result) => {
  if (result.isErr) {
    return result.value;
  } else {
    throw result.value;
  }
};

// src/utils/util.ts
var lowerPathParam = (fn) => (p) => fn(p.toLowerCase());
var isDtsFile = lowerPathParam((p) => p.endsWith(".d.ts") || p.endsWith(".d.mts") || p.endsWith(".d.cts"));
var isTsFile = lowerPathParam(
  (p) => !isDtsFile(p) && (p.endsWith(".ts") || p.endsWith(".mts") || p.endsWith(".cts"))
);
var isTsxFile = lowerPathParam(
  (p) => p.endsWith(".tsx") || p.endsWith(".mtsx") || p.endsWith(".ctsx")
);
var isJsxFile = lowerPathParam(
  (p) => p.endsWith(".jsx") || p.endsWith(".mjsx") || p.endsWith(".cjsx")
);
var isJsFile = lowerPathParam((p) => p.endsWith(".js") || p.endsWith(".mjs") || p.endsWith(".cjs"));

// src/compiler/html/canonical-link.ts
var updateCanonicalLink = (doc, href) => {
  var _a2;
  let canonicalLinkElm = doc.head.querySelector('link[rel="canonical"]');
  if (typeof href === "string") {
    if (canonicalLinkElm == null) {
      canonicalLinkElm = doc.createElement("link");
      canonicalLinkElm.setAttribute("rel", "canonical");
      doc.head.appendChild(canonicalLinkElm);
    }
    canonicalLinkElm.setAttribute("href", href);
  } else {
    if (canonicalLinkElm != null) {
      const existingHref = canonicalLinkElm.getAttribute("href");
      if (!existingHref) {
        (_a2 = canonicalLinkElm.parentNode) == null ? void 0 : _a2.removeChild(canonicalLinkElm);
      }
    }
  }
};

// src/compiler/html/relocate-meta-charset.ts
var relocateMetaCharset = (doc) => {
  const head = doc.head;
  let charsetElm = head.querySelector("meta[charset]");
  if (charsetElm == null) {
    charsetElm = doc.createElement("meta");
    charsetElm.setAttribute("charset", "utf-8");
  } else {
    charsetElm.remove();
  }
  head.insertBefore(charsetElm, head.firstChild);
};

// src/compiler/style/css-parser/parse-css.ts
var parseCss = (css, filePath) => {
  let lineno = 1;
  let column = 1;
  const diagnostics = [];
  const updatePosition = (str) => {
    const lines = str.match(/\n/g);
    if (lines) lineno += lines.length;
    const i = str.lastIndexOf("\n");
    column = ~i ? str.length - i : column + str.length;
  };
  const position = () => {
    const start = { line: lineno, column };
    return (node) => {
      node.position = new ParsePosition(start);
      whitespace();
      return node;
    };
  };
  const error = (msg) => {
    const srcLines = css.split("\n");
    const d = {
      level: "error",
      type: "css",
      language: "css",
      header: "CSS Parse",
      messageText: msg,
      absFilePath: filePath,
      lines: [
        {
          lineIndex: lineno - 1,
          lineNumber: lineno,
          errorCharStart: column,
          text: css[lineno - 1]
        }
      ]
    };
    if (lineno > 1) {
      const previousLine = {
        lineIndex: lineno - 1,
        lineNumber: lineno - 1,
        text: css[lineno - 2],
        errorCharStart: -1,
        errorLength: -1
      };
      d.lines.unshift(previousLine);
    }
    if (lineno + 2 < srcLines.length) {
      const nextLine = {
        lineIndex: lineno,
        lineNumber: lineno + 1,
        text: srcLines[lineno],
        errorCharStart: -1,
        errorLength: -1
      };
      d.lines.push(nextLine);
    }
    diagnostics.push(d);
    return null;
  };
  const stylesheet = () => {
    const rulesList = rules();
    return {
      type: 15 /* StyleSheet */,
      stylesheet: {
        source: filePath,
        rules: rulesList
      }
    };
  };
  const open = () => match2(/^{\s*/);
  const close = () => match2(/^}/);
  const match2 = (re) => {
    const m = re.exec(css);
    if (!m) return;
    const str = m[0];
    updatePosition(str);
    css = css.slice(str.length);
    return m;
  };
  const rules = () => {
    let node;
    const rules2 = [];
    whitespace();
    comments(rules2);
    while (css.length && css.charAt(0) !== "}" && (node = atrule() || rule())) {
      rules2.push(node);
      comments(rules2);
    }
    return rules2;
  };
  const whitespace = () => match2(/^\s*/);
  const comments = (rules2) => {
    let c;
    rules2 = rules2 || [];
    while (c = comment()) {
      rules2.push(c);
    }
    return rules2;
  };
  const comment = () => {
    const pos = position();
    if ("/" !== css.charAt(0) || "*" !== css.charAt(1)) return null;
    let i = 2;
    while ("" !== css.charAt(i) && ("*" !== css.charAt(i) || "/" !== css.charAt(i + 1))) ++i;
    i += 2;
    if ("" === css.charAt(i - 1)) {
      return error("End of comment missing");
    }
    const comment2 = css.slice(2, i - 2);
    column += 2;
    updatePosition(comment2);
    css = css.slice(i);
    column += 2;
    return pos({
      type: 1 /* Comment */,
      comment: comment2
    });
  };
  const selector = () => {
    const m = match2(/^([^{]+)/);
    if (!m) return null;
    return trim(m[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, "").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function(m2) {
      return m2.replace(/,/g, "\u200C");
    }).split(/\s*(?![^(]*\)),\s*/).map(function(s) {
      return s.replace(/\u200C/g, ",");
    });
  };
  const declaration = () => {
    const pos = position();
    let prop = match2(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
    if (!prop) return null;
    prop = trim(prop[0]);
    if (!match2(/^:\s*/)) return error(`property missing ':'`);
    const val = match2(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
    const ret = pos({
      type: 4 /* Declaration */,
      property: prop.replace(commentre, ""),
      value: val ? trim(val[0]).replace(commentre, "") : ""
    });
    match2(/^[;\s]*/);
    return ret;
  };
  const declarations = () => {
    const decls = [];
    if (!open()) return error(`missing '{'`);
    comments(decls);
    let decl;
    while (decl = declaration()) {
      decls.push(decl);
      comments(decls);
    }
    if (!close()) return error(`missing '}'`);
    return decls;
  };
  const keyframe = () => {
    let m;
    const values = [];
    const pos = position();
    while (m = match2(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) {
      values.push(m[1]);
      match2(/^,\s*/);
    }
    if (!values.length) return null;
    return pos({
      type: 9 /* KeyFrame */,
      values,
      declarations: declarations()
    });
  };
  const atkeyframes = () => {
    const pos = position();
    let m = match2(/^@([-\w]+)?keyframes\s*/);
    if (!m) return null;
    const vendor = m[1];
    m = match2(/^([-\w]+)\s*/);
    if (!m) return error(`@keyframes missing name`);
    const name = m[1];
    if (!open()) return error(`@keyframes missing '{'`);
    let frame;
    let frames = comments();
    while (frame = keyframe()) {
      frames.push(frame);
      frames = frames.concat(comments());
    }
    if (!close()) return error(`@keyframes missing '}'`);
    return pos({
      type: 8 /* KeyFrames */,
      name,
      vendor,
      keyframes: frames
    });
  };
  const atsupports = () => {
    const pos = position();
    const m = match2(/^@supports *([^{]+)/);
    if (!m) return null;
    const supports = trim(m[1]);
    if (!open()) return error(`@supports missing '{'`);
    const style = comments().concat(rules());
    if (!close()) return error(`@supports missing '}'`);
    return pos({
      type: 16 /* Supports */,
      supports,
      rules: style
    });
  };
  const athost = () => {
    const pos = position();
    const m = match2(/^@host\s*/);
    if (!m) return null;
    if (!open()) return error(`@host missing '{'`);
    const style = comments().concat(rules());
    if (!close()) return error(`@host missing '}'`);
    return pos({
      type: 6 /* Host */,
      rules: style
    });
  };
  const atquery = (name) => {
    const pos = position();
    const regex = new RegExp("^@" + name + " *([^{]+)");
    const m = match2(regex);
    if (!m) return null;
    const media = trim(m[1]);
    if (!open()) return error(`@${name} missing '{'`);
    const style = comments().concat(rules());
    if (!close()) return error(`@${name} missing '}'`);
    return pos({
      type: name === "media" ? 10 /* Media */ : 11 /* Container */,
      media,
      rules: style
    });
  };
  const nestedAtQuery = (name) => {
    const pos = position();
    const regex = new RegExp("^@" + name + " *([^{]+)");
    const m = match2(regex);
    if (!m) return null;
    const media = trim(m[1]);
    const decls = declarations();
    if (!decls) return null;
    return pos({
      type: name === "media" ? 10 /* Media */ : name === "container" ? 11 /* Container */ : 16 /* Supports */,
      media,
      declarations: decls
    });
  };
  const nestedAtrule = () => {
    if (css[0] !== "@") return null;
    return nestedAtQuery("media") || nestedAtQuery("supports") || nestedAtQuery("container");
  };
  const atcustommedia = () => {
    const pos = position();
    const m = match2(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
    if (!m) return null;
    return pos({
      type: 2 /* CustomMedia */,
      name: trim(m[1]),
      media: trim(m[2])
    });
  };
  const atpage = () => {
    const pos = position();
    const m = match2(/^@page */);
    if (!m) return null;
    const sel = selector() || [];
    if (!open()) return error(`@page missing '{'`);
    let decls = comments();
    let decl;
    while (decl = declaration()) {
      decls.push(decl);
      decls = decls.concat(comments());
    }
    if (!close()) return error(`@page missing '}'`);
    return pos({
      type: 13 /* Page */,
      selectors: sel,
      declarations: decls
    });
  };
  const atdocument = () => {
    const pos = position();
    const m = match2(/^@([-\w]+)?document *([^{]+)/);
    if (!m) return null;
    const vendor = trim(m[1]);
    const doc = trim(m[2]);
    if (!open()) return error(`@document missing '{'`);
    const style = comments().concat(rules());
    if (!close()) return error(`@document missing '}'`);
    return pos({
      type: 3 /* Document */,
      document: doc,
      vendor,
      rules: style
    });
  };
  const atfontface = () => {
    const pos = position();
    const m = match2(/^@font-face\s*/);
    if (!m) return null;
    if (!open()) return error(`@font-face missing '{'`);
    let decls = comments();
    let decl;
    while (decl = declaration()) {
      decls.push(decl);
      decls = decls.concat(comments());
    }
    if (!close()) return error(`@font-face missing '}'`);
    return pos({
      type: 5 /* FontFace */,
      declarations: decls
    });
  };
  const compileAtrule = (nodeName, nodeType) => {
    const re = new RegExp("^@" + nodeName + "\\s*([^;]+);");
    return () => {
      const pos = position();
      const m = match2(re);
      if (!m) return null;
      const node = {
        type: nodeType
      };
      node[nodeName] = m[1].trim();
      return pos(node);
    };
  };
  const atimport = compileAtrule("import", 7 /* Import */);
  const atcharset = compileAtrule("charset", 0 /* Charset */);
  const atnamespace = compileAtrule("namespace", 12 /* Namespace */);
  const atrule = () => {
    if (css[0] !== "@") return null;
    return atkeyframes() || atquery("media") || atquery("container") || atcustommedia() || atsupports() || atimport() || atcharset() || atnamespace() || atdocument() || atpage() || athost() || atfontface();
  };
  const rule = () => {
    const pos = position();
    const sel = selector();
    if (!sel) return error("selector missing");
    comments();
    if (!open()) return error(`missing '{'`);
    const decls = [];
    const nestedRules = [];
    comments(decls);
    while (css.length && css.charAt(0) !== "}") {
      whitespace();
      if (!css.length || css.charAt(0) === "}") {
        break;
      }
      const nextChar = css.charAt(0);
      if (nextChar === "@") {
        const nestedAt = nestedAtrule();
        if (nestedAt) {
          nestedRules.push(nestedAt);
          comments(nestedRules);
          continue;
        }
      }
      if (nextChar === "&" || nextChar === ":" || /[a-zA-Z\.\#\[]/.test(nextChar)) {
        let hasOpenBrace = false;
        if (nextChar === "&" || nextChar === ":") {
          const lookAhead = css.match(/^[^{}]+/);
          hasOpenBrace = lookAhead && css[lookAhead[0].length] === "{";
        } else {
          const lookAhead = css.match(/^[^{};]+/);
          if (lookAhead) {
            const nextSigChar = css[lookAhead[0].length];
            hasOpenBrace = nextSigChar === "{";
          }
        }
        if (hasOpenBrace) {
          const nestedRule = rule();
          if (nestedRule) {
            nestedRules.push(nestedRule);
            comments(nestedRules);
            continue;
          }
        }
      }
      const decl = declaration();
      if (decl) {
        decls.push(decl);
        comments(decls);
        continue;
      }
      break;
    }
    if (!close()) return error(`missing '}'`);
    return pos({
      type: 14 /* Rule */,
      selectors: sel,
      declarations: decls,
      rules: nestedRules.length > 0 ? nestedRules : null
    });
  };
  class ParsePosition {
    start;
    end;
    source;
    content;
    constructor(start) {
      this.start = start;
      this.end = { line: lineno, column };
      this.source = filePath;
    }
  }
  ParsePosition.prototype.content = css;
  return {
    diagnostics,
    ...addParent(stylesheet())
  };
};
var trim = (str) => str ? str.trim() : "";
var addParent = (obj, parent) => {
  const isNode = obj && typeof obj.type === "string";
  const childParent = isNode ? obj : parent;
  for (const k in obj) {
    const value = obj[k];
    if (Array.isArray(value)) {
      value.forEach(function(v) {
        addParent(v, childParent);
      });
    } else if (value && typeof value === "object") {
      addParent(value, childParent);
    }
  }
  if (isNode) {
    Object.defineProperty(obj, "parent", {
      configurable: true,
      writable: true,
      enumerable: false,
      value: parent || null
    });
  }
  return obj;
};
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;

// src/compiler/style/css-parser/get-css-selectors.ts
var getCssSelectors = (sel) => {
  SELECTORS.all.length = SELECTORS.tags.length = SELECTORS.classNames.length = SELECTORS.ids.length = SELECTORS.attrs.length = 0;
  sel = sel.replace(/\./g, " .").replace(/\#/g, " #").replace(/\[/g, " [").replace(/\>/g, " > ").replace(/\+/g, " + ").replace(/\~/g, " ~ ").replace(/\*/g, " * ").replace(/\:not\((.*?)\)/g, " ");
  const items = sel.split(" ");
  for (let i = 0, l = items.length; i < l; i++) {
    items[i] = items[i].split(":")[0];
    if (items[i].length === 0) continue;
    if (items[i].charAt(0) === ".") {
      SELECTORS.classNames.push(items[i].slice(1));
    } else if (items[i].charAt(0) === "#") {
      SELECTORS.ids.push(items[i].slice(1));
    } else if (items[i].charAt(0) === "[") {
      items[i] = items[i].slice(1).split("=")[0].split("]")[0].trim();
      SELECTORS.attrs.push(items[i].toLowerCase());
    } else if (/[a-z]/g.test(items[i].charAt(0))) {
      SELECTORS.tags.push(items[i].toLowerCase());
    }
  }
  SELECTORS.classNames = SELECTORS.classNames.sort((a, b) => {
    if (a.length < b.length) return -1;
    if (a.length > b.length) return 1;
    return 0;
  });
  return SELECTORS;
};
var SELECTORS = {
  all: [],
  tags: [],
  classNames: [],
  ids: [],
  attrs: []
};

// src/compiler/style/css-parser/serialize-css.ts
var serializeCss = (stylesheet, serializeOpts) => {
  const usedSelectors = serializeOpts.usedSelectors || null;
  const opts = {
    usedSelectors: usedSelectors || null,
    hasUsedAttrs: !!usedSelectors && usedSelectors.attrs.size > 0,
    hasUsedClassNames: !!usedSelectors && usedSelectors.classNames.size > 0,
    hasUsedIds: !!usedSelectors && usedSelectors.ids.size > 0,
    hasUsedTags: !!usedSelectors && usedSelectors.tags.size > 0
  };
  const rules = stylesheet.rules;
  if (!rules) {
    return "";
  }
  const rulesLen = rules.length;
  const out = [];
  for (let i = 0; i < rulesLen; i++) {
    out.push(serializeCssVisitNode(opts, rules[i], i, rulesLen));
  }
  return out.join("");
};
var serializeCssVisitNode = (opts, node, index, len) => {
  var _a2;
  const nodeType = node.type;
  if (nodeType === 4 /* Declaration */) {
    return serializeCssDeclaration(node, index, len);
  }
  if (nodeType === 14 /* Rule */) {
    return serializeCssRule(opts, node);
  }
  if (nodeType === 1 /* Comment */) {
    if (((_a2 = node.comment) == null ? void 0 : _a2[0]) === "!") {
      return `/*${node.comment}*/`;
    } else {
      return "";
    }
  }
  if (nodeType === 10 /* Media */) {
    return serializeCssMedia(opts, node);
  }
  if (nodeType === 11 /* Container */) {
    return serializeCssContainer(opts, node);
  }
  if (nodeType === 8 /* KeyFrames */) {
    return serializeCssKeyframes(opts, node);
  }
  if (nodeType === 9 /* KeyFrame */) {
    return serializeCssKeyframe(opts, node);
  }
  if (nodeType === 5 /* FontFace */) {
    return serializeCssFontFace(opts, node);
  }
  if (nodeType === 16 /* Supports */) {
    return serializeCssSupports(opts, node);
  }
  if (nodeType === 7 /* Import */) {
    return "@import " + node.import + ";";
  }
  if (nodeType === 0 /* Charset */) {
    return "@charset " + node.charset + ";";
  }
  if (nodeType === 13 /* Page */) {
    return serializeCssPage(opts, node);
  }
  if (nodeType === 6 /* Host */) {
    return "@host{" + serializeCssMapVisit(opts, node.rules) + "}";
  }
  if (nodeType === 2 /* CustomMedia */) {
    return "@custom-media " + node.name + " " + node.media + ";";
  }
  if (nodeType === 3 /* Document */) {
    return serializeCssDocument(opts, node);
  }
  if (nodeType === 12 /* Namespace */) {
    return "@namespace " + node.namespace + ";";
  }
  return "";
};
var serializeCssRule = (opts, node) => {
  var _a2, _b;
  const decls = node.declarations;
  const usedSelectors = opts.usedSelectors;
  const selectors = (_b = (_a2 = node.selectors) == null ? void 0 : _a2.slice()) != null ? _b : [];
  const hasDecls = decls != null && decls.length > 0;
  const hasNestedRules = node.rules != null && node.rules.length > 0;
  if (!hasDecls && !hasNestedRules) {
    return "";
  }
  if (usedSelectors) {
    let i;
    let j;
    let include = true;
    for (i = selectors.length - 1; i >= 0; i--) {
      const sel = getCssSelectors(selectors[i]);
      include = true;
      let jlen = sel.classNames.length;
      if (jlen > 0 && opts.hasUsedClassNames) {
        for (j = 0; j < jlen; j++) {
          if (!usedSelectors.classNames.has(sel.classNames[j])) {
            include = false;
            break;
          }
        }
      }
      if (include && opts.hasUsedTags) {
        jlen = sel.tags.length;
        if (jlen > 0) {
          for (j = 0; j < jlen; j++) {
            if (!usedSelectors.tags.has(sel.tags[j])) {
              include = false;
              break;
            }
          }
        }
      }
      if (include && opts.hasUsedAttrs) {
        jlen = sel.attrs.length;
        if (jlen > 0) {
          for (j = 0; j < jlen; j++) {
            if (!usedSelectors.attrs.has(sel.attrs[j])) {
              include = false;
              break;
            }
          }
        }
      }
      if (include && opts.hasUsedIds) {
        jlen = sel.ids.length;
        if (jlen > 0) {
          for (j = 0; j < jlen; j++) {
            if (!usedSelectors.ids.has(sel.ids[j])) {
              include = false;
              break;
            }
          }
        }
      }
      if (!include) {
        selectors.splice(i, 1);
      }
    }
  }
  if (selectors.length === 0) {
    return "";
  }
  const cleanedSelectors = [];
  let cleanedSelector = "";
  if (node.selectors) {
    for (const selector of node.selectors) {
      cleanedSelector = removeSelectorWhitespace(selector);
      if (!cleanedSelectors.includes(cleanedSelector)) {
        cleanedSelectors.push(cleanedSelector);
      }
    }
  }
  let declsCss = decls && decls.length > 0 ? serializeCssMapVisit(opts, decls) : "";
  const nestedRulesCss = node.rules ? serializeCssMapVisit(opts, node.rules) : "";
  if (declsCss && nestedRulesCss && declsCss.length > 0) {
    declsCss += ";";
  }
  return `${cleanedSelectors}{${declsCss}${nestedRulesCss}}`;
};
var serializeCssDeclaration = (node, index, len) => {
  if (node.value === "") {
    return "";
  }
  if (len - 1 === index) {
    return node.property + ":" + node.value;
  }
  return node.property + ":" + node.value + ";";
};
var serializeCssMedia = (opts, node) => {
  const mediaCss = node.declarations ? serializeCssMapVisit(opts, node.declarations) : serializeCssMapVisit(opts, node.rules);
  if (mediaCss === "") {
    return "";
  }
  return "@media " + removeMediaWhitespace(node.media) + "{" + mediaCss + "}";
};
var serializeCssKeyframes = (opts, node) => {
  const keyframesCss = serializeCssMapVisit(opts, node.keyframes);
  if (keyframesCss === "") {
    return "";
  }
  return "@" + (node.vendor || "") + "keyframes " + node.name + "{" + keyframesCss + "}";
};
var serializeCssKeyframe = (opts, node) => {
  var _a2, _b;
  return ((_b = (_a2 = node.values) == null ? void 0 : _a2.join(",")) != null ? _b : "") + "{" + serializeCssMapVisit(opts, node.declarations) + "}";
};
var serializeCssFontFace = (opts, node) => {
  const fontCss = serializeCssMapVisit(opts, node.declarations);
  if (fontCss === "") {
    return "";
  }
  return "@font-face{" + fontCss + "}";
};
var serializeCssSupports = (opts, node) => {
  const supportsCss = node.declarations ? serializeCssMapVisit(opts, node.declarations) : serializeCssMapVisit(opts, node.rules);
  if (supportsCss === "") {
    return "";
  }
  return "@supports " + node.supports + "{" + supportsCss + "}";
};
var serializeCssContainer = (opts, node) => {
  const containerCss = node.declarations ? serializeCssMapVisit(opts, node.declarations) : serializeCssMapVisit(opts, node.rules);
  if (containerCss === "") {
    return "";
  }
  return "@container " + removeMediaWhitespace(node.media) + "{" + containerCss + "}";
};
var serializeCssPage = (opts, node) => {
  var _a2, _b;
  const sel = (_b = (_a2 = node.selectors) == null ? void 0 : _a2.join(", ")) != null ? _b : "";
  return "@page " + sel + "{" + serializeCssMapVisit(opts, node.declarations) + "}";
};
var serializeCssDocument = (opts, node) => {
  const documentCss = serializeCssMapVisit(opts, node.rules);
  const doc = "@" + (node.vendor || "") + "document " + node.document;
  if (documentCss === "") {
    return "";
  }
  return doc + "{" + documentCss + "}";
};
var serializeCssMapVisit = (opts, nodes) => {
  let rtn = "";
  if (nodes) {
    for (let i = 0, len = nodes.length; i < len; i++) {
      rtn += serializeCssVisitNode(opts, nodes[i], i, len);
    }
  }
  return rtn;
};
var removeSelectorWhitespace = (selector) => {
  let rtn = "";
  let char = "";
  let inAttr = false;
  selector = selector.trim();
  for (let i = 0, l = selector.length; i < l; i++) {
    char = selector[i];
    if (char === "[" && rtn[rtn.length - 1] !== "\\") {
      inAttr = true;
    } else if (char === "]" && rtn[rtn.length - 1] !== "\\") {
      inAttr = false;
    }
    if (!inAttr && CSS_WS_REG.test(char)) {
      if (CSS_NEXT_CHAR_REG.test(selector[i + 1])) {
        continue;
      }
      if (CSS_PREV_CHAR_REG.test(rtn[rtn.length - 1])) {
        continue;
      }
      rtn += " ";
    } else {
      rtn += char;
    }
  }
  return rtn;
};
var removeMediaWhitespace = (media) => {
  var _a2;
  let rtn = "";
  let char = "";
  media = (_a2 = media == null ? void 0 : media.trim()) != null ? _a2 : "";
  for (let i = 0, l = media.length; i < l; i++) {
    char = media[i];
    if (CSS_WS_REG.test(char)) {
      if (CSS_WS_REG.test(rtn[rtn.length - 1])) {
        continue;
      }
      rtn += " ";
    } else {
      rtn += char;
    }
  }
  return rtn;
};
var CSS_WS_REG = /\s/;
var CSS_NEXT_CHAR_REG = /[>\(\)\~\,\+\s]/;
var CSS_PREV_CHAR_REG = /[>\(\~\,\+]/;

// src/compiler/style/css-parser/used-selectors.ts
var getUsedSelectors = (elm) => {
  const usedSelectors = {
    attrs: /* @__PURE__ */ new Set(),
    classNames: /* @__PURE__ */ new Set(),
    ids: /* @__PURE__ */ new Set(),
    tags: /* @__PURE__ */ new Set()
  };
  collectUsedSelectors(usedSelectors, elm);
  return usedSelectors;
};
var collectUsedSelectors = (usedSelectors, elm) => {
  if (elm != null && elm.nodeType === 1) {
    const children = elm.children;
    const tagName = elm.nodeName.toLowerCase();
    usedSelectors.tags.add(tagName);
    const attributes = elm.attributes;
    for (let i = 0, l = attributes.length; i < l; i++) {
      const attr = attributes.item(i);
      const attrName = attr.name.toLowerCase();
      usedSelectors.attrs.add(attrName);
      if (attrName === "class") {
        const classList = elm.classList;
        for (let i2 = 0, l2 = classList.length; i2 < l2; i2++) {
          usedSelectors.classNames.add(classList.item(i2));
        }
      } else if (attrName === "id") {
        usedSelectors.ids.add(attr.value);
      }
    }
    if (children) {
      for (let i = 0, l = children.length; i < l; i++) {
        collectUsedSelectors(usedSelectors, children[i]);
      }
    }
  }
};

// src/compiler/html/remove-unused-styles.ts
var removeUnusedStyles = (doc, diagnostics) => {
  try {
    const styleElms = doc.head.querySelectorAll(`style[data-styles]`);
    const styleLen = styleElms.length;
    if (styleLen > 0) {
      const usedSelectors = getUsedSelectors(doc.documentElement);
      for (let i = 0; i < styleLen; i++) {
        removeUnusedStyleText(usedSelectors, diagnostics, styleElms[i]);
      }
    }
  } catch (e) {
    catchError(diagnostics, e);
  }
};
var removeUnusedStyleText = (usedSelectors, diagnostics, styleElm) => {
  try {
    const parseResults = parseCss(styleElm.innerHTML);
    diagnostics.push(...parseResults.diagnostics);
    if (hasError(diagnostics)) {
      return;
    }
    try {
      styleElm.innerHTML = serializeCss(parseResults.stylesheet, {
        usedSelectors
      });
    } catch (e) {
      diagnostics.push({
        level: "warn",
        type: "css",
        header: "CSS Stringify",
        messageText: e,
        lines: []
      });
    }
  } catch (e) {
    diagnostics.push({
      level: "warn",
      type: "css",
      header: "CSS Parse",
      messageText: e,
      lines: []
    });
  }
};

// src/hydrate/runner/inspect-element.ts
function inspectElement(results, elm, depth) {
  const children = [...Array.from(elm.children), ...Array.from(elm.shadowRoot ? elm.shadowRoot.children : [])];
  for (let i = 0, ii = children.length; i < ii; i++) {
    const childElm = children[i];
    const tagName = childElm.nodeName.toLowerCase();
    if (tagName.includes("-")) {
      const cmp = results.components.find((c) => c.tag === tagName);
      if (cmp != null) {
        cmp.count++;
        if (depth > cmp.depth) {
          cmp.depth = depth;
        }
      }
    } else {
      switch (tagName) {
        case "a":
          const anchor = collectAttributes(childElm);
          anchor.href = childElm.href;
          if (typeof anchor.href === "string") {
            if (!results.anchors.some((a) => a.href === anchor.href)) {
              results.anchors.push(anchor);
            }
          }
          break;
        case "img":
          const img = collectAttributes(childElm);
          img.src = childElm.src;
          if (typeof img.src === "string") {
            if (!results.imgs.some((a) => a.src === img.src)) {
              results.imgs.push(img);
            }
          }
          break;
        case "link":
          const link = collectAttributes(childElm);
          link.href = childElm.href;
          if (typeof link.rel === "string" && link.rel.toLowerCase() === "stylesheet") {
            if (typeof link.href === "string") {
              if (!results.styles.some((s) => s.link === link.href)) {
                delete link.rel;
                delete link.type;
                results.styles.push(link);
              }
            }
          }
          break;
        case "script":
          const script = collectAttributes(childElm);
          if (childElm.hasAttribute("src")) {
            script.src = childElm.src;
            if (typeof script.src === "string") {
              if (!results.scripts.some((s) => s.src === script.src)) {
                results.scripts.push(script);
              }
            }
          } else {
            const staticDataKey = childElm.getAttribute("data-stencil-static");
            if (staticDataKey) {
              results.staticData.push({
                id: staticDataKey,
                type: childElm.getAttribute("type"),
                content: childElm.textContent
              });
            }
          }
          break;
      }
    }
    depth++;
    inspectElement(results, childElm, depth);
  }
}
function collectAttributes(node) {
  const parsedElm = {};
  const attrs = node.attributes;
  for (let i = 0, ii = attrs.length; i < ii; i++) {
    const attr = attrs.item(i);
    const attrName = attr.nodeName.toLowerCase();
    if (SKIP_ATTRS.has(attrName)) {
      continue;
    }
    const attrValue = attr.nodeValue;
    if (attrName === "class" && attrValue === "") {
      continue;
    }
    parsedElm[attrName] = attrValue;
  }
  return parsedElm;
}
var SKIP_ATTRS = /* @__PURE__ */ new Set(["s-id", "c-id"]);

// src/hydrate/runner/patch-dom-implementation.ts
function patchDomImplementation(doc, opts) {
  let win2;
  if (doc.defaultView != null) {
    opts.destroyWindow = true;
    patchWindow(doc.defaultView);
    win2 = doc.defaultView;
  } else {
    opts.destroyWindow = true;
    opts.destroyDocument = false;
    win2 = new MockWindow(false);
  }
  if (win2.document !== doc) {
    win2.document = doc;
  }
  if (doc.defaultView !== win2) {
    doc.defaultView = win2;
  }
  const HTMLElement2 = doc.documentElement.constructor.prototype;
  if (typeof HTMLElement2.getRootNode !== "function") {
    const elm = doc.createElement("unknown-element");
    const HTMLUnknownElement = elm.constructor.prototype;
    HTMLUnknownElement.getRootNode = getRootNode;
  }
  if (typeof doc.createEvent === "function") {
    const CustomEvent2 = doc.createEvent("CustomEvent").constructor;
    if (win2.CustomEvent !== CustomEvent2) {
      win2.CustomEvent = CustomEvent2;
    }
  }
  try {
    win2.__stencil_baseURI = doc.baseURI;
  } catch (e) {
    Object.defineProperty(doc, "baseURI", {
      get() {
        const baseElm = doc.querySelector("base[href]");
        if (baseElm) {
          return new URL(baseElm.getAttribute("href"), win2.location.href).href;
        }
        return win2.location.href;
      }
    });
  }
  return win2;
}
function getRootNode(opts) {
  const isComposed = opts != null && opts.composed === true;
  let node = this;
  while (node.parentNode != null) {
    node = node.parentNode;
    if (isComposed === true && node.parentNode == null && node.host != null) {
      node = node.host;
    }
  }
  return node;
}

// src/hydrate/runner/render-utils.ts
function normalizeHydrateOptions(inputOpts) {
  const outputOpts = Object.assign(
    {
      serializeToHtml: false,
      destroyWindow: false,
      destroyDocument: false
    },
    inputOpts || {}
  );
  if (typeof outputOpts.clientHydrateAnnotations !== "boolean") {
    outputOpts.clientHydrateAnnotations = true;
  }
  if (typeof outputOpts.constrainTimeouts !== "boolean") {
    outputOpts.constrainTimeouts = true;
  }
  if (typeof outputOpts.maxHydrateCount !== "number") {
    outputOpts.maxHydrateCount = 300;
  }
  if (typeof outputOpts.runtimeLogging !== "boolean") {
    outputOpts.runtimeLogging = false;
  }
  if (typeof outputOpts.timeout !== "number") {
    outputOpts.timeout = 15e3;
  }
  if (Array.isArray(outputOpts.excludeComponents)) {
    outputOpts.excludeComponents = outputOpts.excludeComponents.filter(filterValidTags).map(mapValidTags);
  } else {
    outputOpts.excludeComponents = [];
  }
  if (Array.isArray(outputOpts.staticComponents)) {
    outputOpts.staticComponents = outputOpts.staticComponents.filter(filterValidTags).map(mapValidTags);
  } else {
    outputOpts.staticComponents = [];
  }
  return outputOpts;
}
function filterValidTags(tag) {
  return typeof tag === "string" && tag.includes("-");
}
function mapValidTags(tag) {
  return tag.trim().toLowerCase();
}
function generateHydrateResults(opts) {
  if (typeof opts.url !== "string") {
    opts.url = `https://hydrate.stenciljs.com/`;
  }
  if (typeof opts.buildId !== "string") {
    opts.buildId = createHydrateBuildId();
  }
  const results = {
    buildId: opts.buildId,
    diagnostics: [],
    url: opts.url,
    host: null,
    hostname: null,
    href: null,
    pathname: null,
    port: null,
    search: null,
    hash: null,
    html: null,
    httpStatus: null,
    hydratedCount: 0,
    anchors: [],
    components: [],
    imgs: [],
    scripts: [],
    staticData: [],
    styles: [],
    title: null
  };
  try {
    const url = new URL(opts.url, `https://hydrate.stenciljs.com/`);
    results.url = url.href;
    results.host = url.host;
    results.hostname = url.hostname;
    results.href = url.href;
    results.port = url.port;
    results.pathname = url.pathname;
    results.search = url.search;
    results.hash = url.hash;
  } catch (e) {
    renderCatchError(results, e);
  }
  return results;
}
var createHydrateBuildId = () => {
  let chars = "abcdefghijklmnopqrstuvwxyz";
  let buildId = "";
  while (buildId.length < 8) {
    const char = chars[Math.floor(Math.random() * chars.length)];
    buildId += char;
    if (buildId.length === 1) {
      chars += "0123456789";
    }
  }
  return buildId;
};
function renderBuildDiagnostic(results, level, header, msg) {
  const diagnostic = {
    level,
    type: "build",
    header,
    messageText: msg,
    relFilePath: void 0,
    absFilePath: void 0,
    lines: []
  };
  if (results.pathname) {
    if (results.pathname !== "/") {
      diagnostic.header += ": " + results.pathname;
    }
  } else if (results.url) {
    diagnostic.header += ": " + results.url;
  }
  results.diagnostics.push(diagnostic);
  return diagnostic;
}
function renderBuildError(results, msg) {
  return renderBuildDiagnostic(results, "error", "Hydrate Error", msg || "");
}
function renderCatchError(results, err2) {
  const diagnostic = renderBuildError(results);
  if (err2 != null) {
    if (err2.stack != null) {
      diagnostic.messageText = err2.stack.toString();
    } else {
      if (err2.message != null) {
        diagnostic.messageText = err2.message.toString();
      } else {
        diagnostic.messageText = err2.toString();
      }
    }
  }
  return diagnostic;
}

// src/hydrate/runner/runtime-log.ts
function runtimeLogging(win2, opts, results) {
  try {
    const pathname = win2.location.pathname;
    win2.console.error = (...msgs) => {
      const errMsg = msgs.reduce((errMsg2, m) => {
        if (m) {
          if (m.stack != null) {
            return errMsg2 + " " + String(m.stack);
          } else {
            if (m.message != null) {
              return errMsg2 + " " + String(m.message);
            }
          }
        }
        return String(m);
      }, "").trim();
      if (errMsg !== "") {
        renderCatchError(results, errMsg);
        if (opts.runtimeLogging) {
          runtimeLog(pathname, "error", [errMsg]);
        }
      }
    };
    win2.console.debug = (...msgs) => {
      renderBuildDiagnostic(results, "debug", "Hydrate Debug", [...msgs].join(", "));
      if (opts.runtimeLogging) {
        runtimeLog(pathname, "debug", msgs);
      }
    };
    if (opts.runtimeLogging) {
      ["log", "warn", "assert", "info", "trace"].forEach((type) => {
        win2.console[type] = (...msgs) => {
          runtimeLog(pathname, type, msgs);
        };
      });
    }
  } catch (e) {
    renderCatchError(results, e);
  }
}
function runtimeLog(pathname, type, msgs) {
  global.console[type].apply(global.console, [`[ ${pathname}  ${type} ] `, ...msgs]);
}

// src/hydrate/runner/window-initialize.ts
var docData = {
  hostIds: 0,
  rootLevelIds: 0,
  staticComponents: /* @__PURE__ */ new Set()
};
function initializeWindow(win2, doc, opts, results) {
  if (typeof opts.url === "string") {
    try {
      win2.location.href = opts.url;
    } catch (e) {
    }
  }
  if (typeof opts.userAgent === "string") {
    try {
      win2.navigator.userAgent = opts.userAgent;
    } catch (e) {
    }
  }
  if (typeof opts.cookie === "string") {
    try {
      doc.cookie = opts.cookie;
    } catch (e) {
    }
  }
  if (typeof opts.referrer === "string") {
    try {
      doc.referrer = opts.referrer;
    } catch (e) {
    }
  }
  if (typeof opts.direction === "string") {
    try {
      doc.documentElement.setAttribute("dir", opts.direction);
    } catch (e) {
    }
  }
  if (typeof opts.language === "string") {
    try {
      doc.documentElement.setAttribute("lang", opts.language);
    } catch (e) {
    }
  }
  if (typeof opts.buildId === "string") {
    try {
      doc.documentElement.setAttribute("data-stencil-build", opts.buildId);
    } catch (e) {
    }
  }
  try {
    win2.customElements = null;
  } catch (e) {
  }
  if (opts.constrainTimeouts) {
    constrainTimeouts(win2);
  }
  runtimeLogging(win2, opts, results);
  doc[STENCIL_DOC_DATA] = docData;
  return win2;
}

// src/hydrate/runner/render.ts
var NOOP = () => {
};
function streamToString(html, option) {
  return renderToString(html, option, true);
}
function renderToString(html, options, asStream) {
  const opts = normalizeHydrateOptions(options);
  opts.serializeToHtml = true;
  opts.fullDocument = typeof opts.fullDocument === "boolean" ? opts.fullDocument : true;
  opts.serializeShadowRoot = typeof opts.serializeShadowRoot === "undefined" ? "declarative-shadow-dom" : opts.serializeShadowRoot;
  opts.constrainTimeouts = false;
  return hydrateDocument(html, opts, asStream);
}
function hydrateDocument(doc, options, asStream) {
  const opts = normalizeHydrateOptions(options);
  opts.serializeShadowRoot = typeof opts.serializeShadowRoot === "undefined" ? "declarative-shadow-dom" : opts.serializeShadowRoot;
  let win2 = null;
  const results = generateHydrateResults(opts);
  if (hasError(results.diagnostics)) {
    return Promise.resolve(results);
  }
  if (typeof doc === "string") {
    try {
      opts.destroyWindow = true;
      opts.destroyDocument = true;
      win2 = new MockWindow(doc);
      if (!asStream) {
        return render2(win2, opts, results).then(() => results);
      }
      return renderStream(win2, opts, results);
    } catch (e) {
      if (win2 && win2.close) {
        win2.close();
      }
      win2 = null;
      renderCatchError(results, e);
      return Promise.resolve(results);
    }
  }
  if (isValidDocument(doc)) {
    try {
      opts.destroyDocument = false;
      win2 = patchDomImplementation(doc, opts);
      if (!asStream) {
        return render2(win2, opts, results).then(() => results);
      }
      return renderStream(win2, opts, results);
    } catch (e) {
      if (win2 && win2.close) {
        win2.close();
      }
      win2 = null;
      renderCatchError(results, e);
      return Promise.resolve(results);
    }
  }
  renderBuildError(results, `Invalid html or document. Must be either a valid "html" string, or DOM "document".`);
  return Promise.resolve(results);
}
async function render2(win2, opts, results) {
  if ("process" in globalThis && typeof process.on === "function" && !process.__stencilErrors) {
    process.__stencilErrors = true;
    process.on("unhandledRejection", (e) => {
      console.log("unhandledRejection", e);
    });
  }
  initializeWindow(win2, win2.document, opts, results);
  const beforeHydrateFn = typeof opts.beforeHydrate === "function" ? opts.beforeHydrate : NOOP;
  try {
    await Promise.resolve(beforeHydrateFn(win2.document));
    return new Promise((resolve) => {
      if (Array.isArray(opts.modes)) {
        modeResolutionChain.length = 0;
        opts.modes.forEach((mode) => setMode(mode));
      }
      return hydrateFactory(win2, opts, results, afterHydrate, resolve);
    });
  } catch (e) {
    renderCatchError(results, e);
    return finalizeHydrate(win2, win2.document, opts, results);
  }
}
function renderStream(win2, opts, results) {
  async function* processRender() {
    const renderResult = await render2(win2, opts, results);
    yield renderResult.html;
  }
  return Readable.from(processRender());
}
async function afterHydrate(win2, opts, results, resolve) {
  const afterHydrateFn = typeof opts.afterHydrate === "function" ? opts.afterHydrate : NOOP;
  try {
    await Promise.resolve(afterHydrateFn(win2.document));
    return resolve(finalizeHydrate(win2, win2.document, opts, results));
  } catch (e) {
    renderCatchError(results, e);
    return resolve(finalizeHydrate(win2, win2.document, opts, results));
  }
}
function finalizeHydrate(win2, doc, opts, results) {
  try {
    inspectElement(results, doc.documentElement, 0);
    if (opts.removeUnusedStyles !== false) {
      try {
        removeUnusedStyles(doc, results.diagnostics);
      } catch (e) {
        renderCatchError(results, e);
      }
    }
    if (typeof opts.title === "string") {
      try {
        doc.title = opts.title;
      } catch (e) {
        renderCatchError(results, e);
      }
    }
    results.title = doc.title;
    if (opts.removeScripts) {
      removeScripts(doc.documentElement);
    }
    const styles2 = doc.querySelectorAll("head style");
    if (styles2.length > 0) {
      results.styles.push(
        ...Array.from(styles2).map((style) => ({
          href: style.getAttribute("href"),
          id: style.getAttribute(HYDRATED_STYLE_ID),
          content: style.textContent
        }))
      );
    }
    try {
      updateCanonicalLink(doc, opts.canonicalUrl);
    } catch (e) {
      renderCatchError(results, e);
    }
    try {
      relocateMetaCharset(doc);
    } catch (e) {
    }
    if (!hasError(results.diagnostics)) {
      results.httpStatus = 200;
    }
    try {
      const metaStatus = doc.head.querySelector('meta[http-equiv="status"]');
      if (metaStatus != null) {
        const metaStatusContent = metaStatus.getAttribute("content");
        if (metaStatusContent && metaStatusContent.length > 0) {
          results.httpStatus = parseInt(metaStatusContent, 10);
        }
      }
    } catch (e) {
    }
    if (opts.clientHydrateAnnotations) {
      doc.documentElement.classList.add("hydrated");
    }
    if (opts.serializeToHtml) {
      results.html = serializeDocumentToString(doc, opts);
    }
  } catch (e) {
    renderCatchError(results, e);
  }
  destroyWindow(win2, doc, opts, results);
  return results;
}
function destroyWindow(win2, doc, opts, results) {
  if (!opts.destroyWindow) {
    return;
  }
  try {
    if (!opts.destroyDocument) {
      win2.document = null;
      doc.defaultView = null;
    }
    if (win2.close) {
      win2.close();
    }
  } catch (e) {
    renderCatchError(results, e);
  }
}
function serializeDocumentToString(doc, opts) {
  return serializeNodeToHtml(doc, {
    approximateLineWidth: opts.approximateLineWidth,
    outerHtml: false,
    prettyHtml: opts.prettyHtml,
    removeAttributeQuotes: opts.removeAttributeQuotes,
    removeBooleanAttributeQuotes: opts.removeBooleanAttributeQuotes,
    removeEmptyAttributes: opts.removeEmptyAttributes,
    removeHtmlComments: opts.removeHtmlComments,
    serializeShadowRoot: opts.serializeShadowRoot,
    fullDocument: opts.fullDocument
  });
}
function isValidDocument(doc) {
  return doc != null && doc.nodeType === 9 && doc.documentElement != null && doc.documentElement.nodeType === 1 && doc.body != null && doc.body.nodeType === 1;
}
function removeScripts(elm) {
  const children = elm.children;
  for (let i = children.length - 1; i >= 0; i--) {
    const child = children[i];
    removeScripts(child);
    if (child.nodeName === "SCRIPT" || child.nodeName === "LINK" && child.getAttribute("rel") === "modulepreload") {
      child.remove();
    }
  }
}

export { createWindowFromHtml, deserializeProperty, hydrateDocument, renderToString, serializeDocumentToString, serializeProperty, setTagTransformer, streamToString, transformTag };