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 kB
(()=>{"use strict";const t={d:(e,r)=>{if(Array.isArray(r))for(var n=0;n<r.length;){var o=r[n++],i=r[n++];t.o(e,o)?0===i&&n++:0===i?Object.defineProperty(e,o,{enumerable:!0,value:r[n++]}):Object.defineProperty(e,o,{enumerable:!0,get:i})}else for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}};let e={};t.d(e,{TinyHtml:()=>H});var r={};t.r(r),t.d(r,{iu:()=>i,cq:()=>s,P8:()=>c,BO:()=>p,eh:()=>f,L2:()=>l,lP:()=>a,Kr:()=>o,wE:()=>u,D6:()=>m,PN:()=>T,t_:()=>w,aI:()=>g,ej:()=>y,kx:()=>d,Pd:()=>h,NW:()=>b,Qv:()=>E});var n={};t.r(n),t.d(n,{areElsCollBottom:()=>i,areElsCollLeft:()=>s,areElsCollPerfBottom:()=>c,areElsCollPerfLeft:()=>p,areElsCollPerfRight:()=>f,areElsCollPerfTop:()=>l,areElsCollRight:()=>a,areElsCollTop:()=>o,areElsColliding:()=>u,areElsPerfColliding:()=>m,getElsCollDetails:()=>T,getElsCollDirDepth:()=>w,getElsCollOverlap:()=>g,getElsCollOverlapPos:()=>y,getElsColliding:()=>d,getElsPerfColliding:()=>h,getElsRelativeCenterOffset:()=>b,getRectCenter:()=>E});const o=(t,e)=>t.bottom<e.top,i=(t,e)=>t.top>e.bottom,s=(t,e)=>t.right<e.left,a=(t,e)=>t.left>e.right,l=(t,e)=>t.bottom<=e.top,c=(t,e)=>t.top>=e.bottom,p=(t,e)=>t.right<=e.left,f=(t,e)=>t.left>=e.right,u=(t,e)=>!(s(t,e)||a(t,e)||o(t,e)||i(t,e)),m=(t,e)=>!(p(t,e)||f(t,e)||l(t,e)||c(t,e)),d=(t,e)=>s(t,e)?"left":a(t,e)?"right":o(t,e)?"top":i(t,e)?"bottom":null,h=(t,e)=>p(t,e)?"left":f(t,e)?"right":l(t,e)?"top":c(t,e)?"bottom":null,g=(t,e)=>({overlapLeft:e.right-t.left,overlapRight:t.right-e.left,overlapTop:e.bottom-t.top,overlapBottom:t.bottom-e.top}),y=({overlapLeft:t=-1,overlapRight:e=-1,overlapTop:r=-1,overlapBottom:n=-1}={})=>({dirX:t<e?"right":"left",dirY:r<n?"bottom":"top"}),E=t=>({x:t.left+t.width/2,y:t.top+t.height/2});function b(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 w(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}=g(t,e),{dirX:s,dirY:a}=y({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 T(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}=g(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}=y({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 v=class{#t;get el(){return this.#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(t,{initDetectors:e=[],initCfg:r={}}={}){this.#t=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()}},{wE:A,D6:_,Kr:S,iu:x,cq:C,lP:N}=r,D=new WeakMap,L=new WeakMap,W=new WeakMap,k=new WeakMap,P={top:new WeakMap,bottom:new WeakMap,left:new WeakMap,right:new WeakMap};class I{static Utils={...n};static#i=1;static get version(){return this.#i}static#s=!1;static get elemDebug(){return I.#s}static set elemDebug(t){if("boolean"!=typeof t)throw new TypeError("Expected a boolean value for elemDebug");I.#s=t}static _debugElemError(t,e){if(!I.#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,I._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="undefined"!=typeof window&&void 0!==window.document?new v(window.document.documentElement,{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}(I.parseStyle(e),I.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"]}}):void 0;static get tinyObserver(){return I.#a}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 I.htmlToJson(o)}static async fetchHtmlNodes(t,e){const r=await I.fetchHtmlFile(t,e);return I.jsonToNodes(r)}static async fetchHtmlTinyElems(t,e){const r=await I.fetchHtmlNodes(t,e);return I.toTinyElm(r)}static templateToJson(t){return I.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 I.toTinyElm(I.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[I.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(I.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 I.toTinyElm(I.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=I.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 I(document.createElement(t,e))}static createTextNode(t){if("string"!=typeof t)throw new TypeError("[TinyHtml] createTextNode(): The value must be a string.");return new I(document.createTextNode(t))}static createElementFromHTML(t){const e=document.createElement("template");if(!(t=t.trim()).startsWith("<"))return I.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 I(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 I(r)}static createFromHtml(t){return I.createFromHTML(t)}static query(t,e=document){const r=e.querySelector(t);return r?new I(r):null}querySelector(t){return I.query(t,I._preElem(this,"query"))}static queryAll(t,e=document){return new I(e.querySelectorAll(t))}querySelectorAll(t){return I.queryAll(t,I._preElem(this,"queryAll"))}static getById(t){const e=document.getElementById(t);return e?new I(e):null}static getByClassName(t,e=document){return new I(e.getElementsByClassName(t))}getElementsByClassName(t){return I.getByClassName(t,I._preElem(this,"getByClassName"))}static getByName(t){return new I(document.getElementsByName(t))}static getByTagNameNS(t,e="http://www.w3.org/1999/xhtml",r=document){return new I(r.getElementsByTagNameNS(e,t))}getElementsByTagNameNS(t,e="http://www.w3.org/1999/xhtml"){return I.getByTagNameNS(t,e,I._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 I(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 I._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 I._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 I?i._getElements(e):[i]).map(i=>{let s=!1;for(const t of r)if(i instanceof t){s=!0;break}if(!s)throw I._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 I._preElemsTemplate(this,t,e,r)}static _preElemTemplate(t,e,r,n,o=!1){const i=t=>{const i=t[0],s=i instanceof I?i._getElements(e):[i];if(s.length>1)throw I._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 I._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 I._debugElemError([...t]),new Error(`[TinyHtml] Invalid element amount in ${e}() (Received ${t.length}/1).`);return i(t)}_preElemTemplate(t,e,r,n=!1){return I._preElemTemplate(this,t,e,r,n)}static _preElems(t,e){return I._preElemsTemplate(t,e,[Element],["Element"])}_preElems(t){return I._preElems(this,t)}static _preElem(t,e){return I._preElemTemplate(t,e,[Element],["Element"])}_preElem(t){return I._preElem(this,t)}static _preNodeElems(t,e){return I._preElemsTemplate(t,e,[Node],["Node"])}_preNodeElems(t){return I._preNodeElems(this,t)}static _preNodeElem(t,e){return I._preElemTemplate(t,e,[Node],["Node"])}_preNodeElem(t){return I._preNodeElem(this,t)}static _preNodeElemWithNull(t,e){return I._preElemTemplate(t,e,[Node],["Node"],!0)}_preNodeElemWithNull(t){return I._preNodeElemWithNull(this,t)}static _preHtmlElems(t,e){return I._preElemsTemplate(t,e,[HTMLElement],["HTMLElement"])}_preHtmlElems(t){return I._preHtmlElems(this,t)}static _preHtmlElem(t,e){return I._preElemTemplate(t,e,[HTMLElement],["HTMLElement"])}_preHtmlElem(t){return I._preHtmlElem(this,t)}static _preInputElems(t,e){return I._preElemsTemplate(t,e,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElems(t){return I._preInputElems(this,t)}static _preInputElem(t,e){return I._preElemTemplate(t,e,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}_preInputElem(t){return I._preInputElem(this,t)}static _preEventTargetElems(t,e){return I._preElemsTemplate(t,e,[EventTarget],["EventTarget"])}_preEventTargetElems(t){return I._preEventTargetElems(this,t)}static _preEventTargetElem(t,e){return I._preElemTemplate(t,e,[EventTarget],["EventTarget"])}_preEventTargetElem(t){return I._preEventTargetElem(this,t)}static _preElemsAndWindow(t,e){return I._preElemsTemplate(t,e,[Element,Window],["Element","Window"])}_preElemsAndWindow(t){return I._preElemsAndWindow(this,t)}static _preElemAndWindow(t,e){return I._preElemTemplate(t,e,[Element,Window],["Element","Window"])}_preElemAndWindow(t){return I._preElemAndWindow(this,t)}static _preElemsAndWinAndDoc(t,e){return I._preElemsTemplate(t,e,[Element,Window,Document],["Element","Window","Document"]).map(t=>t instanceof Document?t.documentElement:t)}_preElemsAndWinAndDoc(t){return I._preElemsAndWinAndDoc(this,t)}static _preElemAndWinAndDoc(t,e){const r=I._preElemTemplate(t,e,[Element,Window,Document],["Element","Window","Document"]);return r instanceof Document?r.documentElement:r}_preElemAndWinAndDoc(t){return I._preElemAndWinAndDoc(this,t)}static _preElemsWithDoc(t,e){return I._preElemsTemplate(t,e,[Element,Document],["Element","Document"])}_preElemsWithDoc(t){return I._preElemsWithDoc(this,t)}static _preElemWithDoc(t,e){return I._preElemTemplate(t,e,[Element,Document],["Element","Document"])}_preElemWithDoc(t){return I._preElemWithDoc(this,t)}static toTinyElm(t){const e=t=>t.map(t=>t instanceof I?t:new I(t));return Array.isArray(t)?e(t):e([t])}static fromTinyElm(t){const e=t=>{const e=[];return t.map(t=>(t instanceof I?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 I._preElems(t,r).filter((t,r)=>!!e.call(t,r,t)!==n);if(e instanceof Element)return I._preElems(t,r).filter(t=>t===e!==n);if(Array.isArray(e)||"string"!=typeof e&&null!=e.length)return I._preElems(t,r).filter(t=>e.includes(t)!==n);let o=e;return n&&(o=`:not(${o})`),I._preElems(t,r).filter(t=>1===t.nodeType&&t.matches(o))}static filter(t,e,r=!1){return r&&(e=`:not(${e})`),I._preElems(t,"filter").filter(t=>1===t.nodeType&&t.matches(e))}static filterOnly(t,e){return I.winnow(t,e,"filterOnly",!1)}static not(t,e){return I.winnow(t,e,"not",!0)}not(t){return I.not(this,t)}static find(t,e){const r=[];for(const n of I._preElems(t,"find"))r.push(...n.querySelectorAll(e));return[...new Set(r)]}find(t){return I.find(this,t)}static is(t,e){return I.winnow(t,e,"is",!1).length>0}is(t){return I.is(this,t)}static has(t,e){const r="string"==typeof e?[...document.querySelectorAll(e)]:I._preElems(e,"has");return I._preElems(t,"has").filter(t=>r.some(e=>t&&t.contains(e)))}has(t){return I.has(this,t)}static closest(t,e,r){const n=[];for(const o of I._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 I.closest(this,t,e)}static isSameDom(t,e){return I._preNodeElem(t,"isSameDom")===I._preNodeElem(e,"isSameDom")}isSameDom(t){return I.isSameDom(this,t)}#l={};get _data(){return{...this.#l}}set _data(t){if("object"!=typeof t||null===t||Array.isArray(t))throw new Error("value must be a non-null object.");this.#l=t}static _dataSelector={public:(t,e)=>{const r=I._preElem(e,t);let n=L.get(r);return n||(n={},L.set(r,n)),n},private:(t,e)=>{if(!(e instanceof I))throw new Error(`Element must be a TinyHtml instance to execute ${t}().`);return e.#l}};static data(t,e,r=!1){const n=I._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 I.data(this,t,e)}static setData(t,e,r,n=!1){const o=I._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:I.removeData(t,e),t}setData(t,e,r=!1){return I.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=I._dataSelector[r?"private":"public"]("hasData",t);return Object.prototype.hasOwnProperty.call(n,e)}hasData(t,e=!1){return I.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 I._dataSelector[r?"private":"public"]("removeData",t)[e]}removeData(t,e=!1){return I.removeData(this,t,e)}static _getSibling(t,e,r){let n=I._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=I._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=I._preNodeElemWithNull(t,"parent");const r=e?e.parentNode:null;return r&&11!==r.nodeType?r:null}parent(){return I.parent(this)}static parents(t,e){return I.domDir(t,"parentNode",e,"parents")}parents(t){return I.parents(this,t)}static next(t){return I._getSibling(t,"nextSibling","next")}next(){return I.next(this)}static prev(t){return I._getSibling(t,"previousSibling","prev")}prev(){return I.prev(this)}static nextAll(t){return I.domDir(t,"nextSibling",void 0,"nextAll")}nextAll(){return I.nextAll(this)}static prevAll(t){return I.domDir(t,"previousSibling",void 0,"prevAll")}prevAll(){return I.prevAll(this)}static nextUntil(t,e){return I.domDir(t,"nextSibling",e,"nextUtil")}nextUntil(t){return I.nextUntil(this,t)}static prevUntil(t,e){return I.domDir(t,"previousSibling",e,"prevUtil")}prevUntil(t){return I.prevUntil(this,t)}static siblings(t){const e=I._preNodeElemWithNull(t,"siblings");return I._getSiblings(e&&e.parentNode?e.parentNode.firstChild:null,e)}siblings(){return I.siblings(this)}static children(t){const e=I._preNodeElemWithNull(t,"children");return I._getSiblings(e?e.firstChild:null)}children(){return I.children(this)}static contents(t){const e=I._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 I.contents(this)}static clone(t,e=!0){if("boolean"!=typeof e)throw new TypeError('The "deep" must be a boolean.');return I._preNodeElems(t,"clone").map(t=>t.cloneNode(e))}clone(t){return I.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 I)r.push(...I._preNodeElems(n,t));else if(Array.isArray(n))r.push(...I._appendChecker(t,...n));else for(const e in n){const o=n[e];r.push(...I._appendChecker(t,o))}else r.push(n);return r}static append(t,...e){return I._preElem(t,"append").append(...I._appendChecker("append",...e)),t}append(...t){return I.append(this,...t)}static prepend(t,...e){return I._preElem(t,"prepend").prepend(...I._appendChecker("prepend",...e)),t}prepend(...t){return I.prepend(this,...t)}static before(t,...e){return I._preElem(t,"before").before(...I._appendChecker("before",...e)),t}before(...t){return I.before(this,...t)}static after(t,...e){return I._preElem(t,"after").after(...I._appendChecker("after",...e)),t}after(...t){return I.after(this,...t)}static replaceWith(t,...e){return I._preElem(t,"replaceWith").replaceWith(...I._appendChecker("replaceWith",...e)),t}replaceWith(...t){return I.replaceWith(this,...t)}static appendTo(t,e){const r=I._preNodeElems(t,"appendTo"),n=I._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 I.appendTo(this,t)}static prependTo(t,e){const r=I._preElems(t,"prependTo"),n=I._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 I.prependTo(this,t)}static insertBefore(t,e,r=null){const n=I._preNodeElem(t,"insertBefore"),o=I._preNodeElem(e,"insertBefore"),i=I._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 I.insertBefore(this,t,e)}static insertAfter(t,e,r=null){const n=I._preNodeElem(t,"insertAfter"),o=I._preNodeElem(e,"insertBefore"),i=I._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 I.insertAfter(this,t,e)}static replaceAll(t,e){const r=I._preNodeElems(t,"replaceAll"),n=I._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 I.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 I([...this.#t,...I._selector(t)])}static _selector(t){if(t instanceof I)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 I._elCheck(r),e(r);if(r instanceof NodeList||r instanceof HTMLCollection){const t=[...r];return I._elCheck(t),e(t)}{const t=[r];return I._elCheck(t),e(t)}}constructor(t){this.#t=I._selector(t),this.#c=I.#p}static isWindow(t){return null!=t&&t===t.window}static css(t){const e=I._preElem(t,"css");return window.getComputedStyle(e)}css(){return I.css(this)}static cssString(t,e){const r=I._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 I.cssString(this,t)}static cssList(t,e){const r=I._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 I.cssList(this,t)}static cssFloat(t,e){const r=I._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 I.cssFloat(this,t)}static cssFloats(t,e){const r=I._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 I.cssFloats(this,t)}static#f={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(I.#f,{set:(t,e,r)=>(t[e]=r,I.cssPropRevAliases[r]=e,!0)});static cssPropRevAliases=Object.fromEntries(Object.entries(I.#f).map(([t,e])=>[e,t]));static toStyleKc(t){return"string"==typeof I.cssPropAliases[t]?I.cssPropAliases[t]:t}static toStyleCc(t){return"string"==typeof I.cssPropRevAliases[t]?I.cssPropRevAliases[t]:t}static setStyle(t,e,r=null){return I._preHtmlElems(t,"setStyle").forEach(t=>{if("object"==typeof e)for(const[r,n]of Object.entries(e))t.style.setProperty(I.toStyleKc(r),"string"==typeof n?n:"number"==typeof n?`${n}px`:String(n));else t.style.setProperty(I.toStyleKc(e),r)}),t}setStyle(t,e){return I.setStyle(this,t,e)}static getStyle(t,e){return I._preHtmlElem(t,"getStyle").style.getPropertyValue(I.toStyleKc(e))}getStyle(t){return I.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=I._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?I.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?I.toStyleCc(n):n]=i}}return o}style(t){return I.style(this,t)}static removeStyle(t,e){return I._preHtmlElems(t,"removeStyle").forEach(t=>{if(Array.isArray(e))for(const r of e)t.style.removeProperty(I.toStyleKc(r));else t.style.removeProperty(I.toStyleKc(e))}),t}removeStyle(t){return I.removeStyle(this,t)}static toggleStyle(t,e,r,n){return I._preHtmlElems(t,"toggleStyle").forEach(t=>{const o=I.getStyle(t,e).trim()===I.toStyleKc(r)?n:r;I.setStyle(t,e,o)}),t}toggleStyle(t,e,r){return I.toggleStyle(this,t,e,r)}static clearStyle(t){return I._preElems(t,"clearStyle").forEach(t=>t.removeAttribute("style")),t}clearStyle(){return I.clearStyle(this)}static focus(t){return I._preHtmlElem(t,"focus").focus(),t}focus(){return I.focus(this)}static blur(t){return I._preHtmlElem(t,"blur").blur(),t}blur(){return I.blur(this)}static select(t){const e=I._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 I.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.");I.setScrollTop(window,t)}static setWinScrollLeft(t){if("number"!=typeof t)throw new TypeError("The value must be a number.");I.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=I._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(I.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?I.cssFloat(i,t+"Left")+I.cssFloat(i,t+"Right"):I.cssFloat(i,t+"Top")+I.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 I.getDimension(this,t,e)}static setHeight(t,e){const r=I._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 I.setHeight(this,t)}set height(t){I.setHeight(this,t)}static setWidth(t,e){const r=I._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 I.setWidth(this,t)}set width(t){I.setWidth(this,t)}static height(t){const e=I._preElemAndWinAndDoc(t,"height");return I.getDimension(e,"height","content")}get height(){return I.height(this)}static width(t){const e=I._preElemAndWinAndDoc(t,"width");return I.getDimension(e,"width","content")}get width(){return I.width(this)}static innerHeight(t){const e=I._preElemAndWinAndDoc(t,"innerHeight");return I.getDimension(e,"height","padding")}innerHeight(){return I.innerHeight(this)}static innerWidth(t){const e=I._preElemAndWinAndDoc(t,"innerWidth");return I.getDimension(e,"width","padding")}innerWidth(){return I.innerWidth(this)}static outerHeight(t,e=!1){if("boolean"!=typeof e)throw new TypeError('The "includeMargin" must be a boolean.');const r=I._preElemAndWinAndDoc(t,"outerHeight");return I.getDimension(r,"height",e?"margin":"border")}outerHeight(t){return I.outerHeight(this,t)}static outerWidth(t,e=!1){if("boolean"!=typeof e)throw new TypeError('The "includeMargin" must be a boolean.');const r=I._preElemAndWinAndDoc(t,"outerWidth");return I.getDimension(r,"width",e?"margin":"border")}outerWidth(t){return I.outerWidth(this,t)}#c="";get mainDisplay(){return this.#c}set mainDisplay(t){if("string"!=typeof t)throw new TypeError("mainDisplay must be a string.");this.#c=t}static#p="block";static get defaultDisplay(){return I.#p}static set defaultDisplay(t){if("string"!=typeof t)throw new TypeError("defaultDisplay must be a string.");I.#p=t}static getAnimateData(t,e){let r=W.get(t);return r||(r={},W.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=W.get(t);n||(n={},W.set(t,n)),n[e]=r}static#u=!0;static get cancelOldStyleFx(){return I.#u}static set cancelOldStyleFx(t){if("boolean"!=typeof t)throw new TypeError("Expected a boolean value.");I.#u=t}static#m={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 I.#m){const r=I.#m[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.`);I.#m={};for(const[e,r]of Object.entries(t))I.setStyleFxSpeed(e,r)}static getStyleFxSpeed(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');const e=I.#m[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");I.#m[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 I.#m[t]}static hasStyleFxSpeed(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(I.#m,t)}static#d=["Top","Right","Bottom","Left"];static#h={slideDown:I.genStyleFx("show"),slideUp:I.genStyleFx("hide"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}};static get styleEffects(){return JSON.parse(JSON.stringify(I.#h))}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}"]`);I.#h={};for(const e in t)I.setStyleEffect(e,t[e])}static getStyleEffect(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');const e=I.#h[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]}I.#h[t]=r}static deleteStyleEffect(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return delete I.#h[t]}static hasStyleEffect(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(I.#h,t)}static#g={slideDown:"slideUp",slideUp:"slideDown",fadeIn:"fadeOut",fadeOut:"fadeIn",fadeTo:"fadeIn"};static get styleEffectInverse(){return{...I.#g}}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.`);I.#g={};for(const[e,r]of Object.entries(t))I.setStyleEffectInverse(e,r)}static getStyleEffectInverse(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return I.#g[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.`);I.#g[t]=e}static deleteStyleEffectInverse(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return delete I.#g[t]}static hasStyleEffectInverse(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(I.#g,t)}static#y={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{...I.#y}}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.`);I.#y={};for(const[e,r]of Object.entries(t))I.setStyleEffectRd(e,r)}static getStyleEffectRd(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return I.#y[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.`);I.#y[t]=e}static deleteStyleEffectRd(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return delete I.#y[t]}static hasStyleEffectRd(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(I.#y,t)}static#E={show:(t,e,r,n)=>{if("height"===r||"width"===r){const o=I.getAnimateData(t,`orig${r}`)||t.scrollHeight+"px";I.setAnimateData(t,`orig${r}`,o);const i=n[r];e[r]=[i,o]}else if(r.startsWith("margin")||r.startsWith("padding")){const o=I.getAnimateData(t,r)||n[r];I.setAnimateData(t,r,o),e[r]=["0px",o]}else if("opacity"===r){const t=n.opacity;e[r]=[t,1]}else{const o=I.getAnimateData(t,r)||n[r];I.setAnimateData(t,r,o),e[r]=[o,n[r]||1]}},hide:(t,e,r,n)=>{if("height"===r||"width"===r){const o=I.getAnimateData(t,`orig${r}`)||n[r];I.setAnimateData(t,`orig${r}`,o);const i=n[r];e[r]=[i,0]}else if(r.startsWith("margin")||r.startsWith("padding")){const o=I.getAnimateData(t,r)||n[r];I.setAnimateData(t,r,o),e[r]=[n[r],"0px"]}else if("opacity"===r){const t=n.opacity;e[r]=[t,0]}else{const o=I.getAnimateData(t,r)||n[r];I.setAnimateData(t,r,o),e[r]=[o,0]}}};static get styleEffectsProps(){return{...I.#E}}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`);I.#E={};for(const[e,r]of Object.entries(t))I.setStyleEffectProp(e,r)}static getStyleEffectProp(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return I.#E[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`);I.#E[t]=e}static deleteStyleEffectProp(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return delete I.#E[t]}static hasStyleEffectProp(t){if("string"!=typeof t)throw new TypeError('The "name" parameter must be a string.');return Object.prototype.hasOwnProperty.call(I.#E,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=I.#d[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 I._preHtmlElems(t,"applyStyleFx").forEach(i=>{const s={};for(const[t,e]of Object.entries(r))if("string"==typeof e&&this.#E[e]){const r=getComputedStyle(i);this.#E[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 I.#y[e]&&I.#y[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,I.animate(t,a,n,e)[0])}),o}applyStyleFx(t,e,r){return I.applyStyleFx(this,t,e,r)}static getCurrentAnimationId(t){if(!(t instanceof HTMLElement))throw new TypeError("Expected an HTMLElement.");return k.get(t)?.id??void 0}static animate(t,e,r=I.#m._default,n=null,o=I.#u){const i="string"==typeof r?I.#m[r]??void 0:"number"!=typeof r?{...r}:r;"object"==typeof i&&void 0===i.fill&&(i.fill="forwards");cons