{"version":3,"file":"temme.mjs","names":["parse","Validator.isValidHTMLElement"],"sources":["../src/modules/models/TemmyError.ts","../src/modules/errors/InvalidTargetError.ts","../src/modules/idfier.ts","../src/modules/utils.ts","../src/modules/models/Option.ts","../src/modules/options/AttributesOption.ts","../src/modules/options/ChildrenNodesOption.ts","../src/modules/options/ClassesOption.ts","../src/modules/options/sub-options/ContentTypeSubOption.ts","../src/modules/options/sub-options/ValueSubOption.ts","../src/modules/options/ContentOption.ts","../src/modules/options/DatasetOption.ts","../src/modules/options/RefOption.ts","../src/modules/options/sub-options/ChildrenAllowSubOption.ts","../src/modules/options/sub-options/PlacementSubOption.ts","../src/modules/options/sub-options/ChildrenSubOption.ts","../src/modules/options/sub-options/IncludeSubOption.ts","../src/modules/options/sub-options/ExcludeSubOption.ts","../src/modules/options/sub-options/ModeSubOption.ts","../src/modules/options/FromOption.ts","../src/modules/options/IdOption.ts","../src/modules/options/NameOption.ts","../src/modules/options/TemmeIdsOption.ts","../src/modules/options/TemplatesOption.ts","../src/modules/options.ts","../src/modules/parser.ts","../src/modules/errors/CircularReferenceError.ts","../src/modules/errors/InvalidReferenceError.ts","../src/modules/errors/InvalidReferenceOptionValueError.ts","../src/modules/errors/InvalidTemplateReferencingError.ts","../src/modules/errors/ReferenceOutOfScopeError.ts","../src/modules/referencer.ts","../src/modules/sanitizer.ts","../src/modules/errors/InvalidHierarchyError.ts","../src/modules/errors/InvalidOptionNameError.ts","../src/modules/errors/InvalidOptionTypeError.ts","../src/modules/errors/InvalidReferencingOptionError.ts","../src/modules/errors/InvalidSubOptionNameError.ts","../src/modules/errors/InvalidSubOptionTypeError.ts","../src/modules/errors/InvalidSubOptionValueError.ts","../src/modules/errors/InvalidTemplateError.ts","../src/modules/errors/InvalidTemplateOptionError.ts","../src/modules/validator.ts","../src/modules/errors/InvalidOptionValueError.ts","../src/temme.ts"],"sourcesContent":["/**\n * @description\n * The base class of every error Temme throws.\n */\nexport default class TemmyError extends Error {\n  /** The name of the error. */\n  public override readonly name: string = \"TemmyError\";\n\n\n  /**\n   * @description\n   * Constructs a Temme error.\n   *\n   * @param message The message of the error; when empty, `fallback` is used instead.\n   * @param fallback The generic message describing this kind of error.\n   * @param options The standard error options, e.g. the `cause`.\n   */\n  constructor(message: string, fallback: string = \"Temme isn't feeling good\", options?: ErrorOptions) {\n    super(message.length > 0 ? message : fallback, options);\n  }\n}\n","/**\n * @description\n * The error thrown when a target is not a valid HTML element.\n */\n\n\nimport TemmyError from \"../models/TemmyError\";\n\n\n\n/**\n * @description\n * The error thrown when a target is not a valid HTML element.\n */\nexport default class InvalidTargetError extends TemmyError {\n  /** The name of the error. */\n  public override readonly name: string = \"InvalidTargetError\";\n\n\n  /**\n   * @description\n   * Constructs the error.\n   *\n   * @param message The message of the error; a generic one is used when empty.\n   * @param options The standard error options, e.g. the `cause`.\n   */\n  constructor(message: string, options?: ErrorOptions) {\n    super(message, \"The target is not a valid HTML element\", options);\n  }\n}\n","/**\n * @description\n * Everything related to assigning internal temmeId identifiers to hierarchy objects.\n */\n\n\nimport type { Hierarchy } from \"./models/Hierarchy\";\n\n\n\n/** The length of a hierarchy's temmeId. */\nexport const HIERARCHY_ID_LENGTH = 6;\n\n/** The length of a template's temmeId. */\nexport const TEMPLATE_ID_LENGTH = 4;\n\n/** The characters temmeIds are made of. */\nconst ALPHABET = \"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n\n\n/**\n * @description\n * Assigns a temmeId trail to a hierarchy object and all of its descendants and templates.\n * Every temmeId is unique within the tree.\n *\n * @param hierarchy The hierarchy object to assign a temmeId to.\n * @param temmeIds The trail of temmeIds leading up to the current hierarchy object.\n * @param isTemplate Whether the object is a template (4-character id) or not (6-character id).\n * @param used The temmeIds already handed out in this tree.\n * @returns {void}\n */\nexport function idfy(\n  hierarchy: Hierarchy,\n  temmeIds: Array<string> = [],\n  isTemplate: boolean = false,\n  used: Set<string> = new Set(),\n): void {\n  const length = isTemplate ? TEMPLATE_ID_LENGTH : HIERARCHY_ID_LENGTH;\n  let temmeId = generateTemmeId(length);\n\n  while (used.has(temmeId)) {\n    temmeId = generateTemmeId(length);\n  }\n\n  used.add(temmeId);\n  hierarchy.temmeIds = [...temmeIds, temmeId];\n\n  hierarchy.childNodes?.forEach((child: Hierarchy) => idfy(child, hierarchy.temmeIds, false, used));\n  hierarchy.templates?.forEach((template: Hierarchy) => idfy(template, hierarchy.temmeIds, true, used));\n}\n\n\n/**\n * @description\n * Returns the last (innermost) temmeId of a hierarchy or template object.\n *\n * @param hierarchy The hierarchy or template to read the temmeId from.\n * @returns {string} The innermost temmeId.\n */\nexport function getTemmeId(hierarchy: Hierarchy): string {\n  return hierarchy.temmeIds[hierarchy.temmeIds.length - 1] as string;\n}\n\n\n/**\n * @description\n * Generates a random temmeId of the given length.\n *\n * @param length The number of characters.\n * @returns {string} The generated temmeId.\n */\nexport function generateTemmeId(length: number): string {\n  let key = \"\";\n\n  for (let i = 0; i < length; i++) {\n    key += ALPHABET[Math.floor(Math.random() * ALPHABET.length)];\n  }\n\n  return key;\n}\n","/**\n * @description\n * Small, dependency-free helpers shared by the hierarchy pipeline.\n */\n\n\nimport { isObject } from \"@eoussama/core\";\n\n\n\n/**\n * @description\n * The hierarchy objects whose inheritance has already been applied.\n * Re-parsing such an object renders it as-is instead of inheriting a second time.\n */\nconst resolved: WeakSet<object> = /* @__PURE__ */ new WeakSet();\n\n\n/**\n * @description\n * Checks whether a hierarchy object has already been through reference resolution.\n *\n * @param hierarchy The hierarchy object to check.\n * @returns {boolean} `true` when the hierarchy has been resolved before.\n */\nexport function isResolved(hierarchy: object): boolean {\n  return resolved.has(hierarchy);\n}\n\n\n/**\n * @description\n * Marks a hierarchy object as resolved.\n *\n * @param hierarchy The hierarchy object to mark.\n * @returns {void}\n */\nexport function markResolved(hierarchy: object): void {\n  resolved.add(hierarchy);\n}\n\n\n/**\n * @description\n * Deep-copies plain data (arrays and plain objects), leaving every other value as-is.\n * The resolved state of copied hierarchy objects is carried over to their copies.\n *\n * @param value The value to copy.\n * @returns {T} The copy.\n */\nexport function clone<T>(value: T): T {\n  if (Array.isArray(value)) {\n    return value.map(clone) as T;\n  }\n\n  if (isObject(value)) {\n    const copy: Record<string, unknown> = {};\n\n    for (const [key, entry] of Object.entries(value)) {\n      copy[key] = clone(entry);\n    }\n\n    if (isResolved(value)) {\n      markResolved(copy);\n    }\n\n    return copy as T;\n  }\n\n  return value;\n}\n\n\n/**\n * @description\n * Returns the distinct entries of a list, sorted.\n *\n * @param list The list to normalise.\n * @returns {Array<T>} A new sorted list without duplicates.\n */\nexport function uniqueSorted<T>(list: Array<T>): Array<T> {\n  return [...new Set(list)].sort();\n}\n","/**\n * @description\n * The hierarchy's option model — defines what a valid option looks like.\n */\n\n\nimport type { Hierarchy } from \"./Hierarchy\";\nimport { clone } from \"../utils\";\n\n\n\n/**\n * @description\n * The value types an option can be declared with.\n */\nexport type OptionType = \"string\" | \"boolean\" | \"array\" | \"object\";\n\n\n/**\n * @description\n * Base class for every hierarchy option and sub-option.\n * Options that need to inherit, read from outer elements or render override the matching methods.\n */\nexport default class Option {\n  /** The name / label of the option. */\n  public readonly label: string;\n\n  /** The expected data type of the option's value. */\n  public readonly type: OptionType;\n\n  /** The set of allowed values (or allowed array entries); empty means unrestricted. */\n  public readonly values: ReadonlyArray<unknown>;\n\n  /** The sub-options of an object option, keyed by label. */\n  public readonly keys: Readonly<Record<string, Option>> | undefined;\n\n  /** The default value, built from the sub-options' defaults when there are any. */\n  private readonly defaultValue: unknown;\n\n\n  /**\n   * @description\n   * Constructs an Option with the given metadata.\n   *\n   * @param label The name of the option.\n   * @param type The expected data type.\n   * @param values The set of allowed values.\n   * @param defaultValue The default value (ignored when `keys` are given).\n   * @param keys The sub-options of an object option.\n   */\n  constructor(\n    label: string,\n    type: OptionType,\n    values: ReadonlyArray<unknown> = [],\n    defaultValue: unknown = undefined,\n    keys?: Record<string, Option>,\n  ) {\n    this.label = label;\n    this.type = type;\n    this.values = values;\n    this.keys = keys;\n    this.defaultValue = defaultValue;\n  }\n\n\n  /**\n   * @description\n   * Builds a fresh copy of the default value, so that no two hierarchies ever share\n   * (and mutate) the same default object.\n   *\n   * @returns {unknown} A new default value.\n   */\n  public createDefault(): unknown {\n    if (this.keys !== undefined) {\n      return Object.fromEntries(\n        Object.values(this.keys).map((key: Option) => [key.label, key.createDefault()]),\n      );\n    }\n\n    return clone(this.defaultValue);\n  }\n\n\n  /**\n   * @description\n   * Performs the inheritance process for this option on a hierarchy.\n   * No-op unless overridden.\n   *\n   * @param _hierarchy The hierarchy object that is inheriting.\n   * @param _value The (already copied) value to inherit.\n   * @returns {void}\n   */\n  public inherit(_hierarchy: Hierarchy, _value: unknown): void {}\n\n\n  /**\n   * @description\n   * Extracts this option's value from an outer HTML element.\n   * Returns `null` (nothing to inherit) unless overridden.\n   *\n   * @param _element The HTML element to read from.\n   * @returns {unknown} The extracted value, or `null` if not applicable.\n   */\n  public getKeyFromElement(_element: Element): unknown {\n    return null;\n  }\n\n\n  /**\n   * @description\n   * Applies this option's value to a rendered HTML element. No-op unless overridden.\n   *\n   * @param _element The HTML element to apply values to.\n   * @param _hierarchy The hierarchy object supplying the values.\n   * @returns {void}\n   */\n  public parse(_element: HTMLElement, _hierarchy: Hierarchy): void {}\n\n\n  /**\n   * @description\n   * Returns the type name of a value, distinguishing arrays and `null` from objects.\n   *\n   * @param value The value to inspect.\n   * @returns {string} The detected type.\n   */\n  public static typeOf(value: unknown): string {\n    if (value === null) {\n      return \"null\";\n    }\n\n    return Array.isArray(value) ? \"array\" : typeof value;\n  }\n\n\n  /**\n   * @description\n   * Validates that a value has the option's expected data type.\n   *\n   * @param value The value to check.\n   * @param option The option the value belongs to.\n   * @returns {{ valid: boolean; type: string }} Validation result and the detected type.\n   */\n  public static validateOptionType(value: unknown, option: Option): { valid: boolean; type: string } {\n    const type = Option.typeOf(value);\n\n    return { valid: type === option.type, type };\n  }\n\n\n  /**\n   * @description\n   * Validates that a value is one of the option's allowed values.\n   * For array options, every entry must be allowed.\n   *\n   * @param value The value to check.\n   * @param option The option the value belongs to.\n   * @returns {boolean} `true` when the value is valid.\n   */\n  public static validateOptionValue(value: unknown, option: Option): boolean {\n    if (option.values.length === 0) {\n      return true;\n    }\n\n    const entries = option.type === \"array\" ? value as Array<unknown> : [value];\n\n    return entries.every((entry: unknown) => option.values.includes(entry));\n  }\n}\n","/**\n * @description\n * The \"attributes\" option model — manages the HTML attribute map of a hierarchy element.\n */\n\n\nimport type { AttributeValue, Hierarchy } from \"../models/Hierarchy\";\nimport Option from \"../models/Option\";\n\n\n\n/**\n * @description\n * Defines the `attributes` option, which sets or inherits an element's HTML attributes.\n */\nexport default class AttributesOption extends Option {\n  /**\n   * @description\n   * Constructs an AttributesOption with its default metadata.\n   */\n  constructor() {\n    super(\"attributes\", \"object\", [], {});\n  }\n\n\n  /**\n   * @description\n   * Inherits attributes. In \"append\" mode existing attributes win; otherwise incoming ones do.\n   *\n   * @param hierarchy The hierarchy object that inherits.\n   * @param attributes The attribute map to inherit.\n   * @returns {void}\n   */\n  public override inherit(hierarchy: Hierarchy, attributes: unknown): void {\n    const incoming = attributes as Record<string, string>;\n\n    hierarchy.attributes = hierarchy.from.mode === \"append\"\n      ? { ...incoming, ...hierarchy.attributes }\n      : { ...hierarchy.attributes, ...incoming };\n  }\n\n\n  /**\n   * @description\n   * Reads the attributes of an outer element, excluding `id`, `class` and `data-*`\n   * (those are covered by their own options).\n   *\n   * @param element The HTML element to read attributes from.\n   * @returns {Record<string, string>} A map of attribute names to values.\n   */\n  public override getKeyFromElement(element: Element): unknown {\n    return Object.fromEntries(\n      Array.from(element.attributes)\n        .filter((attr: Attr) => attr.name !== \"id\" && attr.name !== \"class\" && !attr.name.startsWith(\"data-\"))\n        .map((attr: Attr) => [attr.name, attr.value]),\n    );\n  }\n\n\n  /**\n   * @description\n   * Applies the attribute map to the target HTML element.\n   *\n   * @param element The HTML element to set attributes on.\n   * @param hierarchy The hierarchy object supplying the attributes.\n   * @returns {void}\n   */\n  public override parse(element: HTMLElement, hierarchy: Hierarchy): void {\n    for (const [name, value] of Object.entries(hierarchy.attributes as Record<string, AttributeValue>)) {\n      element.setAttribute(name, String(value));\n    }\n  }\n}\n","/**\n * @description\n * The \"childNodes\" option model — holds the child hierarchies of a hierarchy element.\n */\n\n\nimport type { Hierarchy } from \"../models/Hierarchy\";\nimport Option from \"../models/Option\";\n\n\n\n/**\n * @description\n * Defines the `childNodes` option, which lists (and can inherit) an element's children.\n * Children are never read from outer elements, as DOM nodes do not map to hierarchies.\n */\nexport default class ChildNodesOption extends Option {\n  /**\n   * @description\n   * Constructs a ChildNodesOption with its default metadata.\n   */\n  constructor() {\n    super(\"childNodes\", \"array\", [], []);\n  }\n\n\n  /**\n   * @description\n   * Inherits child nodes when `from.children.allow` is set. In \"append\" mode they are placed\n   * before or after the existing children (`from.children.placement`); otherwise they replace them.\n   *\n   * @param hierarchy The hierarchy object that inherits.\n   * @param childNodes The (already copied) child hierarchies to inherit.\n   * @returns {void}\n   */\n  public override inherit(hierarchy: Hierarchy, childNodes: unknown): void {\n    const incoming = childNodes as Array<Hierarchy>;\n    const { allow, placement } = hierarchy.from.children;\n\n    if (!allow) {\n      return;\n    }\n\n    if (hierarchy.from.mode === \"override\") {\n      hierarchy.childNodes = incoming;\n    }\n    else {\n      hierarchy.childNodes = placement === \"before\"\n        ? [...incoming, ...hierarchy.childNodes]\n        : [...hierarchy.childNodes, ...incoming];\n    }\n  }\n}\n","/**\n * @description\n * The \"classes\" option model — manages the CSS class list of a hierarchy element.\n */\n\n\nimport type { Hierarchy } from \"../models/Hierarchy\";\nimport Option from \"../models/Option\";\nimport { uniqueSorted } from \"../utils\";\n\n\n\n/**\n * @description\n * Defines the `classes` option, which sets or inherits the element's CSS class list.\n */\nexport default class ClassesOption extends Option {\n  /**\n   * @description\n   * Constructs a ClassesOption with its default metadata.\n   */\n  constructor() {\n    super(\"classes\", \"array\", [], []);\n  }\n\n\n  /**\n   * @description\n   * Inherits CSS classes. In \"append\" mode they are merged with the existing ones,\n   * otherwise they replace them. The result is de-duplicated and sorted.\n   *\n   * @param hierarchy The hierarchy object that inherits.\n   * @param classes The class list to inherit.\n   * @returns {void}\n   */\n  public override inherit(hierarchy: Hierarchy, classes: unknown): void {\n    const incoming = classes as Array<string>;\n    const merged = hierarchy.from.mode === \"append\" ? [...hierarchy.classes, ...incoming] : incoming;\n\n    hierarchy.classes = uniqueSorted(merged);\n  }\n\n\n  /**\n   * @description\n   * Reads the class list of an outer element.\n   *\n   * @param element The HTML element to read classes from.\n   * @returns {Array<string>} The element's class names.\n   */\n  public override getKeyFromElement(element: Element): unknown {\n    return [...element.classList];\n  }\n\n\n  /**\n   * @description\n   * Applies the class list to the target HTML element.\n   *\n   * @param element The HTML element to add classes to.\n   * @param hierarchy The hierarchy object supplying the class list.\n   * @returns {void}\n   */\n  public override parse(element: HTMLElement, hierarchy: Hierarchy): void {\n    // Some DOM implementations create an empty `class` attribute when adding no class.\n    if (hierarchy.classes.length > 0) {\n      element.classList.add(...hierarchy.classes);\n    }\n  }\n}\n","/**\n * @description\n * The \"type\" sub-option model for the `content` option.\n */\n\n\nimport Option from \"../../models/Option\";\n\n\n\n/**\n * @description\n * Defines the content type (\"text\" | \"html\") for an element's content option.\n */\nexport default class ContentTypeSubOption extends Option {\n  /**\n   * @description\n   * Constructs a ContentTypeSubOption with its default metadata.\n   */\n  constructor() {\n    super(\"type\", \"string\", [\"text\", \"html\"], \"text\");\n  }\n}\n","/**\n * @description\n * The \"value\" sub-option model for the `content` option.\n */\n\n\nimport Option from \"../../models/Option\";\n\n\n\n/**\n * @description\n * Holds the actual content string value for an element's `content` option.\n */\nexport default class ValueSubOption extends Option {\n  /**\n   * @description\n   * Constructs a ValueSubOption with its default metadata.\n   */\n  constructor() {\n    super(\"value\", \"string\", [], \"\");\n  }\n}\n","/**\n * @description\n * The \"content\" option model — manages the text or HTML content of a hierarchy element.\n */\n\n\nimport type { Content, Hierarchy } from \"../models/Hierarchy\";\nimport Option from \"../models/Option\";\nimport ContentTypeSubOption from \"./sub-options/ContentTypeSubOption\";\nimport ValueSubOption from \"./sub-options/ValueSubOption\";\n\n\n\n/**\n * @description\n * Defines the `content` option, which controls the inner text or HTML of an element.\n */\nexport default class ContentOption extends Option {\n  /**\n   * @description\n   * Constructs a ContentOption with its `type` and `value` sub-options.\n   */\n  constructor() {\n    super(\"content\", \"object\", [], undefined, {\n      type: new ContentTypeSubOption(),\n      value: new ValueSubOption(),\n    });\n  }\n\n\n  /**\n   * @description\n   * Inherits non-empty content. In \"append\" mode the incoming value is appended after the\n   * existing one (separated by a space) and the existing type is kept; empty existing content\n   * simply takes the incoming content. Otherwise the incoming content replaces it.\n   *\n   * @param hierarchy The hierarchy object that inherits.\n   * @param content The content object to inherit.\n   * @returns {void}\n   */\n  public override inherit(hierarchy: Hierarchy, content: unknown): void {\n    const incoming = content as Content;\n\n    if (incoming.value === \"\") {\n      return;\n    }\n\n    if (hierarchy.from.mode === \"append\" && hierarchy.content.value !== \"\") {\n      hierarchy.content = { ...hierarchy.content, value: `${hierarchy.content.value} ${incoming.value}` };\n    }\n    else {\n      hierarchy.content = { ...incoming };\n    }\n  }\n\n\n  /**\n   * @description\n   * Reads the content of an outer element as HTML.\n   *\n   * @param element The HTML element to read content from.\n   * @returns {Content} The element's inner HTML as a content object.\n   */\n  public override getKeyFromElement(element: Element): unknown {\n    return { type: \"html\", value: element.innerHTML };\n  }\n\n\n  /**\n   * @description\n   * Applies non-empty content to the target HTML element.\n   *\n   * @param element The HTML element to set content on.\n   * @param hierarchy The hierarchy object supplying the content.\n   * @returns {void}\n   */\n  public override parse(element: HTMLElement, hierarchy: Hierarchy): void {\n    if (hierarchy.content.value === \"\") {\n      return;\n    }\n\n    if (hierarchy.content.type === \"text\") {\n      element.textContent = hierarchy.content.value;\n    }\n    else {\n      element.innerHTML = hierarchy.content.value;\n    }\n  }\n}\n","/**\n * @description\n * The \"dataset\" option model — manages the `data-*` attributes of a hierarchy element.\n */\n\n\nimport type { AttributeValue, Hierarchy } from \"../models/Hierarchy\";\nimport Option from \"../models/Option\";\n\n\n\n/**\n * @description\n * Defines the `dataset` option, which sets or inherits an element's `data-*` attributes.\n */\nexport default class DatasetOption extends Option {\n  /**\n   * @description\n   * Constructs a DatasetOption with its default metadata.\n   */\n  constructor() {\n    super(\"dataset\", \"object\", [], {});\n  }\n\n\n  /**\n   * @description\n   * Inherits dataset entries. In \"append\" mode existing entries win; otherwise incoming ones do.\n   *\n   * @param hierarchy The hierarchy object that inherits.\n   * @param dataset The dataset map to inherit.\n   * @returns {void}\n   */\n  public override inherit(hierarchy: Hierarchy, dataset: unknown): void {\n    const incoming = dataset as Record<string, string>;\n\n    hierarchy.dataset = hierarchy.from.mode === \"append\"\n      ? { ...incoming, ...hierarchy.dataset }\n      : { ...hierarchy.dataset, ...incoming };\n  }\n\n\n  /**\n   * @description\n   * Reads the dataset of an outer element.\n   *\n   * @param element The HTML element to read from.\n   * @returns {Record<string, string>} The element's dataset entries.\n   */\n  public override getKeyFromElement(element: Element): unknown {\n    return Object.fromEntries(Object.entries((element as HTMLElement).dataset));\n  }\n\n\n  /**\n   * @description\n   * Applies the dataset entries to the target HTML element.\n   *\n   * @param element The HTML element to set dataset entries on.\n   * @param hierarchy The hierarchy object supplying the dataset.\n   * @returns {void}\n   */\n  public override parse(element: HTMLElement, hierarchy: Hierarchy): void {\n    for (const [key, value] of Object.entries(hierarchy.dataset as Record<string, AttributeValue>)) {\n      element.dataset[key] = String(value);\n    }\n  }\n}\n","/**\n * @description\n * The \"ref\" option model — stores the reference key of a hierarchy element.\n */\n\n\nimport Option from \"../models/Option\";\n\n\n\n/**\n * @description\n * Defines the `ref` option, which identifies a hierarchy element for later referencing.\n */\nexport default class RefOption extends Option {\n  /**\n   * @description\n   * Constructs a RefOption with its default metadata.\n   */\n  constructor() {\n    super(\"ref\", \"string\", [], \"\");\n  }\n}\n","/**\n * @description\n * The \"allow\" sub-option for the `children` sub-option of `from`.\n */\n\n\nimport Option from \"../../models/Option\";\n\n\n\n/**\n * @description\n * Defines whether child nodes are included when inheriting from a referenced hierarchy.\n */\nexport default class ChildrenAllowSubOption extends Option {\n  /**\n   * @description\n   * Constructs a ChildrenAllowSubOption with its default metadata.\n   */\n  constructor() {\n    super(\"allow\", \"boolean\", [], false);\n  }\n}\n","/**\n * @description\n * The \"placement\" sub-option model for the `children` sub-option of `from`.\n */\n\n\nimport Option from \"../../models/Option\";\n\n\n\n/**\n * @description\n * Defines where inherited child nodes are placed (\"before\" | \"after\").\n */\nexport default class PlacementSubOption extends Option {\n  /**\n   * @description\n   * Constructs a PlacementSubOption with its default metadata.\n   */\n  constructor() {\n    super(\"placement\", \"string\", [\"before\", \"after\"], \"after\");\n  }\n}\n","/**\n * @description\n * The \"children\" sub-option model for the `from` option.\n */\n\n\nimport Option from \"../../models/Option\";\nimport ChildrenAllowSubOption from \"./ChildrenAllowSubOption\";\nimport PlacementSubOption from \"./PlacementSubOption\";\n\n\n\n/**\n * @description\n * Defines the child-node inheritance behaviour inside the `from` option.\n */\nexport default class ChildrenSubOption extends Option {\n  /**\n   * @description\n   * Constructs a ChildrenSubOption with its `allow` and `placement` sub-options.\n   */\n  constructor() {\n    super(\"children\", \"object\", [], undefined, {\n      allow: new ChildrenAllowSubOption(),\n      placement: new PlacementSubOption(),\n    });\n  }\n}\n","/**\n * @description\n * The \"include\" sub-option model for the `from` option.\n */\n\n\nimport type { InheritableOption } from \"../../models/Hierarchy\";\nimport Option from \"../../models/Option\";\n\n\n\n/**\n * @description\n * The option labels that can participate in inheritance.\n */\nexport const INHERITABLE: ReadonlyArray<InheritableOption> = [\n  \"name\",\n  \"id\",\n  \"classes\",\n  \"attributes\",\n  \"dataset\",\n  \"content\",\n  \"childNodes\",\n];\n\n\n/**\n * @description\n * Specifies which option keys should be included during inheritance.\n */\nexport default class IncludeSubOption extends Option {\n  /**\n   * @description\n   * Constructs an IncludeSubOption with its default metadata.\n   */\n  constructor() {\n    // The default is sorted like user-provided lists, so sanitizing stays idempotent.\n    super(\"include\", \"array\", INHERITABLE, [...INHERITABLE].sort());\n  }\n}\n","/**\n * @description\n * The \"exclude\" sub-option model for the `from` option.\n */\n\n\nimport Option from \"../../models/Option\";\nimport { INHERITABLE } from \"./IncludeSubOption\";\n\n\n\n/**\n * @description\n * Specifies which option keys should be excluded from inheritance.\n */\nexport default class ExcludeSubOption extends Option {\n  /**\n   * @description\n   * Constructs an ExcludeSubOption with its default metadata.\n   */\n  constructor() {\n    super(\"exclude\", \"array\", INHERITABLE, []);\n  }\n}\n","/**\n * @description\n * The \"mode\" sub-option model for the `from` option.\n */\n\n\nimport Option from \"../../models/Option\";\n\n\n\n/**\n * @description\n * Defines the inheritance mode (\"append\" | \"override\") for the `from` option.\n */\nexport default class ModeSubOption extends Option {\n  /**\n   * @description\n   * Constructs a ModeSubOption with its default metadata.\n   */\n  constructor() {\n    super(\"mode\", \"string\", [\"append\", \"override\"], \"append\");\n  }\n}\n","/**\n * @description\n * The \"from\" option model — defines the referencing and inheritance configuration.\n */\n\n\nimport Option from \"../models/Option\";\nimport RefOption from \"./RefOption\";\nimport ChildrenSubOption from \"./sub-options/ChildrenSubOption\";\nimport ExcludeSubOption from \"./sub-options/ExcludeSubOption\";\nimport IncludeSubOption from \"./sub-options/IncludeSubOption\";\nimport ModeSubOption from \"./sub-options/ModeSubOption\";\n\n\n\n/**\n * @description\n * Defines the `from` option, which controls how a hierarchy element inherits\n * properties from another referenced element.\n */\nexport default class FromOption extends Option {\n  /**\n   * @description\n   * Constructs a FromOption with its sub-options.\n   */\n  constructor() {\n    super(\"from\", \"object\", [], undefined, {\n      ref: new RefOption(),\n      mode: new ModeSubOption(),\n      children: new ChildrenSubOption(),\n      include: new IncludeSubOption(),\n      exclude: new ExcludeSubOption(),\n    });\n  }\n}\n","/**\n * @description\n * The \"id\" option model — manages the HTML element id attribute.\n */\n\n\nimport type { Hierarchy } from \"../models/Hierarchy\";\nimport Option from \"../models/Option\";\n\n\n\n/**\n * @description\n * Defines the `id` option, which sets or inherits the HTML element's id attribute.\n */\nexport default class IdOption extends Option {\n  /**\n   * @description\n   * Constructs an IdOption with its default metadata.\n   */\n  constructor() {\n    super(\"id\", \"string\", [], \"\");\n  }\n\n\n  /**\n   * @description\n   * Inherits a non-empty id. In \"append\" mode an existing id is kept.\n   *\n   * @param hierarchy The hierarchy object that inherits.\n   * @param id The id to inherit.\n   * @returns {void}\n   */\n  public override inherit(hierarchy: Hierarchy, id: unknown): void {\n    if (id !== \"\" && (hierarchy.from.mode === \"override\" || hierarchy.id === \"\")) {\n      hierarchy.id = id as string;\n    }\n  }\n\n\n  /**\n   * @description\n   * Reads the id of an outer element.\n   *\n   * @param element The HTML element to read from.\n   * @returns {string} The element's id.\n   */\n  public override getKeyFromElement(element: Element): unknown {\n    return element.id;\n  }\n\n\n  /**\n   * @description\n   * Applies a non-empty id to the target HTML element.\n   *\n   * @param element The HTML element to set the id on.\n   * @param hierarchy The hierarchy object supplying the id.\n   * @returns {void}\n   */\n  public override parse(element: HTMLElement, hierarchy: Hierarchy): void {\n    if (hierarchy.id !== \"\") {\n      element.id = hierarchy.id;\n    }\n  }\n}\n","/**\n * @description\n * The \"name\" option model — defines the HTML tag name of a hierarchy element.\n */\n\n\nimport type { Hierarchy } from \"../models/Hierarchy\";\nimport Option from \"../models/Option\";\n\n\n\n/**\n * @description\n * Defines the `name` option, which sets the HTML element tag (e.g. \"div\", \"span\").\n */\nexport default class NameOption extends Option {\n  /**\n   * @description\n   * Constructs a NameOption with its default metadata.\n   */\n  constructor() {\n    super(\"name\", \"string\", [], \"div\");\n  }\n\n\n  /**\n   * @description\n   * Inherits the tag name from a referenced hierarchy, in \"override\" mode only.\n   *\n   * @param hierarchy The hierarchy object that inherits.\n   * @param name The tag name to inherit.\n   * @returns {void}\n   */\n  public override inherit(hierarchy: Hierarchy, name: unknown): void {\n    if (hierarchy.from.mode === \"override\") {\n      hierarchy.name = name as string;\n    }\n  }\n}\n","/**\n * @description\n * The \"temmeIds\" option model — stores the internal path identifiers for a hierarchy element.\n */\n\n\nimport Option from \"../models/Option\";\n\n\n\n/**\n * @description\n * Defines the `temmeIds` option, which tracks the internal ID trail through the hierarchy tree.\n */\nexport default class TemmeIdsOption extends Option {\n  /**\n   * @description\n   * Constructs a TemmeIdsOption with its default metadata.\n   */\n  constructor() {\n    super(\"temmeIds\", \"array\", [], []);\n  }\n}\n","/**\n * @description\n * The \"templates\" option model — holds the template hierarchy objects for a hierarchy element.\n */\n\n\nimport Option from \"../models/Option\";\n\n\n\n/**\n * @description\n * Defines the `templates` option, which stores template sub-hierarchies used for inheritance.\n */\nexport default class TemplatesOption extends Option {\n  /**\n   * @description\n   * Constructs a TemplatesOption with its default metadata.\n   */\n  constructor() {\n    super(\"templates\", \"array\", [], []);\n  }\n}\n","/**\n * @description\n * The registry of all supported hierarchy options.\n */\n\n\nimport type Option from \"./models/Option\";\nimport AttributesOption from \"./options/AttributesOption\";\nimport ChildNodesOption from \"./options/ChildrenNodesOption\";\nimport ClassesOption from \"./options/ClassesOption\";\nimport ContentOption from \"./options/ContentOption\";\nimport DatasetOption from \"./options/DatasetOption\";\nimport FromOption from \"./options/FromOption\";\nimport IdOption from \"./options/IdOption\";\nimport NameOption from \"./options/NameOption\";\nimport RefOption from \"./options/RefOption\";\nimport TemmeIdsOption from \"./options/TemmeIdsOption\";\nimport TemplatesOption from \"./options/TemplatesOption\";\n\n\n\n/**\n * @description\n * The option labels that are not permitted inside template hierarchies.\n */\nexport const forbiddenOptions: ReadonlyArray<string> = [\"name\", \"childNodes\", \"templates\"];\n\n\n/**\n * @description\n * The lazily created option instances; built on first use so that importing\n * this module has no side effects.\n */\nlet registry: ReadonlyArray<Option> | undefined;\n\n\n/**\n * @description\n * Returns the ordered list of all recognised hierarchy options.\n * The order is the order in which options are sanitized and rendered.\n *\n * @returns {ReadonlyArray<Option>} The option instances.\n */\nexport function getOptions(): ReadonlyArray<Option> {\n  registry ??= [\n    new RefOption(),\n    new NameOption(),\n    new IdOption(),\n    new ContentOption(),\n    new TemmeIdsOption(),\n    new TemplatesOption(),\n    new ClassesOption(),\n    new ChildNodesOption(),\n    new AttributesOption(),\n    new DatasetOption(),\n    new FromOption(),\n  ];\n\n  return registry;\n}\n\n\n/**\n * @description\n * Finds a top-level option by its label.\n *\n * @param label The option label.\n * @returns {Option | undefined} The matching option, if any.\n */\nexport function findOption(label: string): Option | undefined {\n  return getOptions().find((option: Option) => option.label === label);\n}\n","/**\n * @description\n * Responsible for rendering hierarchy objects into live HTML trees.\n */\n\n\nimport type { Hierarchy } from \"./models/Hierarchy\";\nimport type Option from \"./models/Option\";\nimport { getTemmeId } from \"./idfier\";\nimport { getOptions } from \"./options\";\n\n\n\n/**\n * @description\n * Recursively renders a sanitized hierarchy into HTML elements, appending each one to its parent.\n *\n * @param hierarchy The hierarchy object to render.\n * @param parent The HTML element that will host the rendered element.\n * @param nodeCallback Invoked after each element is rendered, with its temmeId and hierarchy.\n * @param topParent When `true` the hierarchy maps to `parent` itself (no element is created).\n * @returns {void}\n */\nexport function parse(\n  hierarchy: Hierarchy,\n  parent: HTMLElement,\n  nodeCallback: (temmeId: string, currentHierarchy: Hierarchy) => void,\n  topParent: boolean = false,\n): void {\n  const element = topParent ? parent : parent.ownerDocument.createElement(hierarchy.name);\n\n  getOptions().forEach((option: Option) => option.parse(element, hierarchy));\n\n  if (!topParent) {\n    parent.appendChild(element);\n  }\n\n  nodeCallback(getTemmeId(hierarchy), hierarchy);\n\n  hierarchy.childNodes.forEach((child: Hierarchy) => parse(child, element, nodeCallback));\n}\n","/**\n * @description\n * The error thrown when hierarchies (indirectly) inherit from themselves.\n */\n\n\nimport TemmyError from \"../models/TemmyError\";\n\n\n\n/**\n * @description\n * The error thrown when hierarchies (indirectly) inherit from themselves.\n */\nexport default class CircularReferenceError extends TemmyError {\n  /** The name of the error. */\n  public override readonly name: string = \"CircularReferenceError\";\n\n\n  /**\n   * @description\n   * Constructs the error.\n   *\n   * @param reference The offending reference.\n   */\n  constructor(reference: string) {\n    super(reference.length > 0 ? `The “${reference}” reference is part of a circular inheritance chain` : \"\", \"A reference is part of a circular inheritance chain\");\n  }\n}\n","/**\n * @description\n * The error thrown when a reference points to nothing.\n */\n\n\nimport TemmyError from \"../models/TemmyError\";\n\n\n\n/**\n * @description\n * The error thrown when a reference points to nothing.\n */\nexport default class InvalidReferenceError extends TemmyError {\n  /** The name of the error. */\n  public override readonly name: string = \"InvalidReferenceError\";\n\n\n  /**\n   * @description\n   * Constructs the error.\n   *\n   * @param reference The offending reference.\n   */\n  constructor(reference: string) {\n    super(reference.length > 0 ? `“${reference}” is an invalid reference` : \"\", \"A reference is invalid\");\n  }\n}\n","/**\n * @description\n * The error thrown when a reference value is not valid.\n */\n\n\nimport TemmyError from \"../models/TemmyError\";\n\n\n\n/**\n * @description\n * The error thrown when a reference value is not valid.\n */\nexport default class InvalidReferenceOptionValueError extends TemmyError {\n  /** The name of the error. */\n  public override readonly name: string = \"InvalidReferenceOptionValueError\";\n\n\n  /**\n   * @description\n   * Constructs the error.\n   *\n   * @param message The message of the error; a generic one is used when empty.\n   * @param options The standard error options, e.g. the `cause`.\n   */\n  constructor(message: string, options?: ErrorOptions) {\n    super(message, \"“ref” options must not begin with the “@” symbol\", options);\n  }\n}\n","/**\n * @description\n * The error thrown when a template references a non-template object.\n */\n\n\nimport TemmyError from \"../models/TemmyError\";\n\n\n\n/**\n * @description\n * The error thrown when a template references a non-template object.\n */\nexport default class InvalidTemplateReferencingError extends TemmyError {\n  /** The name of the error. */\n  public override readonly name: string = \"InvalidTemplateReferencingError\";\n\n\n  /**\n   * @description\n   * Constructs the error.\n   *\n   * @param ref The template reference.\n   * @param target The referenced key.\n   */\n  constructor(ref: string, target: string) {\n    super(ref.length > 0 ? `The template with the reference “${ref}” is trying to reference “${target}” a non-template object` : \"\", \"Templates can only reference other templates.\");\n  }\n}\n","/**\n * @description\n * The error thrown when a hierarchy references an element out of its scope.\n */\n\n\nimport TemmyError from \"../models/TemmyError\";\n\n\n\n/**\n * @description\n * The error thrown when a hierarchy references an element out of its scope.\n */\nexport default class ReferenceOutOfScopeError extends TemmyError {\n  /** The name of the error. */\n  public override readonly name: string = \"ReferenceOutOfScopeError\";\n\n\n  /**\n   * @description\n   * Constructs the error.\n   *\n   * @param message The message of the error; a generic one is used when empty.\n   * @param options The standard error options, e.g. the `cause`.\n   */\n  constructor(message: string, options?: ErrorOptions) {\n    super(message, \"An object is referencing an element out of its scope\", options);\n  }\n}\n","/**\n * @description\n * Responsible for validating references and applying template and hierarchy inheritance.\n */\n\n\nimport type { Hierarchy, InheritableOption } from \"./models/Hierarchy\";\nimport type Option from \"./models/Option\";\nimport CircularReferenceError from \"./errors/CircularReferenceError\";\nimport InvalidReferenceError from \"./errors/InvalidReferenceError\";\nimport InvalidReferenceOptionValueError from \"./errors/InvalidReferenceOptionValueError\";\nimport InvalidTemplateReferencingError from \"./errors/InvalidTemplateReferencingError\";\nimport ReferenceOutOfScopeError from \"./errors/ReferenceOutOfScopeError\";\nimport { findOption } from \"./options\";\nimport { clone, isResolved, markResolved } from \"./utils\";\n\n\n\n/**\n * @description\n * A hierarchy (or template) of the tree, along with its position.\n */\nexport type ReferenceNode = {\n\n  /** The hierarchy or template object. */\n  hierarchy: Hierarchy;\n\n  /** The nesting depth; templates share the depth of the hierarchy that declares them. */\n  depth: number;\n\n  /** Whether the object is a template. */\n  isTemplate: boolean;\n};\n\n\n/**\n * @description\n * The state shared while resolving one tree.\n */\ntype Context = {\n\n  /** Every node of the tree, in lookup order. */\n  nodes: Array<ReferenceNode>;\n\n  /** The node of every hierarchy object of the tree. */\n  byHierarchy: Map<Hierarchy, ReferenceNode>;\n\n  /** The hierarchies whose inheritance is being resolved (used to detect cycles). */\n  resolving: Set<Hierarchy>;\n\n  /** The document (or any root node) that `@selector` references are queried in, if any. */\n  dom: ParentNode | undefined;\n};\n\n\n/**\n * @description\n * Validates every reference of a sanitized hierarchy tree, then applies inheritance in\n * dependency order: a hierarchy inherits only once the one it references is fully resolved.\n * Hierarchies resolved by a previous call are left untouched.\n *\n * @param root The root hierarchy to process.\n * @param dom The document `@selector` references are looked up in; when absent (e.g. no DOM),\n *   outer-element references are neither checked nor inherited.\n * @returns {void}\n */\nexport function process(root: Hierarchy, dom: ParentNode | undefined): void {\n  const nodes = collect(root, 1, false);\n  const context: Context = {\n    nodes,\n    byHierarchy: new Map(nodes.map((node: ReferenceNode) => [node.hierarchy, node])),\n    resolving: new Set(),\n    dom,\n  };\n  const pending = nodes.filter((node: ReferenceNode) => !isResolved(node.hierarchy));\n\n  pending.forEach((node: ReferenceNode) => validateReference(node, context));\n  pending.forEach((node: ReferenceNode) => validateTemplateReference(node, context));\n  pending.forEach((node: ReferenceNode) => validateScope(node, context));\n  pending.forEach((node: ReferenceNode) => resolve(node, context));\n}\n\n\n/**\n * @description\n * Lists a hierarchy, its children (recursively) and its templates with their depth.\n *\n * @param hierarchy The hierarchy to collect from.\n * @param depth The hierarchy's depth.\n * @param isTemplate Whether the hierarchy is a template.\n * @returns {Array<ReferenceNode>} The nodes, the hierarchy first.\n */\nfunction collect(hierarchy: Hierarchy, depth: number, isTemplate: boolean): Array<ReferenceNode> {\n  return [\n    { hierarchy, depth, isTemplate },\n    ...(hierarchy.childNodes ?? []).flatMap((child: Hierarchy) => collect(child, depth + 1, false)),\n    ...(hierarchy.templates ?? []).flatMap((template: Hierarchy) => collect(template, depth, true)),\n  ];\n}\n\n\n/**\n * @description\n * Finds the node a hierarchy references by name (never the hierarchy itself).\n *\n * @param node The referencing node.\n * @param context The resolution context.\n * @returns {ReferenceNode | undefined} The first node with a matching `ref`, if any.\n */\nfunction findReferenced(node: ReferenceNode, context: Context): ReferenceNode | undefined {\n  return context.nodes.find(\n    (candidate: ReferenceNode) => candidate.hierarchy.ref === node.hierarchy.from.ref && candidate !== node,\n  );\n}\n\n\n/**\n * @description\n * Tells whether a node references another hierarchy of the tree (as opposed to nothing\n * or an outer element).\n *\n * @param node The node to inspect.\n * @returns {boolean} `true` for inner references.\n */\nfunction hasInnerReference(node: ReferenceNode): boolean {\n  const { ref } = node.hierarchy.from;\n\n  return ref !== \"\" && !ref.startsWith(\"@\");\n}\n\n\n/**\n * @description\n * Looks an outer element up, turning malformed selectors into Temme errors.\n *\n * @param dom The root to query.\n * @param selector The CSS selector.\n * @returns {Element | null} The matching element, if any.\n * @throws {InvalidReferenceOptionValueError} When the selector is malformed.\n */\nfunction queryOuterElement(dom: ParentNode, selector: string): Element | null {\n  try {\n    return dom.querySelector(selector);\n  }\n  catch (error) {\n    throw new InvalidReferenceOptionValueError(`\"${selector}\" is not a valid selector`, { cause: error });\n  }\n}\n\n\n/**\n * @description\n * Checks that a node's `from.ref` points to an existing hierarchy, or to an existing\n * outer element for `@selector` references.\n *\n * @param node The node to validate.\n * @param context The resolution context.\n * @returns {void}\n * @throws {InvalidReferenceOptionValueError} When no outer element matches a `@selector`.\n * @throws {InvalidReferenceError} When no hierarchy has the referenced `ref`.\n */\nfunction validateReference(node: ReferenceNode, context: Context): void {\n  const { ref } = node.hierarchy.from;\n\n  if (ref.startsWith(\"@\")) {\n    const selector = ref.substring(1);\n\n    if (context.dom !== undefined && queryOuterElement(context.dom, selector) === null) {\n      throw new InvalidReferenceOptionValueError(`No outer element corresponds to the selector \"${selector}\"`);\n    }\n  }\n  else if (ref !== \"\" && findReferenced(node, context) === undefined) {\n    throw new InvalidReferenceError(ref);\n  }\n}\n\n\n/**\n * @description\n * Checks that templates only reference other templates (or outer elements).\n *\n * @param node The node to validate.\n * @param context The resolution context.\n * @returns {void}\n * @throws {InvalidTemplateReferencingError} When a template references a plain hierarchy.\n */\nfunction validateTemplateReference(node: ReferenceNode, context: Context): void {\n  if (node.isTemplate && hasInnerReference(node) && !(findReferenced(node, context) as ReferenceNode).isTemplate) {\n    throw new InvalidTemplateReferencingError(node.hierarchy.ref, node.hierarchy.from.ref);\n  }\n}\n\n\n/**\n * @description\n * Checks that a node does not reference a hierarchy nested deeper than itself.\n *\n * @param node The node to validate.\n * @param context The resolution context.\n * @returns {void}\n * @throws {ReferenceOutOfScopeError} When the referenced hierarchy is out of scope.\n */\nfunction validateScope(node: ReferenceNode, context: Context): void {\n  if (hasInnerReference(node) && (findReferenced(node, context) as ReferenceNode).depth > node.depth) {\n    throw new ReferenceOutOfScopeError(\"\");\n  }\n}\n\n\n/**\n * @description\n * Returns the option labels a node inherits: `include` minus `exclude`.\n *\n * @param node The inheriting node.\n * @returns {Array<InheritableOption>} The labels to inherit.\n */\nfunction getInheritedLabels(node: ReferenceNode): Array<InheritableOption> {\n  const { include, exclude } = node.hierarchy.from;\n\n  return include.filter((label: InheritableOption) => !exclude.includes(label));\n}\n\n\n/**\n * @description\n * Applies a node's inheritance, after resolving whatever it depends on.\n *\n * @param node The node to resolve.\n * @param context The resolution context.\n * @returns {void}\n * @throws {CircularReferenceError} When the node (indirectly) depends on itself.\n */\nfunction resolve(node: ReferenceNode, context: Context): void {\n  const { hierarchy } = node;\n  const { ref } = hierarchy.from;\n\n  if (context.resolving.has(hierarchy)) {\n    throw new CircularReferenceError(ref);\n  }\n\n  if (isResolved(hierarchy)) {\n    return;\n  }\n\n  context.resolving.add(hierarchy);\n\n  if (ref.startsWith(\"@\")) {\n    inheritFromElement(node, context);\n  }\n  else if (ref !== \"\") {\n    inheritFromHierarchy(node, findReferenced(node, context) as ReferenceNode, context);\n  }\n\n  context.resolving.delete(hierarchy);\n  markResolved(hierarchy);\n}\n\n\n/**\n * @description\n * Applies inheritance from an outer element. Options that can't be read from the DOM\n * (the tag name and the child nodes) are skipped.\n *\n * @param node The inheriting node.\n * @param context The resolution context.\n * @returns {void}\n */\nfunction inheritFromElement(node: ReferenceNode, context: Context): void {\n  if (context.dom === undefined) {\n    return;\n  }\n\n  const element = queryOuterElement(context.dom, node.hierarchy.from.ref.substring(1)) as Element;\n\n  getInheritedLabels(node).forEach((label: InheritableOption) => {\n    const option = findOption(label) as Option;\n    const value = option.getKeyFromElement(element);\n\n    if (value !== null) {\n      option.inherit(node.hierarchy, value);\n    }\n  });\n}\n\n\n/**\n * @description\n * Applies inheritance from another hierarchy of the tree, resolving it first.\n * Inherited values are copied, so the two hierarchies never share mutable state.\n * Options the source doesn't hold (templates have no tag name and no children) are skipped,\n * and so are child nodes unless `from.children.allow` is set.\n *\n * @param node The inheriting node.\n * @param source The referenced node.\n * @param context The resolution context.\n * @returns {void}\n */\nfunction inheritFromHierarchy(node: ReferenceNode, source: ReferenceNode, context: Context): void {\n  resolve(source, context);\n\n  getInheritedLabels(node)\n    .filter((label: InheritableOption) => Object.hasOwn(source.hierarchy, label))\n    .filter((label: InheritableOption) => label !== \"childNodes\" || node.hierarchy.from.children.allow)\n    .forEach((label: InheritableOption) => {\n      const value = label === \"childNodes\"\n        ? inheritChildNodes(source, context)\n        : clone(source.hierarchy[label]);\n\n      (findOption(label) as Option).inherit(node.hierarchy, value);\n    });\n}\n\n\n/**\n * @description\n * Builds the child nodes a node inherits: fully resolved copies of the source's children,\n * stripped of their `ref` so that they never shadow the originals.\n *\n * @param source The referenced (and already resolved) node.\n * @param context The resolution context.\n * @returns {Array<Hierarchy>} The copied children.\n */\nfunction inheritChildNodes(source: ReferenceNode, context: Context): Array<Hierarchy> {\n  collect(source.hierarchy, source.depth, source.isTemplate)\n    .forEach((descendant: ReferenceNode) => resolve(context.byHierarchy.get(descendant.hierarchy) as ReferenceNode, context));\n\n  const copies = clone(source.hierarchy.childNodes);\n\n  copies.forEach(stripReferences);\n\n  return copies;\n}\n\n\n/**\n * @description\n * Clears the `ref` of a copied hierarchy and of everything it contains.\n *\n * @param hierarchy The copied hierarchy.\n * @returns {void}\n */\nfunction stripReferences(hierarchy: Hierarchy): void {\n  hierarchy.ref = \"\";\n  hierarchy.childNodes?.forEach(stripReferences);\n  hierarchy.templates?.forEach(stripReferences);\n}\n","/**\n * @description\n * Responsible for sanitizing hierarchy input and populating option defaults.\n */\n\n\nimport type { Hierarchy } from \"./models/Hierarchy\";\nimport type Option from \"./models/Option\";\nimport { forbiddenOptions, getOptions } from \"./options\";\nimport { uniqueSorted } from \"./utils\";\n\n\n\n/**\n * @description\n * Sanitizes a hierarchy object in place, recursively: missing options get a fresh default,\n * and list values (classes, include, exclude) are de-duplicated and sorted.\n * Sanitizing is idempotent.\n *\n * @param hierarchy The hierarchy object to sanitize.\n * @param isTemplate Whether the object is a template (forbidden options are left out).\n * @returns {void}\n */\nexport function sanitize(hierarchy: Hierarchy, isTemplate: boolean = false): void {\n  getOptions()\n    .filter((option: Option) => !isTemplate || !forbiddenOptions.includes(option.label))\n    .forEach((option: Option) => sanitizeOption(hierarchy, option));\n\n  hierarchy.classes = uniqueSorted(hierarchy.classes);\n\n  hierarchy.childNodes?.forEach((child: Hierarchy) => sanitize(child));\n  hierarchy.templates?.forEach((template: Hierarchy) => sanitize(template, true));\n}\n\n\n/**\n * @description\n * Sanitizes a single option entry on a (sub-)hierarchy object: populates a fresh default\n * when it is missing, normalises restricted list values, and recurses into sub-options.\n *\n * @param target The object holding the option.\n * @param option The option descriptor to apply.\n * @returns {void}\n */\nfunction sanitizeOption(target: Record<string, unknown>, option: Option): void {\n  if (!Object.hasOwn(target, option.label)) {\n    target[option.label] = option.createDefault();\n\n    return;\n  }\n\n  if (option.type === \"array\" && option.values.length > 0) {\n    target[option.label] = uniqueSorted(target[option.label] as Array<unknown>);\n  }\n\n  if (option.keys !== undefined) {\n    const value = target[option.label] as Record<string, unknown>;\n\n    Object.values(option.keys).forEach((subOption: Option) => sanitizeOption(value, subOption));\n  }\n}\n","/**\n * @description\n * The error thrown when a hierarchy is not a valid plain object.\n */\n\n\nimport TemmyError from \"../models/TemmyError\";\n\n\n\n/**\n * @description\n * The error thrown when a hierarchy is not a valid plain object.\n */\nexport default class InvalidHierarchyError extends TemmyError {\n  /** The name of the error. */\n  public override readonly name: string = \"InvalidHierarchyError\";\n\n\n  /**\n   * @description\n   * Constructs the error.\n   *\n   * @param message The message of the error; a generic one is used when empty.\n   * @param options The standard error options, e.g. the `cause`.\n   */\n  constructor(message: string, options?: ErrorOptions) {\n    super(message, \"The hierarchy object is not valid\", options);\n  }\n}\n","/**\n * @description\n * The error thrown when an option is not recognised.\n */\n\n\nimport TemmyError from \"../models/TemmyError\";\n\n\n\n/**\n * @description\n * The error thrown when an option is not recognised.\n */\nexport default class InvalidOptionNameError extends TemmyError {\n  /** The name of the error. */\n  public override readonly name: string = \"InvalidOptionNameError\";\n\n\n  /**\n   * @description\n   * Constructs the error.\n   *\n   * @param option The offending option name.\n   */\n  constructor(option: string) {\n    super(option.length > 0 ? `“${option}” is not a valid option` : \"\", \"An option is not valid\");\n  }\n}\n","/**\n * @description\n * The error thrown when an option's value has the wrong type.\n */\n\n\nimport TemmyError from \"../models/TemmyError\";\n\n\n\n/**\n * @description\n * The error thrown when an option's value has the wrong type.\n */\nexport default class InvalidOptionTypeError extends TemmyError {\n  /** The name of the error. */\n  public override readonly name: string = \"InvalidOptionTypeError\";\n\n\n  /**\n   * @description\n   * Constructs the error.\n   *\n   * @param option The offending option name.\n   * @param type The offending value type.\n   */\n  constructor(option: string, type: string) {\n    super(option.length > 0 ? `The \"${option}\" option doesn't accept values of type \"${type}\"` : \"\", \"An option doesn't have a valid value type\");\n  }\n}\n","/**\n * @description\n * The error thrown when a `from` option is not valid.\n */\n\n\nimport TemmyError from \"../models/TemmyError\";\n\n\n\n/**\n * @description\n * The error thrown when a `from` option is not valid.\n */\nexport default class InvalidReferencingOptionError extends TemmyError {\n  /** The name of the error. */\n  public override readonly name: string = \"InvalidReferencingOptionError\";\n\n\n  /**\n   * @description\n   * Constructs the error.\n   *\n   * @param message The message of the error; a generic one is used when empty.\n   * @param options The standard error options, e.g. the `cause`.\n   */\n  constructor(message: string, options?: ErrorOptions) {\n    super(message, \"A referencing option is not valid\", options);\n  }\n}\n","/**\n * @description\n * The error thrown when a sub-option is not recognised.\n */\n\n\nimport TemmyError from \"../models/TemmyError\";\n\n\n\n/**\n * @description\n * The error thrown when a sub-option is not recognised.\n */\nexport default class InvalidSubOptionNameError extends TemmyError {\n  /** The name of the error. */\n  public override readonly name: string = \"InvalidSubOptionNameError\";\n\n\n  /**\n   * @description\n   * Constructs the error.\n   *\n   * @param option The offending option name.\n   * @param subOption The offending sub-option name.\n   */\n  constructor(option: string, subOption: string) {\n    super(option.length > 0 || subOption.length > 0 ? `The “${option}” option doesn't recognize “${subOption}” as a valid sub-option` : \"\", \"A sub-option is not valid\");\n  }\n}\n","/**\n * @description\n * The error thrown when a sub-option's value has the wrong type.\n */\n\n\nimport TemmyError from \"../models/TemmyError\";\n\n\n\n/**\n * @description\n * The error thrown when a sub-option's value has the wrong type.\n */\nexport default class InvalidSubOptionTypeError extends TemmyError {\n  /** The name of the error. */\n  public override readonly name: string = \"InvalidSubOptionTypeError\";\n\n\n  /**\n   * @description\n   * Constructs the error.\n   *\n   * @param subOption The offending sub-option name.\n   * @param type The offending value type.\n   */\n  constructor(subOption: string, type: string) {\n    super(subOption.length > 0 || type.length > 0 ? `The \"${subOption}\" sub-option doesn't accept values of type \"${type}\"` : \"\", \"A sub-option doesn't have a valid value type\");\n  }\n}\n","/**\n * @description\n * The error thrown when a sub-option's value is not allowed.\n */\n\n\nimport TemmyError from \"../models/TemmyError\";\n\n\n\n/**\n * @description\n * The error thrown when a sub-option's value is not allowed.\n */\nexport default class InvalidSubOptionValueError extends TemmyError {\n  /** The name of the error. */\n  public override readonly name: string = \"InvalidSubOptionValueError\";\n\n\n  /**\n   * @description\n   * Constructs the error.\n   *\n   * @param subOption The offending sub-option name.\n   * @param value The offending value.\n   */\n  constructor(subOption: string, value: string) {\n    super(subOption.length > 0 || value.length > 0 ? `The “${subOption}” sub-option doesn't accept “${value}” as a value` : \"\", \"A sub-option doesn't have a valid value\");\n  }\n}\n","/**\n * @description\n * The error thrown when a template does not have a `ref` option.\n */\n\n\nimport TemmyError from \"../models/TemmyError\";\n\n\n\n/**\n * @description\n * The error thrown when a template does not have a `ref` option.\n */\nexport default class InvalidTemplateError extends TemmyError {\n  /** The name of the error. */\n  public override readonly name: string = \"InvalidTemplateError\";\n\n\n  /**\n   * @description\n   * Constructs the error.\n   *\n   * @param message The message of the error; a generic one is used when empty.\n   * @param options The standard error options, e.g. the `cause`.\n   */\n  constructor(message: string, options?: ErrorOptions) {\n    super(message, \"A template does not have a “ref” option\", options);\n  }\n}\n","/**\n * @description\n * The error thrown when a template uses an option templates can't have.\n */\n\n\nimport TemmyError from \"../models/TemmyError\";\n\n\n\n/**\n * @description\n * The error thrown when a template uses an option templates can't have.\n */\nexport default class InvalidTemplateOptionError extends TemmyError {\n  /** The name of the error. */\n  public override readonly name: string = \"InvalidTemplateOptionError\";\n\n\n  /**\n   * @description\n   * Constructs the error.\n   *\n   * @param option The offending option name.\n   */\n  constructor(option: string) {\n    super(option.length > 0 ? `“${option}” is not a valid option to use in templates` : \"\", \"A template has an invalid option\");\n  }\n}\n","/**\n * @description\n * Responsible for validating hierarchy input — option names, types, values\n * and template constraints. Reference validation lives in the referencer.\n */\n\n\nimport { isObject } from \"@eoussama/core\";\nimport InvalidHierarchyError from \"./errors/InvalidHierarchyError\";\nimport InvalidOptionNameError from \"./errors/InvalidOptionNameError\";\nimport InvalidOptionTypeError from \"./errors/InvalidOptionTypeError\";\nimport InvalidReferenceOptionValueError from \"./errors/InvalidReferenceOptionValueError\";\nimport InvalidReferencingOptionError from \"./errors/InvalidReferencingOptionError\";\nimport InvalidSubOptionNameError from \"./errors/InvalidSubOptionNameError\";\nimport InvalidSubOptionTypeError from \"./errors/InvalidSubOptionTypeError\";\nimport InvalidSubOptionValueError from \"./errors/InvalidSubOptionValueError\";\nimport InvalidTemplateError from \"./errors/InvalidTemplateError\";\nimport InvalidTemplateOptionError from \"./errors/InvalidTemplateOptionError\";\nimport Option from \"./models/Option\";\nimport { findOption, forbiddenOptions } from \"./options\";\n\n\n\n/**\n * @description\n * Checks whether a value is a structurally valid hierarchy (a non-null, non-array object).\n *\n * @param hierarchy The value to check.\n * @returns {boolean} `true` when the value can be used as a hierarchy.\n */\nexport function isValidHierarchy(hierarchy: unknown): hierarchy is Record<string, unknown> {\n  return isObject(hierarchy);\n}\n\n\n/**\n * @description\n * Checks whether a value is an HTML element. Elements from other realms (iframes) are\n * recognised, and environments without a DOM simply get `false`.\n *\n * @param target The value to check.\n * @returns {boolean} `true` when the value is an HTMLElement.\n */\nexport function isValidHTMLElement(target: unknown): target is HTMLElement {\n  if (!isObject(target)) {\n    return false;\n  }\n\n  const HTMLElementOfRealm = (target as Partial<Node>).ownerDocument?.defaultView?.HTMLElement ?? globalThis.HTMLElement;\n\n  return typeof HTMLElementOfRealm === \"function\" && target instanceof HTMLElementOfRealm;\n}\n\n\n/**\n * @description\n * Recursively validates all option names, types, values and sub-options of a hierarchy,\n * its templates and its children.\n *\n * @param hierarchy The hierarchy object to validate.\n * @param isTemplate Whether the object is a template (forbidden options are rejected).\n * @returns {void}\n * @throws {InvalidHierarchyError} When the hierarchy is not a plain object.\n * @throws {InvalidOptionNameError} When an unrecognised option key is encountered.\n * @throws {InvalidTemplateOptionError} When a template contains a forbidden option.\n * @throws {InvalidOptionTypeError} When an option's value has the wrong type.\n * @throws {InvalidSubOptionNameError} When an unrecognised sub-option key is encountered.\n * @throws {InvalidSubOptionTypeError} When a sub-option's value has the wrong type.\n * @throws {InvalidSubOptionValueError} When a sub-option's value is not in the allowed set.\n * @throws {InvalidReferenceOptionValueError} When the `ref` option starts with \"@\".\n * @throws {InvalidReferencingOptionError} When `from` lacks `ref`, or uses both `include` and `exclude`.\n */\nexport function validateOptions(hierarchy: unknown, isTemplate: boolean = false): void {\n  if (!isValidHierarchy(hierarchy)) {\n    throw new InvalidHierarchyError(\"\");\n  }\n\n  for (const [label, value] of Object.entries(hierarchy)) {\n    const option = findOption(label);\n\n    if (option === undefined) {\n      throw new InvalidOptionNameError(label);\n    }\n\n    if (isTemplate && forbiddenOptions.includes(label)) {\n      throw new InvalidTemplateOptionError(label);\n    }\n\n    const { valid, type } = Option.validateOptionType(value, option);\n\n    if (!valid) {\n      throw new InvalidOptionTypeError(label, type);\n    }\n\n    // No top-level option restricts its values; only sub-options (e.g. `mode`) do.\n    if (option.keys !== undefined) {\n      validateSubOptions(label, value as Record<string, unknown>, option.keys);\n    }\n  }\n\n  if (typeof hierarchy.ref === \"string\" && hierarchy.ref.startsWith(\"@\")) {\n    throw new InvalidReferenceOptionValueError(\"\");\n  }\n\n  if (isObject(hierarchy.from)) {\n    validateFrom(hierarchy.from);\n  }\n\n  (hierarchy.templates as Array<unknown> | undefined)?.forEach((template: unknown) => validateTemplates(template));\n  (hierarchy.childNodes as Array<unknown> | undefined)?.forEach((child: unknown) => validateOptions(child));\n}\n\n\n/**\n * @description\n * Validates a template: it must be an object with a `ref` and only template-friendly options.\n *\n * @param template The template object to validate.\n * @returns {void}\n * @throws {InvalidHierarchyError} When the template is not a plain object.\n * @throws {InvalidTemplateError} When the template is missing a `ref` key.\n * @throws {InvalidTemplateOptionError} When the template contains a forbidden option.\n */\nexport function validateTemplates(template: unknown): void {\n  if (!isValidHierarchy(template)) {\n    throw new InvalidHierarchyError(\"\");\n  }\n\n  if (!Object.hasOwn(template, \"ref\")) {\n    throw new InvalidTemplateError(\"\");\n  }\n\n  validateOptions(template, true);\n}\n\n\n/**\n * @description\n * Validates the sub-options of an object option's value.\n *\n * @param optionName The name of the parent option being validated.\n * @param value The value object containing sub-option entries.\n * @param subOptions The expected sub-options, keyed by label.\n * @returns {void}\n * @throws {InvalidSubOptionNameError} When an unrecognised sub-option key is found.\n * @throws {InvalidSubOptionTypeError} When a sub-option has the wrong type.\n * @throws {InvalidSubOptionValueError} When a sub-option has a disallowed value.\n */\nfunction validateSubOptions(optionName: string, value: Record<string, unknown>, subOptions: Readonly<Record<string, Option>>): void {\n  for (const [label, subValue] of Object.entries(value)) {\n    const subOption = Object.hasOwn(subOptions, label) ? subOptions[label] : undefined;\n\n    if (subOption === undefined) {\n      throw new InvalidSubOptionNameError(optionName, label);\n    }\n\n    const { valid, type } = Option.validateOptionType(subValue, subOption);\n\n    if (!valid) {\n      throw new InvalidSubOptionTypeError(label, type);\n    }\n\n    if (!Option.validateOptionValue(subValue, subOption)) {\n      throw new InvalidSubOptionValueError(label, String(subValue));\n    }\n\n    if (subOption.keys !== undefined) {\n      validateSubOptions(label, subValue as Record<string, unknown>, subOption.keys);\n    }\n  }\n}\n\n\n/**\n * @description\n * Validates the referencing constraints of a `from` value: it needs a `ref`, and it\n * can't restrict inheritance with both a non-empty `include` and a non-empty `exclude`.\n *\n * @param from The `from` option value.\n * @returns {void}\n * @throws {InvalidReferencingOptionError} When a constraint is violated.\n */\nfunction validateFrom(from: Record<string, unknown>): void {\n  if (!Object.hasOwn(from, \"ref\")) {\n    throw new InvalidReferencingOptionError(\n      \"The “from” option must always have a “ref” sub-option\",\n    );\n  }\n\n  const include = from.include as Array<string> | undefined;\n  const exclude = from.exclude as Array<string> | undefined;\n\n  if ((include?.length ?? 0) > 0 && (exclude?.length ?? 0) > 0) {\n    throw new InvalidReferencingOptionError(\n      \"The “from” option can’t have both the “include” and “exclude” sub-options at the same time\",\n    );\n  }\n}\n","/**\n * @description\n * The error thrown when an option's value is not allowed.\n */\n\n\nimport TemmyError from \"../models/TemmyError\";\n\n\n\n/**\n * @description\n * The error thrown when an option's value is not allowed.\n */\nexport default class InvalidOptionValueError extends TemmyError {\n  /** The name of the error. */\n  public override readonly name: string = \"InvalidOptionValueError\";\n\n\n  /**\n   * @description\n   * Constructs the error.\n   *\n   * @param option The offending option name.\n   * @param value The offending value.\n   */\n  constructor(option: string, value: string) {\n    super(option.length > 0 ? `The “${option}” option doesn't accept “${value}” as a value` : \"\", \"An option doesn't have a valid value\");\n  }\n}\n","/**\n * Temme (or Emmet in reverse) is to javascript what Emmet is to HTML and CSS,\n * with no doubts, Emmet saved us from the headache of working with HTML and CSS,\n * and now, Temme is doing Javascript the same favour too.\n *\n * https://github.com/eoussama/temmejs\n */\n\n\nimport type { Hierarchy } from \"./modules/models/Hierarchy\";\nimport { isPromise, tryCatchSync } from \"@eoussama/core\";\nimport InvalidTargetError from \"./modules/errors/InvalidTargetError\";\nimport * as Idfier from \"./modules/idfier\";\nimport TemmyError from \"./modules/models/TemmyError\";\nimport * as Parser from \"./modules/parser\";\nimport * as Referencer from \"./modules/referencer\";\nimport * as Sanitizer from \"./modules/sanitizer\";\nimport { clone } from \"./modules/utils\";\nimport * as Validator from \"./modules/validator\";\n\n\n\nexport { default as CircularReferenceError } from \"./modules/errors/CircularReferenceError\";\nexport { default as InvalidHierarchyError } from \"./modules/errors/InvalidHierarchyError\";\nexport { default as InvalidOptionNameError } from \"./modules/errors/InvalidOptionNameError\";\nexport { default as InvalidOptionTypeError } from \"./modules/errors/InvalidOptionTypeError\";\nexport { default as InvalidOptionValueError } from \"./modules/errors/InvalidOptionValueError\";\nexport { default as InvalidReferenceError } from \"./modules/errors/InvalidReferenceError\";\nexport { default as InvalidReferenceOptionValueError } from \"./modules/errors/InvalidReferenceOptionValueError\";\nexport { default as InvalidReferencingOptionError } from \"./modules/errors/InvalidReferencingOptionError\";\nexport { default as InvalidSubOptionNameError } from \"./modules/errors/InvalidSubOptionNameError\";\nexport { default as InvalidSubOptionTypeError } from \"./modules/errors/InvalidSubOptionTypeError\";\nexport { default as InvalidSubOptionValueError } from \"./modules/errors/InvalidSubOptionValueError\";\nexport { default as InvalidTargetError } from \"./modules/errors/InvalidTargetError\";\nexport { default as InvalidTemplateError } from \"./modules/errors/InvalidTemplateError\";\nexport { default as InvalidTemplateOptionError } from \"./modules/errors/InvalidTemplateOptionError\";\nexport { default as InvalidTemplateReferencingError } from \"./modules/errors/InvalidTemplateReferencingError\";\nexport { default as ReferenceOutOfScopeError } from \"./modules/errors/ReferenceOutOfScopeError\";\nexport type { AttributeValue, Content, From, FromInput, Hierarchy, HierarchyInput, InheritableOption, TemplateInput } from \"./modules/models/Hierarchy\";\nexport { default as TemmyError } from \"./modules/models/TemmyError\";\n\n\n/**\n * @description\n * Called once the whole tree has been rendered. May be async: a rejected promise is\n * reported with `console.warn` and never affects the caller.\n */\nexport type ParseEndCallback = (resultedHierarchy: Hierarchy) => void | Promise<void>;\n\n\n/**\n * @description\n * Called right after each element is rendered (the root first, then depth-first).\n */\nexport type ParseNodeCallback = (temmeId: string, currentHierarchy: Hierarchy) => void;\n\n\n/**\n * @description\n * The outcome of `validate`.\n */\nexport type ValidationResult = {\n\n  /** `true` when the hierarchy can be parsed. */\n  valid: boolean;\n\n  /** The error `parse` would throw, or `null` when valid. */\n  error: unknown;\n};\n\n\n/**\n * @description\n * The entry point of Temme — validates, sanitizes, resolves the references of and renders\n * a hierarchy object into a live HTML tree.\n *\n * The hierarchy object is completed in place (defaults, inherited values, temmeIds) and\n * returned. Parsing the returned object again renders the same tree.\n *\n * @param hierarchy The hierarchy object that maps the HTML skeleton.\n * @param target The HTML element that will host the rendered skeleton.\n * @param endCallback The function that executes when the skeleton has been fully rendered.\n * @param nodeCallback The function that executes whenever an individual element is rendered.\n * @returns {Hierarchy} The completed hierarchy object.\n * @throws {TemmyError} When the target or the hierarchy is invalid; the message is prefixed\n *   with \"[Temme]: \". Errors thrown by the callbacks are re-thrown untouched.\n */\nexport function parse(\n  hierarchy: object,\n  target: HTMLElement,\n  endCallback: ParseEndCallback = () => {},\n  nodeCallback: ParseNodeCallback = () => {},\n): Hierarchy {\n  const resolved = prepare(hierarchy, target);\n\n  Parser.parse(resolved, target, nodeCallback, true);\n\n  const result = endCallback(resolved);\n\n  if (isPromise(result)) {\n    result.then(undefined, (error: unknown) => {\n      console.warn(\"[Temme]: async end-callback rejected:\", error);\n    });\n  }\n\n  return resolved;\n}\n\n\n/**\n * @description\n * Validates a hierarchy object without rendering or modifying it: runs every check `parse`\n * runs (options, templates, references, scopes and cycles) on a copy.\n *\n * @param hierarchy The hierarchy object to validate.\n * @returns {ValidationResult} `valid` is `true` when the hierarchy is well-formed,\n *   otherwise `error` holds the error `parse` would throw.\n */\nexport function validate(hierarchy: object): ValidationResult {\n  const [error] = tryCatchSync<Error, void>(() => {\n    Validator.validateOptions(hierarchy);\n\n    const copy = clone(hierarchy) as Hierarchy;\n\n    Sanitizer.sanitize(copy);\n    Referencer.process(copy, globalThis.document);\n  });\n\n  return { valid: error === null, error };\n}\n\n\n/**\n * @description\n * Validates and completes a hierarchy, prefixing Temme's own errors with \"[Temme]: \".\n *\n * @param hierarchy The hierarchy object.\n * @param target The host element.\n * @returns {Hierarchy} The completed hierarchy.\n */\nfunction prepare(hierarchy: object, target: HTMLElement): Hierarchy {\n  try {\n    if (!Validator.isValidHTMLElement(target)) {\n      throw new InvalidTargetError(\"\");\n    }\n\n    Validator.validateOptions(hierarchy);\n\n    const completed = hierarchy as Hierarchy;\n\n    Sanitizer.sanitize(completed);\n    Referencer.process(completed, target.ownerDocument);\n    Idfier.idfy(completed);\n\n    return completed;\n  }\n  catch (error) {\n    if (error instanceof TemmyError) {\n      error.message = `[Temme]: ${error.message}.`;\n    }\n\n    throw error;\n  }\n}\n"],"mappings":";;;;;;;AAIA,IAAqB,aAArB,cAAwC,MAAM;;CAE5C,OAAwC;;;;;;;;;CAWxC,YAAY,SAAiB,WAAmB,4BAA4B,SAAwB;EAClG,MAAM,QAAQ,SAAS,IAAI,UAAU,UAAU,OAAO;CACxD;AACF;;;;;;;;;;ACNA,IAAqB,qBAArB,cAAgD,WAAW;;CAEzD,OAAwC;;;;;;;;CAUxC,YAAY,SAAiB,SAAwB;EACnD,MAAM,SAAS,0CAA0C,OAAO;CAClE;AACF;;ACZA,MAAM,WAAW;;;;;;;;;;;;AAcjB,SAAgB,KACd,WACA,WAA0B,CAAC,GAC3B,aAAsB,OACtB,uBAAoB,IAAI,IAAI,GACtB;CACN,MAAM,SAAS,aAAA,IAAA;CACf,IAAI,UAAU,gBAAgB,MAAM;CAEpC,OAAO,KAAK,IAAI,OAAO,GACrB,UAAU,gBAAgB,MAAM;CAGlC,KAAK,IAAI,OAAO;CAChB,UAAU,WAAW,CAAC,GAAG,UAAU,OAAO;CAE1C,UAAU,YAAY,SAAS,UAAqB,KAAK,OAAO,UAAU,UAAU,OAAO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