/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/billy-herrington-utils@2.1.1/dist/billy-herrington-utils.es.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
function chunks(e,t){return Array.from({length:Math.ceil(e.length/t)},((r,n)=>e.slice(n*t,n*t+t)))}function*irange(e=1,t=1){for(let r=e;;r+=t)yield r}function range(e,t=1,r=1){return irange(t,r).take(e).toArray()}function wait(e){return new Promise((t=>setTimeout(t,e)))}function splitWith(e,t=","){return e.split(t).map((e=>e.trim())).filter(Boolean)}function sanitizeStr(e){return e?.replace(/\n|\t/g," ").replace(/ {2,}/g," ").trim()||""}function waitForElementToAppear(e,t,r){const n=new MutationObserver((i=>{const o=e.querySelector(t);o&&(n.disconnect(),r(o))}));return n.observe(document.body,{childList:!0,subtree:!0}),n}function waitForElementToDisappear(e,t){const r=new MutationObserver((n=>{e.isConnected||(r.disconnect(),t())}));return r.observe(document.body,{childList:!0,subtree:!0}),r}function watchElementChildrenCount(e,t){let r=e.children.length;const n=new MutationObserver(((n,i)=>{for(const o of n)"childList"===o.type&&r!==e.children.length&&(r=e.children.length,t(i,r))}));return n.observe(e,{childList:!0}),n}function watchDomChangesWithThrottle(e,t,r=1e3,n=1/0,i={childList:!0,subtree:!0,attributes:!0}){let o,s,a=n;const c=new MutationObserver(((e,n)=>{if(a!==1/0&&a<1)return void c.disconnect();a--;const i=Date.now();o&&i-o<r&&s&&clearTimeout(s),s=window.setTimeout(t,r),o=i}));return c.observe(e,i),c}function querySelectorLast(e=document,t){const r=e.querySelectorAll(t);return r.length>0?r[r.length-1]:void 0}function querySelectorLastNumber(e,t=document){const r=querySelectorText(t,e);return Number(r.match(/\d+/g)?.pop()||0)}function querySelectorText(e,t){if("string"!=typeof t)return"";return sanitizeStr(e.querySelector(t)?.innerText||"")}function parseHtml(e){const t=(new DOMParser).parseFromString(e,"text/html").body;return t.children.length>1?t:t.firstElementChild}function copyAttributes(e,t){for(const r of t.attributes)r.nodeValue&&e.setAttribute(r.nodeName,r.nodeValue)}function replaceElementTag(e,t){const r=document.createElement(t);return copyAttributes(r,e),r.innerHTML=e.innerHTML,e.parentNode?.replaceChild(r,e),r}function removeClassesAndDataAttributes(e,t){Array.from(e.classList).forEach((r=>{r.includes(t)&&e.classList.remove(r)})),Array.from(e.attributes).forEach((r=>{r.name.startsWith("data-")&&r.name.includes(t)&&e.removeAttribute(r.name)}))}function getCommonParents(e){const t=Array.from(e).map((e=>e.parentElement)).filter((e=>null!==e));return[...new Set(t)]}function findNextSibling(e){return e.nextElementSibling?e.nextElementSibling:e.parentElement?findNextSibling(e.parentElement):null}function checkHomogenity(e,t,r){if(!e||!t)return!1;if(r.id&&e.id!==t.id)return!1;if(r.className){const r=e.className,n=t.className;if(!(r.length>n.length?r.includes(n):n.includes(r)))return!1}return!0}function instantiateTemplate(e,t,r){const n=document.querySelector(e),i=document.createElement("div"),o=n.cloneNode(!0);return i.append(o),Object.entries(t).forEach((([e,t])=>{i.querySelectorAll(`[${e}]`).forEach((r=>{r.setAttribute(e,t)}))})),Object.entries(r).forEach((([e,t])=>{i.querySelectorAll(e).forEach((e=>{e.innerText=t}))})),i.innerHTML}function exterminateVideo(e){e.removeAttribute("src"),e.load(),e.remove()}function downloader(e={append:"",after:"",button:"",cbBefore:()=>{}}){const t=parseHtml(e.button);e.append&&document.querySelector(e.append)?.append(t),e.after&&document.querySelector(e.after)?.after(t),t.addEventListener("click",(t=>{t.preventDefault(),e.cbBefore&&e.cbBefore(),waitForElementToAppear(document.body,"video",(e=>{window.location.href=e.getAttribute("src")}))}))}class OnHover{constructor(e,t,r,n){this.container=e,this.subjectSelector=t,this.onOver=r,this.onLeave=n,this.container.addEventListener("pointerover",(e=>this.handleEvent(e)))}handleLeaveEvent(){this.onLeave?.(this.target),this.onOverFinally?.(),this.target=void 0,this.onOverFinally=void 0,this.leaveSubject=void 0}handleEvent(e){const t=e.target;if(!this.subjectSelector(t)||this.target===t)return;this.leaveSubject?.dispatchEvent(new PointerEvent("pointerleave")),this.target=t;const r=this.onOver(this.target);this.onOverFinally=r?.onOverCallback,this.leaveSubject=r?.leaveTarget||this.target,this.leaveSubject.addEventListener("pointerleave",(e=>this.handleLeaveEvent()),{once:!0})}target;leaveSubject;onOverFinally;static create(...e){return new OnHover(...e)}}class Tick{constructor(e,t=!0){this.delay=e,this.startImmediate=t}tick;callbackFinal;start(e,t){this.stop(),this.callbackFinal=t,this.startImmediate&&e(),this.tick=window.setInterval(e,this.delay)}stop(){void 0!==this.tick&&(clearInterval(this.tick),this.tick=void 0),this.callbackFinal&&(this.callbackFinal(),this.callbackFinal=void 0)}}const MOBILE_UA={"User-Agent":["Mozilla/5.0 (Linux; Android 10; K)","AppleWebKit/537.36 (KHTML, like Gecko)","Chrome/114.0.0.0 Mobile Safari/537.36"].join(" ")};async function fetchWith(e,t){const r=t.init||{};t.mobile&&Object.assign(r,{headers:new Headers(MOBILE_UA)});const n=await fetch(e,r).then((e=>e));return"json"===t.type?await n.json():"html"===t.type?parseHtml(await n.text()):await n.text()}const fetchJson=e=>fetchWith(e,{type:"json"}),fetchHtml=e=>fetchWith(e,{type:"html"}),fetchText=e=>fetchWith(e,{type:"text"});function circularShift(e,t=6,r=1){return(e+r)%t||t}function memoize(e){const t=new Map;return(...r)=>{const n=JSON.stringify(r);if(t.has(n))return t.get(n);const i=e(...r);return t.set(n,i),i}}function objectToFormData(e){const t=new FormData;return Object.entries(e).forEach((([e,r])=>{t.append(e,r)})),t}function propsDifference(e,t){const r=new Set(Object.getOwnPropertyNames(e)),n=new Set(Object.getOwnPropertyNames(t));return{d1:r.difference(n).values().toArray(),d2:n.difference(r).values().toArray()}}class LazyImgLoader{lazyImgObserver;attributeName="data-lazy-load";constructor(e){this.lazyImgObserver=new Observer((t=>{e(t)&&this.delazify(t)}))}lazify(e,t,r){t&&r&&(t.setAttribute(this.attributeName,r),t.src="",this.lazyImgObserver.observe(t))}delazify=e=>{this.lazyImgObserver.observer.unobserve(e),e.src=e.getAttribute(this.attributeName),e.removeAttribute(this.attributeName)}}class Observer{constructor(e){this.callback=e,this.observer=new IntersectionObserver(this.handleIntersection.bind(this))}observer;timeout;observe(e){this.observer.observe(e)}throttle(e,t){this.observer.unobserve(e),this.timeout=window.setTimeout((()=>this.observer.observe(e)),t)}handleIntersection(e){for(const t of e)t.isIntersecting&&this.callback(t.target)}dispose(){this.timeout&&clearTimeout(this.timeout),this.observer.disconnect()}static observeWhile(e,t,r){const n=new Observer((async e=>{await t()&&n.throttle(e,r)}));return n.observe(e),n}}function formatTimeToHHMMSS(e){const t=e=>e.toString().padStart(2,"0"),r=e.match(/(\d+)\s*h/)?.[1]||"0",n=e.match(/(\d+)\s*mi?n/)?.[1]||"0",i=e.match(/(\d+)\s*sec/)?.[1]||"0";return`${t(+r)}:${t(+n)}:${t(+i)}`}function timeToSeconds(e){return(/[a-zA-Z]/.test(e)?formatTimeToHHMMSS(e):e).split(":").reverse().reduce(((e,t,r)=>e+parseInt(t,10)*60**r),0)}function parseIntegerOr(e,t){const r=Number(e);return Number.isSafeInteger(r)?r:t}function parseDataParams(e){return decodeURI(e.trim()).split(";").reduce(((e,t)=>{const r=t.match(/([+\w]+):([\w\- ]+)?/);if(r){const[,t,n]=r;n&&t.split("+").forEach((t=>{e[t]=n}))}return e}),{})}function parseCssUrl(e){return e.replace(/url\("|"\).*/g,"")}class RegexFilter{regexes;constructor(e,t="gi"){this.regexes=memoize(this.compileSearchRegex)(e,t)}compileSearchRegex(e,t){try{if(e.startsWith("r:"))return[new RegExp(e.slice(2),t)];return splitWith(e).map((e=>e.replace(/f:(\w+)/g,((e,t)=>`(^|\\ |,)${t}($|\\ |,)`)))).map((e=>new RegExp(e,t)))}catch(e){return[]}}hasEvery(e){return this.regexes.every((t=>t.test(e)))}hasNone(e){return this.regexes.every((t=>!t.test(e)))}}export{LazyImgLoader,Observer,OnHover,RegexFilter,Tick,checkHomogenity,chunks,circularShift,copyAttributes,downloader,exterminateVideo,fetchHtml,fetchJson,fetchText,fetchWith,findNextSibling,getCommonParents,instantiateTemplate,memoize,objectToFormData,parseCssUrl,parseDataParams,parseHtml,parseIntegerOr,propsDifference,querySelectorLast,querySelectorLastNumber,querySelectorText,range,removeClassesAndDataAttributes,replaceElementTag,sanitizeStr,splitWith,timeToSeconds,wait,waitForElementToAppear,waitForElementToDisappear,watchDomChangesWithThrottle,watchElementChildrenCount};
//# sourceMappingURL=/sm/fe5d883df686293ab2856c1ce544de4cd365e935c69e88ebea1a97ad40766ed1.map