xel
Version:
Xel - Widget Toolkit
1 lines • 484 kB
JavaScript
let t=(t,e=null)=>{let i=t.split(":"),s=null;if(1===i.length){let[t]=i;s=null===e?document.createElement(t):document.createElement(t,e)}else if(2===i.length){let[t,e]=i;"svg"===t&&(s=document.createElementNS("http://www.w3.org/2000/svg",e))}return s},e=(t,e,i=!0)=>{let s=document.elementFromPoint(t,e);if(i&&s)for(;;){let i=s.shadowRoot||s._shadowRoot;if(!i)break;{let n=i.elementFromPoint(t,e);if(n.getRootNode()!==i&&(n=null),!n||n===s)break;s=n}}return s},i=(t,e)=>{let i=e.getBoundingClientRect();return t.clientX>=i.x&&t.clientX<=i.x+i.width&&t.clientY>=i.y&&t.clientY<=i.y+i.height},s=(t,e,i=!0)=>{let n=t.closest(e);return i&&!n&&t.getRootNode().host?s(t.getRootNode().host,e):n},n=t=>{let e=t=>t&&t!==document.body?(t=>{let e=getComputedStyle(t,null);return/(auto|scroll)/.test(e.getPropertyValue("overflow")+e.getPropertyValue("overflow-y")+e.getPropertyValue("overflow-x"))})(t)&&"x-texteditor"!==t.localName?t:e(t.parentElement||t.parentNode.host):document.body;return e(t.parentElement||t.parentNode.host)},a=t=>{let e=null,i=[],s=t;for(;s&&""!==s.href.baseVal;){null===e&&(e=t.ownerSVGElement);let n=e.querySelector(s.href.baseVal);if(!n||"linearGradient"!==n.localName&&"radialGradient"!==n.localName||n===t||!1!==i.includes(n))break;i.push(n),s=n}return i};const o=/\b(iPad|iPhone)\b/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,r=navigator.userAgent.indexOf("Safari/")>-1&&-1===navigator.userAgent.indexOf("Chrome")&&0===navigator.maxTouchPoints;if(!1===Object.hasOwn(MouseEvent.prototype,"pointerType")&&Object.defineProperty(MouseEvent.prototype,"pointerType",{get(){return this.sourceCapabilities?this.sourceCapabilities.firesTouchEvents?"touch":"mouse":/\b(iPad|iPhone)\b/.test(navigator.userAgent)?"touch":"mouse"}}),Element.prototype.setPointerCapture){let t,e=Element.prototype.setPointerCapture;Element.prototype.setPointerCapture=function(i){if(e.call(this,i),!1!==this.hasPointerCapture(i)){{let t,e,s,n=!1,a=!1,o=()=>{this.removeEventListener("pointerup",t),this.removeEventListener("pointercancel",e),this.removeEventListener("lostpointercapture",s)};this.addEventListener("pointerup",t=t=>{t.pointerId===i&&(n=!0,o())}),this.addEventListener("pointercancel",e=t=>{t.pointerId===i&&(a=!0,o())}),this.addEventListener("lostpointercapture",s=t=>{if(t.pointerId===i&&(o(),!1===n&&!1===a)){let e=new PointerEvent("pointercancel",{pointerId:i,isPrimary:t.isPrimary});this.dispatchEvent(e)}})}r&&(async()=>{if(t=t||(await Promise.resolve().then(function(){return lo})).default,this.hasPointerCapture(i)){"*, *, *"!==t.themeStyleSheet.cssRules[0].selectorText&&t.themeStyleSheet.insertRule("*, *, * {}",0);let e,s=t.themeStyleSheet.cssRules[0];setTimeout(()=>{if(this.hasPointerCapture(i)){let t=getComputedStyle(this).cursor;"default"!==t&&s.style.setProperty("cursor",t,"important")}},80),this.addEventListener("lostpointercapture",e=s=>{s.pointerId===i&&(this.removeEventListener("lostpointercapture",e),"*, *, *"===t.themeStyleSheet.cssRules[0].selectorText&&t.themeStyleSheet.deleteRule(0))})}})()}}}if(o){const t=500,i=10;let s=null,n=0,a={capture:!0,passive:!0},o=null,r=()=>{o&&(clearTimeout(o),o=null)};class l extends Event{static eventName="contextmenu";clientX=0;clientY=0;screenX=0;screenY=0;button=2;buttons=2;view=window;constructor(t,e){super(l.eventName,{bubbles:!0,composed:!0,cancelable:!0}),this.clientX=t,this.clientY=e,this.screenX=t,this.screenY=e}}document.addEventListener("pointerdown",i=>{if(r(),i.isPrimary&&["pen","touch"].includes(i.pointerType)){let a=e(i.clientX,i.clientY);s=i,o=setTimeout(()=>{r();let t=new l(i.clientX,i.clientY);a.dispatchEvent(t),n=Date.now();let e=new PointerEvent("pointercancel",{pointerId:i.pointerId,isPrimary:i.isPrimary,bubbles:!0,composed:!0});a.dispatchEvent(e);for(let t=a;t;t=t.parentElement||t.parentNode?.host)t?.hasPointerCapture(i.pointerId)&&t.releasePointerCapture(i.pointerId)},t)}},a),document.addEventListener("pointermove",t=>{if(o){let e=t.clientX-s.clientX,n=t.clientY-s.clientY;Math.sqrt(e*e+n*n)>i&&r()}},a),document.addEventListener("pointerup",()=>{r()},a),document.addEventListener("pointercancel",()=>{r()},a),document.addEventListener("contextmenu",t=>{t instanceof l==!1&&Date.now()-n<500&&(t.preventDefault(),t.stopImmediatePropagation())},a)}Object.defineProperty(Animation.prototype,"finished",{get(){return new Promise(t=>{"finished"===this.playState?t():this.addEventListener("finish",()=>t(),{once:!0})})}}),window.requestIdleCallback||(window.requestIdleCallback=(t,e={})=>{let i=e.timeout||1,s=performance.now();return setTimeout(()=>{t({get didTimeout(){return!e.timeout&&performance.now()-s-1>i},timeRemaining:()=>Math.max(0,performance.now()-s+1)})},1)}),Element.prototype.scrollIntoViewIfNeeded||(Element.prototype.scrollIntoViewIfNeeded=function(t=!0){let e=this;new IntersectionObserver(function([i]){let s=i.intersectionRatio;if(s<1){let i=s<=0&&t?"center":"nearest";e.scrollIntoView({block:i,inline:i})}this.disconnect()}).observe(this)}),Node.prototype.append||(Node.prototype.append=function(t){this.appendChild(t)}),Node.prototype.prepend||(Node.prototype.prepend=function(t){this.insertBefore(t,this.firstElementChild)}),Node.prototype.before||(Node.prototype.before=function(t){this.parentElement.insertBefore(t,this)}),Node.prototype.after||(Node.prototype.after=function(t){this.parentElement.insertBefore(t,this.nextElementSibling)}),Node.prototype.closest||(Node.prototype.closest=function(t){return this.parentNode?this.parentNode.closest(t):null}),Node.prototype.replaceWith||(Node.prototype.replaceWith=function(t){this.parentNode.replaceChild(t,this)});let l=HTMLDialogElement.prototype.showModal,h=HTMLDialogElement.prototype.close,d=[],c={get open(){return this.hasAttribute("open")},showModal(){return new Promise(async t=>{if(!0!==this.open&&!1!==this.isConnected){this.o&&await this.o.finished,this.p&&await this.p.finished,l.apply(this);{let t,e={html:document.documentElement.style.overflow,body:document.body.style.overflow};document.documentElement.style.overflow="hidden",document.body.style.overflow="hidden",d.push(this),this.addEventListener("close",t=i=>{i.target===this&&(this.removeEventListener("close",t),d=d.filter(t=>t!==this),0===d.length&&(document.documentElement.style.overflow=e.html,document.body.style.overflow=e.body))})}{let t=this.querySelector("[autofocus]");t?t.focus():this.focus()}if(!1===this.hasAttribute("hidden")){let t=getComputedStyle(this),e=1e3*Number.parseFloat(t.getPropertyValue("transition-duration")||"0s"),i=t.getPropertyValue("transition-timing-function"),s=t.getPropertyValue("--transition-type")||"stretch";this.o=this.animate({transform:"grow"===s?["scale(0.9)","scale(1)"]:["scaleY(0)","scaleY(1)"],opacity:["0","1"]},{duration:e,easing:i})}{let t,e,i;this.addEventListener("keydown",t=t=>{"Escape"===t.code&&t.preventDefault()}),document.addEventListener("keydown",e=t=>{"Escape"===t.code&&t.target===document.body&&t.preventDefault()}),this.addEventListener("close",i=s=>{s.target===this&&(this.removeEventListener("close",i),this.removeEventListener("keydown",t),document.removeEventListener("keydown",e))})}{let t,e,s,n=!0;this.addEventListener("pointerdown",t=t=>{n=!1===i(t,this)}),this.addEventListener("click",e=t=>{t.target===this&&!0===t.isTrusted&&!1===t.defaultPrevented&&!0===n&&!1===i(t,this)&&!0===this.hasAttribute("open")&&(this.close(),this.dispatchEvent(new CustomEvent("userclose")))}),this.addEventListener("close",s=i=>{i.target===this&&(this.removeEventListener("pointerdown",t),this.removeEventListener("click",e),this.removeEventListener("close",s))})}this.o&&(await this.o.finished,this.o=null),t()}else t()})},close(t){return new Promise(async e=>{if(this.o&&await this.o.finished,this.p&&await this.p.finished,!1===this.hasAttribute("hidden")){let t=getComputedStyle(this),e=1e3*Number.parseFloat(t.getPropertyValue("transition-duration")||"0s"),i=t.getPropertyValue("transition-timing-function")||"ease",s=t.getPropertyValue("--transition-type")||"stretch";this.p=this.animate({transform:"grow"===s?["scale(1)","scale(0.9)"]:["scaleY(1)","scaleY(0)"],opacity:["1","0"]},{duration:e,easing:i})}this.p&&(await this.p.finished,this.p=null),this.hasAttribute("open")&&h.apply(this,[t]),e()})}};for(let[t,e]of Object.entries(Object.getOwnPropertyDescriptors(c)))Object.defineProperty(HTMLDialogElement.prototype,t,e);const{entries:u,setPrototypeOf:p,isFrozen:m,getPrototypeOf:b,getOwnPropertyDescriptor:g}=Object;let{freeze:f,seal:x,create:w}=Object,{apply:v,construct:y}="undefined"!=typeof Reflect&&Reflect;f||(f=function(t){return t}),x||(x=function(t){return t}),v||(v=function(t,e){for(var i=arguments.length,s=new Array(i>2?i-2:0),n=2;n<i;n++)s[n-2]=arguments[n];return t.apply(e,s)}),y||(y=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];return new t(...i)});const k=I(Array.prototype.forEach),C=I(Array.prototype.lastIndexOf),z=I(Array.prototype.pop),E=I(Array.prototype.push),$=I(Array.prototype.splice),S=I(String.prototype.toLowerCase),M=I(String.prototype.toString),L=I(String.prototype.match),A=I(String.prototype.replace),T=I(String.prototype.indexOf),P=I(String.prototype.trim),R=I(Object.prototype.hasOwnProperty),D=I(RegExp.prototype.test),B=(O=TypeError,function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return y(O,e)});var O;function I(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var i=arguments.length,s=new Array(i>1?i-1:0),n=1;n<i;n++)s[n-1]=arguments[n];return v(t,e,s)}}function N(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:S;p&&p(t,null);let s=e.length;for(;s--;){let n=e[s];if("string"==typeof n){const t=i(n);t!==n&&(m(e)||(e[s]=t),n=t)}t[n]=!0}return t}function H(t){for(let e=0;e<t.length;e++){R(t,e)||(t[e]=null)}return t}function j(t){const e=w(null);for(const[i,s]of u(t)){R(t,i)&&(Array.isArray(s)?e[i]=H(s):s&&"object"==typeof s&&s.constructor===Object?e[i]=j(s):e[i]=s)}return e}function X(t,e){for(;null!==t;){const i=g(t,e);if(i){if(i.get)return I(i.get);if("function"==typeof i.value)return I(i.value)}t=b(t)}return function(){return null}}const G=f(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),F=f(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),_=f(["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"]),Z=f(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),U=f(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Y=f(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),V=f(["#text"]),W=f(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),q=f(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","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","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),K=f(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","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","supscriptshift","symmetric","voffset","width","xmlns"]),J=f(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Q=x(/\{\{[\w\W]*|[\w\W]*\}\}/gm),tt=x(/<%[\w\W]*|[\w\W]*%>/gm),et=x(/\$\{[\w\W]*/gm),it=x(/^data-[\-\w.\u00B7-\uFFFF]+$/),st=x(/^aria-[\-\w]+$/),nt=x(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),at=x(/^(?:\w+script|data):/i),ot=x(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),rt=x(/^html$/i),lt=x(/^[a-z][.\w]*(-[.\w]+)+$/i);var ht=Object.freeze({__proto__:null,ARIA_ATTR:st,ATTR_WHITESPACE:ot,CUSTOM_ELEMENT:lt,DATA_ATTR:it,DOCTYPE_NAME:rt,ERB_EXPR:tt,IS_ALLOWED_URI:nt,IS_SCRIPT_OR_DATA:at,MUSTACHE_EXPR:Q,TMPLIT_EXPR:et});const dt=1,ct=3,ut=7,pt=8,mt=9,bt=function(){return"undefined"==typeof window?null:window};var gt=function t(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:bt();const i=e=>t(e);if(i.version="3.3.3",i.removed=[],!e||!e.document||e.document.nodeType!==mt||!e.Element)return i.isSupported=!1,i;let{document:s}=e;const n=s,a=n.currentScript,{DocumentFragment:o,HTMLTemplateElement:r,Node:l,Element:h,NodeFilter:d,NamedNodeMap:c=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:m,trustedTypes:b}=e,g=h.prototype,x=X(g,"cloneNode"),v=X(g,"remove"),y=X(g,"nextSibling"),O=X(g,"childNodes"),I=X(g,"parentNode");if("function"==typeof r){const t=s.createElement("template");t.content&&t.content.ownerDocument&&(s=t.content.ownerDocument)}let H,Q="";const{implementation:tt,createNodeIterator:et,createDocumentFragment:it,getElementsByTagName:st}=s,{importNode:at}=n;let ot={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};i.isSupported="function"==typeof u&&"function"==typeof I&&tt&&void 0!==tt.createHTMLDocument;const{MUSTACHE_EXPR:lt,ERB_EXPR:gt,TMPLIT_EXPR:ft,DATA_ATTR:xt,ARIA_ATTR:wt,IS_SCRIPT_OR_DATA:vt,ATTR_WHITESPACE:yt,CUSTOM_ELEMENT:kt}=ht;let{IS_ALLOWED_URI:Ct}=ht,zt=null;const Et=N({},[...G,...F,..._,...U,...V]);let $t=null;const St=N({},[...W,...q,...K,...J]);let Mt=Object.seal(w(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Lt=null,At=null;const Tt=Object.seal(w(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Pt=!0,Rt=!0,Dt=!1,Bt=!0,Ot=!1,It=!0,Nt=!1,Ht=!1,jt=!1,Xt=!1,Gt=!1,Ft=!1,_t=!0,Zt=!1,Ut=!0,Yt=!1,Vt={},Wt=null;const qt=N({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Kt=null;const Jt=N({},["audio","video","img","source","image","track"]);let Qt=null;const te=N({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ee="http://www.w3.org/1998/Math/MathML",ie="http://www.w3.org/2000/svg",se="http://www.w3.org/1999/xhtml";let ne=se,ae=!1,oe=null;const re=N({},[ee,ie,se],M);let le=N({},["mi","mo","mn","ms","mtext"]),he=N({},["annotation-xml"]);const de=N({},["title","style","font","a","script"]);let ce=null;const ue=["application/xhtml+xml","text/html"];let pe=null,me=null;const be=s.createElement("form"),ge=function(t){return t instanceof RegExp||t instanceof Function},fe=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!me||me!==t){if(t&&"object"==typeof t||(t={}),t=j(t),ce=-1===ue.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,pe="application/xhtml+xml"===ce?M:S,zt=R(t,"ALLOWED_TAGS")?N({},t.ALLOWED_TAGS,pe):Et,$t=R(t,"ALLOWED_ATTR")?N({},t.ALLOWED_ATTR,pe):St,oe=R(t,"ALLOWED_NAMESPACES")?N({},t.ALLOWED_NAMESPACES,M):re,Qt=R(t,"ADD_URI_SAFE_ATTR")?N(j(te),t.ADD_URI_SAFE_ATTR,pe):te,Kt=R(t,"ADD_DATA_URI_TAGS")?N(j(Jt),t.ADD_DATA_URI_TAGS,pe):Jt,Wt=R(t,"FORBID_CONTENTS")?N({},t.FORBID_CONTENTS,pe):qt,Lt=R(t,"FORBID_TAGS")?N({},t.FORBID_TAGS,pe):j({}),At=R(t,"FORBID_ATTR")?N({},t.FORBID_ATTR,pe):j({}),Vt=!!R(t,"USE_PROFILES")&&t.USE_PROFILES,Pt=!1!==t.ALLOW_ARIA_ATTR,Rt=!1!==t.ALLOW_DATA_ATTR,Dt=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Bt=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,Ot=t.SAFE_FOR_TEMPLATES||!1,It=!1!==t.SAFE_FOR_XML,Nt=t.WHOLE_DOCUMENT||!1,Xt=t.RETURN_DOM||!1,Gt=t.RETURN_DOM_FRAGMENT||!1,Ft=t.RETURN_TRUSTED_TYPE||!1,jt=t.FORCE_BODY||!1,_t=!1!==t.SANITIZE_DOM,Zt=t.SANITIZE_NAMED_PROPS||!1,Ut=!1!==t.KEEP_CONTENT,Yt=t.IN_PLACE||!1,Ct=t.ALLOWED_URI_REGEXP||nt,ne=t.NAMESPACE||se,le=t.MATHML_TEXT_INTEGRATION_POINTS||le,he=t.HTML_INTEGRATION_POINTS||he,Mt=t.CUSTOM_ELEMENT_HANDLING||{},t.CUSTOM_ELEMENT_HANDLING&&ge(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Mt.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&ge(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Mt.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Mt.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ot&&(Rt=!1),Gt&&(Xt=!0),Vt&&(zt=N({},V),$t=w(null),!0===Vt.html&&(N(zt,G),N($t,W)),!0===Vt.svg&&(N(zt,F),N($t,q),N($t,J)),!0===Vt.svgFilters&&(N(zt,_),N($t,q),N($t,J)),!0===Vt.mathMl&&(N(zt,U),N($t,K),N($t,J))),R(t,"ADD_TAGS")||(Tt.tagCheck=null),R(t,"ADD_ATTR")||(Tt.attributeCheck=null),t.ADD_TAGS&&("function"==typeof t.ADD_TAGS?Tt.tagCheck=t.ADD_TAGS:(zt===Et&&(zt=j(zt)),N(zt,t.ADD_TAGS,pe))),t.ADD_ATTR&&("function"==typeof t.ADD_ATTR?Tt.attributeCheck=t.ADD_ATTR:($t===St&&($t=j($t)),N($t,t.ADD_ATTR,pe))),t.ADD_URI_SAFE_ATTR&&N(Qt,t.ADD_URI_SAFE_ATTR,pe),t.FORBID_CONTENTS&&(Wt===qt&&(Wt=j(Wt)),N(Wt,t.FORBID_CONTENTS,pe)),t.ADD_FORBID_CONTENTS&&(Wt===qt&&(Wt=j(Wt)),N(Wt,t.ADD_FORBID_CONTENTS,pe)),Ut&&(zt["#text"]=!0),Nt&&N(zt,["html","head","body"]),zt.table&&(N(zt,["tbody"]),delete Lt.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw B('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw B('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');H=t.TRUSTED_TYPES_POLICY,Q=H.createHTML("")}else void 0===H&&(H=function(t,e){if("object"!=typeof t||"function"!=typeof t.createPolicy)return null;let i=null;const s="data-tt-policy-suffix";e&&e.hasAttribute(s)&&(i=e.getAttribute(s));const n="dompurify"+(i?"#"+i:"");try{return t.createPolicy(n,{createHTML:t=>t,createScriptURL:t=>t})}catch(t){return console.warn("TrustedTypes policy "+n+" could not be created."),null}}(b,a)),null!==H&&"string"==typeof Q&&(Q=H.createHTML(""));f&&f(t),me=t}},xe=N({},[...F,..._,...Z]),we=N({},[...U,...Y]),ve=function(t){E(i.removed,{element:t});try{I(t).removeChild(t)}catch(e){v(t)}},ye=function(t,e){try{E(i.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){E(i.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t)if(Xt||Gt)try{ve(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},ke=function(t){let e=null,i=null;if(jt)t="<remove></remove>"+t;else{const e=L(t,/^[\r\n\t ]+/);i=e&&e[0]}"application/xhtml+xml"===ce&&ne===se&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const n=H?H.createHTML(t):t;if(ne===se)try{e=(new m).parseFromString(n,ce)}catch(t){}if(!e||!e.documentElement){e=tt.createDocument(ne,"template",null);try{e.documentElement.innerHTML=ae?Q:n}catch(t){}}const a=e.body||e.documentElement;return t&&i&&a.insertBefore(s.createTextNode(i),a.childNodes[0]||null),ne===se?st.call(e,Nt?"html":"body")[0]:Nt?e.documentElement:a},Ce=function(t){return et.call(t.ownerDocument||t,t,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},ze=function(t){return t instanceof p&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||!(t.attributes instanceof c)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes)},Ee=function(t){return"function"==typeof l&&t instanceof l};function $e(t,e,s){k(t,t=>{t.call(i,e,s,me)})}const Se=function(t){let e=null;if($e(ot.beforeSanitizeElements,t,null),ze(t))return ve(t),!0;const s=pe(t.nodeName);if($e(ot.uponSanitizeElement,t,{tagName:s,allowedTags:zt}),It&&t.hasChildNodes()&&!Ee(t.firstElementChild)&&D(/<[/\w!]/g,t.innerHTML)&&D(/<[/\w!]/g,t.textContent))return ve(t),!0;if(t.nodeType===ut)return ve(t),!0;if(It&&t.nodeType===pt&&D(/<[/\w]/g,t.data))return ve(t),!0;if(!(Tt.tagCheck instanceof Function&&Tt.tagCheck(s))&&(!zt[s]||Lt[s])){if(!Lt[s]&&Le(s)){if(Mt.tagNameCheck instanceof RegExp&&D(Mt.tagNameCheck,s))return!1;if(Mt.tagNameCheck instanceof Function&&Mt.tagNameCheck(s))return!1}if(Ut&&!Wt[s]){const e=I(t)||t.parentNode,i=O(t)||t.childNodes;if(i&&e){for(let s=i.length-1;s>=0;--s){const n=x(i[s],!0);n.k=(t.k||0)+1,e.insertBefore(n,y(t))}}}return ve(t),!0}return t instanceof h&&!function(t){let e=I(t);e&&e.tagName||(e={namespaceURI:ne,tagName:"template"});const i=S(t.tagName),s=S(e.tagName);return!!oe[t.namespaceURI]&&(t.namespaceURI===ie?e.namespaceURI===se?"svg"===i:e.namespaceURI===ee?"svg"===i&&("annotation-xml"===s||le[s]):Boolean(xe[i]):t.namespaceURI===ee?e.namespaceURI===se?"math"===i:e.namespaceURI===ie?"math"===i&&he[s]:Boolean(we[i]):t.namespaceURI===se?!(e.namespaceURI===ie&&!he[s])&&!(e.namespaceURI===ee&&!le[s])&&!we[i]&&(de[i]||!xe[i]):!("application/xhtml+xml"!==ce||!oe[t.namespaceURI]))}(t)?(ve(t),!0):"noscript"!==s&&"noembed"!==s&&"noframes"!==s||!D(/<\/no(script|embed|frames)/i,t.innerHTML)?(Ot&&t.nodeType===ct&&(e=t.textContent,k([lt,gt,ft],t=>{e=A(e,t," ")}),t.textContent!==e&&(E(i.removed,{element:t.cloneNode()}),t.textContent=e)),$e(ot.afterSanitizeElements,t,null),!1):(ve(t),!0)},Me=function(t,e,i){if(At[e])return!1;if(_t&&("id"===e||"name"===e)&&(i in s||i in be))return!1;if(Rt&&!At[e]&&D(xt,e));else if(Pt&&D(wt,e));else if(Tt.attributeCheck instanceof Function&&Tt.attributeCheck(e,t));else if(!$t[e]||At[e]){if(!(Le(t)&&(Mt.tagNameCheck instanceof RegExp&&D(Mt.tagNameCheck,t)||Mt.tagNameCheck instanceof Function&&Mt.tagNameCheck(t))&&(Mt.attributeNameCheck instanceof RegExp&&D(Mt.attributeNameCheck,e)||Mt.attributeNameCheck instanceof Function&&Mt.attributeNameCheck(e,t))||"is"===e&&Mt.allowCustomizedBuiltInElements&&(Mt.tagNameCheck instanceof RegExp&&D(Mt.tagNameCheck,i)||Mt.tagNameCheck instanceof Function&&Mt.tagNameCheck(i))))return!1}else if(Qt[e]);else if(D(Ct,A(i,yt,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==T(i,"data:")||!Kt[t]){if(Dt&&!D(vt,A(i,yt,"")));else if(i)return!1}else;return!0},Le=function(t){return"annotation-xml"!==t&&L(t,kt)},Ae=function(t){$e(ot.beforeSanitizeAttributes,t,null);const{attributes:e}=t;if(!e||ze(t))return;const s={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$t,forceKeepAttr:void 0};let n=e.length;for(;n--;){const a=e[n],{name:o,namespaceURI:r,value:l}=a,h=pe(o),d=l;let c="value"===o?d:P(d);if(s.attrName=h,s.attrValue=c,s.keepAttr=!0,s.forceKeepAttr=void 0,$e(ot.uponSanitizeAttribute,t,s),c=s.attrValue,!Zt||"id"!==h&&"name"!==h||(ye(o,t),c="user-content-"+c),It&&D(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,c)){ye(o,t);continue}if("attributename"===h&&L(c,"href")){ye(o,t);continue}if(s.forceKeepAttr)continue;if(!s.keepAttr){ye(o,t);continue}if(!Bt&&D(/\/>/i,c)){ye(o,t);continue}Ot&&k([lt,gt,ft],t=>{c=A(c,t," ")});const u=pe(t.nodeName);if(Me(u,h,c)){if(H&&"object"==typeof b&&"function"==typeof b.getAttributeType)if(r);else switch(b.getAttributeType(u,h)){case"TrustedHTML":c=H.createHTML(c);break;case"TrustedScriptURL":c=H.createScriptURL(c)}if(c!==d)try{r?t.setAttributeNS(r,o,c):t.setAttribute(o,c),ze(t)?ve(t):z(i.removed)}catch(e){ye(o,t)}}else ye(o,t)}$e(ot.afterSanitizeAttributes,t,null)},Te=function t(e){let i=null;const s=Ce(e);for($e(ot.beforeSanitizeShadowDOM,e,null);i=s.nextNode();)$e(ot.uponSanitizeShadowNode,i,null),Se(i),Ae(i),i.content instanceof o&&t(i.content);$e(ot.afterSanitizeShadowDOM,e,null)};return i.sanitize=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=null,a=null,r=null,h=null;if(ae=!t,ae&&(t="\x3c!--\x3e"),"string"!=typeof t&&!Ee(t)){if("function"!=typeof t.toString)throw B("toString is not a function");if("string"!=typeof(t=t.toString()))throw B("dirty is not a string, aborting")}if(!i.isSupported)return t;if(Ht||fe(e),i.removed=[],"string"==typeof t&&(Yt=!1),Yt){if(t.nodeName){const e=pe(t.nodeName);if(!zt[e]||Lt[e])throw B("root node is forbidden and cannot be sanitized in-place")}}else if(t instanceof l)s=ke("\x3c!----\x3e"),a=s.ownerDocument.importNode(t,!0),a.nodeType===dt&&"BODY"===a.nodeName||"HTML"===a.nodeName?s=a:s.appendChild(a);else{if(!Xt&&!Ot&&!Nt&&-1===t.indexOf("<"))return H&&Ft?H.createHTML(t):t;if(s=ke(t),!s)return Xt?null:Ft?Q:""}s&&jt&&ve(s.firstChild);const d=Ce(Yt?t:s);for(;r=d.nextNode();)Se(r),Ae(r),r.content instanceof o&&Te(r.content);if(Yt)return t;if(Xt){if(Gt)for(h=it.call(s.ownerDocument);s.firstChild;)h.appendChild(s.firstChild);else h=s;return($t.shadowroot||$t.shadowrootmode)&&(h=at.call(n,h,!0)),h}let c=Nt?s.outerHTML:s.innerHTML;return Nt&&zt["!doctype"]&&s.ownerDocument&&s.ownerDocument.doctype&&s.ownerDocument.doctype.name&&D(rt,s.ownerDocument.doctype.name)&&(c="<!DOCTYPE "+s.ownerDocument.doctype.name+">\n"+c),Ot&&k([lt,gt,ft],t=>{c=A(c,t," ")}),H&&Ft?H.createHTML(c):c},i.setConfig=function(){fe(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Ht=!0},i.clearConfig=function(){me=null,Ht=!1},i.isValidAttribute=function(t,e,i){me||fe({});const s=pe(t),n=pe(e);return Me(s,n,i)},i.addHook=function(t,e){"function"==typeof e&&E(ot[t],e)},i.removeHook=function(t,e){if(void 0!==e){const i=C(ot[t],e);return-1===i?void 0:$(ot[t],i,1)[0]}return z(ot[t])},i.removeHooks=function(t){ot[t]=[]},i.removeAllHooks=function(){ot={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},i}();class ft{#t={};addEventListener(t,e){this.#t||(this.#t={});let i=this.#t[t];i||(this.#t[t]=i=[]),i.push(e),i.length>1e4&&console.warn(`Potential EventEmitter memory leak: ${i.length} listeners subscribed to event "${t}"`)}removeEventListener(t,e){if(!this.#t||!this.#t[t])return;let i=[];for(let s=0;s<this.#t[t].length;s+=1)this.#t[t][s]!==e&&i.push(this.#t[t][s]);this.#t[t]=i}dispatchEvent(t){if(!this.#t)return;let e=this.#t[t.type];if(!e)return;let i=null;for(let s=e.length-1;s>=0;s-=1){let n,a=e[s];try{n=a.call(window,t)}catch(t){null===i&&(i=t)}if(!1===n)break}if(i)throw i}}let xt=(t,e,i=!1)=>{if(t.length!==e.length)return!1;if(i)for(let i=0;i<t.length;i+=1){if(t[i]!==e[i])return!1}else{for(let i=0;i<t.length;i+=1)if(!e.includes(t[i]))return!1;for(let i=0;i<e.length;i+=1)if(!t.includes(e[i]))return!1}return!0};function wt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function vt(t,e,i=[0,0,0]){const s=wt(t,e[0]),n=wt(t,e[1]),a=wt(t,e[2]);return i[0]=s,i[1]=n,i[2]=a,i}function yt(t){return"string"===kt(t)}function kt(t){return(Object.prototype.toString.call(t).match(/^\[object\s+(.*?)\]$/)[1]||"").toLowerCase()}function Ct(t,{precision:e=16,unit:i}){return zt(t)?"none":(t=+$t(t,e))+(i??"")}function zt(t){return null===t}function Et(t){return zt(t)?0:t}function $t(t,e){if(0===t)return 0;let i=~~t,s=0;i&&e&&(s=1+~~Math.log10(Math.abs(i)));const n=10**(e-s);return Math.floor(t*n+.5)/n}function St(t,e,i){return isNaN(t)?e:isNaN(e)?t:t+(e-t)*i}function Mt(t,e,i){return!t||!e||t===e||t[0]===e[0]&&t[1]===e[1]||isNaN(i)||null===i?i:St(e[0],e[1],function(t,e,i){return(i-t)/(e-t)}(t[0],t[1],i))}function Lt(t,e,i){return Math.max(Math.min(i,e),t)}function At(t,e){return Math.sign(t)===Math.sign(e)?t:-t}function Tt(t,e){return At(Math.abs(t)**e,t)}function Pt(t,e){return 0===e?0:t/e}function Rt(t,e){if(t instanceof e)return!0;const i=e.name;for(;t;){const e=Object.getPrototypeOf(t),s=e?.constructor?.name;if(s===i)return!0;if(!s||"Object"===s)return!1;t=e}return!1}class Dt{type;coordMeta;coordRange;range;constructor(t,e){if("object"==typeof t&&(this.coordMeta=t),e&&(this.coordMeta=e,this.coordRange=e.range??e.refRange),"string"==typeof t){let e=t.trim().match(/^(?<type><[a-z]+>)(\[(?<min>-?[.\d]+),\s*(?<max>-?[.\d]+)\])?$/);if(!e)throw new TypeError(`Cannot parse ${t} as a type definition.`);this.type=e.groups.type;let{min:i,max:s}=e.groups;(i||s)&&(this.range=[+i,+s])}}get computedRange(){return this.range?this.range:"<percentage>"===this.type?this.percentageRange():"<angle>"===this.type?[0,360]:null}get unit(){return"<percentage>"===this.type?"%":"<angle>"===this.type?"deg":""}resolve(t){if("<angle>"===this.type)return t;let e=this.computedRange,i=this.coordRange;return"<percentage>"===this.type&&(i??=this.percentageRange()),Mt(e,i,t)}serialize(t,e){let i="<percentage>"===this.type?this.percentageRange(100):this.computedRange,s=this.unit;return Ct(t=Mt(this.coordRange,i,t),{unit:s,precision:e})}toString(){let t=this.type;if(this.range){let[e="",i=""]=this.range;t+=`[${e},${i}]`}return t}percentageRange(t=1){let e;return e=this.coordMeta&&this.coordMeta.range||this.coordRange&&this.coordRange[0]>=0?[0,1]:[-1,1],[e[0]*t,e[1]*t]}static get(t,e){return Rt(t,this)?t:new this(t,e)}}const Bt=Symbol("instance");class Ot{type;name;spaceCoords;coords;id;alpha;constructor(t,e=t.space){t[Bt]=this,this.type="function",this.name="color",Object.assign(this,t),this.space=e,"custom"!==this.type&&(this.spaceCoords=Object.values(e.coords),this.coords||(this.coords=this.spaceCoords.map(t=>{let e=["<number>","<percentage>"];return"angle"===t.type&&e.push("<angle>"),e})),this.coords=this.coords.map((t,e)=>{let i=this.spaceCoords[e];return"string"==typeof t&&(t=t.trim().split(/\s*\|\s*/)),t.map(t=>Dt.get(t,i))}))}serializeCoords(t,e,i){return i=t.map((t,e)=>Dt.get(i?.[e]??this.coords[e][0],this.spaceCoords[e])),t.map((t,s)=>i[s].serialize(t,e))}coerceCoords(t,e){return Object.entries(this.space.coords).map(([i,s],n)=>{let a=t[n];if(zt(a)||isNaN(a))return a;let o=e[n],r=this.coords[n].find(t=>t.type==o);if(!r){let t=s.name||i;throw new TypeError(`${o??a?.raw??a} not allowed for ${t} in ${this.name}()`)}return a=r.resolve(a),r.range&&(e[n]=r.toString()),a})}canSerialize(){return"function"===this.type||this.serialize}parse(t){return null}static get(t,...e){return!t||Rt(t,this)?t:t[Bt]?t[Bt]:new Ot(t,...e)}}const It=new class{add(t,e,i){if("string"==typeof arguments[0])(Array.isArray(t)?t:[t]).forEach(function(t){this[t]=this[t]||[],e&&this[t][i?"unshift":"push"](e)},this);else for(var t in arguments[0])this.add(t,arguments[0][t],arguments[1])}run(t,e){this[t]=this[t]||[],this[t].forEach(function(t){t.call(e&&e.context?e.context:e,e)})}},Nt={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function Ht(t){return Array.isArray(t)?t:Nt[t]}function jt(t,e,i,s={}){if(t=Ht(t),e=Ht(e),!t||!e)throw new TypeError(`Missing white point to convert ${t?"":"from"}${t||e?"":"/"}${e?"":"to"}`);if(t===e)return i;let n={W1:t,W2:e,XYZ:i,options:s};if(It.run("chromatic-adaptation-start",n),n.M||(n.W1===Nt.D65&&n.W2===Nt.D50?n.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:n.W1===Nt.D50&&n.W2===Nt.D65&&(n.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),It.run("chromatic-adaptation-end",n),n.M)return vt(n.XYZ,n.M);throw new TypeError("Only Bradford CAT with white points D50 and D65 supported for now.")}var Xt={gamut_mapping:"css",precision:5,deltaE:"76",verbose:"test"!==globalThis?.process?.env?.NODE_ENV?.toLowerCase(),warn:function(t){this.verbose&&globalThis?.console?.warn?.(t)}};function Gt(t,e){let i,s={str:String(t)?.trim(),options:e};if(It.run("parse-start",s),s.color)return s.color;s.parsed=function(t){if(!t)return;t=t.trim();let e=t.match(_t.function);if(e){let t=[],i=[],s=!1,n=e[1].toLowerCase(),a=e[2].replace(_t.singleArgument,(e,a)=>{let{value:o,meta:r}=function(t){let e={},i=t.match(_t.unitValue)?.[0],s=e.raw=t;i?(e.type="%"===i?"<percentage>":"<angle>",e.unit=i,e.unitless=Number(s.slice(0,-i.length)),s=e.unitless*Ft[i]):_t.number.test(s)?(s=Number(s),e.type="<number>"):"none"===s?s=null:"NaN"===s||"calc(NaN)"===s?(s=NaN,e.type="<number>"):e.type="<ident>";return{value:s,meta:e}}(a);return(e.startsWith("/")||"color"!==n&&3===t.length)&&(s=!0),t.push(o),i.push(r),""});return{name:n,args:t,argMeta:i,lastAlpha:s,commas:a.includes(","),rawName:e[1],rawArgs:e[2]}}}(s.str);let n=s.options?s.options.parseMeta??s.options.meta:null;if(s.parsed){let e,a,o=s.parsed.name,r=s.parsed.args,l=r.map((t,e)=>s.parsed.argMeta[e]?.type);if("color"===o){let i=r.shift();l.shift();let n=i.startsWith("--")?i.substring(2):`--${i}`,h=[i,n];if(e=Ut.findFormat({name:o,id:h,type:"function"}),!e){let e,a=i in Ut.registry?i:n;if(a in Ut.registry){let s=Ut.registry[a].formats?.color?.id;if(s){e=`Did you mean ${t.replace("color("+i,"color("+s)}?`}}throw new TypeError(`Cannot parse ${s.str}. `+(e??"Missing a plugin?"))}a=e.space,e.id.startsWith("--")&&!i.startsWith("--")&&Xt.warn(`${a.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${e.id}) instead of color(${i}).`),i.startsWith("--")&&!e.id.startsWith("--")&&Xt.warn(`${a.name} is a standard space and supported in the CSS spec. Use color(${e.id}) instead of prefixed color(${i}).`)}else e=Ut.findFormat({name:o,type:"function"}),a=e.space;n&&Object.assign(n,{format:e,formatId:e.name,types:l,commas:s.parsed.commas});let h=1;s.parsed.lastAlpha&&(h=s.parsed.args.pop(),n&&(n.alphaType=l.pop()));let d=e.coords.length;if(r.length!==d)throw new TypeError(`Expected ${d} coordinates for ${a.id} in ${s.str}), got ${r.length}`);r=e.coerceCoords(r,l),i={spaceId:a.id,coords:r,alpha:h}}else t:for(let t of Ut.all)for(let e in t.formats){let a=t.formats[e];if("custom"!==a.type)continue;if(a.test&&!a.test(s.str))continue;let o=t.getFormat(a),r=o.parse(s.str);if(r){n&&Object.assign(n,{format:o,formatId:e}),i=r;break t}}if(!i)throw new TypeError(`Could not parse ${t} as a color. Missing a plugin?`);return i.alpha=zt(i.alpha)?i.alpha:void 0===i.alpha?1:Lt(0,i.alpha,1),i}const Ft={"%":.01,deg:1,grad:.9,rad:180/Math.PI,turn:360},_t={function:/^([a-z]+)\(((?:calc\(NaN\)|.)+?)\)$/i,number:/^([-+]?(?:[0-9]*\.)?[0-9]+(e[-+]?[0-9]+)?)$/i,unitValue:RegExp(`(${Object.keys(Ft).join("|")})$`),singleArgument:/\/?\s*(none|NaN|calc\(NaN\)|[-+\w.]+(?:%|deg|g?rad|turn)?)/g};function Zt(t,e){if(Array.isArray(t))return t.map(t=>Zt(t,e));if(!t)throw new TypeError("Empty color reference");yt(t)&&(t=Gt(t,e));let i=t.space||t.spaceId;return"string"==typeof i&&(t.space=Ut.get(i)),void 0===t.alpha&&(t.alpha=1),t}class Ut{constructor(t){this.id=t.id,this.name=t.name,this.base=t.base?Ut.get(t.base):null,this.aliases=t.aliases,this.base&&(this.fromBase=t.fromBase,this.toBase=t.toBase);let e=t.coords??this.base.coords;for(let t in e)"name"in e[t]||(e[t].name=t);this.coords=e;let i=t.white??this.base.white??"D65";this.white=Ht(i),this.formats=t.formats??{};for(let t in this.formats){let e=this.formats[t];e.type||="function",e.name||=t}this.formats.color?.id||(this.formats.color={...this.formats.color??{},id:t.cssId||this.id}),t.gamutSpace?this.gamutSpace="self"===t.gamutSpace?this:Ut.get(t.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(t,e)=>!0),this.referred=t.referred,Object.defineProperty(this,"path",{value:Yt(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),It.run("colorspace-init-end",this)}inGamut(t,{epsilon:e=75e-6}={}){if(!this.equals(this.gamutSpace))return t=this.to(this.gamutSpace,t),this.gamutSpace.inGamut(t,{epsilon:e});let i=Object.values(this.coords);return t.every((t,s)=>{let n=i[s];if("angle"!==n.type&&n.range){if(zt(t))return!0;let[i,s]=n.range;return(void 0===i||t>=i-e)&&(void 0===s||t<=s+e)}return!0})}get isUnbounded(){return Object.values(this.coords).every(t=>!("range"in t))}get cssId(){return this.formats?.color?.id||this.id}get isPolar(){for(let t in this.coords)if("angle"===this.coords[t].type)return!0;return!1}getFormat(t){if(!t)return null;"default"===t?t=Object.values(this.formats)[0]:"string"==typeof t&&(t=this.formats[t]);let e=Ot.get(t,this);return e!==t&&t.name in this.formats&&(this.formats[t.name]=e),e}equals(t){return!!t&&(this===t||this.id===t||this.id===t.id)}to(t,e){if(1===arguments.length){const i=Zt(t);[t,e]=[i.space,i.coords]}if(t=Ut.get(t),this.equals(t))return e;e=e.map(t=>zt(t)?0:t);let i,s,n=this.path,a=t.path;for(let t=0;t<n.length&&n[t].equals(a[t]);t++)i=n[t],s=t;if(!i)throw new Error(`Cannot convert between color spaces ${this} and ${t}: no connection space was found`);for(let t=n.length-1;t>s;t--)e=n[t].toBase(e);for(let t=s+1;t<a.length;t++)e=a[t].fromBase(e);return e}from(t,e){if(1===arguments.length){const i=Zt(t);[t,e]=[i.space,i.coords]}return(t=Ut.get(t)).to(this,e)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let t=[];for(let e in this.coords){let i=this.coords[e],s=i.range||i.refRange;t.push(s?.min??0)}return t}static registry={};static get all(){return[...new Set(Object.values(Ut.registry))]}static register(t,e){if(1===arguments.length&&(t=(e=arguments[0]).id),e=this.get(e),this.registry[t]&&this.registry[t]!==e)throw new Error(`Duplicate color space registration: '${t}'`);if(this.registry[t]=e,1===arguments.length&&e.aliases)for(let t of e.aliases)this.register(t,e);return e}static get(t,...e){if(!t||Rt(t,this))return t;if("string"===kt(t)){let e=Ut.registry[t.toLowerCase()];if(!e)throw new TypeError(`No color space found with id = "${t}"`);return e}if(e.length)return Ut.get(...e);throw new TypeError(`${t} is not a valid color space`)}static findFormat(t,e=Ut.all){if(!t)return null;"string"==typeof t&&(t={name:t});for(let i of e)for(let[e,s]of Object.entries(i.formats)){s.name??=e,s.type??="function";let n=!(t.name&&s.name!==t.name||t.type&&s.type!==t.type);if(t.id){let e=s.ids||[s.id],i=Array.isArray(t.id)?t.id:[t.id];n&&=i.some(t=>e.includes(t))}if(n){let t=Ot.get(s,i);return t!==s&&(i.formats[s.name]=t),t}}return null}static resolveCoord(t,e){let i,s,n=kt(t);if("string"===n?t.includes(".")?[i,s]=t.split("."):[i,s]=[,t]:Array.isArray(t)?[i,s]=t:(i=t.space,s=t.coordId),i=Ut.get(i),i||(i=e),!i)throw new TypeError(`Cannot resolve coordinate reference ${t}: No color space specified and relative references are not allowed here`);if(n=kt(s),"number"===n||"string"===n&&s>=0){let t=Object.entries(i.coords)[s];if(t)return{space:i,id:t[0],index:s,...t[1]}}i=Ut.get(i);let a=s.toLowerCase(),o=0;for(let t in i.coords){let e=i.coords[t];if(t.toLowerCase()===a||e.name?.toLowerCase()===a)return{space:i,id:t,index:o,...e};o++}throw new TypeError(`No "${s}" coordinate found in ${i.name}. Its coordinates are: ${Object.keys(i.coords).join(", ")}`)}static DEFAULT_FORMAT={type:"functions",name:"color"}}function Yt(t){let e=[t];for(let i=t;i=i.base;)e.push(i);return e}var Vt=new Ut({id:"xyz-d65",name:"XYZ D65",coords:{x:{refRange:[0,1],name:"X"},y:{refRange:[0,1],name:"Y"},z:{refRange:[0,1],name:"Z"}},white:"D65",formats:{color:{ids:["xyz-d65","xyz"]}},aliases:["xyz"]}),Wt=new Ut({id:"xyz-d50",name:"XYZ D50",white:"D50",base:Vt,fromBase:t=>jt(Vt.white,"D50",t),toBase:t=>jt("D50",Vt.white,t)});const qt=216/24389,Kt=24/116,Jt=24389/27;let Qt=Nt.D50;var te=new Ut({id:"lab",name:"Lab",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:Qt,base:Wt,fromBase(t){let e=t.map((t,e)=>t/Qt[e]).map(t=>t>qt?Math.cbrt(t):(Jt*t+16)/116);return[116*e[1]-16,500*(e[0]-e[1]),200*(e[1]-e[2])]},toBase(t){let[e,i,s]=t,n=[];return n[1]=(e+16)/116,n[0]=i/500+n[1],n[2]=n[1]-s/200,[n[0]>Kt?Math.pow(n[0],3):(116*n[0]-16)/Jt,t[0]>8?Math.pow((t[0]+16)/116,3):t[0]/Jt,n[2]>Kt?Math.pow(n[2],3):(116*n[2]-16)/Jt].map((t,e)=>t*Qt[e])},formats:{lab:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <percentage>"]}}});function ee(t){return"number"!=typeof t?t:(t%360+360)%360}var ie=new Ut({id:"lch",name:"LCH",coords:{l:{refRange:[0,100],name:"Lightness"},c:{refRange:[0,150],name:"Chroma"},h:{refRange:[0,360],type:"angle",name:"Hue"}},base:te,fromBase(t){if(void 0===this.ε){let t=Object.values(this.base.coords)[1].refRange,e=t[1]-t[0];this.ε=e/1e5}let[e,i,s]=t,n=Math.abs(i)<this.ε&&Math.abs(s)<this.ε,a=n?null:ee(180*Math.atan2(s,i)/Math.PI);return[e,n?0:Math.sqrt(i**2+s**2),a]},toBase(t){let[e,i,s]=t,n=null,a=null;return zt(s)||(i=i<0?0:i,n=i*Math.cos(s*Math.PI/180),a=i*Math.sin(s*Math.PI/180)),[e,n,a]},formats:{lch:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <angle>"]}}});const se=25**7,ne=Math.PI,ae=180/ne,oe=ne/180;function re(t){const e=t*t;return e*e*e*t}function le(t,e,{kL:i=1,kC:s=1,kH:n=1}={}){[t,e]=Zt([t,e]);let[a,o,r]=te.from(t),l=ie.from(te,[a,o,r])[1],[h,d,c]=te.from(e),u=ie.from(te,[h,d,c])[1];l<0&&(l=0),u<0&&(u=0);let p=re((l+u)/2),m=.5*(1-Math.sqrt(p/(p+se))),b=(1+m)*o,g=(1+m)*d,f=Math.sqrt(b**2+r**2),x=Math.sqrt(g**2+c**2),w=0===b&&0===r?0:Math.atan2(r,b),v=0===g&&0===c?0:Math.atan2(c,g);w<0&&(w+=2*ne),v<0&&(v+=2*ne),w*=ae,v*=ae;let y,k=h-a,C=x-f,z=v-w,E=w+v,$=Math.abs(z);f*x===0?y=0:$<=180?y=z:z>180?y=z-360:z<-180?y=z+360:Xt.warn("the unthinkable has happened");let S,M=2*Math.sqrt(x*f)*Math.sin(y*oe/2),L=(a+h)/2,A=(f+x)/2,T=re(A);S=f*x===0?E:$<=180?E/2:E<360?(E+360)/2:(E-360)/2;let P=(L-50)**2,R=1+.015*P/Math.sqrt(20+P),D=1+.045*A,B=1;B-=.17*Math.cos((S-30)*oe),B+=.24*Math.cos(2*S*oe),B+=.32*Math.cos((3*S+6)*oe),B-=.2*Math.cos((4*S-63)*oe);let O=1+.015*A*B,I=30*Math.exp(-1*((S-275)/25)**2),N=2*Math.sqrt(T/(T+se)),H=(k/(i*R))**2;return H+=(C/(s*D))**2,H+=(M/(n*O))**2,H+=-1*Math.sin(2*I*oe)*N*(C/(s*D))*(M/(n*O)),Math.sqrt(H)}const he=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],de=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],ce=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],ue=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var pe=new Ut({id:"oklab",name:"Oklab",coords:{l:{refRange:[0,1],name:"Lightness"},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:"D65",base:Vt,fromBase(t){let e=vt(t,he);return e[0]=Math.cbrt(e[0]),e[1]=Math.cbrt(e[1]),e[2]=Math.cbrt(e[2]),vt(e,ce,e)},toBase(t){let e=vt(t,ue);return e[0]=e[0]**3,e[1]=e[1]**3,e[2]=e[2]**3,vt(e,de,e)},formats:{oklab:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <percentage>"]}}});function me(t,e){[t,e]=Zt([t,e]);let[i,s,n]=pe.from(t),[a,o,r]=pe.from(e),l=i-a,h=s-o,d=n-r;return Math.sqrt(l**2+h**2+d**2)}function be(t,e,{epsilon:i=75e-6}={}){t=Zt(t),e||(e=t.space),e=Ut.get(e);let s=t.coords;return e!==t.space&&(s=e.from(t)),e.inGamut(s,{epsilon:i})}function ge(t,e){t=Zt(t);let i,s=Ut.get(e,e?.space),n=e?.precision;return i=!s||t.space.equals(s)?t.coords.slice():s.from(t),void 0===n?i:i.map(t=>$t(t,n))}function fe(t,e){if(t=Zt(t),"alpha"===e)return t.alpha??1;let{space:i,index:s}=Ut.resolveCoord(e,t.space);return ge(t,i)[s]}function xe(t,e,i,s){return t=Zt(t),Array.isArray(e)&&([e,i,s]=[t.space,e,i]),e=Ut.get(e),t.coords=e===t.space?i.slice():e.to(t.space,i),void 0!==s&&(t.alpha=s),t}function we(t,e,i){if(t=Zt(t),2===arguments.length&&"object"===kt(arguments[1])){let e=arguments[1];for(let i in e)we(t,i,e[i])}else if("function"==typeof i&&(i=i(fe(t,e))),"alpha"===e)t.alpha=i;else{let{space:s,index:n}=Ut.resolveCoord(e,t.space),a=ge(t,s);a[n]=i,xe(t,s,a)}return t}function ve(t){return{space:t.space,coords:t.coords.slice(),alpha:t.alpha}}xe.returns="color",we.returns="color";const ye=Math.PI/180;var ke=new Ut({id:"xyz-abs-d65",cssId:"--xyz-abs-d65",name:"Absolute XYZ D65",coords:{x:{refRange:[0,9504.7],name:"Xa"},y:{refRange:[0,1e4],name:"Ya"},z:{refRange:[0,10888.3],name:"Za"}},base:Vt,fromBase:t=>t.map(t=>203*t),toBase:t=>t.map(t=>t/203)});const Ce=1.15,ze=.66,Ee=2610/16384,$e=16384/2610,Se=.8359375,Me=2413/128,Le=18.6875,Ae=1.7*2523/32,Te=32/(1.7*2523),Pe=-.56,Re=16295499532821565e-27,De=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],Be=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],Oe=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]]