@aegisjsproject/core
Version:
A fast, secure, modern, light-weight, and simple JS library for creating web components and more!
11 lines • 136 kB
JavaScript
let e=!0;const t=(e,t=document)=>t.querySelectorAll(e),r=(e,t=document)=>t.querySelector(e),n="requestFullscreenSelector",o="toggleFullscreenSelector",a={debug:{log:"aegis:debug:log",info:"aegis:debug:info",warn:"aegis:debug:warn",error:"aegis:debug:error"},navigate:{back:"aegis:navigate:back",forward:"aegis:navigate:forward",reload:"aegis:navigate:reload",close:"aegis:navigate:close",link:"aegis:navigate:go",popup:"aegis:navigate:popup"},ui:{command:"aegis:ui:command",print:"aegis:ui:print",remove:"aegis:ui:remove",hide:"aegis:ui:hide",unhide:"aegis:ui:unhide",showModal:"aegis:ui:showModal",closeModal:"aegis:ui:closeModal",showPopover:"aegis:ui:showPopover",hidePopover:"aegis:ui:hidePopover",togglePopover:"aegis:ui:togglePopover",enable:"aegis:ui:enable",disable:"aegis:ui:disable",scrollTo:"aegis:ui:scrollTo",prevent:"aegis:ui:prevent",revokeObjectURL:"aegis:ui:revokeObjectURL",cancelAnimationFrame:"aegis:ui:cancelAnimationFrame",clearInterval:"aegis:clearInterval",clearTimeout:"aegis:clearTimeout",requestFullscreen:"aegis:ui:requestFullscreen",toggleFullscreen:"aegis:ui:toggleFullsceen",exitFullsceen:"aegis:ui:exitFullscreen",open:"aegis:ui:open",close:"aegis:ui:close",abortController:"aegis:ui:controller:abort"}},i=new Map([[a.debug.log,console.log],[a.debug.warn,console.warn],[a.debug.error,console.error],[a.debug.info,console.info],[a.navigate.back,()=>history.back()],[a.navigate.forward,()=>history.forward()],[a.navigate.reload,()=>history.go(0)],[a.navigate.close,()=>globalThis.close()],[a.navigate.link,e=>{e.isTrusted&&(e.preventDefault(),location.href=e.currentTarget.dataset.url)}],[a.navigate.popup,e=>{e.isTrusted&&(e.preventDefault(),globalThis.open(e.currentTarget.dataset.url))}],[a.ui.hide,({currentTarget:e})=>{t(e.dataset.hideSelector).forEach((e=>e.hidden=!0))}],[a.ui.unhide,({currentTarget:e})=>{t(e.dataset.unhideSelector).forEach((e=>e.hidden=!1))}],[a.ui.disable,({currentTarget:e})=>{t(e.dataset.disableSelector).forEach((e=>e.disabled=!0))}],[a.ui.enable,({currentTarget:e})=>{t(e.dataset.enableSelector).forEach((e=>e.disabled=!1))}],[a.ui.remove,({currentTarget:e})=>{t(e.dataset.removeSelector).forEach((e=>e.remove()))}],[a.ui.scrollTo,({currentTarget:e})=>{const t=r(e.dataset.scrollToSelector);t instanceof Element&&t.scrollIntoView({behavior:matchMedia("(prefers-reduced-motion: reduce)").matches?"instant":"smooth"})}],[a.ui.revokeObjectURL,({currentTarget:e})=>URL.revokeObjectURL(e.src)],[a.ui.cancelAnimationFrame,({currentTarget:e})=>cancelAnimationFrame(parseInt(e.dataset.animationFrame))],[a.ui.clearInterval,({currentTarget:e})=>clearInterval(parseInt(e.dataset.clearInterval))],[a.ui.clearTimeout,({currentTarget:e})=>clearTimeout(parseInt(e.dataset.timeout))],[a.ui.abortController,({currentTarget:e})=>function(e,t){const r=Ht(e);return r instanceof AbortController&&("string"==typeof t?(r.abort(new Error(t)),!0):(r.abort(t),!0))}(e.dataset.aegisEventController,e.dataset.aegisControllerReason)],[a.ui.open,({currentTarget:e})=>document.querySelector(e.dataset.openSelector).open=!0],[a.ui.close,({currentTarget:e})=>document.querySelector(e.dataset.closeSelector).open=!1],[a.ui.showModal,({currentTarget:e})=>{const t=r(e.dataset.showModalSelector);t instanceof HTMLDialogElement&&t.showModal()}],[a.ui.closeModal,({currentTarget:e})=>{const t=r(e.dataset.closeModalSelector);t instanceof HTMLDialogElement&&t.close()}],[a.ui.showPopover,({currentTarget:e})=>{const t=r(e.dataset.showPopoverSelector);t instanceof HTMLElement&&t.showPopover()}],[a.ui.hidePopover,({currentTarget:e})=>{const t=r(e.dataset.hidePopoverSelector);t instanceof HTMLElement&&t.hidePopover()}],[a.ui.togglePopover,({currentTarget:e})=>{const t=r(e.dataset.togglePopoverSelector);t instanceof HTMLElement&&t.togglePopover()}],[a.ui.print,()=>globalThis.print()],[a.ui.prevent,e=>e.preventDefault()],[a.ui.requestFullscreen,({currentTarget:e})=>{e.dataset.hasOwnProperty(n)?document.getElementById(e.dataset[n]).requestFullscreen():e.requestFullscreen()}],[a.ui.toggleFullscreen,({currentTarget:e})=>{const t=e.dataset.hasOwnProperty(o)?document.getElementById(e.dataset[o]):e;t.isSameNode(document.fullscreenElement)?document.exitFullscreen():t.requestFullscreen()}],[a.ui.exitFullsceen,()=>document.exitFullscreen()]]);class s extends String{[Symbol.dispose](){i.delete(this.toString())}}const c=()=>e=!1,l=()=>Object.freeze(Array.from(i.keys())),d=e=>i.has(e?.toString()),u=e=>i.get(e?.toString()),g=(e,{stack:t}={})=>p("aegis:callback:"+crypto.randomUUID(),e,{stack:t});function f(e,...t){if(i.has(e?.toString()))return i.get(e?.toString()).apply(this||globalThis,t);throw new Error(`No ${e} function registered.`)}function p(t,r,{stack:n}={}){if("string"==typeof t)return p(new s(t),r,{stack:n});if(t instanceof s){if("object"==typeof r&&"function"==typeof r.handleEvent)return p(t,r.handleEvent.bind(r),{stack:n});if("function"!=typeof r&&"function"!=typeof r?.handleEvent)throw new TypeError("Callback must be a function.");if(e){if(i.has(t?.toString()))throw new Error(`Handler "${t}" is already registered.`);if(n instanceof DisposableStack||n instanceof AsyncDisposableStack){const e=n.use(new s(t));return i.set(e.toString(),r),e}{const e=new s(t);return i.set(e.toString(),r),e}}throw new TypeError("Cannot register new callbacks because registry is closed.")}throw new TypeError("Callback name must be a disposable string/CallbackRegistryKey.")}function m(e){return e instanceof Event?m(e.currentTarget):e instanceof Document?e:e instanceof Element?m(e.getRootNode()):e instanceof ShadowRoot?e.host:null}globalThis.registry=i;const h=Symbol("signal:watcher:notify"),b=Symbol("signal:currentComputed"),y=Symbol("Signal:subtle:watched"),v=Symbol("Signal:subtle:unwatched"),w=Symbol("signal:initial"),S=Symbol("Signal:isWatched"),T=Symbol("Signal:onWatch"),k=Symbol("Signal:onUnwatch"),E=Symbol("Signal:sources"),L=Symbol("Signal:sinks"),A=Object.is,R=Object.freeze({equals:A});class M{#e;#t;[v]=null;[T]=null;[k]=null;[S]=!1;[L]=new Set;[E]=new Set;constructor(e,t=R){if("object"!=typeof t)throw new TypeError("Invalid options.");this.#t=t.equals??A,this.#e=e,"function"==typeof t?.[y]&&(this[T]=t[y].bind(this)),"function"==typeof t?.[v]&&(this[k]=t[v].bind(this))}get(){const e=x.subtle.currentComputed();return e instanceof $&&!e[E].has(this)&&(e[E].add(this),this[L].add(e)),this.#e}set(e){if(!this.#t(this.#e,e)){this.#e=e;for(const e of x.subtle.introspectSinks(this))e[h](this)}}}class ${#t;#r;#n=!0;#e=w;[y]=null;[v]=null;[T]=null;[k]=null;[S]=!1;[L]=new Set;[E]=new Set;constructor(e,t=R){if("function"!=typeof e)throw new TypeError("Computation must be a function.");if("object"!=typeof t)throw new TypeError("Invalid options.");this.#t=t.equals??A,this.#r=e,"function"==typeof t[y]&&(this[T]=t[y].bind(this)),"function"==typeof t[v]&&(this[k]=t[v].bind(this))}get(){const e=x.subtle.currentComputed();try{if(e!==this&&null!==e&&(e[E].add(this),this[L].add(e)),x[b]=this,this.#n){for(const e of x.subtle.introspectSources(this))e[L].delete(this);this[E].clear();const e=this.#r();if(!this.#t(e,this.#e)){this.#e=e;for(const e of x.subtle.introspectSinks(this))e[h](this)}return this.#n=!1,e}return this.#e}finally{x[b]=e}}[h](e){this.#n=!0,this[E].add(e),e[L].add(this);for(const e of x.subtle.introspectSinks(this))e[h](this)}}class U{#o=!1;#a=new Set;#i;[E]=new Set;constructor(e){if("function"!=typeof e)throw new TypeError(`Notify must be a function but got a ${typeof e}.`);this.#i=e}watch(...e){this.#o=!0;for(const t of e){if(!(t instanceof M||t instanceof $))throw new TypeError("Signal must be an instance of `Signal.State` or `Signal.Computed`.");this[E].has(t)||("function"!=typeof t[T]||t[S]||(t[S]=!0,t[T].call(t)),this[E].add(t),t[L].add(this))}}unwatch(...e){for(const t of e){if(!(t instanceof M||t instanceof $))throw new TypeError("Signal must be an instance of `Signal.State` or `Signal.Computed`.");if("function"==typeof t[k]&&t[S]){1===x.subtle.introspectSinks(t).filter((e=>e instanceof x.subtle.Watcher)).length&&(t[S]=!1,t[k].call(t))}t[L].delete(this),this[E].delete(t)}}getPending(){const e=Array.from(this.#a);return this.#a.clear(),e}[h](e){this.#a.add(e),this.#o&&this.#i.call(this)}}const x={State:M,Computed:$,subtle:{Watcher:U,watched:y,unwatched:v,untrack(e){if("function"!=typeof e)throw new TypeError("Callback must be a function.");{const t=x.subtle.currentComputed();x[b]=null;try{return e()}finally{x[b]=t}}},currentComputed:()=>x[b],introspectSources(e){if(e instanceof $||e instanceof U)return Array.from(e[E]);throw new TypeError("Expected a `Signal.Watcher` or `Signal.Computed`.")},introspectSinks(e){if(e instanceof M||e instanceof $)return Array.from(e[L]);throw new TypeError("Expected a `Signal.State` or `Signal.Computed`.")},hasSinks(e){if(e instanceof M||e instanceof $)return 0!==e[L].size;throw new TypeError("Expected a `Signal.State` or `Signal.Computed`.")},hasSources(e){if(e instanceof $||e instanceof U)return 0!==e[E].size;throw new TypeError("Expected a `Signal.Watcher` or `Signal.Computed`.")}},[b]:null},P="data-aegis-event-",C=P+"on-",O="aegisEventOn",F=12,N=Symbol("aegis:signal"),j=Symbol("aegis:controller"),D=new Map,z=new Map,H=P+"once",I=P+"passive",q=P+"capture",B=P+"signal",V=C+"abort",W=C+"blur",_=C+"focus",G=C+"cancel",X=C+"auxclick",K=C+"beforeinput",Q=C+"beforetoggle",Y=C+"canplay",J=C+"canplaythrough",Z=C+"change",ee=C+"click",te=C+"close",re=C+"command",ne=C+"contextmenu",oe=C+"copy",ae=C+"cuechange",ie=C+"cut",se=C+"dblclick",ce=C+"drag",le=C+"dragend",de=C+"dragenter",ue=C+"dragexit",ge=C+"dragleave",fe=C+"dragover",pe=C+"dragstart",me=C+"drop",he=C+"durationchange",be=C+"emptied",ye=C+"ended",ve=C+"formdata",we=C+"input",Se=C+"invalid",Te=C+"keydown",ke=C+"keypress",Ee=C+"keyup",Le=C+"load",Ae=C+"loadeddata",Re=C+"loadedmetadata",Me=C+"loadstart",$e=C+"mousedown",Ue=C+"mouseenter",xe=C+"mouseleave",Pe=C+"mousemove",Ce=C+"mouseout",Oe=C+"mouseover",Fe=C+"mouseup",Ne=C+"wheel",je=C+"paste",De=C+"pause",ze=C+"play",He=C+"playing",Ie=C+"progress",qe=C+"ratechange",Be=C+"reset",Ve=C+"resize",We=C+"scroll",_e=C+"scrollend",Ge=C+"securitypolicyviolation",Xe=C+"seeked",Ke=C+"seeking",Qe=C+"select",Ye=C+"slotchange",Je=C+"stalled",Ze=C+"submit",et=C+"suspend",tt=C+"timeupdate",rt=C+"volumechange",nt=C+"waiting",ot=C+"selectstart",at=C+"selectionchange",it=C+"toggle",st=C+"pointercancel",ct=C+"pointerdown",lt=C+"pointerup",dt=C+"pointermove",ut=C+"pointerout",gt=C+"pointerover",ft=C+"pointerenter",pt=C+"pointerleave",mt=C+"gotpointercapture",ht=C+"lostpointercapture",bt=C+"mozfullscreenchange",yt=C+"mozfullscreenerror",vt=C+"animationcancel",wt=C+"animationend",St=C+"animationiteration",Tt=C+"animationstart",kt=C+"transitioncancel",Et=C+"transitionend",Lt=C+"transitionrun",At=C+"transitionstart",Rt=C+"webkitanimationend",Mt=C+"webkitanimationiteration",$t=C+"webkitanimationstart",Ut=C+"webkittransitionend",xt=C+"error",Pt=new x.State([V,W,_,G,X,K,Q,Y,J,Z,ee,te,re,ne,oe,ae,ie,se,ce,le,de,ue,ge,fe,pe,me,he,be,ye,ve,we,Se,Te,ke,Ee,Le,Ae,Re,Me,$e,Ue,xe,Pe,Ce,Oe,Fe,Ne,je,De,ze,He,Ie,qe,Be,Ve,We,_e,Ge,Xe,Ke,Qe,Ye,Je,Ze,et,tt,rt,nt,ot,at,it,st,ct,lt,dt,ut,gt,ft,pt,mt,ht,bt,yt,vt,wt,St,Tt,kt,Et,Lt,At,Rt,Mt,$t,Ut,xt]),Ct=new x.Computed((()=>Pt.get().map((e=>`[${CSS.escape(e)}]`)).join(","))),Ot=([e])=>e.startsWith(O);function Ft(e,{signal:t,attrFilter:r=jt}={}){const n=e.dataset;for(const[o,a]of Object.entries(n).filter(Ot))try{const i="on"+o.substring(F);r.hasOwnProperty(i)&&d(a)&&e.addEventListener(i.substring(2).toLowerCase(),u(a),{passive:n.hasOwnProperty("aegisEventPassive"),capture:n.hasOwnProperty("aegisEventCapture"),once:n.hasOwnProperty("aegisEventOnce"),signal:n.hasOwnProperty("aegisEventSignal")?qt(n.aegisEventSignal):t})}catch(e){reportError(e)}}const Nt=new MutationObserver((e=>{e.forEach((e=>{switch(e.type){case"childList":[...e.addedNodes].filter((e=>e.nodeType===Node.ELEMENT_NODE)).forEach((e=>Bt(e)));break;case"attributes":"string"==typeof e.oldValue&&d(e.oldValue)&&e.target.removeEventListener(e.attributeName.substring(20),u(e.oldValue),{once:e.target.hasAttribute(H),capture:e.target.hasAttribute(q),passive:e.target.hasAttribute(I)}),e.target.hasAttribute(e.attributeName)&&d(e.target.getAttribute(e.attributeName))&&e.target.addEventListener(e.attributeName.substring(20),u(e.target.getAttribute(e.attributeName)),{once:e.target.hasAttribute(H),capture:e.target.hasAttribute(q),passive:e.target.hasAttribute(I),signal:e.target.hasAttribute(B)?qt(e.target.getAttribute(B)):void 0})}}))})),jt={onAbort:V,onBlur:W,onFocus:_,onCancel:G,onAuxclick:X,onBeforeinput:K,onBeforetoggle:Q,onCanplay:Y,onCanplaythrough:J,onChange:Z,onClick:ee,onClose:te,onCommand:re,onContextmenu:ne,onCopy:oe,onCuechange:ae,onCut:ie,onDblclick:se,onDrag:ce,onDragend:le,onDragenter:de,onDragexit:ue,onDragleave:ge,onDragover:fe,onDragstart:pe,onDrop:me,onDurationchange:he,onEmptied:be,onEnded:ye,onFormdata:ve,onInput:we,onInvalid:Se,onKeydown:Te,onKeypress:ke,onKeyup:Ee,onLoad:Le,onLoadeddata:Ae,onLoadedmetadata:Re,onLoadstart:Me,onMousedown:$e,onMouseenter:Ue,onMouseleave:xe,onMousemove:Pe,onMouseout:Ce,onMouseover:Oe,onMouseup:Fe,onWheel:Ne,onPaste:je,onPause:De,onPlay:ze,onPlaying:He,onProgress:Ie,onRatechange:qe,onReset:Be,onResize:Ve,onScroll:We,onScrollend:_e,onSecuritypolicyviolation:Ge,onSeeked:Xe,onSeeking:Ke,onSelect:Qe,onSlotchange:Ye,onStalled:Je,onSubmit:Ze,onSuspend:et,onTimeupdate:tt,onVolumechange:rt,onWaiting:nt,onSelectstart:ot,onSelectionchange:at,onToggle:it,onPointercancel:st,onPointerdown:ct,onPointerup:lt,onPointermove:dt,onPointerout:ut,onPointerover:gt,onPointerenter:ft,onPointerleave:pt,onGotpointercapture:mt,onLostpointercapture:ht,onMozfullscreenchange:bt,onMozfullscreenerror:yt,onAnimationcancel:vt,onAnimationend:wt,onAnimationiteration:St,onAnimationstart:Tt,onTransitioncancel:kt,onTransitionend:Et,onTransitionrun:Lt,onTransitionstart:At,onWebkitanimationend:Rt,onWebkitanimationiteration:Mt,onWebkitanimationstart:$t,onWebkittransitionend:Ut,onError:xt,once:H,passive:I,capture:q};function Dt(e,{addListeners:t=!1,base:r=document.body,signal:n}={}){const o=C+e.toLowerCase(),a=Pt.get();if(!a.includes(o)){const e=`[${CSS.escape(o)}]`,i=(e=>`on${e[20].toUpperCase()}${e.substring(21)}`)(o);Pt.set([...a,o]),jt[i]=o,t&&requestAnimationFrame((()=>{const t={attrFilter:{[i]:e},signal:n};[r,...r.querySelectorAll(e)].forEach((e=>Ft(e,t)))}))}return o}function zt(e){return e instanceof AbortController?z.delete(e.signal[j]):e instanceof AbortSignal?z.delete(e[j]):z.delete(e)}const Ht=e=>z.get(e);function It(e){if(e instanceof AbortSignal){if("string"==typeof e[N])return e[N];{const t="aegis:event:signal:"+crypto.randomUUID();return Object.defineProperty(e,N,{value:t,writable:!1,enumerable:!1}),D.set(t,e),e.addEventListener("abort",(({target:e})=>function(e){if(e instanceof AbortSignal)return D.delete(e[N]);if("string"==typeof e)return D.delete(e);throw new TypeError("Signal must be an `AbortSignal` or registered key/attribute.")}(e[N])),{once:!0}),t}}throw new TypeError("Signal must be an `AbortSignal`.")}const qt=e=>D.get(e);function Bt(e,{signal:t}={}){return(e instanceof Element&&e.matches(Ct.get())?[e,...e.querySelectorAll(Ct.get())]:e.querySelectorAll(Ct.get())).forEach((e=>Ft(e,{signal:t}))),e}function Vt(e=document){Bt(e),Nt.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0,attributeFilter:Pt.get()})}const Wt=()=>Nt.disconnect();function _t(e,{capture:t,once:r,passive:n,signal:o}={}){if(!(e instanceof Function))throw new TypeError("Callback is not a function.");globalThis.addEventListener("error",e,{capture:t,once:r,passive:n,signal:o})}const Gt=/[<>"']|&(?![a-zA-Z\d]{2,40};|#\d{1,6};)/g,Xt=/[\u0000-\u001f\u007f-\u009f\s"'\\/=><&]/g,Kt=Object.freeze({"&":"&",'"':""","'":"'","<":"<",">":">"}),Qt=(e,t="")=>e?.toString?.()??t,Yt=e=>Qt(e).replaceAll(Gt,(e=>Kt[e])),Jt=e=>(console.warn("`escapeAttrVal()` is deprecated. Please use `escape()` instead."),Yt(e));function Zt(e,t="",r){const n="string"==typeof r?document.createAttributeNS(r,e):document.createAttribute(e);return n.value=t,n}const er=e=>{return`${t=e?.name,Qt(t).replace(Xt,(e=>"_"+e.charCodeAt(0).toString(16).padStart(4,"0")+"_"))}="${Yt(e?.value)}"`;var t},tr=(e="_aegis-scope")=>`${e}-${crypto.randomUUID()}`;function rr(e,...t){if(!(e instanceof Node))throw new TypeError("Expected target to be a Document, DocumentFragment, ShadowRoot, or Element.");if(!(e instanceof Document||e instanceof ShadowRoot)){if(e instanceof Element||DocumentFragment){if(e.shadowRoot instanceof ShadowRoot)return rr(e.shadowRoot,...t);if(e.isConnected)return rr(e.getRootNode({composed:!1}),...t);throw new TypeError("Target is not connected to the document yet.")}throw new TypeError("Expected target to be a Document, DocumentFragment, ShadowRoot, or Element.")}e.adoptedStyleSheets=t}function nr(e,...t){if(!(e instanceof Node))throw new TypeError("Expected target to be a Document, DocumentFragment, ShadowRoot, or Element.");if(!(e instanceof Document||e instanceof ShadowRoot))return e.shadowRoot instanceof ShadowRoot?nr(e.shadowRoot,...t):nr(e.getRootNode({composed:!1}),...t);rr(e,...e.adoptedStyleSheets,...t)}function or(e,...t){if(!(e instanceof Node))throw new TypeError("Target must be a Node.");{const r=t.filter((e=>e instanceof CSSStyleSheet)),n=t.filter((e=>"string"==typeof e||e instanceof Node));0!==r.length&&nr(e,...r),0!==n.length&&e.append(...n),Bt(e instanceof ShadowRoot?e.host:e)}}function ar(e,...t){if(!(e instanceof Node))throw new TypeError("Target must be a Node.");{const r=t.filter((e=>e instanceof CSSStyleSheet)),n=t.filter((e=>"string"==typeof e||e instanceof Node));0!==r.length&&nr(e,...r),0!==n.length&&e.prepend(...n),Bt(e instanceof ShadowRoot?e.host:e)}}function ir(e,...t){if(!(e instanceof Node))throw new TypeError("Target must be a Node.");{const r=t.filter((e=>e instanceof CSSStyleSheet)),n=t.filter((e=>"string"==typeof e||e instanceof Node));0!==r.length&&rr(e,...r),0!==n.length&&e.replaceChildren(...n),Bt(e instanceof ShadowRoot?e.host:e)}}const sr=new WeakMap;function cr(e){if(e instanceof Blob){if(sr.has(e))return sr.get(e);{const t=URL.createObjectURL(e);return sr.set(e,t),t}}throw new TypeError("Expected a `Blob`")}function lr(e){if(sr.has(e)){const t=sr.get(e);return URL.revokeObjectURL(t),sr.delete(e),!0}return!1}const dr=e=>sr.get(e),ur=e=>sr.has(e),gr=([e,t])=>["data-"+e.replaceAll(/[A-Z]/g,(e=>`-${e.toLowerCase()}`)),t],fr=e=>Object.entries(e).map((([e,t])=>{switch(typeof t){case"string":return Zt(e,t);case"number":case"bigint":return Number.isNaN(t)?void 0:Zt(e,t.toString());case"boolean":return t?Zt(e):void 0;case"undefined":return;case"function":return g(t);case"object":return null===t?void 0:t instanceof URL?Zt(e,t.href):t instanceof Date?Zt(e,t.toISOString()):Zt(e,t.toString());case"symbol":return Zt(e,t.description);default:return Zt(e,t.toString())}})).filter((e=>e instanceof Attr)).map(er).join(" ");function pr(e){return fr(Object.fromEntries(Object.entries(e).map(gr)))}const mr={weekday:"short",month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"},hr=(e,{weekday:t=mr.weekday,month:r=mr.month,day:n=mr.day,year:o=mr.year,hour:a=mr.hour,minute:i=mr.minute}=mr)=>e.toLocaleString(navigator.language,{weekday:t,month:r,day:n,year:o,hour:a,minute:i}),br="Intl"in globalThis&&Intl.ListFormat instanceof Function?e=>(new Intl.ListFormat).format(e.map(vr)):e=>e.join(", "),yr="Intl"in globalThis&&Intl.NumberFormat instanceof Function?e=>(new Intl.NumberFormat).format(e):e=>e.toString(),vr=e=>{switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"symbol":return e.description;case"number":case"bigint":return yr(e);case"undefined":return"";case"function":return g(e);case"object":if(null===e)return"";if(Array.isArray(e))return br(e);if(e instanceof HTMLTemplateElement){const t=document.createElement("div");return t.append(e.content.cloneNode(!0)),t.innerHTML}if(e instanceof Element)return e.outerHTML;if(e instanceof DocumentFragment){const t=document.createElement("div");return t.append(e.cloneNode(!0)),t.innerHTML}if(e instanceof CSSStyleSheet){document.adoptedStyleSheets=[...document.adoptedStyleSheets,e];break}return e instanceof Blob?cr(e):e instanceof Date?hr(e):e instanceof DOMTokenList?[...e].join(" "):e instanceof NodeList||e instanceof HTMLCollection||e instanceof HTMLFormControlsCollection?[...e].map((e=>e.outerHTML)).join("\n"):e instanceof MediaList?e.mediaText:e instanceof Attr?er(e):e instanceof NamedNodeMap?Array.from(e,er).join(" "):"TrustedType"in globalThis&&e instanceof globalThis.TrustedType?e:"Iterator"in globalThis&&e instanceof globalThis.Iterator?vr([...e]):e instanceof AbortSignal?It(e):e instanceof AbortController?function(e){if(e instanceof AbortController){if(e.signal.aborted)throw e.signal.reason;if("string"==typeof e.signal[j])return e.signal[j];{const t="aegis:event:controller:"+crypto.randomUUID();return Object.defineProperty(e.signal,j,{value:t,writable:!1,enumerable:!1}),z.set(t,e),e.signal.addEventListener("abort",zt,{once:!0}),t}}throw new TypeError("Controller is not an `AbortSignal.")}(e):e.toString();default:return e.toString()}},wr=(e,...t)=>Array.isArray(e)&&Array.isArray(e.raw)?String.raw(e,...t.map(vr)):String.raw({raw:Array.isArray(e)?e:[e]},...t.map(vr)),Sr=e=>{switch(typeof e){case"undefined":return"";case"boolean":return e?"true":"false";case"object":return null===e?"":e instanceof CSSStyleSheet?[...e.cssRules].map((e=>e.cssText)).join("\n\n"):e instanceof CSSRule?e.cssText:e instanceof HTMLLinkElement?Sr(e.sheet):e instanceof ArrayBuffer&&Uint8Array.prototype.toBase64 instanceof Function?new Uint8Array(e).toBase64():ArrayBuffer.isView(e)&&e.toBase64 instanceof Function?e.toBase64():e instanceof Blob?URL.createObjectURL(e):e.toString();default:return e.toString()}};function Tr(e,{media:t,disabled:r,baseURL:n}={}){const o=new CSSStyleSheet({media:t instanceof MediaQueryList?t.media:t,disabled:r,baseURL:n});return o.replace(e).catch(reportError),o}const kr=({media:e,disabled:t,baseURL:r,sync:n=!1}={})=>n?(n,...o)=>function(e,{media:t,disabled:r,baseURL:n}={}){const o=new CSSStyleSheet({media:t instanceof MediaQueryList?t.media:t,disabled:r,baseURL:n});return o.replaceSync(e),o}(String.raw(n,...o.map(Sr)).trim(),{media:e,disabled:t,baseURL:r}):(n,...o)=>Tr(String.raw(n,...o.map(Sr)).trim(),{media:e,disabled:t,baseURL:r}),Er=kr();function Lr(e){switch(typeof e){case"string":case"number":case"bigint":return e;case"undefined":case"symbol":return"";case"object":return e instanceof Blob?`url(${cr(e)})`:e instanceof URL?`url(${e.href})`:null===e?"":e.toString();default:return e.toString()}}const Ar="_aegis_style_scope_";function Rr({baseURL:e,media:t,disabled:r,prefix:n=Ar}={}){const o=new CSSStyleSheet({baseURL:e,media:t instanceof MediaQueryList?t.media:t,disabled:r});return Object.freeze([o,(e,...t)=>{const r=crypto.randomUUID(),a=`${n}${r}`,i=`.${CSS.escape(n)+r} { ${String.raw(e,...t.map(Lr))} }`;return o.insertRule(i,o.cssRules.length),a}])}function Mr(e=document,{baseURL:t,media:r,disabled:n,prefix:o=Ar}={}){console.warn("`createStyleScope()` is deprecated. Please use `useScopedStyle()` instead.");const a=Rr({baseURL:t,media:r,disabled:n,prefix:o});return e.adoptedStyleSheets=[...document.adoptedStyleSheets,a[0]],a[1]}const $r=kr({media:"(prefers-color-scheme: light)",baseURL:document.baseURI}),Ur=kr({media:"(prefers-color-scheme: dark)",baseURL:document.baseURI});function xr(e,t){if(t instanceof CSSStyleSheet||t instanceof CSSConditionRule||t instanceof CSSMediaRule)xr(e,t.cssRules);else if(t instanceof CSSRuleList)for(const r of t)xr(e,r);else t instanceof CSSStyleRule&&(t.selectorText=`${e} ${t.selectorText}`)}function Pr({root:e=document,media:t,disabled:r=!1,baseURL:n=document.baseURI,prefix:o}={}){if(e instanceof HTMLElement)return Pr({root:e.getRootNode(),media:t,disabled:r,baseURL:n});if("string"==typeof o){const a=kr({media:t,disabled:r,baseURL:n});return(...t)=>e.adoptedStyleSheets=[...e.adoptedStyleSheets,xr(o,a.apply(null,t))]}{const o=kr({media:t,disabled:r,baseURL:n});return(...t)=>e.adoptedStyleSheets=[...e.adoptedStyleSheets,o.apply(null,t)]}}const Cr=Pr();function Or(e,t="styles.css"){if(e instanceof CSSStyleSheet){const r=Array.from(e.cssRules,(e=>e.cssText));return new File(r,t,{type:e.type})}throw new TypeError("Not a CSSStyleSheet.")}function Fr(e){const t=Or(e),r=document.createElement("link");return r.relList.add("stylesheet"),r.disabled=e.disabled,0!==e.media.length&&(r.media=e.media.mediaText),r.href=cr(t),r}
/**
* @copyright 2023-2024 Chris Zuber <admin@kernvalley.us>
*/const Nr="http://www.w3.org/1999/xhtml",jr="http://www.w3.org/1999/xlink",Dr="http://www.w3.org/1998/Math/MathML";function zr(e,t=Nr){if("string"==typeof e)return Object.freeze({name:e,namespace:t});if("object"==typeof e&&"string"==typeof e.name){const{name:r,namespace:n=t,attributes:o}=e;return Object.freeze({name:r,namespace:"string"==typeof n&&0!==n.length?n:t,attributes:o})}throw new TypeError("Invalid config entry for `elements`.")}function Hr(e,t){if("string"==typeof e)return Object.freeze({name:e,namespace:t});if("object"==typeof e&&"string"==typeof e.name){const{name:r,namespace:n=t,elements:o,...a}=e;return Object.freeze({name:r,namespace:"string"==typeof n?n:t,elements:o,...a})}throw new TypeError("Invalid entry in `attributes` config.")}new Set(("HTMLElement"in globalThis?Object.keys(HTMLElement.prototype):[]).filter((e=>e.startsWith("on"))));const Ir=Object.freeze(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","height","hidden","id","inert","inputmode","itemid","itemprop","itemref","itemscope","itemtype","lang","part","popover","slot","spellcheck","tabindex","title","translate","virtualkeyboardpolicy","width","aria-keyshortcuts","aria-activedescendant","aria-atomic","aria-autocomplete","aria-braillelabel","aria-brailleroledescription","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colindextext","aria-colspan","aria-controls","aria-current","aria-describedby","aria-description","aria-details","aria-disabled","aria-dropeffect","aria-errormessage","aria-expanded","aria-flowto","aria-grabbed","aria-haspopup","aria-hidden","aria-invalid","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowindextext","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext"].map((e=>Hr(e,null)))),qr=Object.freeze(["html","head","link","meta","body","address","article","aside","footer","header","h1","h2","h3","h4","h5","h6","hgroup","main","nav","section","search","blockquote","cite","div","dd","dt","dl","figcaption","figure","hr","li","ol","ul","menu","p","pre","a","abbr","b","bdi","bdo","br","code","data","dfn","em","i","kbd","mark","q","rp","ruby","rt","s","del","ins","samp","small","span","strong","sub","sup","time","u","var","wbr","area","audio","img","map","track","video","picture","source","canvas","caption","col","colgroup","table","tbody","tr","td","tfoot","th","thead","button","datalist","option","fieldset","label","form","input","legend","meter","optgroup","select","output","progress","textarea","details","summary","dialog","slot","dir","template","strike","selectmenu","center"].map((e=>zr(e,Nr)))),Br=Object.freeze(["abbr","accept","accept-charset","align","alink","allow","allowfullscreen","alt","anchor","archive","as","async","autocomplete","autocorrect","autopictureinpicture","autoplay","axis","background","behavior","border","bordercolor","capture","cellpadding","cellspacing","challenge","char","charoff","charset","checked","cite","classid","clear","code","codetype","color","cols","colspan","command","commandfor","compact","content","controls","controlslist","conversiondestination","coords","crossorigin","csp","data","datetime","declare","decoding","default","defer","direction","dirname","disabled","disablepictureinpicture","disableremoteplayback","disallowdocumentaccess","download","elementtiming","enctype","end","for","form","formenctype","formmethod","formnovalidate","formtarget","frameborder","headers","high","href","hreflang","hreftranslate","hspace","imagesizes","imagesrcset","importance","impressiondata","impressionexpiry","incremental","integrity","invisible","is","ismap","keytype","kind","label","language","latencyhint","leftmargin","link","list","loading","longdesc","loop","low","lowsrc","manifest","marginheight","marginwidth","max","maxlength","mayscript","media","method","min","minlength","multiple","muted","name","nohref","nomodule","noresize","noshade","novalidate","nowrap","object","open","optimum","pattern","ping","placeholder","playsinline","policy","popovertarget","popovertargetaction","poster","preload","pseudo","readonly","referrerpolicy","rel","reportingorigin","required","resources","rev","reversed","role","rows","rowspan","rules","sandbox","scheme","scope","scopes","scrollamount","scrolldelay","scrolling","select","selected","shadowrootclonable","shadowrootdelegatesfocus","shadowrootmode","shadowrootserializable","shape","size","sizes","span","src","srcdoc","srclang","srcset","standby","start","step","summary","target","text","topmargin","truespeed","trusttoken","type","usemap","valign","value","valuetype","version","vlink","vspace","webkitdirectory","wrap"].map((e=>Hr(e,null))));
/**
* @copyright 2023-2025 Chris Zuber <admin@kernvalley.us>
* @see https://wicg.github.io/sanitizer-api/#built-in-safe-default-configuration
*/Object.freeze(Br.concat(Ir));const Vr=Object.freeze(["a","animate","animateMotion","animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","foreignObject","g","line","linearGradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tspan","view","missing-glyph","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","hkern","vkern","glyph","glyphRef","tref","cursor"].map((e=>zr(e,"http://www.w3.org/2000/svg")))),Wr=Object.freeze(["accent-height","accumulate","additive","alignment-baseline","alphabetic","amplitude","arabic-form","ascent","attributeName","attributeType","azimuth","baseFrequency","baseline-shift","baseProfile","bbox","begin","bias","by","calcMode","cap-height","clip","clipPathUnits","clip-path","clip-rule","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cursor","cx","cy","d","decelerate","descent","diffuseConstant","display","divisor","dominant-baseline","dur","dx","dy","edgeMode","elevation","enable-background","exponent","fill","fill-opacity","fill-rule","filter","filterUnits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","format","from","fr","fx","fy","g1","g2","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","glyphRef","gradientTransform","gradientUnits","hanging","horiz-adv-x","horiz-origin-x","ideographic","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letter-spacing","lighting-color","limitingConeAngle","local","marker-end","marker-mid","marker-start","markerHeight","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overline-position","overline-thickness","panose-1","paint-order","path","pathLength","patternContentUnits","patternTransform","patternUnits","pointer-events","points","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","rendering-intent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","scale","seed","shape-rendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","string","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","surfaceScale","systemLanguage","tableValues","targetX","targetY","text-anchor","text-decoration","text-rendering","textLength","to","transform","transform-origin","u1","u2","underline-position","underline-thickness","unicode","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","values","vector-effect","vert-adv-y","vert-origin-x","vert-origin-y","viewBox","visibility","widths","word-spacing","writing-mode","x","x-height","x1","x2","xChannelSelector","y","y1","y2","yChannelSelector","z","zoomAndPan","autoReverse","accelerate","xmlns",{name:"actuate",namespace:jr},{name:"arcrole",namespaec:jr},{name:"href",namespace:jr},{name:"role",namespace:jr},{name:"show",namespace:jr},{name:"title",namespace:jr},{name:"type",namespace:jr},{name:"space",namespace:"http://www.w3.org/XML/1998/namespace"}].map((e=>"string"==typeof e?Hr(e):e))),_r=Object.freeze(Wr.concat(Ir)),Gr=Object.freeze([...qr,...Vr]),Xr=Object.freeze([...Ir,...Br,...Wr]),Kr=new Set;function Qr(e,t,r){if(Kr.has(e))throw new Error(`<${e}> is already registered.`);return customElements.define(e,t,r),Kr.add(e),t}function Yr(){return Object.freeze(Array.from(Kr))}function Jr(){return Object.freeze(Array.from(Kr,(e=>customElements.get(e))))}const Zr=e=>Array.from(e[Symbol.iterator](),(e=>e.nodeType===Node.ELEMENT_NODE?e.outerHTML:e.textContent)).join("");function en(e){switch(typeof e){case"string":return e;case"function":throw new TypeError("Functions are not supported.");case"undefined":return"";case"object":return null===e?"":e instanceof DocumentFragment||e instanceof Document?Zr(e.childNodes):e instanceof NodeList||e instanceof HTMLCollection?Zr(e):e instanceof Element?e.outerHTML:e instanceof Date?e.toISOString():Array.isArray(e)?e.map(en).join(""):e instanceof ArrayBuffer&&Uint8Array.prototype.toBase64 instanceof Function?new Uint8Array(e).toBase64():ArrayBuffer.isView(e)&&e.toBase64 instanceof Function?e.toBase64():e instanceof Blob?URL.createObjectURL(e):e.toString();default:return e.toString()}}const tn={elements:Gr,attributes:Xr,dataAttributes:!0,comments:!0},rn=(e,t,r=en)=>String.raw(e,...t.map(r)).trim();function nn(e=tn,{mapper:t=en}={}){return(r,...n)=>{const o=document.createElement("template");return o.setHTML(rn(r,n,t),{sanitizer:e}),o.content}}function on(e,...t){return Document.parseHTML(rn(e,t),{sanitizer:tn})}
/**
* @copyright 2023-2024 Chris Zuber <admin@kernvalley.us>
*/function an(e,t,r,{policy:n}={}){switch(gn(e.tagName,t)){case"TrustedScript":e[t]=yn(r,{policy:n});break;case"TrustedScriptURL":e[t]=vn(r,{policy:n});break;case"TrustedHTML":e[t]=bn(r,{policy:n});break;default:e[t]=r}}function sn(e,t,r,{elementNs:n,policy:o}={}){switch(un(e.tagName,t,n)){case"TrustedScriptURL":"string"==typeof n?e.setAttributeNs(n,t,vn(r,{policy:o})):e.setAttribute(t,vn(r,{policy:o}));break;case"TrustedScript":"string"==typeof n?e.setAttributeNS(n,t,yn(r,{policy:o})):e.setAttribute(t,yn(r,{policy:o}));break;case"TrustedHTML":"string"==typeof n?e.setAttributeNS(n,t,bn(r,{policy:o})):e.setAttribute(t,bn(r,{policy:o}));break;default:"string"==typeof n?e.setAttributeNS(n,t,r):e.setAttribute(t,r)}}function cn(){return"trustedTypes"in globalThis&&trustedTypes.createPolicy instanceof Function}function ln(e){return"TrustedTypePolicy"in globalThis&&e instanceof TrustedTypePolicy||null!=e&&e.createHTML instanceof Function}function dn(){return cn()&&ln(trustedTypes.defaultPolicy)}function un(e,t,r){return cn()?trustedTypes.getAttributeType(e.toLowerCase(),t,r):null}function gn(e,t){return cn()?trustedTypes.getPropertyType(e.toLowerCase(),t):null}function fn(e){return cn()?trustedTypes.isHTML(e):"string"==typeof e}function pn(e){return cn()?trustedTypes.isScript(e):"string"==typeof e}function mn(e){return cn()?trustedTypes.isScriptURL(e):"string"==typeof e||e instanceof URL}function hn(e){return!cn()||(trustedTypes.isHTML(e)||trustedTypes.isScript(e)||trustedTypes.isScriptURL(e))}function bn(e,{policy:t=Tn()}={}){return ln(t)&&!fn(e)?t.createHTML(e):e}function yn(e,{policy:t=Tn()}={}){return ln(t)&&!pn(e)?t.createScript(e):e}function vn(e,{policy:t=Tn()}={}){return ln(t)&&!mn(e)?t.createScriptURL(e):e}function wn(e,{createHTML:t=(()=>{throw new TypeError("This policy does not provide `createHTML()`")}),createScript:r=(()=>{throw new TypeError("This policy does not provide `createScript()`")}),createScriptURL:n=(()=>{throw new TypeError("This policy does not provide `createScriptURL()`")})}){return cn()?trustedTypes.createPolicy(e,{createHTML:t,createScript:r,createScriptURL:n}):Object.freeze({name:e,createHTML:(e,...r)=>t(e.toString(),...r),createScript:(e,...t)=>r(e.toString(),...t),createScriptURL:(e,...t)=>n(e.toString(),...t)})}function Sn(e="aegis#html"){return wn(e,{createHTML:(e,t)=>Document.parseHTML(e,t).body.innerHTML})}function Tn(){return"trustedTypes"in globalThis?trustedTypes.defaultPolicy:null}const kn=Object.freeze({comments:!0,dataAttributes:!0,get elements(){return[...Gr,...Yr()]},get attributes(){return["theme",...Xr]}}),En=nn(kn,{mapper:vr}),Ln=(...e)=>En.apply(null,e)?.firstElementChild;function An({tagName:e="div",mode:t="open",clonable:r=!0,serializable:n=!0,delegatesFocus:o=!1,slotAssignment:a="named",sanitizer:i=kn,exportParts:s,callback:c=(({shadowRoot:e})=>Vt(e))}={}){const l=nn(i,{mapper:vr});return Array.isArray(s)?s=s.join(", "):"object"==typeof s&&(s=Object.entries(s).map((([e,t])=>`${e}: ${t}`)).join(", ")),(...i)=>{const d=document.createElement(e),u=d.attachShadow({mode:t,clonable:r,serializable:n,delegatesFocus:o,slotAssignment:a}),g=l.apply(l,i);return u.adoptedStyleSheets=Array.from(g.querySelectorAll("style"),(e=>{const t=new CSSStyleSheet({media:e.media,disabled:e.hasAttribute("disabled"),baseURL:e.dataset.baseUrl});return t.replaceSync(e.textContent),e.remove(),t})),u.append(g),"string"==typeof s&&d.setAttribute("exportparts",s),c instanceof Function&&c.call(d,{shadowRoot:u,host:d}),d}}const Rn=An(),Mn=An({mode:"closed",clonable:!1,sanitizer:{elements:[...kn.elements,"style"]}});function $n(e){if(ln(e))return(t,...r)=>e.createHTML(String.raw(t,...r.map(vr)));throw new TypeError("Not a Trusted Types Policy.")}function Un(e,...t){if(ln(trustedTypes?.defaultPolicy))return trustedTypes.defaultPolicy.createHTML(String.raw(e,...t.map(vr)));throw"trustedTypes"in globalThis?new TypeError("No default Trusted Types Policy is available."):new Error("Trusted Types is not supported.")}function xn(e,...t){const r=String.raw(e,...t.map(vr)),n=document.createDocumentFragment(),o=document.createElement("div");return o.setHTMLUnsafe(r),n.append(...o.childNodes),n}function Pn(e,...t){const r=String.raw(e,...t.map(vr));return Document.parseHTMLUnsafe(r)}function Cn(e,t="document.html",{elements:r=kn.elements,attributes:n=kn.attributes,comments:o=kn.comments,...a}=kn){const i=Document.parseHTML(e,{elements:r,attributes:n,comments:o,...a});return new File([`<!DOCTYPE ${i.doctype instanceof Node?i.doctype.name:"html"}>`,i.documentElement.outerHTML],t,{type:i.contentType})}const On=(...e)=>(new DOMParser).parseFromString(String.raw.apply(null,e).trim(),"application/xml");function Fn(...e){return Document.parseHTML(String.raw.apply(null,e).trim(),{sanitizer:{elements:["html","head","body",...Vr],attributes:_r,comments:!0,dataAttributes:!0}}).body.firstElementChild}const Nn=(...e)=>JSON.parse(String.raw.apply(null,e).trim()),jn=Object.freeze(["math","maction","annotation","annotation-xml","menclose","merror","mfenced","mfrac","mi","mmultiscripts","mn","mo","mover","mpadded","mphantom","mprescripts","mroot","mrow","ms","semantics","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"].map((e=>zr(e,Dr)))),Dn=Object.freeze(["accent","accentunder","actiontype","align","background","close","color","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","fence","fontfamily","fontsize","fontstyle","fontweight","frame","framespacing","height","href","id","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","superscriptshift","symmetric","voffset","width","xmlns"].map((e=>Hr(e,Dr)))),zn=Object.freeze(Dn.concat(Ir));function Hn(...e){return Document.parseHTML(String.raw.apply(null,e).trim(),{sanitizer:{elements:["html","head","body",...jn],attributes:zn}}).body.firstElementChild}function In(e){switch(typeof e){case"string":return e;case"function":throw new TypeError("Functions are not supported.");case"undefined":return"";case"object":return null===e?"":e instanceof Date?e.toISOString():Array.isArray(e)?e.map(In).join(","):e instanceof ArrayBuffer&&Uint8Array.prototype.toBase64 instanceof Function?new Uint8Array(e).toBase64():ArrayBuffer.isView(e)&&e.toBase64 instanceof Function?e.toBase64():e instanceof Blob?URL.createObjectURL(e):e.toString();default:return e.toString()}}function qn(e){return encodeURIComponent(In(e).trim()).replaceAll("..%2F","%2E%2E%2F").replaceAll(".%2F","%2E%2E%2F")}const Bn=function(e=globalThis?.document?.baseURI){return function(t,r,...n){return r instanceof Blob&&2===t.length&&""===t[0]&&""===t[1]?new URL(URL.createObjectURL(r)):URL.canParse(r)?URL.parse(String.raw(t,"",...n.map(qn)),r):t[0].startsWith("/")||t[0].startsWith("./")||t[0].startsWith("../")?URL.parse(String.raw(t,qn(r),...n.map(qn)),e):URL.parse(String.raw(t,qn(r),...n.map(qn)))}}();function Vn(e,t=!0){if(e.shadowRoot instanceof ShadowRoot&&e.shadowRoot.clonable){const r=e.cloneNode(t);return r.shadowRoot.adoptedStyleSheets=e.shadowRoot.adoptedStyleSheets,r}return e.cloneNode(t)}function Wn({tag:e="div",template:t="<slot></slot>",styles:r,mode:n="open",delegatesFocus:o=!1,clonable:a=!0,slotAssignment:i="named",exportParts:s,sanitizer:{elements:c,attributes:l,comments:d=!1,dataAttributes:u=!0,...g}={},...f}){const p=document.createElement(e),m=p.attachShadow({mode:n,clonable:a,delegatesFocus:o,slotAssignment:i});if("string"==typeof t&&0!==t.length)m.setHTML(t,{elements:c,attributes:l,comments:d,dataAttributes:u,...g});else{if(!(t instanceof Node))throw new TypeError("Missing or invalid template.");t instanceof HTMLTemplateElement?m.append(t.content.cloneNode(!0)):t instanceof DocumentFragment?m.append(t.cloneNode(!0)):m.append(t)}return Array.isArray(r)?Promise.all(r.map((e=>"string"==typeof e?(new CSSStyleSheet).replace(e):e))).then((e=>m.adoptedStyleSheets=e)):"string"==typeof r&&0!==r.length&&(new CSSStyleSheet).replace(r).then((e=>m.adoptedStyleSheets=[e])),"string"==typeof s?p.setAttribute("exportparts",s):Array.isArray(s)?p.setAttribute("exportparts",s.join(", ")):"object"==typeof s&&null!==s&&p.setAttribute("exportparts",Object.entries(s).map((([e,t])=>`${e}:${t}`)).join(", ")),Object.entries(f).forEach((([e,t])=>p.setAttribute(e,t))),p}const _n=new Map,Gn=new BroadcastChannel("aegis:state_sync"),Xn=crypto.randomUUID(),Kn=Symbol("proxy"),Qn=Symbol("aegis:state:update");let Yn=!0;const Jn=new EventTarget,Zn="aegisStateKey",eo="aegisStateAttr",to="aegisStateStyle",ro="aegisStateProperty",no="data-aegis-state-key",oo="data-aegis-state-attr",ao="data-aegis-state-property",io="data-aegis-state-style",so="change",co="beforechange",lo=(e,t=null)=>history.state?.[e]??t;function uo(e,t=document.documentElement){const r=t.querySelectorAll(e);return t.matches instanceof Function&&t.matches(e)?[t,...r]:Array.from(r)}async function go({state:e=history.state??{}}={}){const t=this.dataset.aegisStateKey,r=e?.[t];if(await(scheduler?.yield()),"string"==typeof this.dataset[eo]){const e=this.dataset[eo],t=this.getAttribute(e);"string"==typeof t&&t.startsWith("blob:")&&URL.revokeObjectURL(t),"boolean"==typeof r?this.toggleAttribute(e,r):null==r?this.removeAttribute(e):r instanceof Blob?this.setAttribute(e,URL.createObjectURL(r)):this.setAttribute(e,r)}else"string"==typeof this.dataset[ro]&&"innerHTML"!==this.dataset[ro]?this[this.dataset[ro]]=r:"string"==typeof this.dataset[to]?null==r||!1===r?this.style.removeProperty(this.dataset[to]):this.style.setProperty(this.dataset[to],r):this instanceof HTMLInputElement||this instanceof HTMLSelectElement||this instanceof HTMLTextAreaElement?this.value=r:this.textContent=r}const fo=new MutationObserver((e=>{e.forEach((e=>{switch(e.type){case"childList":e.addedNodes.forEach((e=>{e.nodeType===Node.ELEMENT_NODE&&uo(`[${no}]`,e.target).forEach((e=>{e[Qn]=go.bind(e),vo(e[Qn],e.dataset[Zn])}))})),e.removedNodes.forEach((e=>{e.nodeType===Node.ELEMENT_NODE&&uo(`[${no}]`,e.target).forEach((e=>{So(e[Qn]),delete e[Qn]}))}));break;case"attributes":"string"==typeof e.oldValue?(So(e.target[Qn]),delete e.target[Qn]):"string"==typeof e.target.dataset[Zn]&&(e.target[Qn]=go.bind(e.target),vo(e.target[Qn],e.target.dataset[Zn]))}}))}));function po(e,t,r={}){return{sender:Xn,type:e,state:To(),msgId:crypto.randomUUID(),recipient:t,location:location.href,timestamp:Date.now(),...r}}function mo(e=To(),t=location.href){const r=bo(e);return 0!==r.length&&(history.replaceState(e,"",t),yo(r),!0)}function ho(){Yn&&(Gn.close(),Yn=!1)}function bo(e,t=To()){if(t!==e){const r=Object.keys(t),n=Object.keys(e),o=n.filter((e=>!r.includes(e))),a=r.filter((e=>!n.includes(e))),i=r.filter((r=>r in e&&r in t&&e[r]!==t[r]));return Object.freeze([...o,...i,...a])}return[]}async function yo(e){if(Array.isArray(e)&&0!==e.length){const t=To(),r=Object.fromEntries(e.map((e=>[e,t[e]])));await Promise.allSettled(Array.from(_n.entries(),(([t,n])=>{(0===n.length||n.some((t=>e.includes(t))))&&t({diff:e,state:r})})))}}function vo(e,...t){return e instanceof Function&&!_n.has(e)&&(_n.set(e,t),!0)}function wo(e,t=null){return new Proxy({toString:()=>lo(e,t)?.toString()??"",valueOf(){const r=lo(e,t);return r?.valueOf instanceof Function?r.valueOf():r},toJSON:()=>lo(e,t),[Symbol.toPrimitive](r){const n=lo(e,t);return typeof n===r||"default"===r&&"object"!=typeof n?n:n?.[Symbol.toPrimitive]instanceof Function?n?.[Symbol.toPrimitive]instanceof Function?n[Symbol.toPrimitive](r):n:"number"!==r&&n?.toString instanceof Function?n.toString():"number"===r?parseFloat(n):n},[Kn]:!0,[Symbol.toStringTag]:"StateValue",[Symbol.iterator]:()=>lo(e,t)?.[Symbol.iterator]()},{defineProperty(r,n,o){const a=lo(e,t);return!!Reflect.defineProperty(a,n,o)&&(Eo(e,a),a)},deleteProperty:(r,n)=>Reflect.deleteProperty(lo(e,t),n),get(r,n){const o=lo(e,t);if(n in r)return r[n];if("object"==typeof o){const e=Reflect.get(o,n,o);return e instanceof Function?e.bind(o):e}return o[n]},getOwnPropertyDescriptor:(r,n)=>Reflect.getOwnPropertyDescriptor(lo(e,t),n),getPrototypeOf(){const r=lo(e,t);return"object"==typeof r?Reflect.getPrototypeOf(r):Object.getPrototypeOf(r)},has:(r,n)=>Reflect.has(lo(e,t),n),isExtensible:()=>Reflect.isExtensible(lo(e,t)),ownKeys:()=>Reflect.ownKeys(lo(e,t)),preventExtensions:()=>Reflect.preventExtensions(lo(e,t)),set(r,n,o){const a=lo(e,t);return!!Reflect.set(a,n,o,a)&&(Eo(e,a),!0)}})}const So=e=>_n.delete(e),To=()=>Object.freeze(null===history.state?{}:structuredClone(history.state)),ko=e=>e in To();function Eo(e,t){const r=To();if("string"!=typeof e||0===e.length)throw new TypeError("Invalid key.");if("function"==typeof t)Lo(e,t);else if(r[e]!==t){const n={key:e,oldValue:r[e],newValue:t},o=new CustomEvent(co,{cancelable:!0,detail:n});Jn.dispatchEvent(o),o.defaultPrevented||(xo({...To(),[e]:t?.[Kn]?t.valueOf():t},location.href),Jn.dispatchEvent(new CustomEvent(so,{detail:n})))}}const Lo=async(e,t)=>await Promise.try((()=>t(lo(e),e))).then((t=>(Eo(e,t),t)));function Ao(e,t=null){return[wo(e,t),t=>Eo(e,t)]}function Ro(e){const t={...To()};delete t[e],xo(t,location.href)}const Mo=(e="aegis:state")=>localStorage.setItem(e,JSON.stringify(To())),$o=(e="aegis:state")=>mo(JSON.parse(localStorage.getItem(e)),location.href),Uo=()=>xo({},location.href);function xo(e=To(),t=location.href){mo(e,t)&&Yn&&Gn.postMessage(po("update"))}function Po({signal:e}={}){Gn.addEventListener("message",(e=>{if(e.isTrusted&&"string"==typeof e.data.msgId&&"string"==typeof e.data.sender&&e.data.sender!==Xn&&"object"==typeof e.data.state&&("string"!=typeof e.data.recipient||e.data.recipient===Xn)){const t=To();if(0!==bo(e.data.state,t).length)switch(e.data.type){case"update":mo({...t,...e.data.state},location.href);break;case"sync":Yn&&Gn.postMessage(po("update",e.data.sender));break;case"clear":mo({},location.href);break;default:reportError(new Error(`Unhandled broadcast channel message type: ${e.data.type}`))}}}),{signal:e}),Gn.postMessage(po("sync")),e instanceof AbortSignal&&e.aborted?ho():e instanceof AbortSignal&&e.addEventListener("abort",ho,{once:!0})}function Co(e=document.documentElement,{signal:t,base:r=document.documentElement}={}){if(t instanceof AbortSignal&&t.aborted)throw t.reason;if("string"==typeof e)Co(r.querySelector(e),{signal:t});else{if(!(e instanceof Element||e instanceof ShadowRoot))throw new TypeError("Target