tytdlite/TYTDLite/Assets/beer.min.js

4 lines
7.8 KiB
JavaScript
Raw Normal View History

2024-07-01 00:50:11 +00:00
export default (() => {
let k,F,N,P;const s={light:"",dark:""},Z=[];async function X(t){return await new Promise(n=>setTimeout(n,t))}function Y(){return"fxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=Math.random()*16|0;return(t==="x"?n:n&3|8).toString(16)})}function h(t,n){try{return typeof t=="string"?(n!=null?n:document).querySelector(t):t}catch{return null}}function l(t,n){try{return typeof t=="string"?(n!=null?n:document).querySelectorAll(t):t!=null?t:Z}catch{return Z}}function f(t,n){var e,r;return(r=(e=t==null?void 0:t.classList)==null?void 0:e.contains(n))!=null?r:!1}function L(t,n){var e;return((e=t==null?void 0:t.tagName)==null?void 0:e.toLowerCase())===n}function m(t,n){var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())===n}function p(t,n){var e;(e=t==null?void 0:t.classList)==null||e.add(n)}function u(t,n){var e;(e=t==null?void 0:t.classList)==null||e.remove(n)}function g(t,n,e,r=!0){t==null||t.addEventListener(n,e,r)}function G(t,n,e,r=!0){t==null||t.removeEventListener(n,e,r)}function J(t,n){var e;(e=n==null?void 0:n.parentNode)==null||e.insertBefore(t,n)}function D(t){return t==null?void 0:t.previousElementSibling}function H(t){return t==null?void 0:t.nextElementSibling}function T(t){return t==null?void 0:t.parentElement}function tt(t){const n=document.createElement("div");for(const e in t)n.setAttribute(e,t[e]);return n}function x(t){const n=t;m(n,"number")&&!n.value&&(n.value=""),n.placeholder||(n.placeholder=" "),t.getAttribute("data-ui")&&V(t,null)}function nt(t){V(t.currentTarget,null,null,t)}function et(t){const n=t.currentTarget,e=T(n),r=h("input:not([type=file], [type=checkbox], [type=radio]), select, textarea",e);r&&r.focus()}function rt(t){const n=t.currentTarget;x(n)}function at(t){const n=t.currentTarget;x(n)}function Q(t){G(document.body,"click",Q);const n=t.target;l("menu.active").forEach(r=>z(n,r,t))}function it(t){const n=t.currentTarget;u(n,"active"),k&&clearTimeout(k)}function ot(t){const n=t.currentTarget;q(n)}function ct(t){const n=t.currentTarget;I(n)}function ut(t){const n=t.currentTarget;q(n,t)}function st(t){const n=t.currentTarget;I(n,t)}function j(){F&&clearTimeout(F),F=setTimeout(()=>{A()},180)}function q(t,n){if(n&&n.key==="Enter"){const i=D(t);return m(i,"file")?i.click():void 0}const e=t,r=H(t);!m(r,"text")||(r.value=e.files?Array.from(e.files).map(i=>i.name).join(", "):"",r.readOnly=!0,g(r,"keydown",ut,!1),x(r))}function I(t,n){if(n&&n.key==="Enter"){const i=D(t);return m(i,"color")?i.click():void 0}const e=t,r=H(t);!m(r,"text")||(r.readOnly=!0,r.value=e.value,g(r,"keydown",st,!1),x(r))}function W(t){const n=T(t),e=h("span",n),r=l("input",n);if(!r.length||!e)return;const i=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--size"))||16,c=.25*i*100/r[0].offsetWidth,o=[],a=[];for(let y=0;y<r.length;y++){const B=parseFloat(r[y].min),O=parseFloat(r[y].max),K=parseFloat(r[y].value),E=B||0,$=O||100,w=K||0,R=(w-E)*100/($-E),U=c/2-c*R/100;o.push(R+U),a.push(w),B!==E&&(r[y].min=`${E}`),O!==$&&(r[y].max=`${$}`),K!==w&&(r[y].value=`${w}`)}let d=o[0],v=0,b=100-v-d,S=a[0],M=a[1]||0;r.length>1&&(d=Math.abs(o[1]-o[0]),v=o[1]>o[0]?o[0]:o[1],b=100-v-d,M>S&&(S=a[1]||0,M=a[0])),n.style.setProperty("---start",`${v}%`),n.style.setProperty("---end",`${b}%`),n.style.setProperty("---value1",`'${S}'`),n.style.setProperty("---value2",`'${M}'`)}function _(t){if(t){const e=t.target;if(e.type==="range")return W(e)}const n=l(".slider > input[type=range]");n.length?g(globalThis,"input",_,!1):G(globalThis,"input",_,!1),n.forEach(W)}async function V(t,n,e,r){if(!(!n&&(n=h(t.getAttribute("data-ui")),!n))){if(L(n,"dialog"))return await ft(t,n);if(L(n,"menu"))return z(t,n,r);if(f(n,"snackbar"))return dt(t,n,e);if(f(n,"page"))return lt(t,n);if(C(t),f(n,"active"))return u(n,"active");p(n,"active")}}function C(t){t.id&&f(t,"page")&&(t=h(`[data-ui="#${t.id}"]`));const n=T(t);if(!f(n,"tabs"))return;l("a",n).forEach(r=>u(r,"active")),p(t,"active")}function lt(t,n){C(t);const e=T(n);if(e)for(let r=0;r<e.children.length;r++)f(e.children[r],"page")&&u(e.children[r],"active");p(n,"active"
return globalThis.ui;
})();