tiny-essentials 1.21.7 → 1.21.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (()=>{"use strict";var t={d:(e,r)=>{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=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.d(e,{TinyDragger:()=>M});var r={};t.r(r),t.d(r,{areElsCollBottom:()=>n,areElsCollLeft:()=>i,areElsCollPerfBottom:()=>a,areElsCollPerfLeft:()=>c,areElsCollPerfRight:()=>d,areElsCollPerfTop:()=>l,areElsCollRight:()=>s,areElsCollTop:()=>o,areElsColliding:()=>m,areElsPerfColliding:()=>u,getElsCollDetails:()=>w,getElsCollDirDepth:()=>E,getElsCollOverlap:()=>g,getElsCollOverlapPos:()=>f,getElsColliding:()=>h,getElsPerfColliding:()=>p,getElsRelativeCenterOffset:()=>b,getRectCenter:()=>y});const o=(t,e)=>t.bottom<e.top,n=(t,e)=>t.top>e.bottom,i=(t,e)=>t.right<e.left,s=(t,e)=>t.left>e.right,l=(t,e)=>t.bottom<=e.top,a=(t,e)=>t.top>=e.bottom,c=(t,e)=>t.right<=e.left,d=(t,e)=>t.left>=e.right,m=(t,e)=>!(i(t,e)||s(t,e)||o(t,e)||n(t,e)),u=(t,e)=>!(c(t,e)||d(t,e)||l(t,e)||a(t,e)),h=(t,e)=>i(t,e)?"left":s(t,e)?"right":o(t,e)?"top":n(t,e)?"bottom":null,p=(t,e)=>c(t,e)?"left":d(t,e)?"right":l(t,e)?"top":a(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}),f=({overlapLeft:t=-1,overlapRight:e=-1,overlapTop:r=-1,overlapBottom:o=-1}={})=>({dirX:t<e?"right":"left",dirY:r<o?"bottom":"top"}),y=t=>({x:t.left+t.width/2,y:t.top+t.height/2});function b(t,e){const r=t.left+t.width/2,o=t.top+t.height/2;return{x:e.left+e.width/2-r,y:e.top+e.height/2-o}}function E(t,e){if(!u(t,e))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:o,overlapTop:n,overlapBottom:i}=g(t,e),{dirX:s,dirY:l}=f({overlapLeft:r,overlapRight:o,overlapTop:n,overlapBottom:i}),a=Math.min(r,o),c=Math.min(n,i);let d;return d=a<c?s:l,{inDir:d,dirX:s,dirY:l,depthX:a,depthY:c}}function w(t,e){const r=u(t,e),o={in:null,x:null,y:null},n={y:null,x:null},i={top:0,bottom:0,left:0,right:0},{overlapLeft:s,overlapRight:l,overlapTop:a,overlapBottom:c}=g(e,t);i.top=a,i.bottom=c,i.left=s,i.right=l;const d=Object.entries(i).filter(([,t])=>t>0).sort((t,e)=>t[1]-e[1]),{dirX:m,dirY:h}=f({overlapLeft:l,overlapRight:s,overlapTop:c,overlapBottom:a});return o.y=h,o.x=m,i.bottom<0?n.y="bottom":i.top<0&&(n.y="top"),i.left<0?n.x="left":i.right<0&&(n.x="right"),o.in=r?i.top===i.bottom&&i.bottom===i.left&&i.left===i.right?"center":d.length?d[0][0]:"top":null,{dirs:o,depth:i,isNeg:n}}const{areElsColliding:v,areElsPerfColliding:T,areElsCollTop:C,areElsCollBottom:x,areElsCollLeft:_,areElsCollRight:A}=r,D=new WeakMap,L=new WeakMap,S={top:new WeakMap,bottom:new WeakMap,left:new WeakMap,right:new WeakMap};class k{static Utils={...r};static async fetchHtmlFile(t,e={method:"GET"}){const r=await fetch(t,e),o=r.headers.get("Content-Type")||"";if(!r.ok)throw new Error(`Failed to fetch: ${r.status} ${r.statusText}`);if(!o.includes("text/html"))throw new Error(`Invalid content type: ${o} (expected text/html)`);const n=await r.text();return k.htmlToJson(n)}static async fetchHtmlNodes(t,e){const r=await k.fetchHtmlFile(t,e);return k.jsonToNodes(r)}static async fetchHtmlTinyElems(t,e){const r=await k.fetchHtmlNodes(t,e);return k.toTinyElm(r)}static templateToJson(t){return k.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 k.toTinyElm(k.templateToNodes(t))}static htmlToJson(t){const e=document.createElement("div");e.innerHTML=t.trim();const r=[],o=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[k.getPropName(e.name)]=e.value;const n=Array.from(t.childNodes).map(o).filter(Boolean);return n.length>0?[e,r,...n]:[e,r]};for(const t of e.childNodes){const e=o(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,o,...n]=t,i=document.createElement(r);for(const[t,e]of Object.entries(o))i.setAttribute(k.getAttrName(t),e);for(const t of n){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 k.toTinyElm(k.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=k.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 k(document.createElement(t,e))}static createTextNode(t){if("string"!=typeof t)throw new TypeError("[TinyHtml] createTextNode(): The value must be a string.");return new k(document.createTextNode(t))}static createElementFromHTML(t){const e=document.createElement("template");if(!(t=t.trim()).startsWith("<"))return k.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 k(e.content.firstChild)}static query(t,e=document){const r=e.querySelector(t);return r?new k(r):null}querySelector(t){return k.query(t,k._preElem(this,"query"))}static queryAll(t,e=document){return new k(e.querySelectorAll(t))}querySelectorAll(t){return k.queryAll(t,k._preElem(this,"queryAll"))}static getById(t){const e=document.getElementById(t);return e?new k(e):null}static getByClassName(t,e=document){return new k(e.getElementsByClassName(t))}getElementsByClassName(t){return k.getByClassName(t,k._preElem(this,"getByClassName"))}static getByName(t){return new k(document.getElementsByName(t))}static getByTagNameNS(t,e="http://www.w3.org/1999/xhtml",r=document){return new k(r.getElementsByTagNameNS(e,t))}getElementsByTagNameNS(t,e="http://www.w3.org/1999/xhtml"){return k.getByTagNameNS(t,e,k._preElem(this,"getByTagNameNS"))}forEach(t){const e=this.getAll().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 k(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 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 new Error(`[TinyHtml] Invalid Element in ${t}().`);return[...this.#t]}static _preElemsTemplate(t,e,r,o){const n=t=>{const n=[];return t.map(t=>(t instanceof k?t._getElements(e):[t]).map(t=>{let i=!1;for(const e of r)if(t instanceof e){i=!0;break}if(!i)throw new Error(`[TinyHtml] Invalid element of the list "${o.join(",")}" in ${e}().`);return n.push(t),t})),n};return Array.isArray(t)?n(t):n([t])}static _preElemTemplate(t,e,r,o,n=!1){const i=t=>{const i=t[0],s=i instanceof k?i._getElements(e):[i];if(s.length>1)throw new Error(`[TinyHtml] Invalid element amount in ${e}() (Received ${s.length}/1).`);let l=!1;for(const t of r)if(s[0]instanceof t){l=!0;break}if(!n||null!==s[0]&&void 0!==s[0]||(s[0]=null,l=!0),!l)throw new Error(`[TinyHtml] Invalid element of the list "${o.join(",")}" in ${e}().`);return s[0]};if(!Array.isArray(t))return i([t]);if(t.length>1)throw new Error(`[TinyHtml] Invalid element amount in ${e}() (Received ${t.length}/1).`);return i(t)}static _preElems(t,e){return k._preElemsTemplate(t,e,[Element],["Element"])}static _preElem(t,e){return k._preElemTemplate(t,e,[Element],["Element"])}static _preNodeElems(t,e){return k._preElemsTemplate(t,e,[Node],["Node"])}static _preNodeElem(t,e){return k._preElemTemplate(t,e,[Node],["Node"])}static _preNodeElemWithNull(t,e){return k._preElemTemplate(t,e,[Node],["Node"],!0)}static _preHtmlElems(t,e){return k._preElemsTemplate(t,e,[HTMLElement],["HTMLElement"])}static _preHtmlElem(t,e){return k._preElemTemplate(t,e,[HTMLElement],["HTMLElement"])}static _preInputElems(t,e){return k._preElemsTemplate(t,e,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}static _preInputElem(t,e){return k._preElemTemplate(t,e,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}static _preEventTargetElems(t,e){return k._preElemsTemplate(t,e,[EventTarget],["EventTarget"])}static _preEventTargetElem(t,e){return k._preElemTemplate(t,e,[EventTarget],["EventTarget"])}static _preElemsAndWindow(t,e){return k._preElemsTemplate(t,e,[Element,Window],["Element","Window"])}static _preElemAndWindow(t,e){return k._preElemTemplate(t,e,[Element,Window],["Element","Window"])}static _preElemsAndWinAndDoc(t,e){return k._preElemsTemplate(t,e,[Element,Window,Document],["Element","Window","Document"]).map(t=>t instanceof Document?t.documentElement:t)}static _preElemAndWinAndDoc(t,e){const r=k._preElemTemplate(t,e,[Element,Window,Document],["Element","Window","Document"]);return r instanceof Document?r.documentElement:r}static _preElemsWithDoc(t,e){return k._preElemsTemplate(t,e,[Element,Document],["Element","Document"])}static _preElemWithDoc(t,e){return k._preElemTemplate(t,e,[Element,Document],["Element","Document"])}static toTinyElm(t){const e=t=>t.map(t=>t instanceof k?t:new k(t));return Array.isArray(t)?e(t):e([t])}static fromTinyElm(t){const e=t=>{const e=[];return t.map(t=>(t instanceof k?t._getElements("fromTinyElm"):[t]).map(t=>e.push(t))),e};return Array.isArray(t)?e(t):e([t])}static winnow(t,e,r,o=!1){if("boolean"!=typeof o)throw new TypeError('The "not" must be a boolean.');if("function"==typeof e)return k._preElems(t,r).filter((t,r)=>!!e.call(t,r,t)!==o);if(e instanceof Element)return k._preElems(t,r).filter(t=>t===e!==o);if(Array.isArray(e)||"string"!=typeof e&&null!=e.length)return k._preElems(t,r).filter(t=>e.includes(t)!==o);let n=e;return o&&(n=`:not(${n})`),k._preElems(t,r).filter(t=>1===t.nodeType&&t.matches(n))}static filter(t,e,r=!1){return r&&(e=`:not(${e})`),k._preElems(t,"filter").filter(t=>1===t.nodeType&&t.matches(e))}static filterOnly(t,e){return k.winnow(t,e,"filterOnly",!1)}static not(t,e){return k.winnow(t,e,"not",!0)}not(t){return k.not(this,t)}static find(t,e){const r=[];for(const o of k._preElems(t,"find"))r.push(...o.querySelectorAll(e));return[...new Set(r)]}find(t){return k.find(this,t)}static is(t,e){return k.winnow(t,e,"is",!1).length>0}is(t){return k.is(this,t)}static has(t,e){const r="string"==typeof e?[...document.querySelectorAll(e)]:k._preElems(e,"has");return k._preElems(t,"has").filter(t=>r.some(e=>t&&t.contains(e)))}has(t){return k.has(this,t).length>0}static closest(t,e,r){const o=[];for(const n of k._preElems(t,"closest")){let t=n;for(;t&&t!==r;){if(1===t.nodeType&&("string"==typeof e?t.matches(e):t===e)){o.push(t);break}t=t.parentElement}}return[...new Set(o)]}closest(t,e){return k.closest(this,t,e)}static isSameDom(t,e){return k._preNodeElem(t,"isSameDom")===k._preNodeElem(e,"isSameDom")}isSameDom(t){return k.isSameDom(this,t)}#e={};get _data(){return{...this.#e}}set _data(t){if("object"!=typeof t||null===t||Array.isArray(t))throw new Error("value must be a non-null object.");this.#e=t}static _dataSelector={public:(t,e)=>{const r=k._preElem(e,t);let o=L.get(r);return o||(o={},L.set(r,o)),o},private:(t,e)=>{if(!(e instanceof k))throw new Error(`Element must be a TinyHtml instance to execute ${t}().`);return e.#e}};static data(t,e,r=!1){const o=k._dataSelector[r?"private":"public"]("data",t);if(null==e)return{...o};if("string"!=typeof e)throw new TypeError("The key must be a string.");return o.hasOwnProperty(e)?o[e]:void 0}data(t,e){return k.data(this,t,e)}static setData(t,e,r,o=!1){const n=k._dataSelector[o?"private":"public"]("setData",t);if("string"!=typeof e)throw new TypeError("The key must be a string.");return n[e]=r,t}setData(t,e,r=!1){return k.setData(this,t,e,r)}static _getSibling(t,e,r){let o=k._preNodeElemWithNull(t,r);for(;o&&(o=o[e])&&1!==o.nodeType;);return o instanceof Node?o:null}static _getSiblings(t,e){let r=t;const o=[];for(;r;r=r.nextSibling)1===r.nodeType&&r!==e&&o.push(r);return o}static domDir(t,e,r,o="domDir"){if("string"!=typeof e)throw new TypeError('The "direction" must be a string.');let n=k._preNodeElemWithNull(t,o);const i=[];for(;n&&(n=n[e]);)if(1===n.nodeType){if(r&&("string"==typeof r?n.matches(r):n===r))break;i.push(n)}return i}static parent(t){let e=k._preNodeElemWithNull(t,"parent");const r=e?e.parentNode:null;return r&&11!==r.nodeType?r:null}parent(){return k.parent(this)}static parents(t,e){return k.domDir(t,"parentNode",e,"parents")}parents(t){return k.parents(this,t)}static next(t){return k._getSibling(t,"nextSibling","next")}next(){return k.next(this)}static prev(t){return k._getSibling(t,"previousSibling","prev")}prev(){return k.prev(this)}static nextAll(t){return k.domDir(t,"nextSibling",void 0,"nextAll")}nextAll(){return k.nextAll(this)}static prevAll(t){return k.domDir(t,"previousSibling",void 0,"prevAll")}prevAll(){return k.prevAll(this)}static nextUntil(t,e){return k.domDir(t,"nextSibling",e,"nextUtil")}nextUntil(t){return k.nextUntil(this,t)}static prevUntil(t,e){return k.domDir(t,"previousSibling",e,"prevUtil")}prevUntil(t){return k.prevUntil(this,t)}static siblings(t){const e=k._preNodeElemWithNull(t,"siblings");return k._getSiblings(e&&e.parentNode?e.parentNode.firstChild:null,e)}siblings(){return k.siblings(this)}static children(t){const e=k._preNodeElemWithNull(t,"children");return k._getSiblings(e?e.firstChild:null)}children(){return k.children(this)}static contents(t){const e=k._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 k.contents(this)}static clone(t,e=!0){if("boolean"!=typeof e)throw new TypeError('The "deep" must be a boolean.');return k._preNodeElems(t,"clone").map(t=>t.cloneNode(e))}clone(t){return k.clone(this,t)[0]}static _appendChecker(t,...e){const r=[],o=[...e];for(const e in o)"string"!=typeof o[e]?r.push(k._preNodeElem(o[e],t)):r.push(o[e]);return r}static append(t,...e){return k._preElem(t,"append").append(...k._appendChecker("append",...e)),t}append(...t){return k.append(this,...t)}static prepend(t,...e){return k._preElem(t,"prepend").prepend(...k._appendChecker("prepend",...e)),t}prepend(...t){return k.prepend(this,...t)}static before(t,...e){return k._preElem(t,"before").before(...k._appendChecker("before",...e)),t}before(...t){return k.before(this,...t)}static after(t,...e){return k._preElem(t,"after").after(...k._appendChecker("after",...e)),t}after(...t){return k.after(this,...t)}static replaceWith(t,...e){return k._preElem(t,"replaceWith").replaceWith(...k._appendChecker("replaceWith",...e)),t}replaceWith(...t){return k.replaceWith(this,...t)}static appendTo(t,e){const r=k._preNodeElems(t,"appendTo"),o=k._preNodeElems(e,"appendTo");return o.forEach((t,e)=>{r.forEach(r=>t.appendChild(e===o.length-1?r:r.cloneNode(!0)))}),t}appendTo(t){return k.appendTo(this,t)}static prependTo(t,e){const r=k._preElems(t,"prependTo"),o=k._preElems(e,"prependTo");return o.forEach((t,e)=>{r.slice().reverse().forEach(r=>t.prepend(e===o.length-1?r:r.cloneNode(!0)))}),t}prependTo(t){return k.prependTo(this,t)}static insertBefore(t,e,r=null){const o=k._preNodeElem(t,"insertBefore"),n=k._preNodeElem(e,"insertBefore"),i=k._preNodeElemWithNull(r,"insertBefore");if(!n.parentNode)throw new Error("The target element has no parent node to insert before.");return n.parentNode.insertBefore(o,i||n),t}insertBefore(t,e){return k.insertBefore(this,t,e)}static insertAfter(t,e,r=null){const o=k._preNodeElem(t,"insertAfter"),n=k._preNodeElem(e,"insertBefore"),i=k._preNodeElemWithNull(r,"insertBefore");if(!n.parentNode)throw new Error("The target element has no parent node to insert after.");return n.parentNode.insertBefore(o,i||n.nextSibling),t}insertAfter(t,e){return k.insertAfter(this,t,e)}static replaceAll(t,e){const r=k._preNodeElems(t,"replaceAll"),o=k._preNodeElems(e,"replaceAll");return o.forEach((t,e)=>{const n=t.parentNode;r.forEach(r=>{n&&n.replaceChild(e===o.length-1?r:r.cloneNode(!0),t)})}),t}replaceAll(t){return k.replaceAll(this,t)}#t;get size(){return this.#t.length}constructor(t){if(t instanceof k)throw new Error("[TinyHtml] You are trying to put a TinyHtml inside another TinyHtml in constructor.");const e=t=>{if(!t.every(t=>t instanceof Element||t instanceof Window||t instanceof Document||t instanceof Text))throw new Error("[TinyHtml] Invalid Target in constructor.")};if(Array.isArray(t))e(t),this.#t=t;else if(t instanceof NodeList||t instanceof HTMLCollection){const r=[...t];e(r),this.#t=r}else{const r=[t];e(r),this.#t=r}}static isWindow(t){return null!=t&&t===t.window}static css(t){const e=k._preElem(t,"css");return window.getComputedStyle(e)}css(){return k.css(this)}static cssString(t,e){const r=k._preElem(t,"cssString");if("string"!=typeof e)throw new TypeError("The prop must be a string.");const o=window.getComputedStyle(r)[e];return"string"==typeof o?o:"number"==typeof o?o.toString():null}cssString(t){return k.cssString(this,t)}static cssList(t,e){const r=k._preElem(t,"cssList");if(!Array.isArray(e))throw new TypeError("The prop must be an array of strings.");const o=window.getComputedStyle(r),n={};for(const t of e)void 0!==t&&(n[t]=o.getPropertyValue(t));return n}cssList(t){return k.cssList(this,t)}static cssFloat(t,e){const r=k._preElem(t,"cssFloat");if("string"!=typeof e)throw new TypeError("The prop must be a string.");const o=window.getComputedStyle(r)[e];return parseFloat(o)||0}cssFloat(t){return k.cssFloat(this,t)}static cssFloats(t,e){const r=k._preElem(t,"cssFloats");if(!Array.isArray(e))throw new TypeError("The prop must be an array of strings.");const o=window.getComputedStyle(r),n={};for(const t of e)n[t]=parseFloat(o[t])||0;return n}cssFloats(t){return k.cssFloats(this,t)}static#r={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(k.#r,{set:(t,e,r)=>(t[e]=r,k.cssPropRevAliases[r]=e,!0)});static cssPropRevAliases=Object.fromEntries(Object.entries(k.#r).map(([t,e])=>[e,t]));static toStyleKc(t){return"string"==typeof k.cssPropAliases[t]?k.cssPropAliases[t]:t}static toStyleCc(t){return"string"==typeof k.cssPropRevAliases[t]?k.cssPropRevAliases[t]:t}static setStyle(t,e,r=null){return k._preHtmlElems(t,"setStyle").forEach(t=>{if("object"==typeof e)for(const[r,o]of Object.entries(e))t.style.setProperty(k.toStyleKc(r),"string"==typeof o?o:"number"==typeof o?`${o}px`:String(o));else t.style.setProperty(k.toStyleKc(e),r)}),t}setStyle(t,e){return k.setStyle(this,t,e)}static getStyle(t,e){return k._preHtmlElem(t,"getStyle").style.getPropertyValue(k.toStyleKc(e))}getStyle(t){return k.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 o=k._preHtmlElem(t,"style"),n={};if(r){const t=(o.getAttribute("style")||"").split(";");for(const r of t){const[t,o]=r.split(":");if(!t||!o)continue;const i=t.trim(),s=o.trim();n[e?k.toStyleCc(i):i]=s}}else{const t=o.style;for(let r=0;r<t.length;r++){const o=t[r],i=t.getPropertyValue(o);n[e?k.toStyleCc(o):o]=i}}return n}style(t){return k.style(this,t)}static removeStyle(t,e){return k._preHtmlElems(t,"removeStyle").forEach(t=>{if(Array.isArray(e))for(const r of e)t.style.removeProperty(k.toStyleKc(r));else t.style.removeProperty(k.toStyleKc(e))}),t}removeStyle(t){return k.removeStyle(this,t)}static toggleStyle(t,e,r,o){return k._preHtmlElems(t,"toggleStyle").forEach(t=>{const n=k.getStyle(t,e).trim()===k.toStyleKc(r)?o:r;k.setStyle(t,e,n)}),t}toggleStyle(t,e,r){return k.toggleStyle(this,t,e,r)}static clearStyle(t){return k._preElems(t,"clearStyle").forEach(t=>t.removeAttribute("style")),t}clearStyle(){return k.clearStyle(this)}static focus(t){return k._preHtmlElem(t,"focus").focus(),t}focus(){return k.focus(this)}static blur(t){return k._preHtmlElem(t,"blur").blur(),t}blur(){return k.blur(this)}static select(t){const e=k._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 k.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.");k.setScrollTop(window,t)}static setWinScrollLeft(t){if("number"!=typeof t)throw new TypeError("The value must be a number.");k.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 o=k._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 n="width"===e?"Width":"Height";if(k.isWindow(o))return"margin"===r?o["inner"+n]:o.document.documentElement["client"+n];const i=o;if(9===i.nodeType){const t=i.documentElement;return Math.max(i.body["scroll"+n],t["scroll"+n],i.body["offset"+n],t["offset"+n],t["client"+n])}let s=i.getBoundingClientRect()[e];function l(t){return"width"===e?k.cssFloat(i,t+"Left")+k.cssFloat(i,t+"Right"):k.cssFloat(i,t+"Top")+k.cssFloat(i,t+"Bottom")}switch(r){case"content":s-=l("padding"),s-=l("border");break;case"padding":s-=l("border");break;case"border":break;case"margin":s+=l("margin")}return s}getDimension(t,e){return k.getDimension(this,t,e)}static setHeight(t,e){const r=k._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 k.setHeight(this,t)}static setWidth(t,e){const r=k._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 k.setWidth(this,t)}static height(t){const e=k._preElemAndWinAndDoc(t,"height");return k.getDimension(e,"height","content")}height(){return k.height(this)}static width(t){const e=k._preElemAndWinAndDoc(t,"width");return k.getDimension(e,"width","content")}width(){return k.width(this)}static innerHeight(t){const e=k._preElemAndWinAndDoc(t,"innerHeight");return k.getDimension(e,"height","padding")}innerHeight(){return k.innerHeight(this)}static innerWidth(t){const e=k._preElemAndWinAndDoc(t,"innerWidth");return k.getDimension(e,"width","padding")}innerWidth(){return k.innerWidth(this)}static outerHeight(t,e=!1){if("boolean"!=typeof e)throw new TypeError('The "includeMargin" must be a boolean.');const r=k._preElemAndWinAndDoc(t,"outerHeight");return k.getDimension(r,"height",e?"margin":"border")}outerHeight(t){return k.outerHeight(this,t)}static outerWidth(t,e=!1){if("boolean"!=typeof e)throw new TypeError('The "includeMargin" must be a boolean.');const r=k._preElemAndWinAndDoc(t,"outerWidth");return k.getDimension(r,"width",e?"margin":"border")}outerWidth(t){return k.outerWidth(this,t)}static animate(t,e,r){return k._preElems(t,"animate").forEach(t=>t.animate(e,r)),t}animate(t,e){return k.animate(this,t,e)}static offset(t){const e=k._preElem(t,"offset").getBoundingClientRect(),r=window.scrollY||document.documentElement.scrollTop,o=window.scrollX||document.documentElement.scrollLeft;return{top:e.top+r,left:e.left+o}}offset(){return k.offset(this)}static position(t){const e=k._preHtmlElem(t,"position");let r,o,n={top:0,left:0};if("fixed"===window.getComputedStyle(e).position)o=e.getBoundingClientRect();else{o=k.offset(e),r=e.offsetParent||document.documentElement;const{position:t}=window.getComputedStyle(r);for(;r instanceof HTMLElement&&(r===document.body||r===document.documentElement)&&"static"===t;)r=r.parentNode;if(r instanceof HTMLElement&&r!==e&&1===r.nodeType){const{borderTopWidth:t,borderLeftWidth:e}=k.cssFloats(r,["borderTopWidth","borderLeftWidth"]);n=k.offset(r),n.top+=t,n.left+=e}}return{top:o.top-n.top-k.cssFloat(e,"marginTop"),left:o.left-n.left-k.cssFloat(e,"marginLeft")}}position(){return k.position(this)}static offsetParent(t){let e=k._preHtmlElem(t,"offsetParent").offsetParent;for(;e instanceof HTMLElement&&"static"===window.getComputedStyle(e).position;)e=e.offsetParent;return e instanceof HTMLElement?e:document.documentElement}offsetParent(){return k.offsetParent(this)}static scrollTop(t){const e=k._preElemAndWindow(t,"scrollTop");return k.isWindow(e)?e.pageYOffset:9===e.nodeType?e.defaultView.pageYOffset:e.scrollTop}scrollTop(){return k.scrollTop(this)}static scrollLeft(t){const e=k._preElemAndWindow(t,"scrollLeft");return k.isWindow(e)?e.pageXOffset:9===e.nodeType?e.defaultView.pageXOffset:e.scrollLeft}scrollLeft(){return k.scrollLeft(this)}static easings={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:(4-2*t)*t-1,easeInCubic:t=>t*t*t,easeOutCubic:t=>--t*t*t+1,easeInOutCubic:t=>t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1};static scrollToXY(t,{targetX:e,targetY:r,duration:o,easing:n,onAnimation:i}={}){if(void 0!==e&&"number"!=typeof e)throw new TypeError("`targetX` must be a number if provided.");if(void 0!==r&&"number"!=typeof r)throw new TypeError("`targetY` must be a number if provided.");if(void 0!==o&&"number"!=typeof o)throw new TypeError("`duration` must be a number if provided.");if(void 0!==n&&"string"!=typeof n)throw new TypeError("`easing` must be a string if provided.");if(void 0!==n&&"function"!=typeof k.easings[n])throw new TypeError(`Unknown easing function: "${n}".`);if(void 0!==i&&"function"!=typeof i)throw new TypeError("`onAnimation` must be a function if provided.");const s=(t,e,r,o)=>{if(t instanceof Window)window.scrollTo(e,r);else if(9===t.nodeType)t.defaultView.scrollTo(e,r);else{const o=t instanceof Window?window.scrollX:t.scrollLeft,n=t instanceof Window?window.scrollY:t.scrollTop;o!==e&&(t.scrollLeft=e),n!==r&&(t.scrollTop=r)}"function"==typeof i&&i({x:e,y:r,isComplete:o>=1,time:o})};return k._preElemsAndWindow(t,"scrollToXY").forEach(t=>{const i=t instanceof Window?window.scrollX:t.scrollLeft,l=t instanceof Window?window.scrollY:t.scrollTop,a=e??i,c=r??l,d=a-i,m=c-l,u="string"==typeof n&&k.easings[n]||null;if("number"!=typeof o||"function"!=typeof u)return s(t,a,c,1);const h=performance.now(),p=o??0;requestAnimationFrame(function e(r){if("function"!=typeof u)return;const o=Math.min(1,(r-h)/p),n=u(o);s(t,i+d*n,l+m*n,o),o<1&&requestAnimationFrame(e)})}),t}scrollToXY({targetX:t,targetY:e,duration:r,easing:o,onAnimation:n}={}){return k.scrollToXY(this,{targetX:t,targetY:e,duration:r,easing:o,onAnimation:n})}static setScrollTop(t,e){if("number"!=typeof e)throw new TypeError("ScrollTop value must be a number.");return k.scrollToXY(t,{targetY:e})}setScrollTop(t){return k.setScrollTop(this,t)}static setScrollLeft(t,e){if("number"!=typeof e)throw new TypeError("ScrollLeft value must be a number.");return k.scrollToXY(t,{targetX:e})}setScrollLeft(t){return k.setScrollLeft(this,t)}static borderWidth(t){const e=k._preElem(t,"borderWidth"),{borderLeftWidth:r,borderRightWidth:o,borderTopWidth:n,borderBottomWidth:i}=k.cssFloats(e,["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"]);return{x:r+o,y:n+i,left:r,right:o,top:n,bottom:i}}borderWidth(){return k.borderWidth(this)}static border(t){const e=k._preElem(t,"border"),{borderLeft:r,borderRight:o,borderTop:n,borderBottom:i}=k.cssFloats(e,["borderLeft","borderRight","borderTop","borderBottom"]);return{x:r+o,y:n+i,left:r,right:o,top:n,bottom:i}}border(){return k.border(this)}static margin(t){const e=k._preElem(t,"margin"),{marginLeft:r,marginRight:o,marginTop:n,marginBottom:i}=k.cssFloats(e,["marginLeft","marginRight","marginTop","marginBottom"]);return{x:r+o,y:n+i,left:r,right:o,top:n,bottom:i}}margin(){return k.margin(this)}static padding(t){const e=k._preElem(t,"padding"),{paddingLeft:r,paddingRight:o,paddingTop:n,paddingBottom:i}=k.cssFloats(e,["paddingLeft","paddingRight","paddingTop","paddingBottom"]);return{x:r+o,y:n+i,left:r,right:o,top:n,bottom:i}}padding(){return k.padding(this)}static addClass(t,...e){return k._preElems(t,"addClass").forEach(t=>t.classList.add(...e)),t}addClass(...t){return k.addClass(this,...t)}static removeClass(t,...e){return k._preElems(t,"removeClass").forEach(t=>t.classList.remove(...e)),t}removeClass(...t){return k.removeClass(this,...t)}static replaceClass(t,e,r){if("string"!=typeof e)throw new TypeError('The "token" parameter must be a string.');if("string"!=typeof r)throw new TypeError('The "newToken" parameter must be a string.');const o=[];return k._preElems(t,"replaceClass").forEach(t=>o.push(t.classList.replace(e,r))),o}replaceClass(t,e){return k.replaceClass(this,t,e)[0]}static classItem(t,e){const r=k._preElem(t,"classItem");if("number"!=typeof e)throw new TypeError('The "index" parameter must be a number.');return r.classList.item(e)}classItem(t){return k.classItem(this,t)}static toggleClass(t,e,r){if("string"!=typeof e)throw new TypeError('The "token" parameter must be a string.');if(void 0!==r&&"boolean"!=typeof r)throw new TypeError('The "force" parameter must be a boolean.');const o=[];return k._preElems(t,"toggleClass").forEach(t=>o.push(t.classList.toggle(e,r))),o}toggleClass(t,e){return k.toggleClass(this,t,e)[0]}static hasClass(t,e){const r=k._preElem(t,"hasClass");if("string"!=typeof e)throw new TypeError('The "token" parameter must be a string.');return r.classList.contains(e)}hasClass(t){return k.hasClass(this,t)}static classLength(t){return k._preElem(t,"classLength").classList.length}classLength(){return k.classLength(this)}static classList(t){return k._preElem(t,"classList").classList.values().toArray()}classList(){return k.classList(this)}static tagName(t){return k._preElem(t,"tagName").tagName}tagName(){return k.tagName(this)}static id(t){return k._preElem(t,"id").id}id(){return k.id(this)}static toBigInt(t){const e=k._preElem(t,"toBigInt"),r=e.textContent?.trim();let o=null;try{o=BigInt(r??"")}catch{o=null}return o}toBigInt(){return k.toBigInt(this)}static setBigInt(t,e){if("bigint"!=typeof e)throw new Error("Value is not a valid BigInt.");const r=e.toString();return k._preElems(t,"setBigInt").forEach(t=>t.textContent=r),t}setBigInt(t){return k.setBigInt(this,t)}static toDate(t){const e=k._preElem(t,"toDate"),r=e.textContent?.trim();if(!r)return null;const o=new Date(r);return Number.isNaN(o.getTime())?null:o}toDate(){return k.toDate(this)}static setDate(t,e){if(!(e instanceof Date)||Number.isNaN(e.getTime()))throw new Error("Value is not a valid Date.");const r=e.toISOString();return k._preElems(t,"setDate").forEach(t=>t.textContent=r),t}setDate(t){return k.setDate(this,t)}static toJson(t){const e=k._preElem(t,"toJson"),r=e.textContent?.trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}toJson(){return k.toJson(this)}static setJson(t,e,r,o){const n=JSON.stringify(e,r,o);return k._preElems(t,"setJson").forEach(t=>t.textContent=n),t}setJson(t,e,r){return k.setJson(this,t,e,r)}static toNumber(t){const e=k._preElem(t,"toNumber");return"string"==typeof e.textContent?parseFloat(e.textContent.trim()):null}toNumber(){return k.toNumber(this)}static setNumber(t,e){if("number"!=typeof e)throw new Error("Value is not a valid number.");const r=e.toString();return k._preElems(t,"setNumber").forEach(t=>t.textContent=r),t}setNumber(t){return k.setNumber(this,t)}static toBoolean(t){const e=k._preElem(t,"toBoolean"),r=e.textContent?.trim();return null==r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}toBoolean(){return k.toBoolean(this)}static setBoolean(t,e){if("boolean"!=typeof e)throw new Error("Value is not a valid boolean.");const r=e.toString();return k._preElems(t,"setBoolean").forEach(t=>t.textContent=r),t}setBoolean(t){return k.setBoolean(this,t)}static toString(t){const e=k._preElem(t,"toString");return"string"==typeof e.textContent?e.textContent:null}toString(){return k.toString(this)}static setString(t,e){if("string"!=typeof e)throw new Error("Value is not a valid string.");return k._preElems(t,"setString").forEach(t=>t.textContent=e),t}setString(t){return k.setString(this,t)}static text(t){return k._preElem(t,"text").textContent}text(){return k.text(this)}static setText(t,e){const r=String(e);return k._preElems(t,"setText").forEach(t=>t.textContent=r),t}setText(t){return k.setText(this,t)}static empty(t){return k._preElems(t,"empty").forEach(t=>t.textContent=""),t}empty(){return k.empty(this)}static html(t,e){return k._preElem(t,"html").getHTML(e)}html(t){return k.html(this,t)}static setHtml(t,e){if("string"!=typeof e)throw new Error("Value is not a valid string.");return k._preElems(t,"setHtml").forEach(t=>t.innerHTML=e),t}setHtml(t){return k.setHtml(this,t)}static _valHooks={option:{get:t=>{const e=t.getAttribute("value");return null!=e?e:t.textContent}},select:{get:t=>{const e=t.options,r=t.selectedIndex,o="select-one"===t.type,n=o?r+1:e.length,i=[];let s=r<0?n:o?r:0;for(;s<n;s++){const t=e[s],n=t.parentNode;if((t.selected||s===r)&&!t.disabled&&(!n||!n.disabled||"OPTGROUP"!==n.tagName)){const e=k._valHooks.option.get(t);if(o)return e;i.push(e)}}return i},set:(t,e)=>{const r=t.options,o=Array.isArray(e)?e.map(String):[String(e)];let n=!1;for(let t=0;t<r.length;t++){const e=r[t],i=k._valHooks.option.get(e);"string"==typeof i&&(e.selected=o.includes(i))&&(n=!0)}return n||(t.selectedIndex=-1),o}},radio:{get:t=>t.checked?"on":"off",set(t,e){if("boolean"==typeof e){const r=t.closest("label");return e&&r&&r.querySelectorAll('input[type="radio"]').forEach(e=>{e instanceof HTMLInputElement&&e!==t&&(e.checked=!1)}),t.checked=e,e}}},checkbox:{get:t=>t.checked?"on":"off",set(t,e){if("boolean"==typeof e)return t.checked=e,e}}};static setVal(t,e){return k._preInputElems(t,"setVal").forEach(t=>{if(1!==t.nodeType)return;let r="function"==typeof e?e(t,k.val(t)):e;null==r?r="":"number"==typeof r?r=String(r):Array.isArray(r)&&(r=((t,e)=>{const r=[];for(let o=0;o<t.length;o++)r.push(e(t[o]));return r})(r,t=>null==t?"":String(t)));const o=k._valHooks[t.type]||k._valHooks[t.nodeName.toLowerCase()];if(!o||"function"!=typeof o.set||void 0===o.set(t,r,"value")){if("string"!=typeof r&&"boolean"!=typeof r)throw new Error(`Invalid setValue "${typeof r}" value.`);"string"==typeof r&&(t.value=r)}}),t}setVal(t){return k.setVal(this,t)}static _valTypes={string:t=>t.value,date:t=>t.valueAsDate,number:t=>t.valueAsNumber};static _getValByType(t,e,r){if("string"!=typeof e)throw new TypeError('The "type" must be a string.');if("string"!=typeof r)throw new TypeError('The "where" must be a string.');if(!(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement))throw new Error(`Provided element is not an HTMLInputElement in ${r}().`);if("function"!=typeof k._valTypes[e])throw new Error(`No handler found for type "${e}" in ${r}().`);return k._valTypes[e](t)}static _val(t,e,r){const o=k._preInputElem(t,e),n=k._valHooks[o.type]||k._valHooks[o.nodeName.toLowerCase()];if(n&&"function"==typeof n.get){const t=n.get(o,"value",r);if(void 0!==t)return"string"==typeof t?t.replace(/\r/g,""):t}return k._getValByType(o,r,e)}_val(t,e){return k._val(this,t,e)}static val(t){return k._val(t,"val","string")}val(){return k.val(this)}static valTxt(t){const e=k._val(t,"valTxt","string");if("string"!=typeof e&&null!==e)throw new Error("Value is not a valid string.");return null==e?"":"string"==typeof e?e.replace(/\r/g,""):e}valTxt(){return k.valTxt(this)}static _valArr(t,e,r){const o=k._val(t,e,r);if(!Array.isArray(o))throw new Error(`Value expected an array but got ${typeof o}.`);return o}_valArr(t,e){return k._valArr(this,t,e)}static valArr(t){return k._valArr(t,"valArr","string")}valArr(){return k.valArr(this)}static valNb(t){if(!(k._preInputElem(t,"valNb")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const e=k._val(t,"valNb","number");if(Number.isNaN(e))throw new Error("Value is not a valid number.");return e}valNb(){return k.valNb(this)}static valDate(t){if(!(k._preInputElem(t,"valDate")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const e=k._val(t,"valDate","date");if(!(e instanceof Date))throw new Error("Value is not a valid date.");return e}valDate(){return k.valDate(this)}static valBool(t){const e=k._preInputElem(t,"valBool");if(!(e instanceof HTMLInputElement))throw new Error("Element must be an input element.");return"on"===k.val(e)}valBool(){return k.valBool(this)}static listenForPaste(t,{onFilePaste:e,onTextPaste:r}={}){if(void 0!==e&&"function"!=typeof e)throw new TypeError("onFilePaste must be a function.");if(void 0!==r&&"function"!=typeof r)throw new TypeError("onTextPaste must be a function.");const o=t=>{if(!(t instanceof ClipboardEvent))return;const o=t.clipboardData?.items||[];for(const t of o)if("file"===t.kind){if("function"==typeof e){const r=t.getAsFile();r&&e(t,r)}}else"string"===t.kind&&"function"==typeof r&&t.getAsString(e=>r(t,e))};return k._preElemsWithDoc(t,"listenForPaste").forEach(t=>k.on(t,"paste",o)),o}listenForPaste({onFilePaste:t,onTextPaste:e}={}){return k.listenForPaste(this,{onFilePaste:t,onTextPaste:e})}static hasEventListener(t,e){const r=k._preEventTargetElem(t,"hasEventListener");if(!D.has(r))return!1;const o=D.get(r);return!!(o&&Array.isArray(o[e])&&o[e].length>0)}hasEventListener(t){return k.hasEventListener(this,t)}static hasExactEventListener(t,e,r){const o=k._preEventTargetElem(t,"hasExactEventListener");if("function"!=typeof r)throw new TypeError('The "handler" must be a function.');if(!D.has(o))return!1;const n=D.get(o);return!(!n||!Array.isArray(n[e]))&&n[e].some(t=>t.handler===r)}hasExactEventListener(t,e){return k.hasExactEventListener(this,t,e)}static on(t,e,r,o){if(!("string"==typeof e||Array.isArray(e)&&e.every(t=>"string"==typeof t)))throw new TypeError("The events must be a string or array of strings.");for(const n of Array.isArray(e)?Array.from(new Set(e)):[e]){if("string"!=typeof n)throw new TypeError("The event name must be a string.");k._preEventTargetElems(t,"on").forEach(t=>{t.addEventListener(n,r,o),D.has(t)||D.set(t,{});const e=D.get(t);e&&(Array.isArray(e[n])||(e[n]=[]),e[n].push({handler:r,options:o}))})}return t}on(t,e,r){return k.on(this,t,e,r)}static once(t,e,r,o={}){if(!("string"==typeof e||Array.isArray(e)&&e.every(t=>"string"==typeof t)))throw new TypeError("The events must be a string or array of strings.");for(const n of Array.isArray(e)?Array.from(new Set(e)):[e]){if("string"!=typeof n)throw new TypeError("The event name must be a string.");k._preEventTargetElems(t,"once").forEach(t=>{const e=o=>{k.off(t,n,e),"function"==typeof r&&r(o)};k.on(t,n,e,"boolean"==typeof o?o:{...o,once:!0})})}return t}once(t,e,r={}){return k.once(this,t,e,r)}static off(t,e,r,o){if(!("string"==typeof e||Array.isArray(e)&&e.every(t=>"string"==typeof t)))throw new TypeError("The events must be a string or array of strings.");for(const n of Array.isArray(e)?Array.from(new Set(e)):[e]){if("string"!=typeof n)throw new TypeError("The event name must be a string.");k._preEventTargetElems(t,"off").forEach(t=>{t.removeEventListener(n,r,o);const e=D.get(t);e&&e[n]&&(e[n]=e[n].filter(t=>t.handler!==r),0===e[n].length&&delete e[n])})}return t}off(t,e,r){return k.off(this,t,e,r)}static offAll(t,e){if(!("string"==typeof e||Array.isArray(e)&&e.every(t=>"string"==typeof t)))throw new TypeError("The events must be a string or array of strings.");for(const r of Array.isArray(e)?Array.from(new Set(e)):[e]){if("string"!=typeof r)throw new TypeError("The event name must be a string.");k._preEventTargetElems(t,"offAll").forEach(t=>{const e=D.get(t);if(e&&e[r]){for(const o of e[r])t.removeEventListener(r,o.handler,o.options);delete e[r]}})}return t}offAll(t){return k.offAll(this,t)}static offAllTypes(t,e=null){if(null!==e&&"function"!=typeof e)throw new TypeError('The "filterFn" must be a function.');return k._preEventTargetElems(t,"offAllTypes").forEach(t=>{const r=D.get(t);if(r){for(const o in r)for(const n of r[o])("function"!=typeof e||e(n.handler,o))&&t.removeEventListener(o,n.handler,n.options);D.delete(t)}}),t}offAllTypes(t=null){return k.offAllTypes(this,t)}static trigger(t,e,r={}){if(!("string"==typeof e||Array.isArray(e)&&e.every(t=>"string"==typeof t)))throw new TypeError("The events must be a string or array of strings.");for(const o of Array.isArray(e)?Array.from(new Set(e)):[e]){if("string"!=typeof o)throw new TypeError("The event name must be a string.");k._preEventTargetElems(t,"trigger").forEach(t=>{const e=r instanceof Event||r instanceof CustomEvent?r:new CustomEvent(o,{bubbles:!0,cancelable:!0,detail:r});t.dispatchEvent(e)})}return t}trigger(t,e={}){return k.trigger(this,t,e)}static#o={for:"htmlFor",class:"className"};static propFix=new Proxy(k.#o,{set:(t,e,r)=>(t[e]=r,k.attrFix[r]=e,!0)});static attrFix=Object.fromEntries(Object.entries(k.#o).map(([t,e])=>[e,t]));static getPropName(t){return"string"==typeof k.propFix[t]?k.propFix[t]:t}static getAttrName(t){return"string"==typeof k.attrFix[t]?k.attrFix[t]:t}static attr(t,e){if("string"!=typeof e)throw new TypeError('The "name" must be a string.');return k._preElem(t,"attr").getAttribute(k.getAttrName(e))}attr(t){return k.attr(this,t)}static setAttr(t,e,r=null){if("string"!=typeof e)throw new TypeError('The "name" must be a string.');if(null!==r&&"string"!=typeof r)throw new TypeError('The "value" must be a string.');return k._preElems(t,"setAttr").forEach(t=>{null===r?t.removeAttribute(k.getAttrName(e)):t.setAttribute(k.getAttrName(e),r)}),t}setAttr(t,e){return k.setAttr(this,t,e)}static removeAttr(t,e){if("string"!=typeof e)throw new TypeError('The "name" must be a string.');return k._preElems(t,"removeAttr").forEach(t=>t.removeAttribute(k.getAttrName(e))),t}removeAttr(t){return k.removeAttr(this,t)}static hasAttr(t,e){if("string"!=typeof e)throw new TypeError('The "name" must be a string.');return k._preElem(t,"hasAttr").hasAttribute(k.getAttrName(e))}hasAttr(t){return k.hasAttr(this,t)}static hasProp(t,e){if("string"!=typeof e)throw new TypeError('The "name" must be a string.');return!!k._preElem(t,"hasProp")[k.getPropName(e)]}hasProp(t){return k.hasProp(this,t)}static addProp(t,e){if("string"!=typeof e)throw new TypeError('The "name" must be a string.');return k._preElems(t,"addProp").forEach(t=>{t[k.getPropName(e)]=!0}),t}addProp(t){return k.addProp(this,t)}static removeProp(t,e){if("string"!=typeof e)throw new TypeError('The "name" must be a string.');return k._preElems(t,"removeProp").forEach(t=>{t[k.getPropName(e)]=!1}),t}removeProp(t){return k.removeProp(this,t)}static toggleProp(t,e,r){if("string"!=typeof e)throw new TypeError('The "name" must be a string.');if(void 0!==r&&"boolean"!=typeof r)throw new TypeError('The "force" must be a boolean.');k._preElems(t,"toggleProp").forEach(t=>{(void 0===r?!t[k.getPropName(e)]:r)?k.addProp(t,e):k.removeProp(t,e)})}toggleProp(t,e){return k.toggleProp(this,t,e)}static remove(t){return k._preElems(t,"remove").forEach(t=>t.remove()),t}remove(){return k.remove(this)}static index(t,e=null){const r=k._preElem(t,"index");if(!r)return-1;if(!e)return Array.prototype.indexOf.call(r.parentNode?.children||[],r);if(e){const t="string"==typeof e?document.querySelectorAll(e):k._preElems(e,"index");return Array.prototype.indexOf.call(t,r)}return-1}index(t){return k.index(this,t)}static _getCustomRect(t,e){const r={height:0,width:0,x:0,y:0,bottom:0,left:0,right:0,top:0,toJSON:function(){throw new Error("Function not implemented.")}};for(const e in t)"number"==typeof t[e]&&(r[e]=t[e]);if("object"!=typeof e||null===e||Array.isArray(e))throw new Error("extraRect must be a non-null object.");const{height:o=0,width:n=0,top:i=0,bottom:s=0,left:l=0,right:a=0}=e;if("number"!=typeof o)throw new Error("extraRect.height must be a number.");if("number"!=typeof n)throw new Error("extraRect.width must be a number.");if("number"!=typeof i)throw new Error("extraRect.top must be a number.");if("number"!=typeof s)throw new Error("extraRect.bottom must be a number.");if("number"!=typeof l)throw new Error("extraRect.left must be a number.");if("number"!=typeof a)throw new Error("extraRect.right must be a number.");return r.height+=o,r.width+=n,r.top+=i,r.bottom+=s,r.left+=l,r.right+=a,r}static isCollWith(t,e,r={}){const o=k._getCustomRect(k._preElem(t,"isCollWith").getBoundingClientRect(),r),n=k._preElem(e,"isCollWith").getBoundingClientRect();return v(o,n)}isCollWith(t,e){return k.isCollWith(this,t,e)}static isCollPerfWith(t,e,r={}){const o=k._getCustomRect(k._preElem(t,"isCollPerfWith").getBoundingClientRect(),r),n=k._preElem(e,"isCollPerfWith").getBoundingClientRect();return T(o,n)}isCollPerfWith(t,e){return k.isCollPerfWith(this,t,e)}static _isCollWithLock(t,e,r,o,n){const i=S[n];if(t)return i.has(o)||i.set(o,!0),!0;if(i.has(o)){let t=!1;switch(n){case"top":t=C(e,r);break;case"bottom":t=x(e,r);break;case"left":t=_(e,r);break;case"right":t=A(e,r)}return t&&i.delete(o),i.has(o)}return!1}static isCollWithLock(t,e,r,o={}){const n=k._preElem(t,"isCollWithLock"),i=k._preElem(e,"isCollWithLock"),s=k._getCustomRect(n.getBoundingClientRect(),o),l=i.getBoundingClientRect(),a=v(s,l);return k._isCollWithLock(a,s,l,n,r)}isCollWithLock(t,e,r){return k.isCollWithLock(this,t,e,r)}static isCollPerfWithLock(t,e,r,o={}){const n=k._preElem(t,"isCollPerfWithLock"),i=k._preElem(e,"isCollPerfWithLock"),s=k._getCustomRect(n.getBoundingClientRect(),o),l=i.getBoundingClientRect(),a=T(s,l);return k._isCollWithLock(a,s,l,n,r)}isCollPerfWithLock(t,e,r){return k.isCollPerfWithLock(this,t,e,r)}static resetCollLock(t){const e=k._preElem(t,"resetCollLock");let r=!1;for(const t of["top","bottom","left","right"])S[t].has(e)&&(S[t].delete(e),r=!0);return r}resetCollLock(){return k.resetCollLock(this)}static resetCollLockDir(t,e){const r=k._preElem(t,"resetCollLockDir"),o=S[e];return!!o.has(r)&&(o.delete(r),!0)}resetCollLockDir(t){return k.resetCollLockDir(this,t)}static isInViewport(t){const e=k._preElem(t,"isInViewport");if(!e.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=k.offset(e).top,o=r+k.outerHeight(e),n=k.scrollTop(window),i=n+k.height(window);return o>n&&r<i}isInViewport(){return k.isInViewport(this)}static isScrolledIntoView(t){const e=k._preElem(t,"isScrolledIntoView");if(!e.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=k.scrollTop(window),o=r+k.height(window),n=k.offset(e).top;return n+k.height(e)<=o&&n>=r}isScrolledIntoView(){return k.isScrolledIntoView(this)}static isInContainer(t,e){const r=k._preElem(t,"isInContainer"),o=k._preElem(e,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const n=r.getBoundingClientRect(),i=o.getBoundingClientRect(),s=n.bottom>i.top&&n.top<i.bottom,l=n.right>i.left&&n.left<i.right;return s&&l}isInContainer(t){return k.isInContainer(this,t)}static isFullyInContainer(t,e){const r=k._preElem(t,"isScrolledIntoView"),o=k._preElem(e,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const n=r.getBoundingClientRect(),i=o.getBoundingClientRect();return n.top>=i.top&&n.bottom<=i.bottom&&n.left>=i.left&&n.right<=i.right}isFullyInContainer(t){return k.isFullyInContainer(this,t)}static hasScroll(t){const e=k._preElem(t,"hasScroll");return{v:e.scrollHeight>e.clientHeight,h:e.scrollWidth>e.clientWidth}}hasScroll(){return k.hasScroll(this)}}const B=k;function P(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&"[object Object]"===Object.prototype.toString.call(t)}class N{static Utils={...r,TinyHtml:B};#n=!0;#i=!1;#s=0;#l=0;#a=!0;#c=!1;#d=!1;#m=!1;#u=!1;#h=!1;#p=!1;#g=null;#f=[];#y=null;#b={start:!1,end:!1,collide:!1,move:!1};#E=null;#w;#v="drag-hidden";#T="dragging";#C="drag-active";#x="jail-drag-active";#_="jail-drag-disabled";#A="dragging-collision";#D=9999;constructor(t,e={}){const r=t instanceof B?t.get(0):t;if(!(r instanceof HTMLElement))throw new Error("TinyDragger requires a valid target HTMLElement to initialize.");if(this.#w=r,void 0!==e.jail&&!(e.jail instanceof HTMLElement))throw new Error('The "jail" option must be an HTMLElement if provided.');if(void 0!==e.defaultZIndex&&this.setDefaultZIndex(e.defaultZIndex),void 0!==e.vibration&&!1!==e.vibration&&!P(e.vibration))throw new Error('The "vibration" option must be an object or false.');const o=(t,e)=>{if(void 0!==t&&"boolean"!=typeof t)throw new Error(`The "${e}" option must be a boolean.`)},n=(t,e)=>{if(void 0!==t&&"string"!=typeof t)throw new Error(`The "${e}" option must be a string.`)};o(e.mirrorElem,"mirrorElem"),o(e.collisionByMouse,"collisionByMouse"),o(e.lockInsideJail,"lockInsideJail"),o(e.dropInJailOnly,"dropInJailOnly"),o(e.revertOnDrop,"revertOnDrop"),o(e.multiCollision,"multiCollision"),n(e.classDragging,"classDragging"),n(e.classBodyDragging,"classBodyDragging"),n(e.classJailDragging,"classJailDragging"),n(e.classJailDragDisabled,"classJailDragDisabled"),n(e.classDragCollision,"classDragCollision"),n(e.classHidden,"classHidden"),e.jail instanceof HTMLElement&&(this.#E=e.jail),this.#b=Object.assign({start:!1,end:!1,collide:!1,move:!1},P(e.vibration)?e.vibration:{}),"string"==typeof e.classDragging&&(this.#T=e.classDragging),"string"==typeof e.classBodyDragging&&(this.#C=e.classBodyDragging),"string"==typeof e.classJailDragging&&(this.#x=e.classJailDragging),"string"==typeof e.classJailDragDisabled&&(this.#_=e.classJailDragDisabled),"string"==typeof e.classHidden&&(this.#v=e.classHidden),"string"==typeof e.classDragCollision&&(this.#A=e.classDragCollision),"boolean"==typeof e.collisionByMouse&&(this.#h=e.collisionByMouse),"boolean"==typeof e.mirrorElem&&(this.#a=e.mirrorElem),"boolean"==typeof e.revertOnDrop&&(this.#m=e.revertOnDrop),"boolean"==typeof e.lockInsideJail&&(this.#d=e.lockInsideJail),"boolean"==typeof e.dropInJailOnly&&(this.#p=e.dropInJailOnly),"boolean"==typeof e.multiCollision&&(this.#c=e.multiCollision),this._onMouseDown=this.#L.bind(this),this._onMouseMove=this.#S.bind(this),this._onMouseUp=this.#k.bind(this),this._onTouchStart=t=>this.#L(t.touches[0]),this._onTouchMove=t=>this.#S(t.touches[0]),this._onTouchEnd=t=>this.#k(t.changedTouches[0]),this.#w.addEventListener("mousedown",this._onMouseDown),this.#w.addEventListener("touchstart",this._onTouchStart,{passive:!1})}enable(){this.#B(),this.#E&&this.#E.classList.add(this.#_),this.#n=!0}disable(){this.#E&&this.#E.classList.remove(this.#_),this.#n=!1}addCollidable(t){if(this.#B(),!(t instanceof HTMLElement))throw new Error("addCollidable expects an HTMLElement as argument.");this.#f.includes(t)||this.#f.push(t)}removeCollidable(t){if(this.#B(),!(t instanceof HTMLElement))throw new Error("removeCollidable expects an HTMLElement as argument.");this.#f=this.#f.filter(e=>e!==t)}setVibrationPattern({startPattern:t=!1,endPattern:e=!1,collidePattern:r=!1,movePattern:o=!1}={}){this.#B();const n=t=>!1===t||Array.isArray(t)&&t.every(t=>"number"==typeof t);if(!n(t))throw new Error('Invalid "startPattern": must be false or an array of numbers.');if(!n(e))throw new Error('Invalid "endPattern": must be false or an array of numbers.');if(!n(r))throw new Error('Invalid "collidePattern": must be false or an array of numbers.');if(!n(o))throw new Error('Invalid "movePattern": must be false or an array of numbers.');this.#b={start:t,end:e,collide:r,move:o}}disableVibration(){this.#B(),this.#b={start:!1,end:!1,collide:!1,move:!1}}getOffset(t){if(this.#B(),!(t instanceof MouseEvent||t instanceof Touch)||"number"!=typeof t.clientX||"number"!=typeof t.clientY)throw new Error("getOffset expects an event with valid clientX and clientY coordinates.");const e=this.#w.getBoundingClientRect(),{left:r,top:o}=B.borderWidth(this.#w);return{x:t.clientX-e.left+r,y:t.clientY-e.top+o}}#L(t){if(t instanceof MouseEvent&&t.preventDefault(),this.#i||!this.#n||!this.#w.parentElement)return;if(this.#a){const t=this.#w.cloneNode(!0);if(!(t instanceof HTMLElement))throw new Error("[TinyDragger] INVALID DRAG ELEMENT!");this.#y=t}else this.#y=this.#w;this.#u=!0;const e=this.#w.getBoundingClientRect();Object.assign(this.#y.style,{position:"absolute",pointerEvents:"none",left:`${this.#w.offsetLeft}px`,top:`${this.#w.offsetTop}px`,width:`${e.width}px`,height:`${e.height}px`,zIndex:this.#D}),this.#a&&(this.#w.classList.add(this.#v),this.#w.parentElement.appendChild(this.#y));const{x:r,y:o}=this.getOffset(t);this.#l=r,this.#s=o,this.#y.classList.add(this.#T),document.body.classList.add(this.#C),this.#E&&this.#E.classList.add(this.#x),document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp),document.addEventListener("touchmove",this._onTouchMove,{passive:!1}),document.addEventListener("touchend",this._onTouchEnd),navigator.vibrate&&Array.isArray(this.#b.start)&&navigator.vibrate(this.#b.start),this.checkDragCollision(t),this.#P("drag")}#N=[];#M(t){t&&(t.classList.add(this.#A),this.#N.push(t))}#I(){for(;this.#N.length>0;){const t=this.#N.shift();t&&t.classList.remove(this.#A)}this.#g&&this.#g.classList.remove(this.#A)}checkDragCollision(t){const{collidedElements:e}=this.execCollision(t),r=e[0]||null;this.#g&&!e.includes(this.#g)&&this.#I(),e.forEach(t=>this.#M(t)),this.#f.forEach(t=>{e.includes(t)||t.classList.remove(this.#A)}),navigator.vibrate&&Array.isArray(this.#b.collide)&&e.length>0&&navigator.vibrate(this.#b.collide),this.#g=r}#S(t){if(t instanceof MouseEvent&&t.preventDefault(),this.#i||!this.#u||!this.#n||!this.#y)return;const e=(this.#y.offsetParent||document.body).getBoundingClientRect();let r=t.clientX-e.left-this.#l,o=t.clientY-e.top-this.#s;if(this.#d&&this.#E){const t=this.#E.getBoundingClientRect(),n=this.#y.getBoundingClientRect(),i=t.left-e.left,s=t.top-e.top,{x:l,y:a}=B.borderWidth(this.#E),c=i+t.width-n.width-a,d=s+t.height-n.height-l;r=Math.max(i,Math.min(r,c)),o=Math.max(s,Math.min(o,d))}this.#y.style.position="absolute",this.#y.style.left=`${r}px`,this.#y.style.top=`${o}px`,navigator.vibrate&&Array.isArray(this.#b.move)&&navigator.vibrate(this.#b.move),this.checkDragCollision(t),this.#P("dragging")}execCollision(t){if(this.#i||!this.#y)return{inJail:!1,collidedElements:[]};let e=[],r=!0;const o=this.#E?.getBoundingClientRect();if(this.#h){const n=t.clientX,i=t.clientY;this.#p&&this.#E&&o&&(r=n>=o.left&&n<=o.right&&i>=o.top&&i<=o.bottom),e=r?this.#c?this.getAllCollidedElements(n,i):[this.getCollidedElement(n,i)].filter(Boolean):[]}else{const t=this.#y.getBoundingClientRect();this.#p&&this.#E&&o&&(r=t.left>=o.left&&t.right<=o.right&&t.top>=o.top&&t.bottom<=o.bottom),e=r?this.#c?this.getAllCollidedElementsByRect(t):[this.getCollidedElementByRect(t)].filter(Boolean):[]}return{inJail:r,collidedElements:e}}#k(t){if(t instanceof MouseEvent&&t.preventDefault(),this.#i||!this.#u)return;if(this.#u=!1,!this.#y)return;this.#w.classList.remove(this.#T),document.body.classList.remove(this.#C),this.#E&&this.#E.classList.remove(this.#x),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd);const{collidedElements:e}=this.execCollision(t);navigator.vibrate&&Array.isArray(this.#b.end)&&navigator.vibrate(this.#b.end);const r=this.#y.style.left,o=this.#y.style.top;this.#y&&(this.#a?this.#y.remove():Object.assign(this.#y.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#y=null),this.#g&&this.#I(),this.#g=null,this.#a&&this.#w.classList.remove(this.#v),this.#m||(this.#w.style.left=r,this.#w.style.top=o);const n=new CustomEvent("drop",{detail:{targets:e,first:e[0]||null}});this.#w.dispatchEvent(n)}#W(t,e){const r=t.getBoundingClientRect();return!(e.right<r.left||e.left>r.right||e.bottom<r.top||e.top>r.bottom)}getAllCollidedElementsByRect(t){if(this.#B(),!(t instanceof DOMRect)||"number"!=typeof t.left||"number"!=typeof t.right||"number"!=typeof t.top||"number"!=typeof t.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#f.filter(e=>this.#W(e,t))}getCollidedElementByRect(t){if(this.#B(),!(t instanceof DOMRect)||"number"!=typeof t.left||"number"!=typeof t.right||"number"!=typeof t.top||"number"!=typeof t.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#f.find(e=>this.#W(e,t))||null}#H(t,e,r){const o=t.getBoundingClientRect();return e>=o.left&&e<=o.right&&r>=o.top&&r<=o.bottom}getAllCollidedElements(t,e){if(this.#B(),"number"!=typeof t||"number"!=typeof e)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#f.filter(r=>this.#H(r,t,e))}getCollidedElement(t,e){if(this.#B(),"number"!=typeof t||"number"!=typeof e)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#f.find(r=>this.#H(r,t,e))||null}#P(t){const e=new CustomEvent(t);this.#w.dispatchEvent(e)}getDragging(){return this.#u}getLockInsideJail(){return this.#d}setLockInsideJail(t){if("boolean"!=typeof t)throw new Error("lockInsideJail must be a boolean.");this.#d=t}getRevertOnDrop(){return this.#m}setRevertOnDrop(t){if("boolean"!=typeof t)throw new Error("revertOnDrop must be a boolean.");this.#m=t}getCollisionByMouse(){return this.#h}setCollisionByMouse(t){if("boolean"!=typeof t)throw new Error("collisionByMouse must be a boolean.");this.#h=t}getDropInJailOnly(){return this.#p}setDropInJailOnly(t){if("boolean"!=typeof t)throw new Error("dropInJailOnly must be a boolean.");this.#p=t}getDefaultZIndex(){return this.#D}setDefaultZIndex(t){if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("Z-index must be a finite number.");this.#D=t}isMirrorEnabled(){return this.#a}setMirrorEnabled(t){if("boolean"!=typeof t)throw new TypeError("Mirror setting must be a boolean.");this.#a=t}getTarget(){return this.#w}getJail(){return this.#E}getDragProxy(){return this.#y}getLastCollision(){return this.#g}getCollidables(){return[...this.#f]}getDragHiddenClass(){return this.#v}getClassDragging(){return this.#T}getClassBodyDragging(){return this.#C}getClassJailDragging(){return this.#x}getClassJailDragDisabled(){return this.#_}getClassDragCollision(){return this.#A}getVibrations(){return{...this.#b}}getStartVibration(){return this.#b.start}getEndVibration(){return this.#b.end}getCollideVibration(){return this.#b.collide}getMoveVibration(){return this.#b.move}isEnabled(){return this.#n}#B(){if(this.#i)throw new Error("This TinyDragger instance has been destroyed and can no longer be used.")}destroy(){this.#i||(this.disable(),this.#w.removeEventListener("mousedown",this._onMouseDown),this.#w.removeEventListener("touchstart",this._onTouchStart),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd),this.#g&&this.#I(),this.#y&&(this.#a?this.#y.remove():Object.assign(this.#y.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#y=null),this.#f=[],this.#u=!1,this.#g=null,this.#a&&this.#w.classList.remove(this.#v),this.#w.classList.remove(this.#T),document.body.classList.remove(this.#C),this.#E&&this.#E.classList.remove(this.#x,this.#_),this.#i=!0)}}const M=N;window.TinyDragger=e.TinyDragger})();
1
+ (()=>{"use strict";var t={d:(e,r)=>{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=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.d(e,{TinyDragger:()=>M});var r={};t.r(r),t.d(r,{areElsCollBottom:()=>n,areElsCollLeft:()=>i,areElsCollPerfBottom:()=>a,areElsCollPerfLeft:()=>c,areElsCollPerfRight:()=>d,areElsCollPerfTop:()=>l,areElsCollRight:()=>s,areElsCollTop:()=>o,areElsColliding:()=>m,areElsPerfColliding:()=>u,getElsCollDetails:()=>w,getElsCollDirDepth:()=>E,getElsCollOverlap:()=>g,getElsCollOverlapPos:()=>f,getElsColliding:()=>h,getElsPerfColliding:()=>p,getElsRelativeCenterOffset:()=>b,getRectCenter:()=>y});const o=(t,e)=>t.bottom<e.top,n=(t,e)=>t.top>e.bottom,i=(t,e)=>t.right<e.left,s=(t,e)=>t.left>e.right,l=(t,e)=>t.bottom<=e.top,a=(t,e)=>t.top>=e.bottom,c=(t,e)=>t.right<=e.left,d=(t,e)=>t.left>=e.right,m=(t,e)=>!(i(t,e)||s(t,e)||o(t,e)||n(t,e)),u=(t,e)=>!(c(t,e)||d(t,e)||l(t,e)||a(t,e)),h=(t,e)=>i(t,e)?"left":s(t,e)?"right":o(t,e)?"top":n(t,e)?"bottom":null,p=(t,e)=>c(t,e)?"left":d(t,e)?"right":l(t,e)?"top":a(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}),f=({overlapLeft:t=-1,overlapRight:e=-1,overlapTop:r=-1,overlapBottom:o=-1}={})=>({dirX:t<e?"right":"left",dirY:r<o?"bottom":"top"}),y=t=>({x:t.left+t.width/2,y:t.top+t.height/2});function b(t,e){const r=t.left+t.width/2,o=t.top+t.height/2;return{x:e.left+e.width/2-r,y:e.top+e.height/2-o}}function E(t,e){if(!u(t,e))return{inDir:null,dirX:null,dirY:null,depthX:0,depthY:0};const{overlapLeft:r,overlapRight:o,overlapTop:n,overlapBottom:i}=g(t,e),{dirX:s,dirY:l}=f({overlapLeft:r,overlapRight:o,overlapTop:n,overlapBottom:i}),a=Math.min(r,o),c=Math.min(n,i);let d;return d=a<c?s:l,{inDir:d,dirX:s,dirY:l,depthX:a,depthY:c}}function w(t,e){const r=u(t,e),o={in:null,x:null,y:null},n={y:null,x:null},i={top:0,bottom:0,left:0,right:0},{overlapLeft:s,overlapRight:l,overlapTop:a,overlapBottom:c}=g(e,t);i.top=a,i.bottom=c,i.left=s,i.right=l;const d=Object.entries(i).filter(([,t])=>t>0).sort((t,e)=>t[1]-e[1]),{dirX:m,dirY:h}=f({overlapLeft:l,overlapRight:s,overlapTop:c,overlapBottom:a});return o.y=h,o.x=m,i.bottom<0?n.y="bottom":i.top<0&&(n.y="top"),i.left<0?n.x="left":i.right<0&&(n.x="right"),o.in=r?i.top===i.bottom&&i.bottom===i.left&&i.left===i.right?"center":d.length?d[0][0]:"top":null,{dirs:o,depth:i,isNeg:n}}const{areElsColliding:v,areElsPerfColliding:T,areElsCollTop:C,areElsCollBottom:x,areElsCollLeft:_,areElsCollRight:A}=r,D=new WeakMap,L=new WeakMap,S={top:new WeakMap,bottom:new WeakMap,left:new WeakMap,right:new WeakMap};class k{static Utils={...r};static async fetchHtmlFile(t,e={method:"GET"}){const r=await fetch(t,e),o=r.headers.get("Content-Type")||"";if(!r.ok)throw new Error(`Failed to fetch: ${r.status} ${r.statusText}`);if(!o.includes("text/html"))throw new Error(`Invalid content type: ${o} (expected text/html)`);const n=await r.text();return k.htmlToJson(n)}static async fetchHtmlNodes(t,e){const r=await k.fetchHtmlFile(t,e);return k.jsonToNodes(r)}static async fetchHtmlTinyElems(t,e){const r=await k.fetchHtmlNodes(t,e);return k.toTinyElm(r)}static templateToJson(t){return k.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 k.toTinyElm(k.templateToNodes(t))}static htmlToJson(t){const e=document.createElement("div");e.innerHTML=t.trim();const r=[],o=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[k.getPropName(e.name)]=e.value;const n=Array.from(t.childNodes).map(o).filter(Boolean);return n.length>0?[e,r,...n]:[e,r]};for(const t of e.childNodes){const e=o(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,o,...n]=t,i=document.createElement(r);for(const[t,e]of Object.entries(o))i.setAttribute(k.getAttrName(t),e);for(const t of n){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 k.toTinyElm(k.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=k.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 k(document.createElement(t,e))}static createTextNode(t){if("string"!=typeof t)throw new TypeError("[TinyHtml] createTextNode(): The value must be a string.");return new k(document.createTextNode(t))}static createElementFromHTML(t){const e=document.createElement("template");if(!(t=t.trim()).startsWith("<"))return k.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 k(e.content.firstChild)}static query(t,e=document){const r=e.querySelector(t);return r?new k(r):null}querySelector(t){return k.query(t,k._preElem(this,"query"))}static queryAll(t,e=document){return new k(e.querySelectorAll(t))}querySelectorAll(t){return k.queryAll(t,k._preElem(this,"queryAll"))}static getById(t){const e=document.getElementById(t);return e?new k(e):null}static getByClassName(t,e=document){return new k(e.getElementsByClassName(t))}getElementsByClassName(t){return k.getByClassName(t,k._preElem(this,"getByClassName"))}static getByName(t){return new k(document.getElementsByName(t))}static getByTagNameNS(t,e="http://www.w3.org/1999/xhtml",r=document){return new k(r.getElementsByTagNameNS(e,t))}getElementsByTagNameNS(t,e="http://www.w3.org/1999/xhtml"){return k.getByTagNameNS(t,e,k._preElem(this,"getByTagNameNS"))}forEach(t){const e=this.getAll().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 k(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 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 new Error(`[TinyHtml] Invalid Element in ${t}().`);return[...this.#t]}static _preElemsTemplate(t,e,r,o){const n=t=>{const n=[];return t.map(t=>(t instanceof k?t._getElements(e):[t]).map(t=>{let i=!1;for(const e of r)if(t instanceof e){i=!0;break}if(!i)throw new Error(`[TinyHtml] Invalid element of the list "${o.join(",")}" in ${e}().`);return n.push(t),t})),n};return Array.isArray(t)?n(t):n([t])}static _preElemTemplate(t,e,r,o,n=!1){const i=t=>{const i=t[0],s=i instanceof k?i._getElements(e):[i];if(s.length>1)throw new Error(`[TinyHtml] Invalid element amount in ${e}() (Received ${s.length}/1).`);let l=!1;for(const t of r)if(s[0]instanceof t){l=!0;break}if(!n||null!==s[0]&&void 0!==s[0]||(s[0]=null,l=!0),!l)throw new Error(`[TinyHtml] Invalid element of the list "${o.join(",")}" in ${e}().`);return s[0]};if(!Array.isArray(t))return i([t]);if(t.length>1)throw new Error(`[TinyHtml] Invalid element amount in ${e}() (Received ${t.length}/1).`);return i(t)}static _preElems(t,e){return k._preElemsTemplate(t,e,[Element],["Element"])}static _preElem(t,e){return k._preElemTemplate(t,e,[Element],["Element"])}static _preNodeElems(t,e){return k._preElemsTemplate(t,e,[Node],["Node"])}static _preNodeElem(t,e){return k._preElemTemplate(t,e,[Node],["Node"])}static _preNodeElemWithNull(t,e){return k._preElemTemplate(t,e,[Node],["Node"],!0)}static _preHtmlElems(t,e){return k._preElemsTemplate(t,e,[HTMLElement],["HTMLElement"])}static _preHtmlElem(t,e){return k._preElemTemplate(t,e,[HTMLElement],["HTMLElement"])}static _preInputElems(t,e){return k._preElemsTemplate(t,e,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}static _preInputElem(t,e){return k._preElemTemplate(t,e,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLOptionElement],["HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement"])}static _preEventTargetElems(t,e){return k._preElemsTemplate(t,e,[EventTarget],["EventTarget"])}static _preEventTargetElem(t,e){return k._preElemTemplate(t,e,[EventTarget],["EventTarget"])}static _preElemsAndWindow(t,e){return k._preElemsTemplate(t,e,[Element,Window],["Element","Window"])}static _preElemAndWindow(t,e){return k._preElemTemplate(t,e,[Element,Window],["Element","Window"])}static _preElemsAndWinAndDoc(t,e){return k._preElemsTemplate(t,e,[Element,Window,Document],["Element","Window","Document"]).map(t=>t instanceof Document?t.documentElement:t)}static _preElemAndWinAndDoc(t,e){const r=k._preElemTemplate(t,e,[Element,Window,Document],["Element","Window","Document"]);return r instanceof Document?r.documentElement:r}static _preElemsWithDoc(t,e){return k._preElemsTemplate(t,e,[Element,Document],["Element","Document"])}static _preElemWithDoc(t,e){return k._preElemTemplate(t,e,[Element,Document],["Element","Document"])}static toTinyElm(t){const e=t=>t.map(t=>t instanceof k?t:new k(t));return Array.isArray(t)?e(t):e([t])}static fromTinyElm(t){const e=t=>{const e=[];return t.map(t=>(t instanceof k?t._getElements("fromTinyElm"):[t]).map(t=>e.push(t))),e};return Array.isArray(t)?e(t):e([t])}static winnow(t,e,r,o=!1){if("boolean"!=typeof o)throw new TypeError('The "not" must be a boolean.');if("function"==typeof e)return k._preElems(t,r).filter((t,r)=>!!e.call(t,r,t)!==o);if(e instanceof Element)return k._preElems(t,r).filter(t=>t===e!==o);if(Array.isArray(e)||"string"!=typeof e&&null!=e.length)return k._preElems(t,r).filter(t=>e.includes(t)!==o);let n=e;return o&&(n=`:not(${n})`),k._preElems(t,r).filter(t=>1===t.nodeType&&t.matches(n))}static filter(t,e,r=!1){return r&&(e=`:not(${e})`),k._preElems(t,"filter").filter(t=>1===t.nodeType&&t.matches(e))}static filterOnly(t,e){return k.winnow(t,e,"filterOnly",!1)}static not(t,e){return k.winnow(t,e,"not",!0)}not(t){return k.not(this,t)}static find(t,e){const r=[];for(const o of k._preElems(t,"find"))r.push(...o.querySelectorAll(e));return[...new Set(r)]}find(t){return k.find(this,t)}static is(t,e){return k.winnow(t,e,"is",!1).length>0}is(t){return k.is(this,t)}static has(t,e){const r="string"==typeof e?[...document.querySelectorAll(e)]:k._preElems(e,"has");return k._preElems(t,"has").filter(t=>r.some(e=>t&&t.contains(e)))}has(t){return k.has(this,t).length>0}static closest(t,e,r){const o=[];for(const n of k._preElems(t,"closest")){let t=n;for(;t&&t!==r;){if(1===t.nodeType&&("string"==typeof e?t.matches(e):t===e)){o.push(t);break}t=t.parentElement}}return[...new Set(o)]}closest(t,e){return k.closest(this,t,e)}static isSameDom(t,e){return k._preNodeElem(t,"isSameDom")===k._preNodeElem(e,"isSameDom")}isSameDom(t){return k.isSameDom(this,t)}#e={};get _data(){return{...this.#e}}set _data(t){if("object"!=typeof t||null===t||Array.isArray(t))throw new Error("value must be a non-null object.");this.#e=t}static _dataSelector={public:(t,e)=>{const r=k._preElem(e,t);let o=L.get(r);return o||(o={},L.set(r,o)),o},private:(t,e)=>{if(!(e instanceof k))throw new Error(`Element must be a TinyHtml instance to execute ${t}().`);return e.#e}};static data(t,e,r=!1){const o=k._dataSelector[r?"private":"public"]("data",t);if(null==e)return{...o};if("string"!=typeof e)throw new TypeError("The key must be a string.");return o.hasOwnProperty(e)?o[e]:void 0}data(t,e){return k.data(this,t,e)}static setData(t,e,r,o=!1){const n=k._dataSelector[o?"private":"public"]("setData",t);if("string"!=typeof e)throw new TypeError("The key must be a string.");return n[e]=r,t}setData(t,e,r=!1){return k.setData(this,t,e,r)}static _getSibling(t,e,r){let o=k._preNodeElemWithNull(t,r);for(;o&&(o=o[e])&&1!==o.nodeType;);return o instanceof Node?o:null}static _getSiblings(t,e){let r=t;const o=[];for(;r;r=r.nextSibling)1===r.nodeType&&r!==e&&o.push(r);return o}static domDir(t,e,r,o="domDir"){if("string"!=typeof e)throw new TypeError('The "direction" must be a string.');let n=k._preNodeElemWithNull(t,o);const i=[];for(;n&&(n=n[e]);)if(1===n.nodeType){if(r&&("string"==typeof r?n.matches(r):n===r))break;i.push(n)}return i}static parent(t){let e=k._preNodeElemWithNull(t,"parent");const r=e?e.parentNode:null;return r&&11!==r.nodeType?r:null}parent(){return k.parent(this)}static parents(t,e){return k.domDir(t,"parentNode",e,"parents")}parents(t){return k.parents(this,t)}static next(t){return k._getSibling(t,"nextSibling","next")}next(){return k.next(this)}static prev(t){return k._getSibling(t,"previousSibling","prev")}prev(){return k.prev(this)}static nextAll(t){return k.domDir(t,"nextSibling",void 0,"nextAll")}nextAll(){return k.nextAll(this)}static prevAll(t){return k.domDir(t,"previousSibling",void 0,"prevAll")}prevAll(){return k.prevAll(this)}static nextUntil(t,e){return k.domDir(t,"nextSibling",e,"nextUtil")}nextUntil(t){return k.nextUntil(this,t)}static prevUntil(t,e){return k.domDir(t,"previousSibling",e,"prevUtil")}prevUntil(t){return k.prevUntil(this,t)}static siblings(t){const e=k._preNodeElemWithNull(t,"siblings");return k._getSiblings(e&&e.parentNode?e.parentNode.firstChild:null,e)}siblings(){return k.siblings(this)}static children(t){const e=k._preNodeElemWithNull(t,"children");return k._getSiblings(e?e.firstChild:null)}children(){return k.children(this)}static contents(t){const e=k._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 k.contents(this)}static clone(t,e=!0){if("boolean"!=typeof e)throw new TypeError('The "deep" must be a boolean.');return k._preNodeElems(t,"clone").map(t=>t.cloneNode(e))}clone(t){return k.clone(this,t)[0]}static _appendChecker(t,...e){const r=[],o=[...e];for(const e in o)"string"!=typeof o[e]?r.push(k._preNodeElem(o[e],t)):r.push(o[e]);return r}static append(t,...e){return k._preElem(t,"append").append(...k._appendChecker("append",...e)),t}append(...t){return k.append(this,...t)}static prepend(t,...e){return k._preElem(t,"prepend").prepend(...k._appendChecker("prepend",...e)),t}prepend(...t){return k.prepend(this,...t)}static before(t,...e){return k._preElem(t,"before").before(...k._appendChecker("before",...e)),t}before(...t){return k.before(this,...t)}static after(t,...e){return k._preElem(t,"after").after(...k._appendChecker("after",...e)),t}after(...t){return k.after(this,...t)}static replaceWith(t,...e){return k._preElem(t,"replaceWith").replaceWith(...k._appendChecker("replaceWith",...e)),t}replaceWith(...t){return k.replaceWith(this,...t)}static appendTo(t,e){const r=k._preNodeElems(t,"appendTo"),o=k._preNodeElems(e,"appendTo");return o.forEach((t,e)=>{r.forEach(r=>t.appendChild(e===o.length-1?r:r.cloneNode(!0)))}),t}appendTo(t){return k.appendTo(this,t)}static prependTo(t,e){const r=k._preElems(t,"prependTo"),o=k._preElems(e,"prependTo");return o.forEach((t,e)=>{r.slice().reverse().forEach(r=>t.prepend(e===o.length-1?r:r.cloneNode(!0)))}),t}prependTo(t){return k.prependTo(this,t)}static insertBefore(t,e,r=null){const o=k._preNodeElem(t,"insertBefore"),n=k._preNodeElem(e,"insertBefore"),i=k._preNodeElemWithNull(r,"insertBefore");if(!n.parentNode)throw new Error("The target element has no parent node to insert before.");return n.parentNode.insertBefore(o,i||n),t}insertBefore(t,e){return k.insertBefore(this,t,e)}static insertAfter(t,e,r=null){const o=k._preNodeElem(t,"insertAfter"),n=k._preNodeElem(e,"insertBefore"),i=k._preNodeElemWithNull(r,"insertBefore");if(!n.parentNode)throw new Error("The target element has no parent node to insert after.");return n.parentNode.insertBefore(o,i||n.nextSibling),t}insertAfter(t,e){return k.insertAfter(this,t,e)}static replaceAll(t,e){const r=k._preNodeElems(t,"replaceAll"),o=k._preNodeElems(e,"replaceAll");return o.forEach((t,e)=>{const n=t.parentNode;r.forEach(r=>{n&&n.replaceChild(e===o.length-1?r:r.cloneNode(!0),t)})}),t}replaceAll(t){return k.replaceAll(this,t)}#t;get size(){return this.#t.length}constructor(t){if(t instanceof k)throw new Error("[TinyHtml] You are trying to put a TinyHtml inside another TinyHtml in constructor.");const e=t=>{if(!t.every(t=>t instanceof Element||t instanceof Window||t instanceof Document||t instanceof Text))throw new Error("[TinyHtml] Invalid Target in constructor.")};if(Array.isArray(t))e(t),this.#t=t;else if(t instanceof NodeList||t instanceof HTMLCollection){const r=[...t];e(r),this.#t=r}else{const r=[t];e(r),this.#t=r}}static isWindow(t){return null!=t&&t===t.window}static css(t){const e=k._preElem(t,"css");return window.getComputedStyle(e)}css(){return k.css(this)}static cssString(t,e){const r=k._preElem(t,"cssString");if("string"!=typeof e)throw new TypeError("The prop must be a string.");const o=window.getComputedStyle(r)[e];return"string"==typeof o?o:"number"==typeof o?o.toString():null}cssString(t){return k.cssString(this,t)}static cssList(t,e){const r=k._preElem(t,"cssList");if(!Array.isArray(e))throw new TypeError("The prop must be an array of strings.");const o=window.getComputedStyle(r),n={};for(const t of e)void 0!==t&&(n[t]=o.getPropertyValue(t));return n}cssList(t){return k.cssList(this,t)}static cssFloat(t,e){const r=k._preElem(t,"cssFloat");if("string"!=typeof e)throw new TypeError("The prop must be a string.");const o=window.getComputedStyle(r)[e];return parseFloat(o)||0}cssFloat(t){return k.cssFloat(this,t)}static cssFloats(t,e){const r=k._preElem(t,"cssFloats");if(!Array.isArray(e))throw new TypeError("The prop must be an array of strings.");const o=window.getComputedStyle(r),n={};for(const t of e)n[t]=parseFloat(o[t])||0;return n}cssFloats(t){return k.cssFloats(this,t)}static#r={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(k.#r,{set:(t,e,r)=>(t[e]=r,k.cssPropRevAliases[r]=e,!0)});static cssPropRevAliases=Object.fromEntries(Object.entries(k.#r).map(([t,e])=>[e,t]));static toStyleKc(t){return"string"==typeof k.cssPropAliases[t]?k.cssPropAliases[t]:t}static toStyleCc(t){return"string"==typeof k.cssPropRevAliases[t]?k.cssPropRevAliases[t]:t}static setStyle(t,e,r=null){return k._preHtmlElems(t,"setStyle").forEach(t=>{if("object"==typeof e)for(const[r,o]of Object.entries(e))t.style.setProperty(k.toStyleKc(r),"string"==typeof o?o:"number"==typeof o?`${o}px`:String(o));else t.style.setProperty(k.toStyleKc(e),r)}),t}setStyle(t,e){return k.setStyle(this,t,e)}static getStyle(t,e){return k._preHtmlElem(t,"getStyle").style.getPropertyValue(k.toStyleKc(e))}getStyle(t){return k.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 o=k._preHtmlElem(t,"style"),n={};if(r){const t=(o.getAttribute("style")||"").split(";");for(const r of t){const[t,o]=r.split(":");if(!t||!o)continue;const i=t.trim(),s=o.trim();n[e?k.toStyleCc(i):i]=s}}else{const t=o.style;for(let r=0;r<t.length;r++){const o=t[r],i=t.getPropertyValue(o);n[e?k.toStyleCc(o):o]=i}}return n}style(t){return k.style(this,t)}static removeStyle(t,e){return k._preHtmlElems(t,"removeStyle").forEach(t=>{if(Array.isArray(e))for(const r of e)t.style.removeProperty(k.toStyleKc(r));else t.style.removeProperty(k.toStyleKc(e))}),t}removeStyle(t){return k.removeStyle(this,t)}static toggleStyle(t,e,r,o){return k._preHtmlElems(t,"toggleStyle").forEach(t=>{const n=k.getStyle(t,e).trim()===k.toStyleKc(r)?o:r;k.setStyle(t,e,n)}),t}toggleStyle(t,e,r){return k.toggleStyle(this,t,e,r)}static clearStyle(t){return k._preElems(t,"clearStyle").forEach(t=>t.removeAttribute("style")),t}clearStyle(){return k.clearStyle(this)}static focus(t){return k._preHtmlElem(t,"focus").focus(),t}focus(){return k.focus(this)}static blur(t){return k._preHtmlElem(t,"blur").blur(),t}blur(){return k.blur(this)}static select(t){const e=k._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 k.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.");k.setScrollTop(window,t)}static setWinScrollLeft(t){if("number"!=typeof t)throw new TypeError("The value must be a number.");k.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 o=k._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 n="width"===e?"Width":"Height";if(k.isWindow(o))return"margin"===r?o["inner"+n]:o.document.documentElement["client"+n];const i=o;if(9===i.nodeType){const t=i.documentElement;return Math.max(i.body["scroll"+n],t["scroll"+n],i.body["offset"+n],t["offset"+n],t["client"+n])}let s=i.getBoundingClientRect()[e];function l(t){return"width"===e?k.cssFloat(i,t+"Left")+k.cssFloat(i,t+"Right"):k.cssFloat(i,t+"Top")+k.cssFloat(i,t+"Bottom")}switch(r){case"content":s-=l("padding"),s-=l("border");break;case"padding":s-=l("border");break;case"border":break;case"margin":s+=l("margin")}return s}getDimension(t,e){return k.getDimension(this,t,e)}static setHeight(t,e){const r=k._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 k.setHeight(this,t)}static setWidth(t,e){const r=k._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 k.setWidth(this,t)}static height(t){const e=k._preElemAndWinAndDoc(t,"height");return k.getDimension(e,"height","content")}height(){return k.height(this)}static width(t){const e=k._preElemAndWinAndDoc(t,"width");return k.getDimension(e,"width","content")}width(){return k.width(this)}static innerHeight(t){const e=k._preElemAndWinAndDoc(t,"innerHeight");return k.getDimension(e,"height","padding")}innerHeight(){return k.innerHeight(this)}static innerWidth(t){const e=k._preElemAndWinAndDoc(t,"innerWidth");return k.getDimension(e,"width","padding")}innerWidth(){return k.innerWidth(this)}static outerHeight(t,e=!1){if("boolean"!=typeof e)throw new TypeError('The "includeMargin" must be a boolean.');const r=k._preElemAndWinAndDoc(t,"outerHeight");return k.getDimension(r,"height",e?"margin":"border")}outerHeight(t){return k.outerHeight(this,t)}static outerWidth(t,e=!1){if("boolean"!=typeof e)throw new TypeError('The "includeMargin" must be a boolean.');const r=k._preElemAndWinAndDoc(t,"outerWidth");return k.getDimension(r,"width",e?"margin":"border")}outerWidth(t){return k.outerWidth(this,t)}static animate(t,e,r){return k._preElems(t,"animate").forEach(t=>t.animate(e,r)),t}animate(t,e){return k.animate(this,t,e)}static offset(t){const e=k._preElem(t,"offset").getBoundingClientRect(),r=window.scrollY||document.documentElement.scrollTop,o=window.scrollX||document.documentElement.scrollLeft;return{top:e.top+r,left:e.left+o}}offset(){return k.offset(this)}static position(t){const e=k._preHtmlElem(t,"position");let r,o,n={top:0,left:0};if("fixed"===window.getComputedStyle(e).position)o=e.getBoundingClientRect();else{o=k.offset(e),r=e.offsetParent||document.documentElement;const{position:t}=window.getComputedStyle(r);for(;r instanceof HTMLElement&&(r===document.body||r===document.documentElement)&&"static"===t;)r=r.parentNode;if(r instanceof HTMLElement&&r!==e&&1===r.nodeType){const{borderTopWidth:t,borderLeftWidth:e}=k.cssFloats(r,["borderTopWidth","borderLeftWidth"]);n=k.offset(r),n.top+=t,n.left+=e}}return{top:o.top-n.top-k.cssFloat(e,"marginTop"),left:o.left-n.left-k.cssFloat(e,"marginLeft")}}position(){return k.position(this)}static offsetParent(t){let e=k._preHtmlElem(t,"offsetParent").offsetParent;for(;e instanceof HTMLElement&&"static"===window.getComputedStyle(e).position;)e=e.offsetParent;return e instanceof HTMLElement?e:document.documentElement}offsetParent(){return k.offsetParent(this)}static scrollTop(t){const e=k._preElemAndWindow(t,"scrollTop");return k.isWindow(e)?e.pageYOffset:9===e.nodeType?e.defaultView.pageYOffset:e.scrollTop}scrollTop(){return k.scrollTop(this)}static scrollLeft(t){const e=k._preElemAndWindow(t,"scrollLeft");return k.isWindow(e)?e.pageXOffset:9===e.nodeType?e.defaultView.pageXOffset:e.scrollLeft}scrollLeft(){return k.scrollLeft(this)}static easings={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:(4-2*t)*t-1,easeInCubic:t=>t*t*t,easeOutCubic:t=>--t*t*t+1,easeInOutCubic:t=>t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1};static scrollToXY(t,{targetX:e,targetY:r,duration:o,easing:n,onAnimation:i}={}){if(void 0!==e&&"number"!=typeof e)throw new TypeError("`targetX` must be a number if provided.");if(void 0!==r&&"number"!=typeof r)throw new TypeError("`targetY` must be a number if provided.");if(void 0!==o&&"number"!=typeof o)throw new TypeError("`duration` must be a number if provided.");if(void 0!==n&&"string"!=typeof n)throw new TypeError("`easing` must be a string if provided.");if(void 0!==n&&"function"!=typeof k.easings[n])throw new TypeError(`Unknown easing function: "${n}".`);if(void 0!==i&&"function"!=typeof i)throw new TypeError("`onAnimation` must be a function if provided.");const s=(t,e,r,o)=>{if(t instanceof Window)window.scrollTo(e,r);else if(9===t.nodeType)t.defaultView.scrollTo(e,r);else{const o=t instanceof Window?window.scrollX:t.scrollLeft,n=t instanceof Window?window.scrollY:t.scrollTop;o!==e&&(t.scrollLeft=e),n!==r&&(t.scrollTop=r)}"function"==typeof i&&i({x:e,y:r,isComplete:o>=1,time:o})};return k._preElemsAndWindow(t,"scrollToXY").forEach(t=>{const i=t instanceof Window?window.scrollX:t.scrollLeft,l=t instanceof Window?window.scrollY:t.scrollTop,a=e??i,c=r??l,d=a-i,m=c-l,u="string"==typeof n&&k.easings[n]||null;if("number"!=typeof o||"function"!=typeof u)return s(t,a,c,1);const h=performance.now(),p=o??0;requestAnimationFrame(function e(r){if("function"!=typeof u)return;const o=Math.min(1,(r-h)/p),n=u(o);s(t,i+d*n,l+m*n,o),o<1&&requestAnimationFrame(e)})}),t}scrollToXY({targetX:t,targetY:e,duration:r,easing:o,onAnimation:n}={}){return k.scrollToXY(this,{targetX:t,targetY:e,duration:r,easing:o,onAnimation:n})}static setScrollTop(t,e){if("number"!=typeof e)throw new TypeError("ScrollTop value must be a number.");return k.scrollToXY(t,{targetY:e})}setScrollTop(t){return k.setScrollTop(this,t)}static setScrollLeft(t,e){if("number"!=typeof e)throw new TypeError("ScrollLeft value must be a number.");return k.scrollToXY(t,{targetX:e})}setScrollLeft(t){return k.setScrollLeft(this,t)}static borderWidth(t){const e=k._preElem(t,"borderWidth"),{borderLeftWidth:r,borderRightWidth:o,borderTopWidth:n,borderBottomWidth:i}=k.cssFloats(e,["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"]);return{x:r+o,y:n+i,left:r,right:o,top:n,bottom:i}}borderWidth(){return k.borderWidth(this)}static border(t){const e=k._preElem(t,"border"),{borderLeft:r,borderRight:o,borderTop:n,borderBottom:i}=k.cssFloats(e,["borderLeft","borderRight","borderTop","borderBottom"]);return{x:r+o,y:n+i,left:r,right:o,top:n,bottom:i}}border(){return k.border(this)}static margin(t){const e=k._preElem(t,"margin"),{marginLeft:r,marginRight:o,marginTop:n,marginBottom:i}=k.cssFloats(e,["marginLeft","marginRight","marginTop","marginBottom"]);return{x:r+o,y:n+i,left:r,right:o,top:n,bottom:i}}margin(){return k.margin(this)}static padding(t){const e=k._preElem(t,"padding"),{paddingLeft:r,paddingRight:o,paddingTop:n,paddingBottom:i}=k.cssFloats(e,["paddingLeft","paddingRight","paddingTop","paddingBottom"]);return{x:r+o,y:n+i,left:r,right:o,top:n,bottom:i}}padding(){return k.padding(this)}static addClass(t,...e){return k._preElems(t,"addClass").forEach(t=>t.classList.add(...e)),t}addClass(...t){return k.addClass(this,...t)}static removeClass(t,...e){return k._preElems(t,"removeClass").forEach(t=>t.classList.remove(...e)),t}removeClass(...t){return k.removeClass(this,...t)}static replaceClass(t,e,r){if("string"!=typeof e)throw new TypeError('The "token" parameter must be a string.');if("string"!=typeof r)throw new TypeError('The "newToken" parameter must be a string.');const o=[];return k._preElems(t,"replaceClass").forEach(t=>o.push(t.classList.replace(e,r))),o}replaceClass(t,e){return k.replaceClass(this,t,e)[0]}static classItem(t,e){const r=k._preElem(t,"classItem");if("number"!=typeof e)throw new TypeError('The "index" parameter must be a number.');return r.classList.item(e)}classItem(t){return k.classItem(this,t)}static toggleClass(t,e,r){if("string"!=typeof e)throw new TypeError('The "token" parameter must be a string.');if(void 0!==r&&"boolean"!=typeof r)throw new TypeError('The "force" parameter must be a boolean.');const o=[];return k._preElems(t,"toggleClass").forEach(t=>o.push(t.classList.toggle(e,r))),o}toggleClass(t,e){return k.toggleClass(this,t,e)[0]}static hasClass(t,e){const r=k._preElem(t,"hasClass");if("string"!=typeof e)throw new TypeError('The "token" parameter must be a string.');return r.classList.contains(e)}hasClass(t){return k.hasClass(this,t)}static classLength(t){return k._preElem(t,"classLength").classList.length}classLength(){return k.classLength(this)}static classList(t){return k._preElem(t,"classList").classList.values().toArray()}classList(){return k.classList(this)}static tagName(t){return k._preElem(t,"tagName").tagName}tagName(){return k.tagName(this)}static id(t){return k._preElem(t,"id").id}id(){return k.id(this)}static toBigInt(t){const e=k._preElem(t,"toBigInt"),r=e.textContent?.trim();let o=null;try{o=BigInt(r??"")}catch{o=null}return o}toBigInt(){return k.toBigInt(this)}static setBigInt(t,e){if("bigint"!=typeof e)throw new Error("Value is not a valid BigInt.");const r=e.toString();return k._preElems(t,"setBigInt").forEach(t=>t.textContent=r),t}setBigInt(t){return k.setBigInt(this,t)}static toDate(t){const e=k._preElem(t,"toDate"),r=e.textContent?.trim();if(!r)return null;const o=new Date(r);return Number.isNaN(o.getTime())?null:o}toDate(){return k.toDate(this)}static setDate(t,e){if(!(e instanceof Date)||Number.isNaN(e.getTime()))throw new Error("Value is not a valid Date.");const r=e.toISOString();return k._preElems(t,"setDate").forEach(t=>t.textContent=r),t}setDate(t){return k.setDate(this,t)}static toJson(t){const e=k._preElem(t,"toJson"),r=e.textContent?.trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}toJson(){return k.toJson(this)}static setJson(t,e,r,o){const n=JSON.stringify(e,r,o);return k._preElems(t,"setJson").forEach(t=>t.textContent=n),t}setJson(t,e,r){return k.setJson(this,t,e,r)}static toNumber(t){const e=k._preElem(t,"toNumber");return"string"==typeof e.textContent?parseFloat(e.textContent.trim()):null}toNumber(){return k.toNumber(this)}static setNumber(t,e){if("number"!=typeof e)throw new Error("Value is not a valid number.");const r=e.toString();return k._preElems(t,"setNumber").forEach(t=>t.textContent=r),t}setNumber(t){return k.setNumber(this,t)}static toBoolean(t){const e=k._preElem(t,"toBoolean"),r=e.textContent?.trim();return null==r||"true"!==r&&"false"!==r?null:/^true$/i.test(r)}toBoolean(){return k.toBoolean(this)}static setBoolean(t,e){if("boolean"!=typeof e)throw new Error("Value is not a valid boolean.");const r=e.toString();return k._preElems(t,"setBoolean").forEach(t=>t.textContent=r),t}setBoolean(t){return k.setBoolean(this,t)}static toString(t){const e=k._preElem(t,"toString");return"string"==typeof e.textContent?e.textContent:null}toString(){return k.toString(this)}static setString(t,e){if("string"!=typeof e)throw new Error("Value is not a valid string.");return k._preElems(t,"setString").forEach(t=>t.textContent=e),t}setString(t){return k.setString(this,t)}static text(t){return k._preElem(t,"text").textContent}text(){return k.text(this)}static setText(t,e){const r=null!=e?String(e):"";return k._preElems(t,"setText").forEach(t=>t.textContent=r),t}setText(t){return k.setText(this,t)}static empty(t){return k._preElems(t,"empty").forEach(t=>t.textContent=""),t}empty(){return k.empty(this)}static html(t,e){return k._preElem(t,"html").getHTML(e)}html(t){return k.html(this,t)}static setHtml(t,e){if("string"!=typeof e)throw new Error("Value is not a valid string.");return k._preElems(t,"setHtml").forEach(t=>t.innerHTML=e),t}setHtml(t){return k.setHtml(this,t)}static _valHooks={option:{get:t=>{const e=t.getAttribute("value");return null!=e?e:t.textContent}},select:{get:t=>{const e=t.options,r=t.selectedIndex,o="select-one"===t.type,n=o?r+1:e.length,i=[];let s=r<0?n:o?r:0;for(;s<n;s++){const t=e[s],n=t.parentNode;if((t.selected||s===r)&&!t.disabled&&(!n||!n.disabled||"OPTGROUP"!==n.tagName)){const e=k._valHooks.option.get(t);if(o)return e;i.push(e)}}return i},set:(t,e)=>{const r=t.options,o=Array.isArray(e)?e.map(String):[String(e)];let n=!1;for(let t=0;t<r.length;t++){const e=r[t],i=k._valHooks.option.get(e);"string"==typeof i&&(e.selected=o.includes(i))&&(n=!0)}return n||(t.selectedIndex=-1),o}},radio:{get:t=>t.checked?"on":"off",set(t,e){if("boolean"==typeof e){const r=t.closest("label");return e&&r&&r.querySelectorAll('input[type="radio"]').forEach(e=>{e instanceof HTMLInputElement&&e!==t&&(e.checked=!1)}),t.checked=e,e}}},checkbox:{get:t=>t.checked?"on":"off",set(t,e){if("boolean"==typeof e)return t.checked=e,e}}};static setVal(t,e){return k._preInputElems(t,"setVal").forEach(t=>{if(1!==t.nodeType)return;let r="function"==typeof e?e(t,k.val(t)):e;null==r?r="":"number"==typeof r?r=String(r):Array.isArray(r)&&(r=((t,e)=>{const r=[];for(let o=0;o<t.length;o++)r.push(e(t[o]));return r})(r,t=>null==t?"":String(t)));const o=k._valHooks[t.type]||k._valHooks[t.nodeName.toLowerCase()];if(!o||"function"!=typeof o.set||void 0===o.set(t,r,"value")){if("string"!=typeof r&&"boolean"!=typeof r)throw new Error(`Invalid setValue "${typeof r}" value.`);"string"==typeof r&&(t.value=r)}}),t}setVal(t){return k.setVal(this,t)}static _valTypes={string:t=>t.value,date:t=>t.valueAsDate,number:t=>t.valueAsNumber};static _getValByType(t,e,r){if("string"!=typeof e)throw new TypeError('The "type" must be a string.');if("string"!=typeof r)throw new TypeError('The "where" must be a string.');if(!(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement))throw new Error(`Provided element is not an HTMLInputElement in ${r}().`);if("function"!=typeof k._valTypes[e])throw new Error(`No handler found for type "${e}" in ${r}().`);return k._valTypes[e](t)}static _val(t,e,r){const o=k._preInputElem(t,e),n=k._valHooks[o.type]||k._valHooks[o.nodeName.toLowerCase()];if(n&&"function"==typeof n.get){const t=n.get(o,"value",r);if(void 0!==t)return"string"==typeof t?t.replace(/\r/g,""):t}return k._getValByType(o,r,e)}_val(t,e){return k._val(this,t,e)}static val(t){return k._val(t,"val","string")}val(){return k.val(this)}static valTxt(t){const e=k._val(t,"valTxt","string");if("string"!=typeof e&&null!==e)throw new Error("Value is not a valid string.");return null==e?"":"string"==typeof e?e.replace(/\r/g,""):e}valTxt(){return k.valTxt(this)}static _valArr(t,e,r){const o=k._val(t,e,r);if(!Array.isArray(o))throw new Error(`Value expected an array but got ${typeof o}.`);return o}_valArr(t,e){return k._valArr(this,t,e)}static valArr(t){return k._valArr(t,"valArr","string")}valArr(){return k.valArr(this)}static valNb(t){if(!(k._preInputElem(t,"valNb")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const e=k._val(t,"valNb","number");if(Number.isNaN(e))throw new Error("Value is not a valid number.");return e}valNb(){return k.valNb(this)}static valDate(t){if(!(k._preInputElem(t,"valDate")instanceof HTMLInputElement))throw new Error("Element must be an input element.");const e=k._val(t,"valDate","date");if(!(e instanceof Date))throw new Error("Value is not a valid date.");return e}valDate(){return k.valDate(this)}static valBool(t){const e=k._preInputElem(t,"valBool");if(!(e instanceof HTMLInputElement))throw new Error("Element must be an input element.");return"on"===k.val(e)}valBool(){return k.valBool(this)}static listenForPaste(t,{onFilePaste:e,onTextPaste:r}={}){if(void 0!==e&&"function"!=typeof e)throw new TypeError("onFilePaste must be a function.");if(void 0!==r&&"function"!=typeof r)throw new TypeError("onTextPaste must be a function.");const o=t=>{if(!(t instanceof ClipboardEvent))return;const o=t.clipboardData?.items||[];for(const t of o)if("file"===t.kind){if("function"==typeof e){const r=t.getAsFile();r&&e(t,r)}}else"string"===t.kind&&"function"==typeof r&&t.getAsString(e=>r(t,e))};return k._preElemsWithDoc(t,"listenForPaste").forEach(t=>k.on(t,"paste",o)),o}listenForPaste({onFilePaste:t,onTextPaste:e}={}){return k.listenForPaste(this,{onFilePaste:t,onTextPaste:e})}static hasEventListener(t,e){const r=k._preEventTargetElem(t,"hasEventListener");if(!D.has(r))return!1;const o=D.get(r);return!!(o&&Array.isArray(o[e])&&o[e].length>0)}hasEventListener(t){return k.hasEventListener(this,t)}static hasExactEventListener(t,e,r){const o=k._preEventTargetElem(t,"hasExactEventListener");if("function"!=typeof r)throw new TypeError('The "handler" must be a function.');if(!D.has(o))return!1;const n=D.get(o);return!(!n||!Array.isArray(n[e]))&&n[e].some(t=>t.handler===r)}hasExactEventListener(t,e){return k.hasExactEventListener(this,t,e)}static on(t,e,r,o){if(!("string"==typeof e||Array.isArray(e)&&e.every(t=>"string"==typeof t)))throw new TypeError("The events must be a string or array of strings.");for(const n of Array.isArray(e)?Array.from(new Set(e)):[e]){if("string"!=typeof n)throw new TypeError("The event name must be a string.");k._preEventTargetElems(t,"on").forEach(t=>{t.addEventListener(n,r,o),D.has(t)||D.set(t,{});const e=D.get(t);e&&(Array.isArray(e[n])||(e[n]=[]),e[n].push({handler:r,options:o}))})}return t}on(t,e,r){return k.on(this,t,e,r)}static once(t,e,r,o={}){if(!("string"==typeof e||Array.isArray(e)&&e.every(t=>"string"==typeof t)))throw new TypeError("The events must be a string or array of strings.");for(const n of Array.isArray(e)?Array.from(new Set(e)):[e]){if("string"!=typeof n)throw new TypeError("The event name must be a string.");k._preEventTargetElems(t,"once").forEach(t=>{const e=o=>{k.off(t,n,e),"function"==typeof r&&r(o)};k.on(t,n,e,"boolean"==typeof o?o:{...o,once:!0})})}return t}once(t,e,r={}){return k.once(this,t,e,r)}static off(t,e,r,o){if(!("string"==typeof e||Array.isArray(e)&&e.every(t=>"string"==typeof t)))throw new TypeError("The events must be a string or array of strings.");for(const n of Array.isArray(e)?Array.from(new Set(e)):[e]){if("string"!=typeof n)throw new TypeError("The event name must be a string.");k._preEventTargetElems(t,"off").forEach(t=>{t.removeEventListener(n,r,o);const e=D.get(t);e&&e[n]&&(e[n]=e[n].filter(t=>t.handler!==r),0===e[n].length&&delete e[n])})}return t}off(t,e,r){return k.off(this,t,e,r)}static offAll(t,e){if(!("string"==typeof e||Array.isArray(e)&&e.every(t=>"string"==typeof t)))throw new TypeError("The events must be a string or array of strings.");for(const r of Array.isArray(e)?Array.from(new Set(e)):[e]){if("string"!=typeof r)throw new TypeError("The event name must be a string.");k._preEventTargetElems(t,"offAll").forEach(t=>{const e=D.get(t);if(e&&e[r]){for(const o of e[r])t.removeEventListener(r,o.handler,o.options);delete e[r]}})}return t}offAll(t){return k.offAll(this,t)}static offAllTypes(t,e=null){if(null!==e&&"function"!=typeof e)throw new TypeError('The "filterFn" must be a function.');return k._preEventTargetElems(t,"offAllTypes").forEach(t=>{const r=D.get(t);if(r){for(const o in r)for(const n of r[o])("function"!=typeof e||e(n.handler,o))&&t.removeEventListener(o,n.handler,n.options);D.delete(t)}}),t}offAllTypes(t=null){return k.offAllTypes(this,t)}static trigger(t,e,r={}){if(!("string"==typeof e||Array.isArray(e)&&e.every(t=>"string"==typeof t)))throw new TypeError("The events must be a string or array of strings.");for(const o of Array.isArray(e)?Array.from(new Set(e)):[e]){if("string"!=typeof o)throw new TypeError("The event name must be a string.");k._preEventTargetElems(t,"trigger").forEach(t=>{const e=r instanceof Event||r instanceof CustomEvent?r:new CustomEvent(o,{bubbles:!0,cancelable:!0,detail:r});t.dispatchEvent(e)})}return t}trigger(t,e={}){return k.trigger(this,t,e)}static#o={for:"htmlFor",class:"className"};static propFix=new Proxy(k.#o,{set:(t,e,r)=>(t[e]=r,k.attrFix[r]=e,!0)});static attrFix=Object.fromEntries(Object.entries(k.#o).map(([t,e])=>[e,t]));static getPropName(t){return"string"==typeof k.propFix[t]?k.propFix[t]:t}static getAttrName(t){return"string"==typeof k.attrFix[t]?k.attrFix[t]:t}static attr(t,e){if("string"!=typeof e)throw new TypeError('The "name" must be a string.');return k._preElem(t,"attr").getAttribute(k.getAttrName(e))}attr(t){return k.attr(this,t)}static setAttr(t,e,r=null){if("string"!=typeof e)throw new TypeError('The "name" must be a string.');if(null!==r&&"string"!=typeof r)throw new TypeError('The "value" must be a string.');return k._preElems(t,"setAttr").forEach(t=>{null===r?t.removeAttribute(k.getAttrName(e)):t.setAttribute(k.getAttrName(e),r)}),t}setAttr(t,e){return k.setAttr(this,t,e)}static removeAttr(t,e){if("string"!=typeof e)throw new TypeError('The "name" must be a string.');return k._preElems(t,"removeAttr").forEach(t=>t.removeAttribute(k.getAttrName(e))),t}removeAttr(t){return k.removeAttr(this,t)}static hasAttr(t,e){if("string"!=typeof e)throw new TypeError('The "name" must be a string.');return k._preElem(t,"hasAttr").hasAttribute(k.getAttrName(e))}hasAttr(t){return k.hasAttr(this,t)}static hasProp(t,e){if("string"!=typeof e)throw new TypeError('The "name" must be a string.');return!!k._preElem(t,"hasProp")[k.getPropName(e)]}hasProp(t){return k.hasProp(this,t)}static addProp(t,e){if("string"!=typeof e)throw new TypeError('The "name" must be a string.');return k._preElems(t,"addProp").forEach(t=>{t[k.getPropName(e)]=!0}),t}addProp(t){return k.addProp(this,t)}static removeProp(t,e){if("string"!=typeof e)throw new TypeError('The "name" must be a string.');return k._preElems(t,"removeProp").forEach(t=>{t[k.getPropName(e)]=!1}),t}removeProp(t){return k.removeProp(this,t)}static toggleProp(t,e,r){if("string"!=typeof e)throw new TypeError('The "name" must be a string.');if(void 0!==r&&"boolean"!=typeof r)throw new TypeError('The "force" must be a boolean.');k._preElems(t,"toggleProp").forEach(t=>{(void 0===r?!t[k.getPropName(e)]:r)?k.addProp(t,e):k.removeProp(t,e)})}toggleProp(t,e){return k.toggleProp(this,t,e)}static remove(t){return k._preElems(t,"remove").forEach(t=>t.remove()),t}remove(){return k.remove(this)}static index(t,e=null){const r=k._preElem(t,"index");if(!r)return-1;if(!e)return Array.prototype.indexOf.call(r.parentNode?.children||[],r);if(e){const t="string"==typeof e?document.querySelectorAll(e):k._preElems(e,"index");return Array.prototype.indexOf.call(t,r)}return-1}index(t){return k.index(this,t)}static _getCustomRect(t,e){const r={height:0,width:0,x:0,y:0,bottom:0,left:0,right:0,top:0,toJSON:function(){throw new Error("Function not implemented.")}};for(const e in t)"number"==typeof t[e]&&(r[e]=t[e]);if("object"!=typeof e||null===e||Array.isArray(e))throw new Error("extraRect must be a non-null object.");const{height:o=0,width:n=0,top:i=0,bottom:s=0,left:l=0,right:a=0}=e;if("number"!=typeof o)throw new Error("extraRect.height must be a number.");if("number"!=typeof n)throw new Error("extraRect.width must be a number.");if("number"!=typeof i)throw new Error("extraRect.top must be a number.");if("number"!=typeof s)throw new Error("extraRect.bottom must be a number.");if("number"!=typeof l)throw new Error("extraRect.left must be a number.");if("number"!=typeof a)throw new Error("extraRect.right must be a number.");return r.height+=o,r.width+=n,r.top+=i,r.bottom+=s,r.left+=l,r.right+=a,r}static isCollWith(t,e,r={}){const o=k._getCustomRect(k._preElem(t,"isCollWith").getBoundingClientRect(),r),n=k._preElem(e,"isCollWith").getBoundingClientRect();return v(o,n)}isCollWith(t,e){return k.isCollWith(this,t,e)}static isCollPerfWith(t,e,r={}){const o=k._getCustomRect(k._preElem(t,"isCollPerfWith").getBoundingClientRect(),r),n=k._preElem(e,"isCollPerfWith").getBoundingClientRect();return T(o,n)}isCollPerfWith(t,e){return k.isCollPerfWith(this,t,e)}static _isCollWithLock(t,e,r,o,n){const i=S[n];if(t)return i.has(o)||i.set(o,!0),!0;if(i.has(o)){let t=!1;switch(n){case"top":t=C(e,r);break;case"bottom":t=x(e,r);break;case"left":t=_(e,r);break;case"right":t=A(e,r)}return t&&i.delete(o),i.has(o)}return!1}static isCollWithLock(t,e,r,o={}){const n=k._preElem(t,"isCollWithLock"),i=k._preElem(e,"isCollWithLock"),s=k._getCustomRect(n.getBoundingClientRect(),o),l=i.getBoundingClientRect(),a=v(s,l);return k._isCollWithLock(a,s,l,n,r)}isCollWithLock(t,e,r){return k.isCollWithLock(this,t,e,r)}static isCollPerfWithLock(t,e,r,o={}){const n=k._preElem(t,"isCollPerfWithLock"),i=k._preElem(e,"isCollPerfWithLock"),s=k._getCustomRect(n.getBoundingClientRect(),o),l=i.getBoundingClientRect(),a=T(s,l);return k._isCollWithLock(a,s,l,n,r)}isCollPerfWithLock(t,e,r){return k.isCollPerfWithLock(this,t,e,r)}static resetCollLock(t){const e=k._preElem(t,"resetCollLock");let r=!1;for(const t of["top","bottom","left","right"])S[t].has(e)&&(S[t].delete(e),r=!0);return r}resetCollLock(){return k.resetCollLock(this)}static resetCollLockDir(t,e){const r=k._preElem(t,"resetCollLockDir"),o=S[e];return!!o.has(r)&&(o.delete(r),!0)}resetCollLockDir(t){return k.resetCollLockDir(this,t)}static isInViewport(t){const e=k._preElem(t,"isInViewport");if(!e.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=k.offset(e).top,o=r+k.outerHeight(e),n=k.scrollTop(window),i=n+k.height(window);return o>n&&r<i}isInViewport(){return k.isInViewport(this)}static isScrolledIntoView(t){const e=k._preElem(t,"isScrolledIntoView");if(!e.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const r=k.scrollTop(window),o=r+k.height(window),n=k.offset(e).top;return n+k.height(e)<=o&&n>=r}isScrolledIntoView(){return k.isScrolledIntoView(this)}static isInContainer(t,e){const r=k._preElem(t,"isInContainer"),o=k._preElem(e,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const n=r.getBoundingClientRect(),i=o.getBoundingClientRect(),s=n.bottom>i.top&&n.top<i.bottom,l=n.right>i.left&&n.left<i.right;return s&&l}isInContainer(t){return k.isInContainer(this,t)}static isFullyInContainer(t,e){const r=k._preElem(t,"isScrolledIntoView"),o=k._preElem(e,"isInContainer");if(!r.checkVisibility({contentVisibilityAuto:!1,opacityProperty:!1,visibilityProperty:!1}))return!1;const n=r.getBoundingClientRect(),i=o.getBoundingClientRect();return n.top>=i.top&&n.bottom<=i.bottom&&n.left>=i.left&&n.right<=i.right}isFullyInContainer(t){return k.isFullyInContainer(this,t)}static hasScroll(t){const e=k._preElem(t,"hasScroll");return{v:e.scrollHeight>e.clientHeight,h:e.scrollWidth>e.clientWidth}}hasScroll(){return k.hasScroll(this)}}const B=k;function P(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&"[object Object]"===Object.prototype.toString.call(t)}class N{static Utils={...r,TinyHtml:B};#n=!0;#i=!1;#s=0;#l=0;#a=!0;#c=!1;#d=!1;#m=!1;#u=!1;#h=!1;#p=!1;#g=null;#f=[];#y=null;#b={start:!1,end:!1,collide:!1,move:!1};#E=null;#w;#v="drag-hidden";#T="dragging";#C="drag-active";#x="jail-drag-active";#_="jail-drag-disabled";#A="dragging-collision";#D=9999;constructor(t,e={}){const r=t instanceof B?t.get(0):t;if(!(r instanceof HTMLElement))throw new Error("TinyDragger requires a valid target HTMLElement to initialize.");if(this.#w=r,void 0!==e.jail&&!(e.jail instanceof HTMLElement))throw new Error('The "jail" option must be an HTMLElement if provided.');if(void 0!==e.defaultZIndex&&this.setDefaultZIndex(e.defaultZIndex),void 0!==e.vibration&&!1!==e.vibration&&!P(e.vibration))throw new Error('The "vibration" option must be an object or false.');const o=(t,e)=>{if(void 0!==t&&"boolean"!=typeof t)throw new Error(`The "${e}" option must be a boolean.`)},n=(t,e)=>{if(void 0!==t&&"string"!=typeof t)throw new Error(`The "${e}" option must be a string.`)};o(e.mirrorElem,"mirrorElem"),o(e.collisionByMouse,"collisionByMouse"),o(e.lockInsideJail,"lockInsideJail"),o(e.dropInJailOnly,"dropInJailOnly"),o(e.revertOnDrop,"revertOnDrop"),o(e.multiCollision,"multiCollision"),n(e.classDragging,"classDragging"),n(e.classBodyDragging,"classBodyDragging"),n(e.classJailDragging,"classJailDragging"),n(e.classJailDragDisabled,"classJailDragDisabled"),n(e.classDragCollision,"classDragCollision"),n(e.classHidden,"classHidden"),e.jail instanceof HTMLElement&&(this.#E=e.jail),this.#b=Object.assign({start:!1,end:!1,collide:!1,move:!1},P(e.vibration)?e.vibration:{}),"string"==typeof e.classDragging&&(this.#T=e.classDragging),"string"==typeof e.classBodyDragging&&(this.#C=e.classBodyDragging),"string"==typeof e.classJailDragging&&(this.#x=e.classJailDragging),"string"==typeof e.classJailDragDisabled&&(this.#_=e.classJailDragDisabled),"string"==typeof e.classHidden&&(this.#v=e.classHidden),"string"==typeof e.classDragCollision&&(this.#A=e.classDragCollision),"boolean"==typeof e.collisionByMouse&&(this.#h=e.collisionByMouse),"boolean"==typeof e.mirrorElem&&(this.#a=e.mirrorElem),"boolean"==typeof e.revertOnDrop&&(this.#m=e.revertOnDrop),"boolean"==typeof e.lockInsideJail&&(this.#d=e.lockInsideJail),"boolean"==typeof e.dropInJailOnly&&(this.#p=e.dropInJailOnly),"boolean"==typeof e.multiCollision&&(this.#c=e.multiCollision),this._onMouseDown=this.#L.bind(this),this._onMouseMove=this.#S.bind(this),this._onMouseUp=this.#k.bind(this),this._onTouchStart=t=>this.#L(t.touches[0]),this._onTouchMove=t=>this.#S(t.touches[0]),this._onTouchEnd=t=>this.#k(t.changedTouches[0]),this.#w.addEventListener("mousedown",this._onMouseDown),this.#w.addEventListener("touchstart",this._onTouchStart,{passive:!1})}enable(){this.#B(),this.#E&&this.#E.classList.add(this.#_),this.#n=!0}disable(){this.#E&&this.#E.classList.remove(this.#_),this.#n=!1}addCollidable(t){if(this.#B(),!(t instanceof HTMLElement))throw new Error("addCollidable expects an HTMLElement as argument.");this.#f.includes(t)||this.#f.push(t)}removeCollidable(t){if(this.#B(),!(t instanceof HTMLElement))throw new Error("removeCollidable expects an HTMLElement as argument.");this.#f=this.#f.filter(e=>e!==t)}setVibrationPattern({startPattern:t=!1,endPattern:e=!1,collidePattern:r=!1,movePattern:o=!1}={}){this.#B();const n=t=>!1===t||Array.isArray(t)&&t.every(t=>"number"==typeof t);if(!n(t))throw new Error('Invalid "startPattern": must be false or an array of numbers.');if(!n(e))throw new Error('Invalid "endPattern": must be false or an array of numbers.');if(!n(r))throw new Error('Invalid "collidePattern": must be false or an array of numbers.');if(!n(o))throw new Error('Invalid "movePattern": must be false or an array of numbers.');this.#b={start:t,end:e,collide:r,move:o}}disableVibration(){this.#B(),this.#b={start:!1,end:!1,collide:!1,move:!1}}getOffset(t){if(this.#B(),!(t instanceof MouseEvent||t instanceof Touch)||"number"!=typeof t.clientX||"number"!=typeof t.clientY)throw new Error("getOffset expects an event with valid clientX and clientY coordinates.");const e=this.#w.getBoundingClientRect(),{left:r,top:o}=B.borderWidth(this.#w);return{x:t.clientX-e.left+r,y:t.clientY-e.top+o}}#L(t){if(t instanceof MouseEvent&&t.preventDefault(),this.#i||!this.#n||!this.#w.parentElement)return;if(this.#a){const t=this.#w.cloneNode(!0);if(!(t instanceof HTMLElement))throw new Error("[TinyDragger] INVALID DRAG ELEMENT!");this.#y=t}else this.#y=this.#w;this.#u=!0;const e=this.#w.getBoundingClientRect();Object.assign(this.#y.style,{position:"absolute",pointerEvents:"none",left:`${this.#w.offsetLeft}px`,top:`${this.#w.offsetTop}px`,width:`${e.width}px`,height:`${e.height}px`,zIndex:this.#D}),this.#a&&(this.#w.classList.add(this.#v),this.#w.parentElement.appendChild(this.#y));const{x:r,y:o}=this.getOffset(t);this.#l=r,this.#s=o,this.#y.classList.add(this.#T),document.body.classList.add(this.#C),this.#E&&this.#E.classList.add(this.#x),document.addEventListener("mousemove",this._onMouseMove),document.addEventListener("mouseup",this._onMouseUp),document.addEventListener("touchmove",this._onTouchMove,{passive:!1}),document.addEventListener("touchend",this._onTouchEnd),navigator.vibrate&&Array.isArray(this.#b.start)&&navigator.vibrate(this.#b.start),this.checkDragCollision(t),this.#P("drag")}#N=[];#M(t){t&&(t.classList.add(this.#A),this.#N.push(t))}#I(){for(;this.#N.length>0;){const t=this.#N.shift();t&&t.classList.remove(this.#A)}this.#g&&this.#g.classList.remove(this.#A)}checkDragCollision(t){const{collidedElements:e}=this.execCollision(t),r=e[0]||null;this.#g&&!e.includes(this.#g)&&this.#I(),e.forEach(t=>this.#M(t)),this.#f.forEach(t=>{e.includes(t)||t.classList.remove(this.#A)}),navigator.vibrate&&Array.isArray(this.#b.collide)&&e.length>0&&navigator.vibrate(this.#b.collide),this.#g=r}#S(t){if(t instanceof MouseEvent&&t.preventDefault(),this.#i||!this.#u||!this.#n||!this.#y)return;const e=(this.#y.offsetParent||document.body).getBoundingClientRect();let r=t.clientX-e.left-this.#l,o=t.clientY-e.top-this.#s;if(this.#d&&this.#E){const t=this.#E.getBoundingClientRect(),n=this.#y.getBoundingClientRect(),i=t.left-e.left,s=t.top-e.top,{x:l,y:a}=B.borderWidth(this.#E),c=i+t.width-n.width-a,d=s+t.height-n.height-l;r=Math.max(i,Math.min(r,c)),o=Math.max(s,Math.min(o,d))}this.#y.style.position="absolute",this.#y.style.left=`${r}px`,this.#y.style.top=`${o}px`,navigator.vibrate&&Array.isArray(this.#b.move)&&navigator.vibrate(this.#b.move),this.checkDragCollision(t),this.#P("dragging")}execCollision(t){if(this.#i||!this.#y)return{inJail:!1,collidedElements:[]};let e=[],r=!0;const o=this.#E?.getBoundingClientRect();if(this.#h){const n=t.clientX,i=t.clientY;this.#p&&this.#E&&o&&(r=n>=o.left&&n<=o.right&&i>=o.top&&i<=o.bottom),e=r?this.#c?this.getAllCollidedElements(n,i):[this.getCollidedElement(n,i)].filter(Boolean):[]}else{const t=this.#y.getBoundingClientRect();this.#p&&this.#E&&o&&(r=t.left>=o.left&&t.right<=o.right&&t.top>=o.top&&t.bottom<=o.bottom),e=r?this.#c?this.getAllCollidedElementsByRect(t):[this.getCollidedElementByRect(t)].filter(Boolean):[]}return{inJail:r,collidedElements:e}}#k(t){if(t instanceof MouseEvent&&t.preventDefault(),this.#i||!this.#u)return;if(this.#u=!1,!this.#y)return;this.#w.classList.remove(this.#T),document.body.classList.remove(this.#C),this.#E&&this.#E.classList.remove(this.#x),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd);const{collidedElements:e}=this.execCollision(t);navigator.vibrate&&Array.isArray(this.#b.end)&&navigator.vibrate(this.#b.end);const r=this.#y.style.left,o=this.#y.style.top;this.#y&&(this.#a?this.#y.remove():Object.assign(this.#y.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#y=null),this.#g&&this.#I(),this.#g=null,this.#a&&this.#w.classList.remove(this.#v),this.#m||(this.#w.style.left=r,this.#w.style.top=o);const n=new CustomEvent("drop",{detail:{targets:e,first:e[0]||null}});this.#w.dispatchEvent(n)}#W(t,e){const r=t.getBoundingClientRect();return!(e.right<r.left||e.left>r.right||e.bottom<r.top||e.top>r.bottom)}getAllCollidedElementsByRect(t){if(this.#B(),!(t instanceof DOMRect)||"number"!=typeof t.left||"number"!=typeof t.right||"number"!=typeof t.top||"number"!=typeof t.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#f.filter(e=>this.#W(e,t))}getCollidedElementByRect(t){if(this.#B(),!(t instanceof DOMRect)||"number"!=typeof t.left||"number"!=typeof t.right||"number"!=typeof t.top||"number"!=typeof t.bottom)throw new Error("getCollidedElementByRect expects a valid DOMRect object.");return this.#f.find(e=>this.#W(e,t))||null}#H(t,e,r){const o=t.getBoundingClientRect();return e>=o.left&&e<=o.right&&r>=o.top&&r<=o.bottom}getAllCollidedElements(t,e){if(this.#B(),"number"!=typeof t||"number"!=typeof e)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#f.filter(r=>this.#H(r,t,e))}getCollidedElement(t,e){if(this.#B(),"number"!=typeof t||"number"!=typeof e)throw new Error("getCollidedElement expects numeric x and y coordinates.");return this.#f.find(r=>this.#H(r,t,e))||null}#P(t){const e=new CustomEvent(t);this.#w.dispatchEvent(e)}getDragging(){return this.#u}getLockInsideJail(){return this.#d}setLockInsideJail(t){if("boolean"!=typeof t)throw new Error("lockInsideJail must be a boolean.");this.#d=t}getRevertOnDrop(){return this.#m}setRevertOnDrop(t){if("boolean"!=typeof t)throw new Error("revertOnDrop must be a boolean.");this.#m=t}getCollisionByMouse(){return this.#h}setCollisionByMouse(t){if("boolean"!=typeof t)throw new Error("collisionByMouse must be a boolean.");this.#h=t}getDropInJailOnly(){return this.#p}setDropInJailOnly(t){if("boolean"!=typeof t)throw new Error("dropInJailOnly must be a boolean.");this.#p=t}getDefaultZIndex(){return this.#D}setDefaultZIndex(t){if("number"!=typeof t||!Number.isFinite(t))throw new TypeError("Z-index must be a finite number.");this.#D=t}isMirrorEnabled(){return this.#a}setMirrorEnabled(t){if("boolean"!=typeof t)throw new TypeError("Mirror setting must be a boolean.");this.#a=t}getTarget(){return this.#w}getJail(){return this.#E}getDragProxy(){return this.#y}getLastCollision(){return this.#g}getCollidables(){return[...this.#f]}getDragHiddenClass(){return this.#v}getClassDragging(){return this.#T}getClassBodyDragging(){return this.#C}getClassJailDragging(){return this.#x}getClassJailDragDisabled(){return this.#_}getClassDragCollision(){return this.#A}getVibrations(){return{...this.#b}}getStartVibration(){return this.#b.start}getEndVibration(){return this.#b.end}getCollideVibration(){return this.#b.collide}getMoveVibration(){return this.#b.move}isEnabled(){return this.#n}#B(){if(this.#i)throw new Error("This TinyDragger instance has been destroyed and can no longer be used.")}destroy(){this.#i||(this.disable(),this.#w.removeEventListener("mousedown",this._onMouseDown),this.#w.removeEventListener("touchstart",this._onTouchStart),document.removeEventListener("mousemove",this._onMouseMove),document.removeEventListener("mouseup",this._onMouseUp),document.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("touchend",this._onTouchEnd),this.#g&&this.#I(),this.#y&&(this.#a?this.#y.remove():Object.assign(this.#y.style,{position:"",pointerEvents:"",left:"",top:"",width:"",height:"",zIndex:""}),this.#y=null),this.#f=[],this.#u=!1,this.#g=null,this.#a&&this.#w.classList.remove(this.#v),this.#w.classList.remove(this.#T),document.body.classList.remove(this.#C),this.#E&&this.#E.classList.remove(this.#x,this.#_),this.#i=!0)}}const M=N;window.TinyDragger=e.TinyDragger})();