UNPKG

tiny-essentials

Version:

Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.

1 lines 80.1 kB
(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.d(e,{TinyHtml:()=>H});var r={};t.r(r),t.d(r,{areElsCollBottom:()=>o,areElsCollLeft:()=>i,areElsCollPerfBottom:()=>l,areElsCollPerfLeft:()=>c,areElsCollPerfRight:()=>p,areElsCollPerfTop:()=>a,areElsCollRight:()=>s,areElsCollTop:()=>n,areElsColliding:()=>f,areElsPerfColliding:()=>m,getElsCollDetails:()=>w,getElsCollDirDepth:()=>b,getElsCollOverlap:()=>h,getElsCollOverlapPos:()=>g,getElsColliding:()=>u,getElsPerfColliding:()=>d,getElsRelativeCenterOffset:()=>E,getRectCenter:()=>y});const n=(t,e)=>t.bottom<e.top,o=(t,e)=>t.top>e.bottom,i=(t,e)=>t.right<e.left,s=(t,e)=>t.left>e.right,a=(t,e)=>t.bottom<=e.top,l=(t,e)=>t.top>=e.bottom,c=(t,e)=>t.right<=e.left,p=(t,e)=>t.left>=e.right,f=(t,e)=>!(i(t,e)||s(t,e)||n(t,e)||o(t,e)),m=(t,e)=>!(c(t,e)||p(t,e)||a(t,e)||l(t,e)),u=(t,e)=>i(t,e)?"left":s(t,e)?"right":n(t,e)?"top":o(t,e)?"bottom":null,d=(t,e)=>c(t,e)?"left":p(t,e)?"right":a(t,e)?"top":l(t,e)?"bottom":null,h=(t,e)=>({overlapLeft:e.right-t.left,overlapRight:t.right-e.left,overlapTop:e.bottom-t.top,overlapBottom:t.bottom-e.top}),g=({overlapLeft:t=-1,overlapRight:e=-1,overlapTop:r=-1,overlapBottom:n=-1}={})=>({dirX:t<e?"right":"left",dirY:r<n?"bottom":"top"}),y=t=>({x:t.left+t.width/2,y:t.top+t.height/2});function E(t,e){const r=t.left+t.width/2,n=t.top+t.height/2;return{x:e.left+e.width/2-r,y:e.top+e.height/2-n}}function b(t,e){if(!m(t,e))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:i}=h(t,e),{dirX:s,dirY:a}=g({overlapLeft:r,overlapRight:n,overlapTop:o,overlapBottom:i}),l=Math.min(r,n),c=Math.min(o,i);let p;return p=l<c?s:a,{inDir:p,dirX:s,dirY:a,depthX:l,depthY:c}}function w(t,e){const r=m(t,e),n={in:null,x:null,y:null},o={y:null,x:null},i={top:0,bottom:0,left:0,right:0},{overlapLeft:s,overlapRight:a,overlapTop:l,overlapBottom:c}=h(e,t);i.top=l,i.bottom=c,i.left=s,i.right=a;const p=Object.entries(i).filter(([,t])=>t>0).sort((t,e)=>t[1]-e[1]),{dirX:f,dirY:u}=g({overlapLeft:a,overlapRight:s,overlapTop:c,overlapBottom:l});return n.y=u,n.x=f,i.bottom<0?o.y="bottom":i.top<0&&(o.y="top"),i.left<0?o.x="left":i.right<0&&(o.x="right"),n.in=r?i.top===i.bottom&&i.bottom===i.left&&i.left===i.right?"center":p.length?p[0][0]:"top":null,{dirs:n,depth:i,isNeg:o}}const T=class{#t;get el(){return this.#t}set el(t){if(this.#t)throw new Error("The observed element has already been set and cannot be reassigned.");if(void 0!==t&&!(t instanceof Element))throw new TypeError("The observed element must be a valid DOM Element.");this.#t=t}#e={};get settings(){return this.#e}set settings(t){if("object"!=typeof t||null===t)throw new TypeError("settings must be a non-null object.");this.#e=t}#r=null;get observer(){return this.#r}#n=[];get detectors(){return this.#n.map(t=>[t[0],t[1]])}set detectors(t){if(!Array.isArray(t))throw new TypeError("detectors must be an array.");const e=[];for(const[r,n]of t){if("string"!=typeof r)throw new TypeError("Detector name must be a string.");if("function"!=typeof n)throw new TypeError(`Detector handler for "${r}" must be a function.`);e.push([r,n])}this.#n=e}get isActive(){return!!this.#r}get size(){return this.#n.length}constructor({el:t,initDetectors:e=[],initCfg:r={}}={}){this.el=t,e.length&&(this.detectors=e),r&&(this.settings=r)}clear(){this.#n=[]}start(){if(!this.#t)throw new Error("Cannot start observation: no target element has been set.");this.#r||(this.#r=new MutationObserver(t=>{t.forEach((t,e,r)=>this.#n.forEach(n=>n[1](t,e,r)))}),this.#r.observe(this.#t,this.#e))}stop(){this.#r&&(this.#r.disconnect(),this.#r=null)}add(t,e){this.#o(t,e),this.#n.push([t,e])}insertAtStart(t,e){this.#o(t,e),this.#n.unshift([t,e])}insertAt(t,e,r,n="after"){if(this.#o(e,r),"number"!=typeof t||t<0||t>=this.#n.length)throw new RangeError("Invalid index for insertDetectorAt.");const o="before"===n?t:t+1;this.#n.splice(o,0,[e,r])}removeAt(t){if("number"!=typeof t||t<0||t>=this.#n.length)throw new RangeError("Invalid index for removeDetectorAt.");this.#n.splice(t,1)}removeAround(t,e=0,r=0){if("number"!=typeof t||t<0||t>=this.#n.length)throw new RangeError("Invalid index for removeDetectorsAround.");const n=Math.max(0,t-e),o=e+1+r;this.#n.splice(n,o)}isIndexUsed(t){return t>=0&&t<this.#n.length}hasHandler(t){if("function"!=typeof t)throw new TypeError("Handler must be a function.");return this.#n.some(([e,r])=>r===t)}#o(t,e){if("string"!=typeof t||!t.trim())throw new TypeError("Detector name must be a non-empty string.");if("function"!=typeof e)throw new TypeError(`Detector handler for "${t}" must be a function.`)}destroy(){this.stop(),this.clear()}},{areElsColliding:v,areElsPerfColliding:A,areElsCollTop:_,areElsCollBottom:S,areElsCollLeft:x,areElsCollRight:C}=r,N=new WeakMap,D=new WeakMap,L=new WeakMap,W=new WeakMap,k={top:new WeakMap,bottom:new WeakMap,left:new WeakMap,right:new WeakMap};class P{static Utils={...r};static#i=1;static get version(){return this.#i}static#s=!1;static get elemDebug(){return P.#s}static set elemDebug(t){if("boolean"!=typeof t)throw new TypeError("Expected a boolean value for elemDebug");P.#s=t}static _debugElemError(t,e){if(!P.#s)return;const r="[TinyHtml Debug] Element validation error";if(console.groupCollapsed(`${r}${e?" — details below":""}`),console.error(r),"undefined"!=typeof Error&&"function"==typeof Error.captureStackTrace){const t=new Error(r);Error.captureStackTrace(t,P._debugElemError),console.error(t.stack)}else console.trace(r);if(Array.isArray(t)){const e=t.map((t,e)=>({index:e,typeOf:null===t?"null":typeof t,constructor:t?.constructor?.name??(null===t?"null":"primitive"),summary:"undefined"!=typeof Element&&t instanceof Element?`${t.tagName?.toLowerCase?.()??"element"}#${t.id||""}.${String(t.className||"").trim().replace(/\s+/g,".")}`:t&&"object"==typeof t&&"nodeType"in t?`nodeType:${t.nodeType}`:"",value:t}));console.table(e)}else console.warn('[TinyHtml Debug] "elems" is not an array:',t);arguments.length>1&&(console.error("[TinyHtml Debug] Problematic element:",e),e&&"object"==typeof e&&console.dir(e)),console.groupEnd()}static parseStyle(t){const e={};return t.split(";").forEach(t=>{const[r,n]=t.split(":").map(t=>t&&t.trim());r&&n&&(e[r]=n)}),e}static#a=!0;static get autoStartElemObserver(){return P.#a}static set autoStartElemObserver(t){if("boolean"!=typeof t)throw new TypeError("autoStartElemObserver must be a boolean.");P.#a=t}static#l=new T({el:"undefined"!=typeof window&&void 0!==window.document?window.document.documentElement:void 0,initDetectors:[["tinyStyleEvent",t=>{if("attributes"!==t.type||"style"!==t.attributeName||!(t.target instanceof HTMLElement))return;const e=t.oldValue||"",r=t.target.getAttribute("style")||"",n=function(t,e){const r={added:{},removed:{},modified:{}};for(const n in t)n in e?t[n]!==e[n]&&(r.modified[n]={old:t[n],new:e[n]}):r.removed[n]=t[n];for(const n in e)n in t||(r.added[n]=e[n]);return r}(P.parseStyle(e),P.parseStyle(r));(Object.keys(n.added).length||Object.keys(n.removed).length||Object.keys(n.modified).length)&&t.target.dispatchEvent(new CustomEvent("tinyhtml.stylechanged",{detail:n}))}],["tinyClassEvent",t=>{if("attributes"!==t.type||"class"!==t.attributeName||!(t.target instanceof HTMLElement))return;const e=t.oldValue||"",r=t.target.className||"",n=function(t,e){const r=t.filter(t=>!e.includes(t));return{added:e.filter(e=>!t.includes(e)),removed:r}}(e.split(/\s+/).filter(Boolean),r.split(/\s+/).filter(Boolean));(n.added.length||n.removed.length)&&t.target.dispatchEvent(new CustomEvent("tinyhtml.classchanged",{detail:n}))}]],initCfg:{attributeOldValue:!0,attributes:!0,subtree:!0,attributeFilter:["style","class"]}});static get tinyObserver(){return P.#l}static async fetchHtmlFile(t,e={method:"GET"}){const r=await fetch(t,e),n=r.headers.get("Content-Type")||"";if(!r.ok)throw new Error(`Failed to fetch: ${r.status} ${r.statusText}`);if(!n.includes("text/html"))throw new Error(`Invalid content type: ${n} (expected text/html)`);const o=await r.text();return P.htmlToJson(o)}static async fetchHtmlNodes(t,e){const r=await P.fetchHtmlFile(t,e);return P.jsonToNodes(r)}static async fetchHtmlTinyElems(t,e){const r=await P.fetchHtmlNodes(t,e);return P.toTinyElm(r)}static templateToJson(t){return P.htmlToJson([...t.content.childNodes].map(t=>t instanceof Element?t.getHTML():t instanceof Text?t.textContent:"").join(""))}static templateToNodes(t){const e=[];return[...t.content.cloneNode(!0).childNodes].map(t=>{if(!(t instanceof Element||t instanceof Text||t instanceof Comment))throw new Error(`Expected only Element nodes in <template>, but found: ${t.constructor.name}`);t instanceof Comment||e.push(t)}),e}static templateToTinyElems(t){return P.toTinyElm(P.templateToNodes(t))}static htmlToJson(t){const e=document.createElement("div");e.innerHTML=t.trim();const r=[],n=t=>{if(t instanceof Comment)return null;if(t instanceof Text){const e=t.textContent?.trim();return e||null}if(!(t instanceof Element))return null;const e=t.tagName.toLowerCase(),r={};for(const e of t.attributes)r[P.getPropName(e.name)]=e.value;const o=Array.from(t.childNodes).map(n).filter(Boolean);return o.length>0?[e,r,...o]:[e,r]};for(const t of e.childNodes){const e=n(t);e&&r.push(e)}return e.innerHTML="",r}static jsonToNodes(t){const e=t=>{if("string"==typeof t)return document.createTextNode(t);if(!Array.isArray(t))return document.createTextNode("");const[r,n,...o]=t,i=document.createElement(r);for(const[t,e]of Object.entries(n))i.setAttribute(P.getAttrName(t),e);for(const t of o){const r=e(t);r instanceof Comment||i.appendChild(r)}return i};return t.map(e).filter(t=>!(t instanceof Comment))}static jsonToTinyElems(t){return P.toTinyElm(P.jsonToNodes(t))}static createFrom(t,e){if("string"!=typeof t)throw new TypeError('The "tagName" must be a string.');if(void 0!==e&&"object"!=typeof e)throw new TypeError('The "attrs" must be a object.');const r=P.createElement(t);if("object"==typeof e)for(const t in e)r.setAttr(t,e[t]);return r}static createElement(t,e){if("string"!=typeof t)throw new TypeError("[TinyHtml] createElement(): The tagName must be a string.");if(void 0!==e&&"object"!=typeof e)throw new TypeError("[TinyHtml] createElement(): The ops must be a object.");return new P(document.createElement(t,e))}static createTextNode(t){if("string"!=typeof t)throw new TypeError("[TinyHtml] createTextNode(): The value must be a string.");return new P(document.createTextNode(t))}static createElementFromHTML(t){const e=document.createElement("template");if(!(t=t.trim()).startsWith("<"))return P.createTextNode(t);if(e.innerHTML=t,!(e.content.firstChild instanceof Element))throw new Error("The HTML string must contain a valid HTML element.");return new P(e.content.firstChild)}static createFromHTML(t){const e=document.createElement("template");t=t.trim(),e.innerHTML=t;const r=Array.from(e.content.childNodes);if(!r.every(t=>t instanceof Element||t instanceof Text))throw new Error("The HTML string must contain a valid HTML element.");return new P(r)}static createFromHtml(t){return P.createFromHTML(t)}static query(t,e=document){const r=e.querySelector(t);return r?new P(r):null}querySelector(t){return P.query(t,P._preElem(this,"query"))}static queryAll(t,e=document){return new P(e.querySelectorAll(t))}querySelectorAll(t){return P.queryAll(t,P._preElem(this,"queryAll"))}static getById(t){const e=document.getElementById(t);return e?new P(e):null}static getByClassName(t,e=document){return new P(e.getElementsByClassName(t))}getElementsByClassName(t){return P.getByClassName(t,P._preElem(this,"getByClassName"))}static getByName(t){return new P(document.getElementsByName(t))}static getByTagNameNS(t,e="http://www.w3.org/1999/xhtml",r=document){return new P(r.getElementsByTagNameNS(e,t))}getElementsByTagNameNS(t,e="http://www.w3.org/1999/xhtml"){return P.getByTagNameNS(t,e,P._preElem(this,"getByTagNameNS"))}get elements(){return[...this.#t]}forEach(t){const e=this.elements.map((t,e)=>this.extract(e));for(const r in e)t(e[r],Number(r),e);return this}get(t){if("number"!=typeof t)throw new TypeError("The index must be a number.");if(!this.#t[t])throw new Error(`No element found at index ${t}.`);return this.#t[t]}extract(t){if("number"!=typeof t)throw new TypeError("The index must be a number.");if(!this.#t[t])throw new Error(`Cannot extract: no element exists at index ${t}.`);return new P(this.#t[t])}exists(t){if("number"!=typeof t)throw new TypeError("The index must be a number.");return!!this.#t[t]}getAll(){return[...this.#t]}_getElement(t,e){if(!(this.#t[e]instanceof Element||this.#t[e]instanceof Window||this.#t[e]instanceof Document||this.#t[e]instanceof Text))throw P._debugElemError([...this.#t],this.#t[e]),new Error(`[TinyHtml] Invalid Element in ${t}().`);return this.#t[e]}_getElements(t){if(!this.#t.every(t=>t instanceof Element||t instanceof Window||t instanceof Document||t instanceof Text))throw P._debugElemError([...this.#t]),new Error(`[TinyHtml] Invalid Element in ${t}().`);return[...this.#t]}static _preElemsTemplate(t,e,r,n){const o=t=>{const o=[];return t.map(i=>(i instanceof P?i._getElements(e):[i]).map(i=>{let s=!1;for(const t of r)if(i instanceof t){s=!0;break}if(!s)throw P._debugElemError([...t],i),new Error(`[TinyHtml] Invalid element of the list "${n.join(",")}" in ${e}().`);return o.push(i),i})),o};return Array.isArray(t)?o(t):o([t])}_preElemsTemplate(t,e,r){return P._preElemsTemplate(this,t,e,r)}static _preElemTemplate(t,e,r,n,o=!1){const i=t=>{const i=t[0],s=i instanceof P?i._getElements(e):[i];if(s.length>1)throw P._debugElemError([...t]),new Error(`[TinyHtml] Invalid element amount in ${e}() (Received ${s.length}/1).`);let a=!1;for(const t of r)if(s[0]instanceof t){a=!0;break}if(!o||null!==s[0]&&void 0!==s[0]||(s[0]=null,a=!0),!a)throw P._debugElemError([...t],s[0]),new Error(`[TinyHtml] Invalid element of the list "${n.join(",")}" in ${e}().`);return s[0]};if(!Array.isArray(t))return i([t]);if(t.length>1)throw P._debugElemError([...t]),new Error(`[TinyHtml] Invalid element amount in ${e}() (Received ${t.length}/1).`);return i(t)}_preElemTemplate(t,e,r,n=!1){return P._preElemTemplate(this,t,e,r,n)}static _preElems(t,e){return P._preElemsTemplate(t,e,[Element],["Element"])}_preElems(t){return P._preElems(this,t)}static _preElem(t,e){return P._preElemTemplate(t,e,[Element],["Element"])}_preElem(t){return P._preElem(this,t)}static _preNodeElems(t,e){return P._preElemsTemplate(t,e,[Node],["Node"])}_preNodeElems(t){return P._preNodeElems(this,t)}static _preNodeElem(t,e){return P._preElemTemplate(t,e,[Node],["Node"])}_preNodeElem(t){return P._preNodeElem(this,t)}static _preNodeElemWithNull(t,e){return P._preElemTemplate(t,e,[Node],["Node"],!0)}_preNodeElemWithNull(t){return P._preNodeElemWithNull(this,t)}static _preHtmlElems(t,e){return P._preElemsTemplate(t,e,[HTMLElement],["HTMLElement"])}_preHtmlElems(t){return P._preHtmlElems(this,t)}static _preHtmlElem(t,e){return P._preElemTemplate(t,e,[HTMLElement],["HTMLElement"])}_preHtmlElem(t){return P._preHtmlElem(this,t)}static _preInputElems(t,e){return P._preElemsTemplate(t,e,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElems(t){return P._preInputElems(this,t)}static _preInputElem(t,e){return P._preElemTemplate(t,e,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElem(t){return P._preInputElem(this,t)}static _preEventTargetElems(t,e){return P._preElemsTemplate(t,e,[EventTarget],["EventTarget"])}_preEventTargetElems(t){return P._preEventTargetElems(this,t)}static _preEventTargetElem(t,e){return P._preElemTemplate(t,e,[EventTarget],["EventTarget"])}_preEventTargetElem(t){return P._preEventTargetElem(this,t)}static _preElemsAndWindow(t,e){return P._preElemsTemplate(t,e,[Element,Window],["Element","Window"])}_preElemsAndWindow(t){return P._preElemsAndWindow(this,t)}static _preElemAndWindow(t,e){return P._preElemTemplate(t,e,[Element,Window],["Element","Window"])}_preElemAndWindow(t){return P._preElemAndWindow(this,t)}static _preElemsAndWinAndDoc(t,e){return P._preElemsTemplate(t,e,[Element,Window,Document],["Element","Window","Document"]).map(t=>t instanceof Document?t.documentElement:t)}_preElemsAndWinAndDoc(t){return P._preElemsAndWinAndDoc(this,t)}static _preElemAndWinAndDoc(t,e){const r=P._preElemTemplate(t,e,[Element,Window,Document],["Element","Window","Document"]);return r instanceof Document?r.documentElement:r}_preElemAndWinAndDoc(t){return P._preElemAndWinAndDoc(this,t)}static _preElemsWithDoc(t,e){return P._preElemsTemplate(t,e,[Element,Document],["Element","Document"])}_preElemsWithDoc(t){return P._preElemsWithDoc(this,t)}static _preElemWithDoc(t,e){return P._preElemTemplate(t,e,[Element,Document],["Element","Document"])}_preElemWithDoc(t){return P._preElemWithDoc(this,t)}static toTinyElm(t){const e=t=>t.map(t=>t instanceof P?t:new P(t));return Array.isArray(t)?e(t):e([t])}static fromTinyElm(t){const e=t=>{const e=[];return t.map(t=>(t instanceof P?t._getElements("fromTinyElm"):[t]).map(t=>e.push(t))),e};return Array.isArray(t)?e(t):e([t])}static winnow(t,e,r,n=!1){if("boolean"!=typeof n)throw new TypeError('The "not" must be a boolean.');if("function"==typeof e)return P._preElems(t,r).filter((t,r)=>!!e.call(t,r,t)!==n);if(e instanceof Element)return P._preElems(t,r).filter(t=>t===e!==n);if(Array.isArray(e)||"string"!=typeof e&&null!=e.length)return P._preElems(t,r).filter(t=>e.includes(t)!==n);let o=e;return n&&(o=`:not(${o})`),P._preElems(t,r).filter(t=>1===t.nodeType&&t.matches(o))}static filter(t,e,r=!1){return r&&(e=`:not(${e})`),P._preElems(t,"filter").filter(t=>1===t.nodeType&&t.matches(e))}static filterOnly(t,e){return P.winnow(t,e,"filterOnly",!1)}static not(t,e){return P.winnow(t,e,"not",!0)}not(t){return P.not(this,t)}static find(t,e){const r=[];for(const n of P._preElems(t,"find"))r.push(...n.querySelectorAll(e));return[...new Set(r)]}find(t){return P.find(this,t)}static is(t,e){return P.winnow(t,e,"is",!1).length>0}is(t){return P.is(this,t)}static has(t,e){const r="string"==typeof e?[...document.querySelectorAll(e)]:P._preElems(e,"has");return P._preElems(t,"has").filter(t=>r.some(e=>t&&t.contains(e)))}has(t){return P.has(this,t)}static closest(t,e,r){const n=[];for(const o of P._preElems(t,"closest")){let t=o;for(;t&&t!==r;){if(1===t.nodeType&&("string"==typeof e?t.matches(e):t===e)){n.push(t);break}t=t.parentElement}}return[...new Set(n)]}closest(t,e){return P.closest(this,t,e)}static isSameDom(t,e){return P._preNodeElem(t,"isSameDom")===P._preNodeElem(e,"isSameDom")}isSameDom(t){return P.isSameDom(this,t)}#c={};get _data(){return{...this.#c}}set _data(t){if("object"!=typeof t||null===t||Array.isArray(t))throw new Error("value must be a non-null object.");this.#c=t}static _dataSelector={public:(t,e)=>{const r=P._preElem(e,t);let n=D.get(r);return n||(n={},D.set(r,n)),n},private:(t,e)=>{if(!(e instanceof P))throw new Error(`Element must be a TinyHtml instance to execute ${t}().`);return e.#c}};static data(t,e,r=!1){const n=P._dataSelector[r?"private":"public"]("data",t);if(null==e)return{...n};if("string"!=typeof e)throw new TypeError("The key must be a string.");return n.hasOwnProperty(e)?n[e]:void 0}data(t,e){return P.data(this,t,e)}static setData(t,e,r,n=!1){const o=P._dataSelector[n?"private":"public"]("setData",t);if("string"!=typeof e)throw new TypeError("The key must be a string.");return void 0!==r?o[e]=r:P.removeData(t,e),t}setData(t,e,r=!1){return P.setData(this,t,e,r)}static hasData(t,e,r=!1){if("string"!=typeof e)throw new TypeError("The key must be a string.");const n=P._dataSelector[r?"private":"public"]("hasData",t);return Object.prototype.hasOwnProperty.call(n,e)}hasData(t,e=!1){return P.hasData(this,t,e)}static removeData(t,e,r=!1){if("string"!=typeof e)throw new TypeError("The key must be a string.");return delete P._dataSelector[r?"private":"public"]("removeData",t)[e]}removeData(t,e=!1){return P.removeData(this,t,e)}static _getSibling(t,e,r){let n=P._preNodeElemWithNull(t,r);for(;n&&(n=n[e])&&1!==n.nodeType;);return n instanceof Node?n:null}static _getSiblings(t,e){let r=t;const n=[];for(;r;r=r.nextSibling)1===r.nodeType&&r!==e&&n.push(r);return n}static domDir(t,e,r,n="domDir"){if("string"!=typeof e)throw new TypeError('The "direction" must be a string.');let o=P._preNodeElemWithNull(t,n);const i=[];for(;o&&(o=o[e]);)if(1===o.nodeType){if(r&&("string"==typeof r?o.matches(r):o===r))break;i.push(o)}return i}static parent(t){let e=P._preNodeElemWithNull(t,"parent");const r=e?e.parentNode:null;return r&&11!==r.nodeType?r:null}parent(){return P.parent(this)}static parents(t,e){return P.domDir(t,"parentNode",e,"parents")}parents(t){return P.parents(this,t)}static next(t){return P._getSibling(t,"nextSibling","next")}next(){return P.next(this)}static prev(t){return P._getSibling(t,"previousSibling","prev")}prev(){return P.prev(this)}static nextAll(t){return P.domDir(t,"nextSibling",void 0,"nextAll")}nextAll(){return P.nextAll(this)}static prevAll(t){return P.domDir(t,"previousSibling",void 0,"prevAll")}prevAll(){return P.prevAll(this)}static nextUntil(t,e){return P.domDir(t,"nextSibling",e,"nextUtil")}nextUntil(t){return P.nextUntil(this,t)}static prevUntil(t,e){return P.domDir(t,"previousSibling",e,"prevUtil")}prevUntil(t){return P.prevUntil(this,t)}static siblings(t){const e=P._preNodeElemWithNull(t,"siblings");return P._getSiblings(e&&e.parentNode?e.parentNode.firstChild:null,e)}siblings(){return P.siblings(this)}static children(t){const e=P._preNodeElemWithNull(t,"children");return P._getSiblings(e?e.firstChild:null)}children(){return P.children(this)}static contents(t){const e=P._preNodeElemWithNull(t,"contents");return e instanceof HTMLIFrameElement&&null!=e.contentDocument&&Object.getPrototypeOf(e.contentDocument)?[e.contentDocument]:e instanceof HTMLTemplateElement?Array.from((e.content||e).childNodes):e?Array.from(e.childNodes):[]}contents(){return P.contents(this)}static clone(t,e=!0){if("boolean"!=typeof e)throw new TypeError('The "deep" must be a boolean.');return P._preNodeElems(t,"clone").map(t=>t.cloneNode(e))}clone(t){return P.clone(this,t)[0]}static _appendChecker(t,...e){const r=[];for(const n of e)if(null!=n&&!1!==n)if("string"!=typeof n&&"number"!=typeof n)if(n instanceof Node||n instanceof P)r.push(...P._preNodeElems(n,t));else if(Array.isArray(n))r.push(...P._appendChecker(t,...n));else for(const e in n){const o=n[e];r.push(...P._appendChecker(t,o))}else r.push(n);return r}static append(t,...e){return P._preElem(t,"append").append(...P._appendChecker("append",...e)),t}append(...t){return P.append(this,...t)}static prepend(t,...e){return P._preElem(t,"prepend").prepend(...P._appendChecker("prepend",...e)),t}prepend(...t){return P.prepend(this,...t)}static before(t,...e){return P._preElem(t,"before").before(...P._appendChecker("before",...e)),t}before(...t){return P.before(this,...t)}static after(t,...e){return P._preElem(t,"after").after(...P._appendChecker("after",...e)),t}after(...t){return P.after(this,...t)}static replaceWith(t,...e){return P._preElem(t,"replaceWith").replaceWith(...P._appendChecker("replaceWith",...e)),t}replaceWith(...t){return P.replaceWith(this,...t)}static appendTo(t,e){const r=P._preNodeElems(t,"appendTo"),n=P._preNodeElems(e,"appendTo");return n.forEach((t,e)=>{r.forEach(r=>t.appendChild(e===n.length-1?r:r.cloneNode(!0)))}),t}appendTo(t){return P.appendTo(this,t)}static prependTo(t,e){const r=P._preElems(t,"prependTo"),n=P._preElems(e,"prependTo");return n.forEach((t,e)=>{r.slice().reverse().forEach(r=>t.prepend(e===n.length-1?r:r.cloneNode(!0)))}),t}prependTo(t){return P.prependTo(this,t)}static insertBefore(t,e,r=null){const n=P._preNodeElem(t,"insertBefore"),o=P._preNodeElem(e,"insertBefore"),i=P._preNodeElemWithNull(r,"insertBefore");if(!o.parentNode)throw new Error("The target element has no parent node to insert before.");return o.parentNode.insertBefore(n,i||o),t}insertBefore(t,e){return P.insertBefore(this,t,e)}static insertAfter(t,e,r=null){const n=P._preNodeElem(t,"insertAfter"),o=P._preNodeElem(e,"insertBefore"),i=P._preNodeElemWithNull(r,"insertBefore");if(!o.parentNode)throw new Error("The target element has no parent node to insert after.");return o.parentNode.insertBefore(n,i||o.nextSibling),t}insertAfter(t,e){return P.insertAfter(this,t,e)}static replaceAll(t,e){const r=P._preNodeElems(t,"replaceAll"),n=P._preNodeElems(e,"replaceAll");return n.forEach((t,e)=>{const o=t.parentNode;r.forEach(r=>{o&&o.replaceChild(e===n.length-1?r:r.cloneNode(!0),t)})}),t}replaceAll(t){return P.replaceAll(this,t)}#t;get size(){return this.#t.length}static _elCheck(t){for(const e of t)if(!(e instanceof Element||e instanceof Window||e instanceof Document||e instanceof Text))throw new Error("[TinyHtml] Invalid Target in constructor.")}add(t){return new P([...this.#t,...P._selector(t)])}static _selector(t){if(t instanceof P)throw new Error("[TinyHtml] You are trying to put a TinyHtml inside another TinyHtml in constructor.");const e=t=>Array.from(new Set(t)),r="string"!=typeof t?t:document.querySelectorAll(t);if(Array.isArray(r))return P._elCheck(r),e(r);if(r instanceof NodeList||r instanceof HTMLCollection){const t=[...r];return P._elCheck(t),e(t)}{const t=[r];return P._elCheck(t),e(t)}}constructor(t){this.#t=P._selector(t),this.#p=P.#f}static isWindow(t){return null!=t&&t===t.window}static css(t){const e=P._preElem(t,"css");return window.getComputedStyle(e)}css(){return P.css(this)}static cssString(t,e){const r=P._preElem(t,"cssString");if("string"!=typeof e)throw new TypeError("The prop must be a string.");const n=window.getComputedStyle(r)[e];return"string"==typeof n?n:"number"==typeof n?n.toString():null}cssString(t){return P.cssString(this,t)}static cssList(t,e){const r=P._preElem(t,"cssList");if(!Array.isArray(e))throw new TypeError("The prop must be an array of strings.");const n=window.getComputedStyle(r),o={};for(const t of e)void 0!==t&&(o[t]=n.getPropertyValue(t));return o}cssList(t){return P.cssList(this,t)}static cssFloat(t,e){const r=P._preElem(t,"cssFloat");if("string"!=typeof e)throw new TypeError("The prop must be a string.");const n=window.getComputedStyle(r)[e];return parseFloat(n)||0}cssFloat(t){return P.cssFloat(this,t)}static cssFloats(t,e){const r=P._preElem(t,"cssFloats");if(!Array.isArray(e))throw new TypeError("The prop must be an array of strings.");const n=window.getComputedStyle(r),o={};for(const t of e)o[t]=parseFloat(n[t])||0;return o}cssFloats(t){return P.cssFloats(this,t)}static#m={alignContent:"align-content",alignItems:"align-items",alignSelf:"align-self",animationDelay:"animation-delay",animationDirection:"animation-direction",animationDuration:"animation-duration",animationFillMode:"animation-fill-mode",animationIterationCount:"animation-iteration-count",animationName:"animation-name",animationPlayState:"animation-play-state",animationTimingFunction:"animation-timing-function",backfaceVisibility:"backface-visibility",backgroundAttachment:"background-attachment",backgroundBlendMode:"background-blend-mode",backgroundClip:"background-clip",backgroundColor:"background-color",backgroundImage:"background-image",backgroundOrigin:"background-origin",backgroundPosition:"background-position",backgroundRepeat:"background-repeat",backgroundSize:"background-size",borderBottom:"border-bottom",borderBottomColor:"border-bottom-color",borderBottomLeftRadius:"border-bottom-left-radius",borderBottomRightRadius:"border-bottom-right-radius",borderBottomStyle:"border-bottom-style",borderBottomWidth:"border-bottom-width",borderCollapse:"border-collapse",borderColor:"border-color",borderImage:"border-image",borderImageOutset:"border-image-outset",borderImageRepeat:"border-image-repeat",borderImageSlice:"border-image-slice",borderImageSource:"border-image-source",borderImageWidth:"border-image-width",borderLeft:"border-left",borderLeftColor:"border-left-color",borderLeftStyle:"border-left-style",borderLeftWidth:"border-left-width",borderRadius:"border-radius",borderRight:"border-right",borderRightColor:"border-right-color",borderRightStyle:"border-right-style",borderRightWidth:"border-right-width",borderSpacing:"border-spacing",borderStyle:"border-style",borderTop:"border-top",borderTopColor:"border-top-color",borderTopLeftRadius:"border-top-left-radius",borderTopRightRadius:"border-top-right-radius",borderTopStyle:"border-top-style",borderTopWidth:"border-top-width",borderWidth:"border-width",boxDecorationBreak:"box-decoration-break",boxShadow:"box-shadow",boxSizing:"box-sizing",breakAfter:"break-after",breakBefore:"break-before",breakInside:"break-inside",captionSide:"caption-side",caretColor:"caret-color",clipPath:"clip-path",columnCount:"column-count",columnFill:"column-fill",columnGap:"column-gap",columnRule:"column-rule",columnRuleColor:"column-rule-color",columnRuleStyle:"column-rule-style",columnRuleWidth:"column-rule-width",columnSpan:"column-span",columnWidth:"column-width",counterIncrement:"counter-increment",counterReset:"counter-reset",emptyCells:"empty-cells",flexBasis:"flex-basis",flexDirection:"flex-direction",flexFlow:"flex-flow",flexGrow:"flex-grow",flexShrink:"flex-shrink",flexWrap:"flex-wrap",fontFamily:"font-family",fontFeatureSettings:"font-feature-settings",fontKerning:"font-kerning",fontLanguageOverride:"font-language-override",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontSynthesis:"font-synthesis",fontVariant:"font-variant",fontVariantAlternates:"font-variant-alternates",fontVariantCaps:"font-variant-caps",fontVariantEastAsian:"font-variant-east-asian",fontVariantLigatures:"font-variant-ligatures",fontVariantNumeric:"font-variant-numeric",fontVariantPosition:"font-variant-position",fontWeight:"font-weight",gridArea:"grid-area",gridAutoColumns:"grid-auto-columns",gridAutoFlow:"grid-auto-flow",gridAutoRows:"grid-auto-rows",gridColumn:"grid-column",gridColumnEnd:"grid-column-end",gridColumnGap:"grid-column-gap",gridColumnStart:"grid-column-start",gridGap:"grid-gap",gridRow:"grid-row",gridRowEnd:"grid-row-end",gridRowGap:"grid-row-gap",gridRowStart:"grid-row-start",gridTemplate:"grid-template",gridTemplateAreas:"grid-template-areas",gridTemplateColumns:"grid-template-columns",gridTemplateRows:"grid-template-rows",imageRendering:"image-rendering",justifyContent:"justify-content",letterSpacing:"letter-spacing",lineBreak:"line-break",lineHeight:"line-height",listStyle:"list-style",listStyleImage:"list-style-image",listStylePosition:"list-style-position",listStyleType:"list-style-type",marginBottom:"margin-bottom",marginLeft:"margin-left",marginRight:"margin-right",marginTop:"margin-top",maskClip:"mask-clip",maskComposite:"mask-composite",maskImage:"mask-image",maskMode:"mask-mode",maskOrigin:"mask-origin",maskPosition:"mask-position",maskRepeat:"mask-repeat",maskSize:"mask-size",maskType:"mask-type",maxHeight:"max-height",maxWidth:"max-width",minHeight:"min-height",minWidth:"min-width",mixBlendMode:"mix-blend-mode",objectFit:"object-fit",objectPosition:"object-position",offsetAnchor:"offset-anchor",offsetDistance:"offset-distance",offsetPath:"offset-path",offsetRotate:"offset-rotate",outlineColor:"outline-color",outlineOffset:"outline-offset",outlineStyle:"outline-style",outlineWidth:"outline-width",overflowAnchor:"overflow-anchor",overflowWrap:"overflow-wrap",overflowX:"overflow-x",overflowY:"overflow-y",paddingBottom:"padding-bottom",paddingLeft:"padding-left",paddingRight:"padding-right",paddingTop:"padding-top",pageBreakAfter:"page-break-after",pageBreakBefore:"page-break-before",pageBreakInside:"page-break-inside",perspectiveOrigin:"perspective-origin",placeContent:"place-content",placeItems:"place-items",placeSelf:"place-self",pointerEvents:"pointer-events",rowGap:"row-gap",scrollBehavior:"scroll-behavior",scrollMargin:"scroll-margin",scrollMarginBlock:"scroll-margin-block",scrollMarginBlockEnd:"scroll-margin-block-end",scrollMarginBlockStart:"scroll-margin-block-start",scrollMarginBottom:"scroll-margin-bottom",scrollMarginInline:"scroll-margin-inline",scrollMarginInlineEnd:"scroll-margin-inline-end",scrollMarginInlineStart:"scroll-margin-inline-start",scrollMarginLeft:"scroll-margin-left",scrollMarginRight:"scroll-margin-right",scrollMarginTop:"scroll-margin-top",scrollPadding:"scroll-padding",scrollPaddingBlock:"scroll-padding-block",scrollPaddingBlockEnd:"scroll-padding-block-end",scrollPaddingBlockStart:"scroll-padding-block-start",scrollPaddingBottom:"scroll-padding-bottom",scrollPaddingInline:"scroll-padding-inline",scrollPaddingInlineEnd:"scroll-padding-inline-end",scrollPaddingInlineStart:"scroll-padding-inline-start",scrollPaddingLeft:"scroll-padding-left",scrollPaddingRight:"scroll-padding-right",scrollPaddingTop:"scroll-padding-top",scrollSnapAlign:"scroll-snap-align",scrollSnapStop:"scroll-snap-stop",scrollSnapType:"scroll-snap-type",shapeImageThreshold:"shape-image-threshold",shapeMargin:"shape-margin",shapeOutside:"shape-outside",tabSize:"tab-size",tableLayout:"table-layout",textAlign:"text-align",textAlignLast:"text-align-last",textCombineUpright:"text-combine-upright",textDecoration:"text-decoration",textDecorationColor:"text-decoration-color",textDecorationLine:"text-decoration-line",textDecorationStyle:"text-decoration-style",textIndent:"text-indent",textJustify:"text-justify",textOrientation:"text-orientation",textOverflow:"text-overflow",textShadow:"text-shadow",textTransform:"text-transform",transformBox:"transform-box",transformOrigin:"transform-origin",transformStyle:"transform-style",transitionDelay:"transition-delay",transitionDuration:"transition-duration",transitionProperty:"transition-property",transitionTimingFunction:"transition-timing-function",unicodeBidi:"unicode-bidi",userSelect:"user-select",verticalAlign:"vertical-align",whiteSpace:"white-space",willChange:"will-change",wordBreak:"word-break",wordSpacing:"word-spacing",wordWrap:"word-wrap",writingMode:"writing-mode",zIndex:"z-index",WebkitTransform:"-webkit-transform",WebkitTransition:"-webkit-transition",WebkitBoxShadow:"-webkit-box-shadow",MozBoxShadow:"-moz-box-shadow",MozTransform:"-moz-transform",MozTransition:"-moz-transition",msTransform:"-ms-transform",msTransition:"-ms-transition"};static cssPropAliases=new Proxy(P.#m,{set:(t,e,r)=>(t[e]=r,P.cssPropRevAliases[r]=e,!0)});static cssPropRevAliases=Object.fromEntries(Object.entries(P.#m).map(([t,e])=>[e,t]));static toStyleKc(t){return"string"==typeof P.cssPropAliases[t]?P.cssPropAliases[t]:t}static toStyleCc(t){return"string"==typeof P.cssPropRevAliases[t]?P.cssPropRevAliases[t]:t}static setStyle(t,e,r=null){return P._preHtmlElems(t,"setStyle").forEach(t=>{if("object"==typeof e)for(const[r,n]of Object.entries(e))t.style.setProperty(P.toStyleKc(r),"string"==typeof n?n:"number"==typeof n?`${n}px`:String(n));else t.style.setProperty(P.toStyleKc(e),r)}),t}setStyle(t,e){return P.setStyle(this,t,e)}static getStyle(t,e){return P._preHtmlElem(t,"getStyle").style.getPropertyValue(P.toStyleKc(e))}getStyle(t){return P.getStyle(this,t)}static style(t,{camelCase:e=!1,rawAttr:r=!1}={}){if("boolean"!=typeof e)throw new TypeError('"camelCase" must be a boolean. Received: '+typeof e);if("boolean"!=typeof r)throw new TypeError('"rawAttr" must be a boolean. Received: '+typeof r);const n=P._preHtmlElem(t,"style"),o={};if(r){const t=(n.getAttribute("style")||"").split(";");for(const r of t){const[t,n]=r.split(":");if(!t||!n)continue;const i=t.trim(),s=n.trim();o[e?P.toStyleCc(i):i]=s}}else{const t=n.style;for(let r=0;r<t.length;r++){const n=t[r],i=t.getPropertyValue(n);o[e?P.toStyleCc(n):n]=i}}return o}style(t){return P.style(this,t)}static removeStyle(t,e){return P._preHtmlElems(t,"removeStyle").forEach(t=>{if(Array.isArray(e))for(const r of e)t.style.removeProperty(P.toStyleKc(r));else t.style.removeProperty(P.toStyleKc(e))}),t}removeStyle(t){return P.removeStyle(this,t)}static toggleStyle(t,e,r,n){return P._preHtmlElems(t,"toggleStyle").forEach(t=>{const o=P.getStyle(t,e).trim()===P.toStyleKc(r)?n:r;P.setStyle(t,e,o)}),t}toggleStyle(t,e,r){return P.toggleStyle(this,t,e,r)}static clearStyle(t){return P._preElems(t,"clearStyle").forEach(t=>t.removeAttribute("style")),t}clearStyle(){return P.clearStyle(this)}static focus(t){return P._preHtmlElem(t,"focus").focus(),t}focus(){return P.focus(this)}static blur(t){return P._preHtmlElem(t,"blur").blur(),t}blur(){return P.blur(this)}static select(t){const e=P._preHtmlElem(t,"select");if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error("Element must be an <input> or <textarea> to use select().");return e.select(),t}select(){return P.select(this)}static boolCheck(t){return void 0!==t&&("true"===t||"1"===t||!0===t||"on"===t||"number"==typeof t&&t>0)}static setWinScrollTop(t){if("number"!=typeof t)throw new TypeError("The value must be a number.");P.setScrollTop(window,t)}static setWinScrollLeft(t){if("number"!=typeof t)throw new TypeError("The value must be a number.");P.setScrollLeft(window,t)}static winScrollTop(){return window.scrollY||document.documentElement.scrollTop}static winScrollLeft(){return window.scrollX||document.documentElement.scrollLeft}static winInnerHeight(){return window.innerHeight||document.documentElement.clientHeight}static winInnerWidth(){return window.innerWidth||document.documentElement.clientWidth}static isPageTop(){return 0===window.scrollY}static isPageBottom(){return window.innerHeight+window.scrollY>=document.body.offsetHeight}static getDimension(t,e,r="content"){const n=P._preElemAndWinAndDoc(t,"getDimension");if("string"!=typeof e)throw new TypeError("The type must be a string.");if("string"!=typeof r)throw new TypeError("The extra must be a string.");const o="width"===e?"Width":"Height";if(P.isWindow(n))return"margin"===r?n["inner"+o]:n.document.documentElement["client"+o];const i=n;if(9===i.nodeType){const t=i.documentElement;return Math.max(i.body["scroll"+o],t["scroll"+o],i.body["offset"+o],t["offset"+o],t["client"+o])}let s=i.getBoundingClientRect()[e];function a(t){return"width"===e?P.cssFloat(i,t+"Left")+P.cssFloat(i,t+"Right"):P.cssFloat(i,t+"Top")+P.cssFloat(i,t+"Bottom")}switch(r){case"content":s-=a("padding"),s-=a("border");break;case"padding":s-=a("border");break;case"border":break;case"margin":s+=a("margin")}return s}getDimension(t,e){return P.getDimension(this,t,e)}static setHeight(t,e){const r=P._preHtmlElem(t,"setHeight");if("number"!=typeof e&&"string"!=typeof e)throw new TypeError("The value must be a string or number.");return r.style.height="number"==typeof e?`${e}px`:e,t}setHeight(t){return P.setHeight(this,t)}set height(t){P.setHeight(this,t)}static setWidth(t,e){const r=P._preHtmlElem(t,"setWidth");if("number"!=typeof e&&"string"!=typeof e)throw new TypeError("The value must be a string or number.");return r.style.width="number"==typeof e?`${e}px`:e,t}setWidth(t){return P.setWidth(this,t)}set width(t){P.setWidth(this,t)}static height(t){const e=P._preElemAndWinAndDoc(t,"height");return P.getDimension(e,"height","content")}get height(){return P.height(this)}static width(t){const e=P._preElemAndWinAndDoc(t,"width");return P.getDimension(e,"width","content")}get width(){return P.width(this)}static innerHeight(t){const e=P._preElemAndWinAndDoc(t,"innerHeight");return P.getDimension(e,"height","padding")}innerHeight(){return P.innerHeight(this)}static innerWidth(t){const e=P._preElemAndWinAndDoc(t,"innerWidth");return P.getDimension(e,"width","padding")}innerWidth(){return P.innerWidth(this)}static outerHeight(t,e=!1){if("boolean"!=typeof e)throw new TypeError('The "includeMargin" must be a boolean.');const r=P._preElemAndWinAndDoc(t,"outerHeight");return P.getDimension(r,"height",e?"margin":"border")}outerHeight(t){return P.outerHeight(this,t)}static outerWidth(t,e=!1){if("boolean"!=typeof e)throw new TypeError('The "includeMargin" must be a boolean.');const r=P._preElemAndWinAndDoc(t,"outerWidth");return P.getDimension(r,"width",e?"margin":"border")}outerWidth(t){return P.outerWidth(this,t)}#p="";get mainDisplay(){return this.#p}set mainDisplay(t){if("string"!=typeof t)throw new TypeError("mainDisplay must be a string.");this.#p=t}static#f="block";static get defaultDisplay(){return P.#f}static set defaultDisplay(t){if("string"!=typeof t)throw new TypeError("defaultDisplay must be a string.");P.#f=t}static getAnimateData(t,e){let r=L.get(t);return r||(r={},L.set(t,r)),r[e]}static setAnimateData(t,e,r){if(!(t instanceof HTMLElement))throw new TypeError("setAnimateData: el must be an HTMLElement.");if("string"!=typeof e)throw new TypeError("setAnimateData: where must be a string.");if("string"!=typeof r&&"number"!=typeof r)throw new TypeError("setAnimateData: value must be a string or number.");let n=L.get(t);n||(n={},L.set(t,n)),n[e]=r}static#u=!0;static get cancelOldStyleFx(){return P.#u}static set cancelOldStyleFx(t){if("boolean"!=typeof t)throw new TypeError("Expected a boolean value.");P.#u=t}static#d={slow:{duration:600,easing:"ease"},fast:{duration:200,easing:"ease-out"},_default:{duration:400,easing:"linear"}};static get styleFxSpeeds(){const t={};for(const e in P.#d){const r=P.#d[e];t[e]="object"==typeof r?{...r}:r}return t}static set styleFxSpeeds(t){if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("styleFxSpeeds must be an object.");for(const[e,r]of Object.entries(t))if("number"!=typeof r&&"object"!=typeof r)throw new TypeError(`styleFxSpeeds["${e}"] must be a number or KeyframeAnimationOptions.`);P.#d={};for(const[e,r]of Object.entries(t))P.setStyleFxSpeed(e,r)}static getStyleFxSpeed(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');const e=P.#d[t];return"object"==typeof e?{...e}:e}static setStyleFxSpeed(t,e){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');if("number"!=typeof e&&"object"!=typeof e)throw new TypeError("styleFxSpeed must be a number or KeyframeAnimationOptions");P.#d[t]="object"==typeof e?{...e}:e}static deleteStyleFxSpeed(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return delete P.#d[t]}static hasStyleFxSpeed(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(P.#d,t)}static#h=["Top","Right","Bottom","Left"];static#g={slideDown:P.genStyleFx("show"),slideUp:P.genStyleFx("hide"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}};static get styleEffects(){return JSON.parse(JSON.stringify(P.#g))}static set styleEffects(t){if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("styleEffects must be an object");for(const e in t)for(const[r,n]of Object.entries(t[e]))if(!("string"==typeof n||Array.isArray(n)&&n.every(t=>"string"==typeof t||"number"==typeof t)))throw new TypeError(`Invalid styleEffect["${r}"]`);P.#g={};for(const e in t)P.setStyleEffect(e,t[e])}static getStyleEffect(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');const e=P.#g[t];return e?JSON.parse(JSON.stringify(e)):void 0}static setStyleEffect(t,e){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError("styleEffect must be an object");const r={};for(const[t,n]of Object.entries(e))if("string"==typeof n)r[t]=n;else{if(!Array.isArray(n)||!n.every(t=>"string"==typeof t||"number"==typeof t))throw new TypeError(`Invalid styleEffect["${t}"]`);r[t]=[...n]}P.#g[t]=r}static deleteStyleEffect(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return delete P.#g[t]}static hasStyleEffect(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(P.#g,t)}static#y={slideDown:"slideUp",slideUp:"slideDown",fadeIn:"fadeOut",fadeOut:"fadeIn",fadeTo:"fadeIn"};static get styleEffectInverse(){return{...P.#y}}static set styleEffectInverse(t){if("object"!=typeof t||null===t)throw new TypeError("styleEffectInverse must be an object.");for(const[e,r]of Object.entries(t))if("string"!=typeof r)throw new TypeError(`styleEffectInverse["${e}"] must be a string.`);P.#y={};for(const[e,r]of Object.entries(t))P.setStyleEffectInverse(e,r)}static getStyleEffectInverse(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return P.#y[t]||null}static setStyleEffectInverse(t,e){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');if("string"!=typeof e)throw new TypeError(`styleEffectInverse["${t}"] must be a string.`);P.#y[t]=e}static deleteStyleEffectInverse(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return delete P.#y[t]}static hasStyleEffectInverse(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(P.#y,t)}static#E={slideDown:t=>t.height[0]===t.height[1]&&(!t.width||t.width[0]===t.width[1]),slideUp:t=>t.height[0]===t.height[1]&&(!t.width||t.width[0]===t.width[1]),fadeIn:t=>Number(t.opacity[0])===Number(t.opacity[1]),fadeOut:t=>Number(t.opacity[0])===Number(t.opacity[1])};static get styleEffectsRd(){return{...P.#E}}static set styleEffectsRd(t){if("object"!=typeof t||null===t)throw new TypeError("styleEffectsRd must be an object.");for(const[e,r]of Object.entries(t))if("function"!=typeof r)throw new TypeError(`styleEffectsRd["${e}"] must be a function.`);P.#E={};for(const[e,r]of Object.entries(t))P.setStyleEffectRd(e,r)}static getStyleEffectRd(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return P.#E[t]||null}static setStyleEffectRd(t,e){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');if("function"!=typeof e)throw new TypeError(`styleEffectsRd["${t}"] must be a function.`);P.#E[t]=e}static deleteStyleEffectRd(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return delete P.#E[t]}static hasStyleEffectRd(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(P.#E,t)}static#b={show:(t,e,r,n)=>{if("height"===r||"width"===r){const o=P.getAnimateData(t,`orig${r}`)||t.scrollHeight+"px";P.setAnimateData(t,`orig${r}`,o);const i=n[r];e[r]=[i,o]}else if(r.startsWith("margin")||r.startsWith("padding")){const o=P.getAnimateData(t,r)||n[r];P.setAnimateData(t,r,o),e[r]=["0px",o]}else if("opacity"===r){const t=n.opacity;e[r]=[t,1]}else{const o=P.getAnimateData(t,r)||n[r];P.setAnimateData(t,r,o),e[r]=[o,n[r]||1]}},hide:(t,e,r,n)=>{if("height"===r||"width"===r){const o=P.getAnimateData(t,`orig${r}`)||n[r];P.setAnimateData(t,`orig${r}`,o);const i=n[r];e[r]=[i,0]}else if(r.startsWith("margin")||r.startsWith("padding")){const o=P.getAnimateData(t,r)||n[r];P.setAnimateData(t,r,o),e[r]=[n[r],"0px"]}else if("opacity"===r){const t=n.opacity;e[r]=[t,0]}else{const o=P.getAnimateData(t,r)||n[r];P.setAnimateData(t,r,o),e[r]=[o,0]}}};static get styleEffectsProps(){return{...P.#b}}static set styleEffectsProps(t){if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError("styleEffectsProps must be an object");for(const[e,r]of Object.entries(t))if("function"!=typeof r)throw new TypeError(`styleEffectsProps["${e}"] must be a function`);P.#b={};for(const[e,r]of Object.entries(t))P.setStyleEffectProp(e,r)}static getStyleEffectProp(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return P.#b[t]||null}static setStyleEffectProp(t,e){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');if("function"!=typeof e)throw new TypeError(`styleEffectsProps["${t}"] must be a function`);P.#b[t]=e}static deleteStyleEffectProp(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return delete P.#b[t]}static hasStyleEffectProp(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(P.#b,t)}static genStyleFx(t,e=!1){if("string"!=typeof t)throw new TypeError("genStyleFx: type must be a string.");if("boolean"!=typeof e)throw new TypeError("genStyleFx: includeWidth must be a boolean.");let r,n=0;const o={height:t},i=e?1:0;for(;n<4;n+=2-i)r=P.#h[n],o["margin"+r]=t,o["padding"+r]=t;return e&&(o.opacity=t,o.width=t),o}static applyStyleFx(t,e,r,n){if("string"!=typeof e)throw new TypeError("applyStyleFx: id must be a string.");if("object"!=typeof r||null===r)throw new TypeError("applyStyleFx: props must be a non-null object.");if(void 0!==n&&"number"!=typeof n&&"string"!=typeof n&&("object"!=typeof n||null===n))throw new TypeError("applyStyleFx: ops must be a number, string, KeyframeAnimationOptions, or undefined.");const o=new Map;return P._preHtmlElems(t,"applyStyleFx").forEach(i=>{const s={};for(const[t,e]of Object.entries(r))if("string"==typeof e&&this.#b[e]){const r=getComputedStyle(i);this.#b[e](i,s,t,r)}else{if("object"!=typeof e)throw new TypeError(`applyStyleFx: invalid action for prop "${t}". Must be string or array.`);s[t]=e}if("function"==typeof P.#E[e]&&P.#E[e](s))return void o.set(i,null);const a=[],l=s[Object.keys(s)[0]].length;for(let t=0;t<l;t++){const e={};for(const r in s)e[r]=s[r][t];a.push(e)}o.set(i,P.animate(t,a,n,e)[0])}),o}applyStyleFx(t,e,r){return P.applyStyleFx(this,t,e,r)}static getCurrentAnimationId(t){if(!(t instanceof HTMLElement))throw new TypeError("Expected an HTMLElement.");return W.get(t)?.id??void 0}static animate(t,e,r=P.#d._default,n=null,o=P