wrec 0.20.0 → 0.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/wrec.umd.js CHANGED
@@ -1,5 +1,5 @@
1
- (function(T,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(T=typeof globalThis<"u"?globalThis:T||self,g(T.wrec={}))})(this,(function(T){"use strict";var fn=T=>{throw TypeError(T)};var Ee=(T,g,M)=>g.has(T)||fn("Cannot "+M);var O=(T,g,M)=>(Ee(T,g,"read from private field"),M?M.call(T):g.get(T)),q=(T,g,M)=>g.has(T)?fn("Cannot add the same private member more than once"):g instanceof WeakSet?g.add(T):g.set(T,M),at=(T,g,M,bt)=>(Ee(T,g,"write to private field"),bt?bt.call(T,M):g.set(T,M),M),un=(T,g,M)=>(Ee(T,g,"access private method"),M);var K,Lt,H,dt,Tt,Y,Dt,pn;const{entries:g,setPrototypeOf:M,isFrozen:bt,getPrototypeOf:hn,getOwnPropertyDescriptor:mn}=Object;let{freeze:N,seal:x,create:zt}=Object,{apply:$t,construct:Wt}=typeof Reflect<"u"&&Reflect;N||(N=function(t){return t}),x||(x=function(t){return t}),$t||($t=function(t,e){for(var n=arguments.length,s=new Array(n>2?n-2:0),i=2;i<n;i++)s[i-2]=arguments[i];return t.apply(e,s)}),Wt||(Wt=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),s=1;s<e;s++)n[s-1]=arguments[s];return new t(...n)});const St=D(Array.prototype.forEach),dn=D(Array.prototype.lastIndexOf),ge=D(Array.prototype.pop),ct=D(Array.prototype.push),Tn=D(Array.prototype.splice),yt=D(String.prototype.toLowerCase),Gt=D(String.prototype.toString),Bt=D(String.prototype.match),lt=D(String.prototype.replace),En=D(String.prototype.indexOf),gn=D(String.prototype.trim),k=D(Object.prototype.hasOwnProperty),L=D(RegExp.prototype.test),ft=An(TypeError);function D(r){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,n=new Array(e>1?e-1:0),s=1;s<e;s++)n[s-1]=arguments[s];return $t(r,t,n)}}function An(r){return function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return Wt(r,e)}}function d(r,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:yt;M&&M(r,null);let n=t.length;for(;n--;){let s=t[n];if(typeof s=="string"){const i=e(s);i!==s&&(bt(t)||(t[n]=i),s=i)}r[s]=!0}return r}function _n(r){for(let t=0;t<r.length;t++)k(r,t)||(r[t]=null);return r}function U(r){const t=zt(null);for(const[e,n]of g(r))k(r,e)&&(Array.isArray(n)?t[e]=_n(n):n&&typeof n=="object"&&n.constructor===Object?t[e]=U(n):t[e]=n);return t}function ut(r,t){for(;r!==null;){const n=mn(r,t);if(n){if(n.get)return D(n.get);if(typeof n.value=="function")return D(n.value)}r=hn(r)}function e(){return null}return e}const Ae=N(["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"]),jt=N(["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"]),Yt=N(["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"]),bn=N(["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"]),Vt=N(["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"]),Sn=N(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),_e=N(["#text"]),be=N(["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"]),Xt=N(["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"]),Se=N(["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"]),Rt=N(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),yn=x(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Rn=x(/<%[\w\W]*|[\w\W]*%>/gm),wn=x(/\$\{[\w\W]*/gm),On=x(/^data-[\-\w.\u00B7-\uFFFF]+$/),Cn=x(/^aria-[\-\w]+$/),ye=x(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Mn=x(/^(?:\w+script|data):/i),Nn=x(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Re=x(/^html$/i),Ln=x(/^[a-z][.\w]*(-[.\w]+)+$/i);var we=Object.freeze({__proto__:null,ARIA_ATTR:Cn,ATTR_WHITESPACE:Nn,CUSTOM_ELEMENT:Ln,DATA_ATTR:On,DOCTYPE_NAME:Re,ERB_EXPR:Rn,IS_ALLOWED_URI:ye,IS_SCRIPT_OR_DATA:Mn,MUSTACHE_EXPR:yn,TMPLIT_EXPR:wn});const pt={element:1,text:3,progressingInstruction:7,comment:8,document:9},Dn=function(){return typeof window>"u"?null:window},In=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null;const s="data-tt-policy-suffix";e&&e.hasAttribute(s)&&(n=e.getAttribute(s));const i="dompurify"+(n?"#"+n:"");try{return t.createPolicy(i,{createHTML(c){return c},createScriptURL(c){return c}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Oe=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ce(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Dn();const t=f=>Ce(f);if(t.version="3.3.1",t.removed=[],!r||!r.document||r.document.nodeType!==pt.document||!r.Element)return t.isSupported=!1,t;let{document:e}=r;const n=e,s=n.currentScript,{DocumentFragment:i,HTMLTemplateElement:c,Node:u,Element:p,NodeFilter:h,NamedNodeMap:m=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:y,DOMParser:V,trustedTypes:W}=r,X=p.prototype,Xn=ut(X,"cloneNode"),qn=ut(X,"remove"),Kn=ut(X,"nextSibling"),Zn=ut(X,"childNodes"),It=ut(X,"parentNode");if(typeof c=="function"){const f=e.createElement("template");f.content&&f.content.ownerDocument&&(e=f.content.ownerDocument)}let I,Et="";const{implementation:ee,createNodeIterator:Jn,createDocumentFragment:Qn,getElementsByTagName:to}=e,{importNode:eo}=n;let P=Oe();t.isSupported=typeof g=="function"&&typeof It=="function"&&ee&&ee.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ne,ERB_EXPR:oe,TMPLIT_EXPR:se,DATA_ATTR:no,ARIA_ATTR:oo,IS_SCRIPT_OR_DATA:so,ATTR_WHITESPACE:He,CUSTOM_ELEMENT:io}=we;let{IS_ALLOWED_URI:ze}=we,S=null;const $e=d({},[...Ae,...jt,...Yt,...Vt,..._e]);let R=null;const We=d({},[...be,...Xt,...Se,...Rt]);let A=Object.seal(zt(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}})),gt=null,ie=null;const tt=Object.seal(zt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ge=!0,re=!0,Be=!1,je=!0,et=!1,Pt=!0,Z=!1,ae=!1,ce=!1,nt=!1,vt=!1,xt=!1,Ye=!0,Ve=!1;const ro="user-content-";let le=!0,At=!1,ot={},z=null;const fe=d({},["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 Xe=null;const qe=d({},["audio","video","img","source","image","track"]);let ue=null;const Ke=d({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),kt="http://www.w3.org/1998/Math/MathML",Ft="http://www.w3.org/2000/svg",G="http://www.w3.org/1999/xhtml";let st=G,pe=!1,he=null;const ao=d({},[kt,Ft,G],Gt);let Ut=d({},["mi","mo","mn","ms","mtext"]),Ht=d({},["annotation-xml"]);const co=d({},["title","style","font","a","script"]);let _t=null;const lo=["application/xhtml+xml","text/html"],fo="text/html";let b=null,it=null;const uo=e.createElement("form"),Ze=function(o){return o instanceof RegExp||o instanceof Function},me=function(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(it&&it===o)){if((!o||typeof o!="object")&&(o={}),o=U(o),_t=lo.indexOf(o.PARSER_MEDIA_TYPE)===-1?fo:o.PARSER_MEDIA_TYPE,b=_t==="application/xhtml+xml"?Gt:yt,S=k(o,"ALLOWED_TAGS")?d({},o.ALLOWED_TAGS,b):$e,R=k(o,"ALLOWED_ATTR")?d({},o.ALLOWED_ATTR,b):We,he=k(o,"ALLOWED_NAMESPACES")?d({},o.ALLOWED_NAMESPACES,Gt):ao,ue=k(o,"ADD_URI_SAFE_ATTR")?d(U(Ke),o.ADD_URI_SAFE_ATTR,b):Ke,Xe=k(o,"ADD_DATA_URI_TAGS")?d(U(qe),o.ADD_DATA_URI_TAGS,b):qe,z=k(o,"FORBID_CONTENTS")?d({},o.FORBID_CONTENTS,b):fe,gt=k(o,"FORBID_TAGS")?d({},o.FORBID_TAGS,b):U({}),ie=k(o,"FORBID_ATTR")?d({},o.FORBID_ATTR,b):U({}),ot=k(o,"USE_PROFILES")?o.USE_PROFILES:!1,Ge=o.ALLOW_ARIA_ATTR!==!1,re=o.ALLOW_DATA_ATTR!==!1,Be=o.ALLOW_UNKNOWN_PROTOCOLS||!1,je=o.ALLOW_SELF_CLOSE_IN_ATTR!==!1,et=o.SAFE_FOR_TEMPLATES||!1,Pt=o.SAFE_FOR_XML!==!1,Z=o.WHOLE_DOCUMENT||!1,nt=o.RETURN_DOM||!1,vt=o.RETURN_DOM_FRAGMENT||!1,xt=o.RETURN_TRUSTED_TYPE||!1,ce=o.FORCE_BODY||!1,Ye=o.SANITIZE_DOM!==!1,Ve=o.SANITIZE_NAMED_PROPS||!1,le=o.KEEP_CONTENT!==!1,At=o.IN_PLACE||!1,ze=o.ALLOWED_URI_REGEXP||ye,st=o.NAMESPACE||G,Ut=o.MATHML_TEXT_INTEGRATION_POINTS||Ut,Ht=o.HTML_INTEGRATION_POINTS||Ht,A=o.CUSTOM_ELEMENT_HANDLING||{},o.CUSTOM_ELEMENT_HANDLING&&Ze(o.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(A.tagNameCheck=o.CUSTOM_ELEMENT_HANDLING.tagNameCheck),o.CUSTOM_ELEMENT_HANDLING&&Ze(o.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(A.attributeNameCheck=o.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),o.CUSTOM_ELEMENT_HANDLING&&typeof o.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(A.allowCustomizedBuiltInElements=o.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),et&&(re=!1),vt&&(nt=!0),ot&&(S=d({},_e),R=[],ot.html===!0&&(d(S,Ae),d(R,be)),ot.svg===!0&&(d(S,jt),d(R,Xt),d(R,Rt)),ot.svgFilters===!0&&(d(S,Yt),d(R,Xt),d(R,Rt)),ot.mathMl===!0&&(d(S,Vt),d(R,Se),d(R,Rt))),o.ADD_TAGS&&(typeof o.ADD_TAGS=="function"?tt.tagCheck=o.ADD_TAGS:(S===$e&&(S=U(S)),d(S,o.ADD_TAGS,b))),o.ADD_ATTR&&(typeof o.ADD_ATTR=="function"?tt.attributeCheck=o.ADD_ATTR:(R===We&&(R=U(R)),d(R,o.ADD_ATTR,b))),o.ADD_URI_SAFE_ATTR&&d(ue,o.ADD_URI_SAFE_ATTR,b),o.FORBID_CONTENTS&&(z===fe&&(z=U(z)),d(z,o.FORBID_CONTENTS,b)),o.ADD_FORBID_CONTENTS&&(z===fe&&(z=U(z)),d(z,o.ADD_FORBID_CONTENTS,b)),le&&(S["#text"]=!0),Z&&d(S,["html","head","body"]),S.table&&(d(S,["tbody"]),delete gt.tbody),o.TRUSTED_TYPES_POLICY){if(typeof o.TRUSTED_TYPES_POLICY.createHTML!="function")throw ft('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof o.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ft('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');I=o.TRUSTED_TYPES_POLICY,Et=I.createHTML("")}else I===void 0&&(I=In(W,s)),I!==null&&typeof Et=="string"&&(Et=I.createHTML(""));N&&N(o),it=o}},Je=d({},[...jt,...Yt,...bn]),Qe=d({},[...Vt,...Sn]),po=function(o){let a=It(o);(!a||!a.tagName)&&(a={namespaceURI:st,tagName:"template"});const l=yt(o.tagName),E=yt(a.tagName);return he[o.namespaceURI]?o.namespaceURI===Ft?a.namespaceURI===G?l==="svg":a.namespaceURI===kt?l==="svg"&&(E==="annotation-xml"||Ut[E]):!!Je[l]:o.namespaceURI===kt?a.namespaceURI===G?l==="math":a.namespaceURI===Ft?l==="math"&&Ht[E]:!!Qe[l]:o.namespaceURI===G?a.namespaceURI===Ft&&!Ht[E]||a.namespaceURI===kt&&!Ut[E]?!1:!Qe[l]&&(co[l]||!Je[l]):!!(_t==="application/xhtml+xml"&&he[o.namespaceURI]):!1},$=function(o){ct(t.removed,{element:o});try{It(o).removeChild(o)}catch{qn(o)}},J=function(o,a){try{ct(t.removed,{attribute:a.getAttributeNode(o),from:a})}catch{ct(t.removed,{attribute:null,from:a})}if(a.removeAttribute(o),o==="is")if(nt||vt)try{$(a)}catch{}else try{a.setAttribute(o,"")}catch{}},tn=function(o){let a=null,l=null;if(ce)o="<remove></remove>"+o;else{const _=Bt(o,/^[\r\n\t ]+/);l=_&&_[0]}_t==="application/xhtml+xml"&&st===G&&(o='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+o+"</body></html>");const E=I?I.createHTML(o):o;if(st===G)try{a=new V().parseFromString(E,_t)}catch{}if(!a||!a.documentElement){a=ee.createDocument(st,"template",null);try{a.documentElement.innerHTML=pe?Et:E}catch{}}const C=a.body||a.documentElement;return o&&l&&C.insertBefore(e.createTextNode(l),C.childNodes[0]||null),st===G?to.call(a,Z?"html":"body")[0]:Z?a.documentElement:C},en=function(o){return Jn.call(o.ownerDocument||o,o,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},de=function(o){return o instanceof y&&(typeof o.nodeName!="string"||typeof o.textContent!="string"||typeof o.removeChild!="function"||!(o.attributes instanceof m)||typeof o.removeAttribute!="function"||typeof o.setAttribute!="function"||typeof o.namespaceURI!="string"||typeof o.insertBefore!="function"||typeof o.hasChildNodes!="function")},nn=function(o){return typeof u=="function"&&o instanceof u};function B(f,o,a){St(f,l=>{l.call(t,o,a,it)})}const on=function(o){let a=null;if(B(P.beforeSanitizeElements,o,null),de(o))return $(o),!0;const l=b(o.nodeName);if(B(P.uponSanitizeElement,o,{tagName:l,allowedTags:S}),Pt&&o.hasChildNodes()&&!nn(o.firstElementChild)&&L(/<[/\w!]/g,o.innerHTML)&&L(/<[/\w!]/g,o.textContent)||o.nodeType===pt.progressingInstruction||Pt&&o.nodeType===pt.comment&&L(/<[/\w]/g,o.data))return $(o),!0;if(!(tt.tagCheck instanceof Function&&tt.tagCheck(l))&&(!S[l]||gt[l])){if(!gt[l]&&rn(l)&&(A.tagNameCheck instanceof RegExp&&L(A.tagNameCheck,l)||A.tagNameCheck instanceof Function&&A.tagNameCheck(l)))return!1;if(le&&!z[l]){const E=It(o)||o.parentNode,C=Zn(o)||o.childNodes;if(C&&E){const _=C.length;for(let v=_-1;v>=0;--v){const j=Xn(C[v],!0);j.__removalCount=(o.__removalCount||0)+1,E.insertBefore(j,Kn(o))}}}return $(o),!0}return o instanceof p&&!po(o)||(l==="noscript"||l==="noembed"||l==="noframes")&&L(/<\/no(script|embed|frames)/i,o.innerHTML)?($(o),!0):(et&&o.nodeType===pt.text&&(a=o.textContent,St([ne,oe,se],E=>{a=lt(a,E," ")}),o.textContent!==a&&(ct(t.removed,{element:o.cloneNode()}),o.textContent=a)),B(P.afterSanitizeElements,o,null),!1)},sn=function(o,a,l){if(Ye&&(a==="id"||a==="name")&&(l in e||l in uo))return!1;if(!(re&&!ie[a]&&L(no,a))){if(!(Ge&&L(oo,a))){if(!(tt.attributeCheck instanceof Function&&tt.attributeCheck(a,o))){if(!R[a]||ie[a]){if(!(rn(o)&&(A.tagNameCheck instanceof RegExp&&L(A.tagNameCheck,o)||A.tagNameCheck instanceof Function&&A.tagNameCheck(o))&&(A.attributeNameCheck instanceof RegExp&&L(A.attributeNameCheck,a)||A.attributeNameCheck instanceof Function&&A.attributeNameCheck(a,o))||a==="is"&&A.allowCustomizedBuiltInElements&&(A.tagNameCheck instanceof RegExp&&L(A.tagNameCheck,l)||A.tagNameCheck instanceof Function&&A.tagNameCheck(l))))return!1}else if(!ue[a]){if(!L(ze,lt(l,He,""))){if(!((a==="src"||a==="xlink:href"||a==="href")&&o!=="script"&&En(l,"data:")===0&&Xe[o])){if(!(Be&&!L(so,lt(l,He,"")))){if(l)return!1}}}}}}}return!0},rn=function(o){return o!=="annotation-xml"&&Bt(o,io)},an=function(o){B(P.beforeSanitizeAttributes,o,null);const{attributes:a}=o;if(!a||de(o))return;const l={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:R,forceKeepAttr:void 0};let E=a.length;for(;E--;){const C=a[E],{name:_,namespaceURI:v,value:j}=C,rt=b(_),Te=j;let w=_==="value"?Te:gn(Te);if(l.attrName=rt,l.attrValue=w,l.keepAttr=!0,l.forceKeepAttr=void 0,B(P.uponSanitizeAttribute,o,l),w=l.attrValue,Ve&&(rt==="id"||rt==="name")&&(J(_,o),w=ro+w),Pt&&L(/((--!?|])>)|<\/(style|title|textarea)/i,w)){J(_,o);continue}if(rt==="attributename"&&Bt(w,"href")){J(_,o);continue}if(l.forceKeepAttr)continue;if(!l.keepAttr){J(_,o);continue}if(!je&&L(/\/>/i,w)){J(_,o);continue}et&&St([ne,oe,se],ln=>{w=lt(w,ln," ")});const cn=b(o.nodeName);if(!sn(cn,rt,w)){J(_,o);continue}if(I&&typeof W=="object"&&typeof W.getAttributeType=="function"&&!v)switch(W.getAttributeType(cn,rt)){case"TrustedHTML":{w=I.createHTML(w);break}case"TrustedScriptURL":{w=I.createScriptURL(w);break}}if(w!==Te)try{v?o.setAttributeNS(v,_,w):o.setAttribute(_,w),de(o)?$(o):ge(t.removed)}catch{J(_,o)}}B(P.afterSanitizeAttributes,o,null)},ho=function f(o){let a=null;const l=en(o);for(B(P.beforeSanitizeShadowDOM,o,null);a=l.nextNode();)B(P.uponSanitizeShadowNode,a,null),on(a),an(a),a.content instanceof i&&f(a.content);B(P.afterSanitizeShadowDOM,o,null)};return t.sanitize=function(f){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=null,l=null,E=null,C=null;if(pe=!f,pe&&(f="<!-->"),typeof f!="string"&&!nn(f))if(typeof f.toString=="function"){if(f=f.toString(),typeof f!="string")throw ft("dirty is not a string, aborting")}else throw ft("toString is not a function");if(!t.isSupported)return f;if(ae||me(o),t.removed=[],typeof f=="string"&&(At=!1),At){if(f.nodeName){const j=b(f.nodeName);if(!S[j]||gt[j])throw ft("root node is forbidden and cannot be sanitized in-place")}}else if(f instanceof u)a=tn("<!---->"),l=a.ownerDocument.importNode(f,!0),l.nodeType===pt.element&&l.nodeName==="BODY"||l.nodeName==="HTML"?a=l:a.appendChild(l);else{if(!nt&&!et&&!Z&&f.indexOf("<")===-1)return I&&xt?I.createHTML(f):f;if(a=tn(f),!a)return nt?null:xt?Et:""}a&&ce&&$(a.firstChild);const _=en(At?f:a);for(;E=_.nextNode();)on(E),an(E),E.content instanceof i&&ho(E.content);if(At)return f;if(nt){if(vt)for(C=Qn.call(a.ownerDocument);a.firstChild;)C.appendChild(a.firstChild);else C=a;return(R.shadowroot||R.shadowrootmode)&&(C=eo.call(n,C,!0)),C}let v=Z?a.outerHTML:a.innerHTML;return Z&&S["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&L(Re,a.ownerDocument.doctype.name)&&(v="<!DOCTYPE "+a.ownerDocument.doctype.name+`>
2
- `+v),et&&St([ne,oe,se],j=>{v=lt(v,j," ")}),I&&xt?I.createHTML(v):v},t.setConfig=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};me(f),ae=!0},t.clearConfig=function(){it=null,ae=!1},t.isValidAttribute=function(f,o,a){it||me({});const l=b(f),E=b(o);return sn(l,E,a)},t.addHook=function(f,o){typeof o=="function"&&ct(P[f],o)},t.removeHook=function(f,o){if(o!==void 0){const a=dn(P[f],o);return a===-1?void 0:Tn(P[f],a,1)[0]}return ge(P[f])},t.removeHooks=function(f){P[f]=[]},t.removeAllHooks=function(){P=Oe()},t}var Me=Ce();function Ne(r,t){let e=r;for(const n of t.split("."))e=e[n];return e}function Pn(r,t,e){const n=t.split("."),s=n.length-1;let i=r;n.forEach((c,u)=>{u===s?i[c]=e:i=i[c]})}function Le(r,t,e=""){const n=new WeakMap,s={get(i,c){const u=Reflect.get(i,c);if(u===null||typeof u!="object")return u;const p=n.get(u);if(p)return p;const h=e?`${e}.${c}`:c,m=Le(u,t,h);return n.set(u,m),m},set(i,c,u){const p=Reflect.get(i,c);if(p!==u){Reflect.set(i,c,u);const h=e?`${e}.${c}`:c;t(h,p,u)}return!0}};return new Proxy(r,s)}function De(r){const t={};for(const[e,n]of Object.entries(r)){const s=typeof n=="object"&&n!==null;t[e]=s?De(n):n}return t}const wt=typeof window<"u"&&typeof window.document<"u";let Ie=class extends Error{};const Q=class Q{constructor(t,e,n){q(this,Dt);q(this,Lt,Symbol("objectId"));q(this,H,[]);q(this,dt);q(this,Tt);q(this,Y);if(!t)throw new Ie("name cannot be empty");if(O(Q,K).has(t))throw new Ie(`WrecState with name "${t}" already exists`);if(at(this,dt,t),at(this,Tt,e),at(this,Y,Le({},un(this,Dt,pn).bind(this))),e&&wt){const s=sessionStorage.getItem("wrec-state-"+t),i=s?JSON.parse(s):void 0;i&&(n=i)}if(n)for(const[s,i]of Object.entries(n))this.addProperty(s,i);O(Q,K).set(t,this)}static get(t){return O(this,K).get(t)}addListener(t,e={}){const n=O(this,H).find(s=>s.listenerRef.deref()===t);if(n){const{propertyMap:s}=n;for(const[i,c]of Object.entries(e))s[i]=c}else O(this,H).push({listenerRef:new WeakRef(t),propertyMap:e})}addProperty(t,e){Object.defineProperty(this,t,{enumerable:!0,get(){return O(this,Y)[t]},set(n){O(this,Y)[t]=n}}),O(this,Y)[t]=e}get id(){return O(this,Lt)}log(){console.log("WrecState:",O(this,dt));for(const[t,e]of Object.entries(O(this,Y)))console.log(` ${t} = ${JSON.stringify(e)}`)}removeListener(t){at(this,H,O(this,H).filter(e=>e.listenerRef.deref()!==t))}};K=new WeakMap,Lt=new WeakMap,H=new WeakMap,dt=new WeakMap,Tt=new WeakMap,Y=new WeakMap,Dt=new WeakSet,pn=function(t,e,n){const s=new Set;for(const i of O(this,H)){const c=i.listenerRef.deref();if(!c)s.add(i);else if(wt&&c instanceof HTMLElement&&!c.isConnected)s.add(i);else{const{propertyMap:u}=i,p=Object.keys(u);(p.length===0||p.includes(t))&&c.changed(t,u[t],n,e,this)}}at(this,H,O(this,H).filter(i=>!s.has(i)))},q(Q,K,new Map),wt&&window.addEventListener("beforeunload",()=>{for(const[t,e]of O(Q,K).entries())if(O(e,Tt)){const n=De(e);sessionStorage.setItem("wrec-state-"+t,JSON.stringify(n))}});let Ot=Q;wt&&process.env.NODE_ENV==="development"&&(window.WrecState=Ot);const vn=new Set(["onblur","onchange","onclick","onfocus","oninput","onkeydown","onreset","onsubmit"]);Me.addHook("uponSanitizeAttribute",(r,t)=>{const{attrName:e}=t,n=e.toLowerCase();vn.has(n)&&(t.forceKeepAttr=!0)});class Ct extends Error{}const xn=/([a-zA-Z-]+)\s*:\s*([^;}]+)/g,Pe="a-zA-Z_$",kn=Pe+"0-9",ht=`[${Pe}][${kn}]*`,Fn=/<!--\s*(.*?)\s*-->/,Un=/<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g,qt=new RegExp(`^this\\.${ht}$`),Kt=new RegExp(`this\\.${ht}(\\.${ht})*`,"g"),ve=new RegExp(`this\\.${ht}(\\.${ht})*`),Hn=new Set(["class","style"]),xe=5;function zn(r){return r instanceof HTMLButtonElement||r instanceof HTMLFieldSetElement||r instanceof HTMLInputElement||r instanceof HTMLSelectElement||r instanceof HTMLTextAreaElement||r instanceof F}function $n(r,t,e){const n=document.createElement(r);if(t)for(const[s,i]of Object.entries(t))n.setAttribute(s,i);return e&&(n.innerHTML=e),n}const Wn=r=>r===String?"":r===Number?0:r===Boolean?!1:r===Array?[]:r===Object?{}:void 0;function Mt(r){const t=[];let e=r.firstElementChild;for(;e;)t.push(e),e.shadowRoot&&t.push(...Mt(e.shadowRoot)),e.firstElementChild&&t.push(...Mt(e)),e=e.nextElementSibling;return t}const Nt=r=>r.substring(xe).split(".")[0];function ke(r,t){let e=r[0];return t.forEach((n,s)=>{e+=n+r[s+1]}),e}function Zt(r){const t=typeof r;return t==="string"||t==="number"||t==="boolean"}function mt(r){return r.localName==="textarea"}function Jt(r){const{localName:t}=r;return t==="input"||t==="select"}const Gn=r=>r.replace(/<!--[\s\S]*?-->/g,"");function Fe(r,t,e,n){return r.slice(0,t)+n+r.slice(t+e)}function Bn(r){let t=r.trim(),e=null;/^\s*<tr[\s>]/i.test(t)?(t=`<table><tbody>${t}</tbody></table>`,e="tbody"):/^\s*<(td|th)[\s>]/i.test(t)?(t=`<table><tbody><tr>${t}</tr></tbody></table>`,e="tr"):/^\s*<option[\s>]/i.test(t)?(t=`<select>${t}</select>`,e="select"):/^\s*<col[\s>]/i.test(t)&&(t=`<table><colgroup>${t}</colgroup></table>`,e="colgroup");const n=Me.sanitize(t,{ADD_TAGS:["#comment"],ALLOW_UNKNOWN_PROTOCOLS:!0,RETURN_DOM_FRAGMENT:!0});if(e){const s=n.querySelector(e);if(s)return s.childNodes}return n.childNodes}function Qt(r){const t=Number(r);if(isNaN(t))throw new Ct(`can't convert "${r}" to a number`);return t}function Ue(r,t,e){const[n,s]=t.split(":");if(Zt(e))if(typeof e=="boolean"){e?r.setAttribute(n,n):r.removeAttribute(n);const i=F.getPropName(n);r[i]=e}else{const i=r.getAttribute(t),c=String(e);i!==c&&(r.setAttribute(n,c),n==="value"&&Jt(r)&&(r.value=c))}else{const i=F.getPropName(t);r[i]=e}}function te(r,t,e){const[n,s]=t.split(":");r instanceof CSSStyleRule?r.style.setProperty(n,e):(Ue(r,n,e),n==="value"&&Jt(r)&&(r.value=e))}async function jn(r){const t=new Set;for(const n of Mt(r.content)){const{localName:s}=n;s.includes("-")&&t.add(s)}function e(n){return new Promise((s,i)=>{setTimeout(()=>{const c=`custom element <${n}> not defined`;i(new Error(c))},1e3)})}return Promise.all([...t].map(async n=>Promise.race([customElements.whenDefined(n),e(n)])))}class F extends HTMLElement{static attrToPropMap=new Map;static propToAttrMap=new Map;static css="";static elementName="";static formAssociated=!1;static html="";static properties;static propToComputedMap;static propToExprsMap;static template=null;#t=this.constructor;#n=new Map;#c={};#s;#l={};#f=null;#u=new Map;static define(t){this.elementName=t,customElements.define(t,this)}constructor(){super(),this.attachShadow({mode:"open"});const t=this.#t;t.attrToPropMap||(t.attrToPropMap=new Map),t.properties||(t.properties={}),t.propToAttrMap||(t.propToExprsMap=new Map),t.propToComputedMap||(t.propToComputedMap=new Map),t.propToExprsMap||(t.propToExprsMap=new Map)}attributeChangedCallback(t,e,n){t==="disabled"&&this.#h();const s=F.getPropName(t);if(this.#i(s)){const i=this.#A(s,String(n));this[s]=i;const c=this.#c[s];c&&this.setFormValue(c,String(i)),this.propertyChangedCallback(s,e,n)}}async#S(){const t=this.#t;let{template:e}=t;if(!e){e=t.template=document.createElement("template");let n=`<style>
1
+ (function(T,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(T=typeof globalThis<"u"?globalThis:T||self,g(T.wrec={}))})(this,(function(T){"use strict";var fn=T=>{throw TypeError(T)};var Ee=(T,g,M)=>g.has(T)||fn("Cannot "+M);var O=(T,g,M)=>(Ee(T,g,"read from private field"),M?M.call(T):g.get(T)),q=(T,g,M)=>g.has(T)?fn("Cannot add the same private member more than once"):g instanceof WeakSet?g.add(T):g.set(T,M),ct=(T,g,M,St)=>(Ee(T,g,"write to private field"),St?St.call(T,M):g.set(T,M),M),un=(T,g,M)=>(Ee(T,g,"access private method"),M);var K,Nt,H,Tt,Et,Y,Dt,pn;const{entries:g,setPrototypeOf:M,isFrozen:St,getPrototypeOf:hn,getOwnPropertyDescriptor:mn}=Object;let{freeze:L,seal:x,create:zt}=Object,{apply:$t,construct:Wt}=typeof Reflect<"u"&&Reflect;L||(L=function(t){return t}),x||(x=function(t){return t}),$t||($t=function(t,e){for(var n=arguments.length,s=new Array(n>2?n-2:0),i=2;i<n;i++)s[i-2]=arguments[i];return t.apply(e,s)}),Wt||(Wt=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),s=1;s<e;s++)n[s-1]=arguments[s];return new t(...n)});const yt=D(Array.prototype.forEach),dn=D(Array.prototype.lastIndexOf),ge=D(Array.prototype.pop),lt=D(Array.prototype.push),Tn=D(Array.prototype.splice),Rt=D(String.prototype.toLowerCase),Gt=D(String.prototype.toString),Bt=D(String.prototype.match),ft=D(String.prototype.replace),En=D(String.prototype.indexOf),gn=D(String.prototype.trim),k=D(Object.prototype.hasOwnProperty),N=D(RegExp.prototype.test),ut=An(TypeError);function D(r){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var e=arguments.length,n=new Array(e>1?e-1:0),s=1;s<e;s++)n[s-1]=arguments[s];return $t(r,t,n)}}function An(r){return function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return Wt(r,e)}}function d(r,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Rt;M&&M(r,null);let n=t.length;for(;n--;){let s=t[n];if(typeof s=="string"){const i=e(s);i!==s&&(St(t)||(t[n]=i),s=i)}r[s]=!0}return r}function _n(r){for(let t=0;t<r.length;t++)k(r,t)||(r[t]=null);return r}function U(r){const t=zt(null);for(const[e,n]of g(r))k(r,e)&&(Array.isArray(n)?t[e]=_n(n):n&&typeof n=="object"&&n.constructor===Object?t[e]=U(n):t[e]=n);return t}function pt(r,t){for(;r!==null;){const n=mn(r,t);if(n){if(n.get)return D(n.get);if(typeof n.value=="function")return D(n.value)}r=hn(r)}function e(){return null}return e}const Ae=L(["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"]),jt=L(["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"]),Yt=L(["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"]),bn=L(["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"]),Vt=L(["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"]),Sn=L(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),_e=L(["#text"]),be=L(["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"]),Xt=L(["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"]),Se=L(["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"]),wt=L(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),yn=x(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Rn=x(/<%[\w\W]*|[\w\W]*%>/gm),wn=x(/\$\{[\w\W]*/gm),On=x(/^data-[\-\w.\u00B7-\uFFFF]+$/),Cn=x(/^aria-[\-\w]+$/),ye=x(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Mn=x(/^(?:\w+script|data):/i),Ln=x(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Re=x(/^html$/i),Nn=x(/^[a-z][.\w]*(-[.\w]+)+$/i);var we=Object.freeze({__proto__:null,ARIA_ATTR:Cn,ATTR_WHITESPACE:Ln,CUSTOM_ELEMENT:Nn,DATA_ATTR:On,DOCTYPE_NAME:Re,ERB_EXPR:Rn,IS_ALLOWED_URI:ye,IS_SCRIPT_OR_DATA:Mn,MUSTACHE_EXPR:yn,TMPLIT_EXPR:wn});const ht={element:1,text:3,progressingInstruction:7,comment:8,document:9},Dn=function(){return typeof window>"u"?null:window},In=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null;const s="data-tt-policy-suffix";e&&e.hasAttribute(s)&&(n=e.getAttribute(s));const i="dompurify"+(n?"#"+n:"");try{return t.createPolicy(i,{createHTML(c){return c},createScriptURL(c){return c}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Oe=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ce(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Dn();const t=f=>Ce(f);if(t.version="3.3.1",t.removed=[],!r||!r.document||r.document.nodeType!==ht.document||!r.Element)return t.isSupported=!1,t;let{document:e}=r;const n=e,s=n.currentScript,{DocumentFragment:i,HTMLTemplateElement:c,Node:u,Element:p,NodeFilter:h,NamedNodeMap:m=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:y,DOMParser:V,trustedTypes:W}=r,X=p.prototype,Xn=pt(X,"cloneNode"),qn=pt(X,"remove"),Kn=pt(X,"nextSibling"),Zn=pt(X,"childNodes"),It=pt(X,"parentNode");if(typeof c=="function"){const f=e.createElement("template");f.content&&f.content.ownerDocument&&(e=f.content.ownerDocument)}let I,gt="";const{implementation:ee,createNodeIterator:Jn,createDocumentFragment:Qn,getElementsByTagName:to}=e,{importNode:eo}=n;let P=Oe();t.isSupported=typeof g=="function"&&typeof It=="function"&&ee&&ee.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ne,ERB_EXPR:oe,TMPLIT_EXPR:se,DATA_ATTR:no,ARIA_ATTR:oo,IS_SCRIPT_OR_DATA:so,ATTR_WHITESPACE:He,CUSTOM_ELEMENT:io}=we;let{IS_ALLOWED_URI:ze}=we,S=null;const $e=d({},[...Ae,...jt,...Yt,...Vt,..._e]);let R=null;const We=d({},[...be,...Xt,...Se,...wt]);let A=Object.seal(zt(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}})),At=null,ie=null;const et=Object.seal(zt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ge=!0,re=!0,Be=!1,je=!0,nt=!1,Pt=!0,Z=!1,ae=!1,ce=!1,ot=!1,vt=!1,xt=!1,Ye=!0,Ve=!1;const ro="user-content-";let le=!0,_t=!1,st={},z=null;const fe=d({},["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 Xe=null;const qe=d({},["audio","video","img","source","image","track"]);let ue=null;const Ke=d({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),kt="http://www.w3.org/1998/Math/MathML",Ft="http://www.w3.org/2000/svg",G="http://www.w3.org/1999/xhtml";let it=G,pe=!1,he=null;const ao=d({},[kt,Ft,G],Gt);let Ut=d({},["mi","mo","mn","ms","mtext"]),Ht=d({},["annotation-xml"]);const co=d({},["title","style","font","a","script"]);let bt=null;const lo=["application/xhtml+xml","text/html"],fo="text/html";let b=null,rt=null;const uo=e.createElement("form"),Ze=function(o){return o instanceof RegExp||o instanceof Function},me=function(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(rt&&rt===o)){if((!o||typeof o!="object")&&(o={}),o=U(o),bt=lo.indexOf(o.PARSER_MEDIA_TYPE)===-1?fo:o.PARSER_MEDIA_TYPE,b=bt==="application/xhtml+xml"?Gt:Rt,S=k(o,"ALLOWED_TAGS")?d({},o.ALLOWED_TAGS,b):$e,R=k(o,"ALLOWED_ATTR")?d({},o.ALLOWED_ATTR,b):We,he=k(o,"ALLOWED_NAMESPACES")?d({},o.ALLOWED_NAMESPACES,Gt):ao,ue=k(o,"ADD_URI_SAFE_ATTR")?d(U(Ke),o.ADD_URI_SAFE_ATTR,b):Ke,Xe=k(o,"ADD_DATA_URI_TAGS")?d(U(qe),o.ADD_DATA_URI_TAGS,b):qe,z=k(o,"FORBID_CONTENTS")?d({},o.FORBID_CONTENTS,b):fe,At=k(o,"FORBID_TAGS")?d({},o.FORBID_TAGS,b):U({}),ie=k(o,"FORBID_ATTR")?d({},o.FORBID_ATTR,b):U({}),st=k(o,"USE_PROFILES")?o.USE_PROFILES:!1,Ge=o.ALLOW_ARIA_ATTR!==!1,re=o.ALLOW_DATA_ATTR!==!1,Be=o.ALLOW_UNKNOWN_PROTOCOLS||!1,je=o.ALLOW_SELF_CLOSE_IN_ATTR!==!1,nt=o.SAFE_FOR_TEMPLATES||!1,Pt=o.SAFE_FOR_XML!==!1,Z=o.WHOLE_DOCUMENT||!1,ot=o.RETURN_DOM||!1,vt=o.RETURN_DOM_FRAGMENT||!1,xt=o.RETURN_TRUSTED_TYPE||!1,ce=o.FORCE_BODY||!1,Ye=o.SANITIZE_DOM!==!1,Ve=o.SANITIZE_NAMED_PROPS||!1,le=o.KEEP_CONTENT!==!1,_t=o.IN_PLACE||!1,ze=o.ALLOWED_URI_REGEXP||ye,it=o.NAMESPACE||G,Ut=o.MATHML_TEXT_INTEGRATION_POINTS||Ut,Ht=o.HTML_INTEGRATION_POINTS||Ht,A=o.CUSTOM_ELEMENT_HANDLING||{},o.CUSTOM_ELEMENT_HANDLING&&Ze(o.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(A.tagNameCheck=o.CUSTOM_ELEMENT_HANDLING.tagNameCheck),o.CUSTOM_ELEMENT_HANDLING&&Ze(o.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(A.attributeNameCheck=o.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),o.CUSTOM_ELEMENT_HANDLING&&typeof o.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(A.allowCustomizedBuiltInElements=o.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),nt&&(re=!1),vt&&(ot=!0),st&&(S=d({},_e),R=[],st.html===!0&&(d(S,Ae),d(R,be)),st.svg===!0&&(d(S,jt),d(R,Xt),d(R,wt)),st.svgFilters===!0&&(d(S,Yt),d(R,Xt),d(R,wt)),st.mathMl===!0&&(d(S,Vt),d(R,Se),d(R,wt))),o.ADD_TAGS&&(typeof o.ADD_TAGS=="function"?et.tagCheck=o.ADD_TAGS:(S===$e&&(S=U(S)),d(S,o.ADD_TAGS,b))),o.ADD_ATTR&&(typeof o.ADD_ATTR=="function"?et.attributeCheck=o.ADD_ATTR:(R===We&&(R=U(R)),d(R,o.ADD_ATTR,b))),o.ADD_URI_SAFE_ATTR&&d(ue,o.ADD_URI_SAFE_ATTR,b),o.FORBID_CONTENTS&&(z===fe&&(z=U(z)),d(z,o.FORBID_CONTENTS,b)),o.ADD_FORBID_CONTENTS&&(z===fe&&(z=U(z)),d(z,o.ADD_FORBID_CONTENTS,b)),le&&(S["#text"]=!0),Z&&d(S,["html","head","body"]),S.table&&(d(S,["tbody"]),delete At.tbody),o.TRUSTED_TYPES_POLICY){if(typeof o.TRUSTED_TYPES_POLICY.createHTML!="function")throw ut('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof o.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw ut('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');I=o.TRUSTED_TYPES_POLICY,gt=I.createHTML("")}else I===void 0&&(I=In(W,s)),I!==null&&typeof gt=="string"&&(gt=I.createHTML(""));L&&L(o),rt=o}},Je=d({},[...jt,...Yt,...bn]),Qe=d({},[...Vt,...Sn]),po=function(o){let a=It(o);(!a||!a.tagName)&&(a={namespaceURI:it,tagName:"template"});const l=Rt(o.tagName),E=Rt(a.tagName);return he[o.namespaceURI]?o.namespaceURI===Ft?a.namespaceURI===G?l==="svg":a.namespaceURI===kt?l==="svg"&&(E==="annotation-xml"||Ut[E]):!!Je[l]:o.namespaceURI===kt?a.namespaceURI===G?l==="math":a.namespaceURI===Ft?l==="math"&&Ht[E]:!!Qe[l]:o.namespaceURI===G?a.namespaceURI===Ft&&!Ht[E]||a.namespaceURI===kt&&!Ut[E]?!1:!Qe[l]&&(co[l]||!Je[l]):!!(bt==="application/xhtml+xml"&&he[o.namespaceURI]):!1},$=function(o){lt(t.removed,{element:o});try{It(o).removeChild(o)}catch{qn(o)}},J=function(o,a){try{lt(t.removed,{attribute:a.getAttributeNode(o),from:a})}catch{lt(t.removed,{attribute:null,from:a})}if(a.removeAttribute(o),o==="is")if(ot||vt)try{$(a)}catch{}else try{a.setAttribute(o,"")}catch{}},tn=function(o){let a=null,l=null;if(ce)o="<remove></remove>"+o;else{const _=Bt(o,/^[\r\n\t ]+/);l=_&&_[0]}bt==="application/xhtml+xml"&&it===G&&(o='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+o+"</body></html>");const E=I?I.createHTML(o):o;if(it===G)try{a=new V().parseFromString(E,bt)}catch{}if(!a||!a.documentElement){a=ee.createDocument(it,"template",null);try{a.documentElement.innerHTML=pe?gt:E}catch{}}const C=a.body||a.documentElement;return o&&l&&C.insertBefore(e.createTextNode(l),C.childNodes[0]||null),it===G?to.call(a,Z?"html":"body")[0]:Z?a.documentElement:C},en=function(o){return Jn.call(o.ownerDocument||o,o,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},de=function(o){return o instanceof y&&(typeof o.nodeName!="string"||typeof o.textContent!="string"||typeof o.removeChild!="function"||!(o.attributes instanceof m)||typeof o.removeAttribute!="function"||typeof o.setAttribute!="function"||typeof o.namespaceURI!="string"||typeof o.insertBefore!="function"||typeof o.hasChildNodes!="function")},nn=function(o){return typeof u=="function"&&o instanceof u};function B(f,o,a){yt(f,l=>{l.call(t,o,a,rt)})}const on=function(o){let a=null;if(B(P.beforeSanitizeElements,o,null),de(o))return $(o),!0;const l=b(o.nodeName);if(B(P.uponSanitizeElement,o,{tagName:l,allowedTags:S}),Pt&&o.hasChildNodes()&&!nn(o.firstElementChild)&&N(/<[/\w!]/g,o.innerHTML)&&N(/<[/\w!]/g,o.textContent)||o.nodeType===ht.progressingInstruction||Pt&&o.nodeType===ht.comment&&N(/<[/\w]/g,o.data))return $(o),!0;if(!(et.tagCheck instanceof Function&&et.tagCheck(l))&&(!S[l]||At[l])){if(!At[l]&&rn(l)&&(A.tagNameCheck instanceof RegExp&&N(A.tagNameCheck,l)||A.tagNameCheck instanceof Function&&A.tagNameCheck(l)))return!1;if(le&&!z[l]){const E=It(o)||o.parentNode,C=Zn(o)||o.childNodes;if(C&&E){const _=C.length;for(let v=_-1;v>=0;--v){const j=Xn(C[v],!0);j.__removalCount=(o.__removalCount||0)+1,E.insertBefore(j,Kn(o))}}}return $(o),!0}return o instanceof p&&!po(o)||(l==="noscript"||l==="noembed"||l==="noframes")&&N(/<\/no(script|embed|frames)/i,o.innerHTML)?($(o),!0):(nt&&o.nodeType===ht.text&&(a=o.textContent,yt([ne,oe,se],E=>{a=ft(a,E," ")}),o.textContent!==a&&(lt(t.removed,{element:o.cloneNode()}),o.textContent=a)),B(P.afterSanitizeElements,o,null),!1)},sn=function(o,a,l){if(Ye&&(a==="id"||a==="name")&&(l in e||l in uo))return!1;if(!(re&&!ie[a]&&N(no,a))){if(!(Ge&&N(oo,a))){if(!(et.attributeCheck instanceof Function&&et.attributeCheck(a,o))){if(!R[a]||ie[a]){if(!(rn(o)&&(A.tagNameCheck instanceof RegExp&&N(A.tagNameCheck,o)||A.tagNameCheck instanceof Function&&A.tagNameCheck(o))&&(A.attributeNameCheck instanceof RegExp&&N(A.attributeNameCheck,a)||A.attributeNameCheck instanceof Function&&A.attributeNameCheck(a,o))||a==="is"&&A.allowCustomizedBuiltInElements&&(A.tagNameCheck instanceof RegExp&&N(A.tagNameCheck,l)||A.tagNameCheck instanceof Function&&A.tagNameCheck(l))))return!1}else if(!ue[a]){if(!N(ze,ft(l,He,""))){if(!((a==="src"||a==="xlink:href"||a==="href")&&o!=="script"&&En(l,"data:")===0&&Xe[o])){if(!(Be&&!N(so,ft(l,He,"")))){if(l)return!1}}}}}}}return!0},rn=function(o){return o!=="annotation-xml"&&Bt(o,io)},an=function(o){B(P.beforeSanitizeAttributes,o,null);const{attributes:a}=o;if(!a||de(o))return;const l={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:R,forceKeepAttr:void 0};let E=a.length;for(;E--;){const C=a[E],{name:_,namespaceURI:v,value:j}=C,at=b(_),Te=j;let w=_==="value"?Te:gn(Te);if(l.attrName=at,l.attrValue=w,l.keepAttr=!0,l.forceKeepAttr=void 0,B(P.uponSanitizeAttribute,o,l),w=l.attrValue,Ve&&(at==="id"||at==="name")&&(J(_,o),w=ro+w),Pt&&N(/((--!?|])>)|<\/(style|title|textarea)/i,w)){J(_,o);continue}if(at==="attributename"&&Bt(w,"href")){J(_,o);continue}if(l.forceKeepAttr)continue;if(!l.keepAttr){J(_,o);continue}if(!je&&N(/\/>/i,w)){J(_,o);continue}nt&&yt([ne,oe,se],ln=>{w=ft(w,ln," ")});const cn=b(o.nodeName);if(!sn(cn,at,w)){J(_,o);continue}if(I&&typeof W=="object"&&typeof W.getAttributeType=="function"&&!v)switch(W.getAttributeType(cn,at)){case"TrustedHTML":{w=I.createHTML(w);break}case"TrustedScriptURL":{w=I.createScriptURL(w);break}}if(w!==Te)try{v?o.setAttributeNS(v,_,w):o.setAttribute(_,w),de(o)?$(o):ge(t.removed)}catch{J(_,o)}}B(P.afterSanitizeAttributes,o,null)},ho=function f(o){let a=null;const l=en(o);for(B(P.beforeSanitizeShadowDOM,o,null);a=l.nextNode();)B(P.uponSanitizeShadowNode,a,null),on(a),an(a),a.content instanceof i&&f(a.content);B(P.afterSanitizeShadowDOM,o,null)};return t.sanitize=function(f){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=null,l=null,E=null,C=null;if(pe=!f,pe&&(f="<!-->"),typeof f!="string"&&!nn(f))if(typeof f.toString=="function"){if(f=f.toString(),typeof f!="string")throw ut("dirty is not a string, aborting")}else throw ut("toString is not a function");if(!t.isSupported)return f;if(ae||me(o),t.removed=[],typeof f=="string"&&(_t=!1),_t){if(f.nodeName){const j=b(f.nodeName);if(!S[j]||At[j])throw ut("root node is forbidden and cannot be sanitized in-place")}}else if(f instanceof u)a=tn("<!---->"),l=a.ownerDocument.importNode(f,!0),l.nodeType===ht.element&&l.nodeName==="BODY"||l.nodeName==="HTML"?a=l:a.appendChild(l);else{if(!ot&&!nt&&!Z&&f.indexOf("<")===-1)return I&&xt?I.createHTML(f):f;if(a=tn(f),!a)return ot?null:xt?gt:""}a&&ce&&$(a.firstChild);const _=en(_t?f:a);for(;E=_.nextNode();)on(E),an(E),E.content instanceof i&&ho(E.content);if(_t)return f;if(ot){if(vt)for(C=Qn.call(a.ownerDocument);a.firstChild;)C.appendChild(a.firstChild);else C=a;return(R.shadowroot||R.shadowrootmode)&&(C=eo.call(n,C,!0)),C}let v=Z?a.outerHTML:a.innerHTML;return Z&&S["!doctype"]&&a.ownerDocument&&a.ownerDocument.doctype&&a.ownerDocument.doctype.name&&N(Re,a.ownerDocument.doctype.name)&&(v="<!DOCTYPE "+a.ownerDocument.doctype.name+`>
2
+ `+v),nt&&yt([ne,oe,se],j=>{v=ft(v,j," ")}),I&&xt?I.createHTML(v):v},t.setConfig=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};me(f),ae=!0},t.clearConfig=function(){rt=null,ae=!1},t.isValidAttribute=function(f,o,a){rt||me({});const l=b(f),E=b(o);return sn(l,E,a)},t.addHook=function(f,o){typeof o=="function"&&lt(P[f],o)},t.removeHook=function(f,o){if(o!==void 0){const a=dn(P[f],o);return a===-1?void 0:Tn(P[f],a,1)[0]}return ge(P[f])},t.removeHooks=function(f){P[f]=[]},t.removeAllHooks=function(){P=Oe()},t}var Me=Ce();function Le(r,t){let e=r;for(const n of t.split("."))e=e[n];return e}function Pn(r,t,e){const n=t.split("."),s=n.length-1;let i=r;n.forEach((c,u)=>{u===s?i[c]=e:i=i[c]})}function Ne(r,t,e=""){const n=new WeakMap,s={get(i,c){const u=Reflect.get(i,c);if(u===null||typeof u!="object")return u;const p=n.get(u);if(p)return p;const h=e?`${e}.${c}`:c,m=Ne(u,t,h);return n.set(u,m),m},set(i,c,u){const p=Reflect.get(i,c);if(p!==u){Reflect.set(i,c,u);const h=e?`${e}.${c}`:c;t(h,p,u)}return!0}};return new Proxy(r,s)}function De(r){const t={};for(const[e,n]of Object.entries(r)){const s=typeof n=="object"&&n!==null;t[e]=s?De(n):n}return t}const Ot=typeof window<"u"&&typeof window.document<"u";let Ie=class extends Error{};const tt=class tt{constructor(t,e,n){q(this,Dt);q(this,Nt,Symbol("objectId"));q(this,H,[]);q(this,Tt);q(this,Et);q(this,Y);if(!t)throw new Ie("name cannot be empty");if(O(tt,K).has(t))throw new Ie(`WrecState with name "${t}" already exists`);if(ct(this,Tt,t),ct(this,Et,e),ct(this,Y,Ne({},un(this,Dt,pn).bind(this))),e&&Ot){const s=sessionStorage.getItem("wrec-state-"+t),i=s?JSON.parse(s):void 0;i&&(n=i)}if(n)for(const[s,i]of Object.entries(n))this.addProperty(s,i);O(tt,K).set(t,this)}static get(t){return O(this,K).get(t)}addListener(t,e={}){const n=O(this,H).find(s=>s.listenerRef.deref()===t);if(n){const{propertyMap:s}=n;for(const[i,c]of Object.entries(e))s[i]=c}else O(this,H).push({listenerRef:new WeakRef(t),propertyMap:e})}addProperty(t,e){Object.defineProperty(this,t,{enumerable:!0,get(){return O(this,Y)[t]},set(n){O(this,Y)[t]=n}}),O(this,Y)[t]=e}get id(){return O(this,Nt)}log(){console.log("WrecState:",O(this,Tt));for(const[t,e]of Object.entries(O(this,Y)))console.log(` ${t} = ${JSON.stringify(e)}`)}removeListener(t){ct(this,H,O(this,H).filter(e=>e.listenerRef.deref()!==t))}};K=new WeakMap,Nt=new WeakMap,H=new WeakMap,Tt=new WeakMap,Et=new WeakMap,Y=new WeakMap,Dt=new WeakSet,pn=function(t,e,n){const s=new Set;for(const i of O(this,H)){const c=i.listenerRef.deref();if(!c)s.add(i);else if(Ot&&c instanceof HTMLElement&&!c.isConnected)s.add(i);else{const{propertyMap:u}=i,p=Object.keys(u);(p.length===0||p.includes(t))&&c.changed(t,u[t],n,e,this)}}ct(this,H,O(this,H).filter(i=>!s.has(i)))},q(tt,K,new Map),Ot&&window.addEventListener("beforeunload",()=>{for(const[t,e]of O(tt,K).entries())if(O(e,Et)){const n=De(e);sessionStorage.setItem("wrec-state-"+t,JSON.stringify(n))}});let Ct=tt;Ot&&process.env.NODE_ENV==="development"&&(window.WrecState=Ct);const vn=new Set(["onblur","onchange","onclick","onfocus","oninput","onkeydown","onreset","onsubmit"]);Me.addHook("uponSanitizeAttribute",(r,t)=>{const{attrName:e}=t,n=e.toLowerCase();vn.has(n)&&(t.forceKeepAttr=!0)});class Q extends Error{}const xn=/([a-zA-Z-]+)\s*:\s*([^;}]+)/g,Pe="a-zA-Z_$",kn=Pe+"0-9",mt=`[${Pe}][${kn}]*`,Fn=/<!--\s*(.*?)\s*-->/,Un=/<(\w+)(?:\s[^>]*)?>((?:[^<]|<(?!\w))*?)<\/\1>/g,qt=new RegExp(`^this\\.${mt}$`),Kt=new RegExp(`this\\.${mt}(\\.${mt})*`,"g"),ve=new RegExp(`this\\.${mt}(\\.${mt})*`),Hn=new Set(["class","style"]),xe=5;function zn(r){return r instanceof HTMLButtonElement||r instanceof HTMLFieldSetElement||r instanceof HTMLInputElement||r instanceof HTMLSelectElement||r instanceof HTMLTextAreaElement||r instanceof F}function $n(r,t,e){const n=document.createElement(r);if(t)for(const[s,i]of Object.entries(t))n.setAttribute(s,i);return e&&(n.innerHTML=e),n}const Wn=r=>r===String?"":r===Number?0:r===Boolean?!1:r===Array?[]:r===Object?{}:void 0;function Mt(r){const t=[];let e=r.firstElementChild;for(;e;)t.push(e),e.shadowRoot&&t.push(...Mt(e.shadowRoot)),e.firstElementChild&&t.push(...Mt(e)),e=e.nextElementSibling;return t}const Lt=r=>r.substring(xe).split(".")[0];function ke(r,t){let e=r[0];return t.forEach((n,s)=>{e+=n+r[s+1]}),e}function Zt(r){const t=typeof r;return t==="string"||t==="number"||t==="boolean"}function dt(r){return r.localName==="textarea"}function Jt(r){const{localName:t}=r;return t==="input"||t==="select"}const Gn=r=>r.replace(/<!--[\s\S]*?-->/g,"");function Fe(r,t,e,n){return r.slice(0,t)+n+r.slice(t+e)}function Bn(r){let t=r.trim(),e=null;/^\s*<tr[\s>]/i.test(t)?(t=`<table><tbody>${t}</tbody></table>`,e="tbody"):/^\s*<(td|th)[\s>]/i.test(t)?(t=`<table><tbody><tr>${t}</tr></tbody></table>`,e="tr"):/^\s*<option[\s>]/i.test(t)?(t=`<select>${t}</select>`,e="select"):/^\s*<col[\s>]/i.test(t)&&(t=`<table><colgroup>${t}</colgroup></table>`,e="colgroup");const n=Me.sanitize(t,{ADD_TAGS:["#comment"],ALLOW_UNKNOWN_PROTOCOLS:!0,RETURN_DOM_FRAGMENT:!0});if(e){const s=n.querySelector(e);if(s)return s.childNodes}return n.childNodes}function Qt(r){const t=Number(r);if(isNaN(t))throw new Q(`can't convert "${r}" to a number`);return t}function Ue(r,t,e){const[n,s]=t.split(":");if(Zt(e))if(typeof e=="boolean"){e?r.setAttribute(n,n):r.removeAttribute(n);const i=F.getPropName(n);r[i]=e}else{const i=r.getAttribute(t),c=String(e);i!==c&&(r.setAttribute(n,c),n==="value"&&Jt(r)&&(r.value=c))}else{const i=F.getPropName(t);r[i]=e}}function te(r,t,e){const[n,s]=t.split(":");r instanceof CSSStyleRule?r.style.setProperty(n,e):(Ue(r,n,e),n==="value"&&Jt(r)&&(r.value=e))}async function jn(r){const t=new Set;for(const n of Mt(r.content)){const{localName:s}=n;s.includes("-")&&t.add(s)}function e(n){return new Promise((s,i)=>{setTimeout(()=>{const c=`custom element <${n}> not defined`;i(new Error(c))},1e3)})}return Promise.all([...t].map(async n=>Promise.race([customElements.whenDefined(n),e(n)])))}class F extends HTMLElement{static attrToPropMap=new Map;static propToAttrMap=new Map;static css="";static elementName="";static formAssociated=!1;static html="";static properties;static propToComputedMap;static propToExprsMap;static template=null;#t=this.constructor;#n=new Map;#c={};#s;#l={};#f=null;#u=new Map;static define(t){if(this.elementName=t,customElements.get(t))throw new Q(`custom element ${t} is already defined`);customElements.define(t,this)}constructor(){super(),this.attachShadow({mode:"open"});const t=this.#t;t.attrToPropMap||(t.attrToPropMap=new Map),t.properties||(t.properties={}),t.propToAttrMap||(t.propToExprsMap=new Map),t.propToComputedMap||(t.propToComputedMap=new Map),t.propToExprsMap||(t.propToExprsMap=new Map)}attributeChangedCallback(t,e,n){t==="disabled"&&this.#h();const s=F.getPropName(t);if(this.#i(s)){const i=this.#A(s,String(n));this[s]=i;const c=this.#c[s];c&&this.setFormValue(c,String(i)),this.propertyChangedCallback(s,e,n)}}async#S(){const t=this.#t;let{template:e}=t;if(!e){e=t.template=document.createElement("template");let n=`<style>
3
3
  :host([hidden]) { display: none; }`;t.css&&(n+=t.css),n+=`</style>
4
- `;let s=t.html.trim();s.startsWith("<")||(s=`<span><!--${s}--></span>`),e.innerHTML=n+s}await jn(e),this.shadowRoot.replaceChildren(e.content.cloneNode(!0))}changed(t,e,n){this[e]=n}connectedCallback(){this.#P(),this.#R(),this.#S().then(()=>{this.hasAttribute("disabled")&&this.#h(),this.#b(this.shadowRoot),this.#m(this.shadowRoot),this.#y()})}#y(){const t=this.#t,{properties:e}=t;for(const[n,{computed:s}]of Object.entries(e))s&&(this[n]=this.#o(s))}#R(){const t=this.#t,{observedAttributes:e,properties:n}=t;for(const[s,i]of Object.entries(n))this.#w(s,i,e)}#w(t,e,n){const s=F.getAttrName(t),i=this.hasAttribute(s);e.required&&!i&&this.#e(this,t,"is a required attribute");let c=e.value;this.hasOwnProperty(t)&&(c=this[t],delete this[t]);const{type:u}=e,p=u===Boolean?c||i:n.includes(s)&&i?this.#g(t,s):c||Wn(u),h="#"+t;this[h]=p,e.computed&&this.#N(t,e),Object.defineProperty(this,t,{enumerable:!0,get(){return this[h]},set(m){u===Number&&typeof m=="string"&&(m=Qt(m));const y=this[h];if(m===y)return;this.#x(t,u,m),this[h]=m;const{state:V,stateProp:W}=this.#t.properties[t];W&&Pn(V,W,m),this.#D(t),this.#L(t,u,m,s),this.#E(t),this.#I(t,m);const X=this.#c[t];X&&this.setFormValue(X,String(m)),this.propertyChangedCallback(t,y,m),e.dispatch&&this.dispatch("change",{tagName:this.localName,property:t,oldValue:y,value:m})}})}#h(){const t=this.hasAttribute("disabled"),e=Mt(this.shadowRoot);for(const n of e)zn(n)&&(n.disabled=t)}disconnectedCallback(){this.#n.clear(),this.#l.clear(),this.#u.clear()}dispatch(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}displayIfSet(t,e="block"){return`display: ${t?e:"none"}`}#O(t){const e=t instanceof F;for(const n of t.getAttributeNames()){const s=t.getAttribute(n),i=this.#T(t,s);if(i){const c=this[i];c===void 0&&this.#a(t,n,i),t[i]=c;let[u,p]=n.split(":");u==="value"&&(p?(t["on"+p]===void 0&&this.#e(t,n,"refers to an unsupported event name"),t.setAttribute(u,this[i])):p="change"),e&&t.#u.set(F.getPropName(u),i)}this.#r(s,t,n)}}#o(t){const e=new Function("return "+t).call(this);return Array.isArray(e)?e.join(""):e}#C(t){const{localName:e}=t;if(e==="style"){const{sheet:n}=t,s=n?.cssRules??[],i=Array.from(s);for(const c of i)if(c.constructor===CSSStyleRule){const u=Array.from(c.style);for(const p of u)if(p.startsWith("--")){const h=c.style.getPropertyValue(p);this.#r(h,c,p)}}}else{let n="";if(mt(t)){this.#r(t.textContent,t);const s=t.textContent?.match(Fn);s&&(n=s[1])}else{const s=Array.from(t.childNodes).find(i=>i.nodeType===Node.COMMENT_NODE);s&&(n=s.textContent?.trim()??"")}if(n){const s=this.#T(t,n);s&&mt(t)?t.textContent=this[s]:this.#r(n,t)}}}formAssociatedCallback(){let t=this.getAttribute("form-assoc");if(!t){const c=this.getAttribute("name");if(c)if(this.#i("value"))t=`value:${c}`;else return;else return}const e={},n=t.split(",");for(const c of n){const[u,p]=c.split(":");e[u.trim()]=p.trim()}this.#c=e,this.#s=new FormData,this.#f=this.attachInternals(),this.#f.setFormValue(this.#s);const s=Object.keys(this.#t.properties),i=this.#l;for(const c of s)i[c]=this[c]}formResetCallback(){const t=this.#l;for(const e of Object.keys(t)){let n=t[e];qt.test(n)&&(n=this.#o(n)),this[e]=n}}static getAttrName(t){let e=this.propToAttrMap.get(t);return e||(e=t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),this.propToAttrMap.set(t,e)),e}static getPropName(t){let e=this.attrToPropMap.get(t);return e||(e=t.replace(/-([a-z])/g,(n,s)=>s.toUpperCase()),this.attrToPropMap.set(t,e)),e}#M(t,e,n){if(n.length!==1)return;const[s]=n;if(!qt.test(s))return;const i=Jt(t)||mt(t);let[c,u]=(e??"").split(":");if(!(i&&c==="value"||mt(t)))return;u?t["on"+u]===void 0&&this.#e(t,e,"refers to an unsupported event name"):u="change";const h=Nt(s);t.addEventListener(u,m=>{const{target:y}=m;if(!y)return;const V=y.value,{type:W}=this.#t.properties[h];this[h]=W===Number?Qt(V):V,this.#E(h)})}#i(t){return!!this.#t.properties[t]}#m(t){const e=Array.from(t.querySelectorAll("*"));for(const n of e)this.#O(n),n.firstElementChild||this.#C(n)}#d(){if(this.#t.formAssociated||this.closest("form")===null)return;const t=this.#t.name;throw new Ct(`inside form, class ${t} requires "static formAssociated = true;"`)}static get observedAttributes(){const t=Object.keys(this.properties||{}).map(e=>F.getAttrName(e));return t.includes("disabled")||t.push("disabled"),t}propertyChangedCallback(t,e,n){}#T(t,e){if(!e||!qt.test(e))return;const n=Nt(e);return this[n]===void 0&&this.#a(t,"",n),n}#E(t){const s=this.#t.propToExprsMap.get(t)||[];for(const i of s){let c=this.#o(i);const u=this.#n.get(i)??[];for(const p of u)if(p instanceof HTMLElement)this.#_(p,c);else if(!(p instanceof CSSStyleRule)){const{element:h,attrName:m}=p;h instanceof CSSStyleRule?h.style.setProperty(m,c):te(h,m,c)}}}#N(t,e){const{computed:n,uses:s}=e,i=this.#t.propToComputedMap;function c(p,h){let m=i.get(p);m||(m=[],i.set(p,m)),m.push([t,h])}const u=n.match(Kt)||[];for(const p of u){const h=p.substring(xe);this[h]===void 0&&this.#a(null,t,h),typeof this[h]!="function"&&c(h,n)}if(s)for(const p of s.split(","))c(p,n)}#r(t,e,n=void 0){if(!t)return;const s=this.#p(e,n,t);if(!s){const p=t.replaceAll("this..","this.");n?te(e,n,p):"textContent"in e&&(e.textContent=p);return}const i=this.#t;s.forEach(p=>{const h=Nt(p);if(typeof this[h]=="function")return;const m=i.propToExprsMap;let y=m.get(h);y||(y=[],m.set(h,y)),y.includes(t)||y.push(t)});for(const[p,h]of this.#n.entries())for(const m of h){const y=m instanceof HTMLElement||m instanceof CSSStyleRule?m:m.element;y instanceof CSSStyleRule||y.isConnected||this.#n.set(p,h.filter(V=>V!==m))}let c=this.#n.get(t);c||(c=[],this.#n.set(t,c)),c.push(n?{element:e,attrName:n}:e),e instanceof HTMLElement&&this.#M(e,n,s);const u=this.#o(t);n?te(e,n,u):this.#_(e,u)}setAttributeSafe(t,e){this.hasAttribute(t)||this.setAttribute(t,e)}setFormValue(t,e){!this.#s||!Zt(e)||(this.#s.set(t,e),this.#f?.setFormValue(this.#s))}#e(t,e,n){const s=t instanceof HTMLElement?t.localName:"CSS rule";throw new Ct(`component ${this.#t.elementName}`+(t?`, element "${s}"`:"")+(e?`, attribute "${e}"`:"")+` ${n}`)}#a(t,e,n){this.#e(t,e,`refers to missing property "${n}"`)}#g(t,e){return this.#A(t,this.getAttribute(e))}#A(t,e){if(e?.match(Kt))return e;const n=this.#t,{type:s}=n.properties[t];if(s||this.#e(null,t,"does not specify its type"),s===String)return e;if(s===Number)return Qt(e);if(s===Boolean)return e==="true"?!0:e==="false"||e==="null"?!1:(e&&e!==t&&this.#e(null,t,"is a Boolean attribute, so its value must match attribute name or be missing"),e===t)}#L(t,e,n,s){if(Zt(n)&&this.hasAttribute(s)){const i=e===Boolean?this.hasAttribute(s):this.#g(t,s);n!==i&&Ue(this,t,n)}}#D(t){const n=this.#t.propToComputedMap.get(t)||[];for(const[s,i]of n)this[s]=this.#o(i)}#_(t,e){if(e===void 0)return;const n=t instanceof HTMLElement,s=typeof e;if(s!=="string"&&s!=="number"&&this.#e(t,void 0," computed content is not a string or number"),t instanceof HTMLElement&&mt(t))t.value=e;else if(n&&s==="string"&&e.trim().startsWith("<")){const i=Bn(e);t.replaceChildren(...i),this.#b(t),this.#m(t)}else n&&(t.textContent=e)}#I(t,e){const n=this.#u.get(t);if(!n)return;const s=this.getRootNode();if(!(s instanceof ShadowRoot))return;const{host:i}=s;if(!i)return;const c=i;c[n]=e}useState(t,e){if(!e){e={};for(const n of Object.keys(t))e[n]=n}this.#v(t,e);for(const[n,s]of Object.entries(e))if(this.#i(s)){const i=Ne(t,n);i!==void 0&&(this[s]=i);const c=this.#t.properties[s];c.state=t,c.stateProp=n}t.addListener(this,e)}#P(){const t=this.#t,e=new Set(Object.keys(t.properties));for(const n of e)Hn.has(n)&&this.#e(null,"",`property "${n}" is not allowed because it is a reserved attribute`);for(const n of this.getAttributeNames())if(n!=="class"&&n!=="id"&&n!=="disabled"&&!n.startsWith("on")){if(n==="form-assoc"){this.#d();continue}if(!e.has(F.getPropName(n))){if(n==="name"){this.#d();continue}this.#e(null,n,"is not a supported attribute")}}}#p(t,e,n){const s=n.match(Kt);if(s)return s.forEach(i=>{const c=Nt(i);this[c]===void 0&&this.#a(t,e,c)}),s}#v(t,e){for(const[n,s]of Object.entries(e)){let i=Ne(t,n);if(i===void 0)throw new Ct(`invalid state path "${n}"`);i=this[s],this.#i(s)||this.#e(null,s,"refers to missing property in useState map")}}#x(t,e,n){if(n instanceof e)return;let s=typeof n;if(s==="object"){const{constructor:i}=n;s=i.name,i!==e&&this.#e(null,t,`was set to a ${s}, but must be a ${e.name}`)}s!==e.name.toLowerCase()&&this.#e(null,t,`was set to a ${s}, but must be a ${e.name}`)}#b(t){const e=Array.from(t.querySelectorAll("*"));for(const n of e){const s=[];for(const i of Array.from(n.attributes)){const c=i.name;if(c.startsWith("on")){let u=c.slice(2);u=u[0].toLowerCase()+u.slice(1).toLowerCase();const p=i.value;this.#p(n,c,p);let h;typeof this[p]=="function"?h=m=>this[p](m):(this.#p(n,c,p),h=()=>this.#o(p)),n.addEventListener(u,h),s.push(c)}}for(const i of s)n.removeAttribute(i)}}}function Yn(r,...t){let e=ke(r,t);for(;;){const n=xn.exec(e);if(!n)break;const s=n[2];if(ve.test(s)){const i=n[1];if(!i.startsWith("--")){const c=`--${i}: ${s};
5
- ${i}: var(--${i})`;e=Fe(e,n.index,n[0].length,c)}}}return e}function Vn(r,...t){let e=ke(r,t);for(;;){const n=Un.exec(e);if(!n||n[1]==="style")break;const s=Gn(n[2]);if(ve.test(s)){const i=`<!-- ${s.trim()} -->`,c=n.index+n[0].indexOf(">")+1;e=Fe(e,c,s.length,i)}}return e}T.Wrec=F,T.WrecState=Ot,T.createElement=$n,T.css=Yn,T.html=Vn,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})}));
4
+ `;let s=t.html.trim();if(!s)throw new Q("static property html must be set");s.startsWith("<")||(s=`<span><!--${s}--></span>`),e.innerHTML=n+s}await jn(e),this.shadowRoot.replaceChildren(e.content.cloneNode(!0))}changed(t,e,n){this[e]=n}connectedCallback(){this.#P(),this.#R(),this.#S().then(()=>{this.hasAttribute("disabled")&&this.#h(),this.#b(this.shadowRoot),this.#m(this.shadowRoot),this.#y()})}#y(){const t=this.#t,{properties:e}=t;for(const[n,{computed:s}]of Object.entries(e))s&&(this[n]=this.#o(s))}#R(){const t=this.#t,{observedAttributes:e,properties:n}=t;for(const[s,i]of Object.entries(n))this.#w(s,i,e)}#w(t,e,n){const s=F.getAttrName(t),i=this.hasAttribute(s);e.required&&!i&&this.#e(this,t,"is a required attribute");let c=e.value;this.hasOwnProperty(t)&&(c=this[t],delete this[t]);const{type:u}=e,p=u===Boolean?c||i:n.includes(s)&&i?this.#g(t,s):c||Wn(u),h="#"+t;this[h]=p,e.computed&&this.#L(t,e),Object.defineProperty(this,t,{enumerable:!0,get(){return this[h]},set(m){u===Number&&typeof m=="string"&&(m=Qt(m));const y=this[h];if(m===y)return;this.#x(t,u,m),this[h]=m;const{state:V,stateProp:W}=this.#t.properties[t];W&&Pn(V,W,m),this.#D(t),this.#N(t,u,m,s),this.#E(t),this.#I(t,m);const X=this.#c[t];X&&this.setFormValue(X,String(m)),this.propertyChangedCallback(t,y,m),e.dispatch&&this.dispatch("change",{tagName:this.localName,property:t,oldValue:y,value:m})}})}#h(){const t=this.hasAttribute("disabled"),e=Mt(this.shadowRoot);for(const n of e)zn(n)&&(n.disabled=t)}disconnectedCallback(){this.#n.clear(),this.#l.clear(),this.#u.clear()}dispatch(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}displayIfSet(t,e="block"){return`display: ${t?e:"none"}`}#O(t){const e=t instanceof F;for(const n of t.getAttributeNames()){const s=t.getAttribute(n),i=this.#T(t,s);if(i){const c=this[i];c===void 0&&this.#a(t,n,i),t[i]=c;let[u,p]=n.split(":");u==="value"&&(p?(t["on"+p]===void 0&&this.#e(t,n,"refers to an unsupported event name"),t.setAttribute(u,this[i])):p="change"),e&&t.#u.set(F.getPropName(u),i)}this.#r(s,t,n)}}#o(t){const e=new Function("return "+t).call(this);return Array.isArray(e)?e.join(""):e}#C(t){const{localName:e}=t;if(e==="style"){const{sheet:n}=t,s=n?.cssRules??[],i=Array.from(s);for(const c of i)if(c.constructor===CSSStyleRule){const u=Array.from(c.style);for(const p of u)if(p.startsWith("--")){const h=c.style.getPropertyValue(p);this.#r(h,c,p)}}}else{let n="";if(dt(t)){this.#r(t.textContent,t);const s=t.textContent?.match(Fn);s&&(n=s[1])}else{const s=Array.from(t.childNodes).find(i=>i.nodeType===Node.COMMENT_NODE);s&&(n=s.textContent?.trim()??"")}if(n){const s=this.#T(t,n);s&&dt(t)?t.textContent=this[s]:this.#r(n,t)}}}formAssociatedCallback(){let t=this.getAttribute("form-assoc");if(!t){const c=this.getAttribute("name");if(c)if(this.#i("value"))t=`value:${c}`;else return;else return}const e={},n=t.split(",");for(const c of n){const[u,p]=c.split(":");e[u.trim()]=p.trim()}this.#c=e,this.#s=new FormData,this.#f=this.attachInternals(),this.#f.setFormValue(this.#s);const s=Object.keys(this.#t.properties),i=this.#l;for(const c of s)i[c]=this[c]}formResetCallback(){const t=this.#l;for(const e of Object.keys(t)){let n=t[e];qt.test(n)&&(n=this.#o(n)),this[e]=n}}static getAttrName(t){let e=this.propToAttrMap.get(t);return e||(e=t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),this.propToAttrMap.set(t,e)),e}static getPropName(t){let e=this.attrToPropMap.get(t);return e||(e=t.replace(/-([a-z])/g,(n,s)=>s.toUpperCase()),this.attrToPropMap.set(t,e)),e}#M(t,e,n){if(n.length!==1)return;const[s]=n;if(!qt.test(s))return;const i=Jt(t)||dt(t);let[c,u]=(e??"").split(":");if(!(i&&c==="value"||dt(t)))return;u?t["on"+u]===void 0&&this.#e(t,e,"refers to an unsupported event name"):u="change";const h=Lt(s);t.addEventListener(u,m=>{const{target:y}=m;if(!y)return;const V=y.value,{type:W}=this.#t.properties[h];this[h]=W===Number?Qt(V):V,this.#E(h)})}#i(t){return!!this.#t.properties[t]}#m(t){const e=Array.from(t.querySelectorAll("*"));for(const n of e)this.#O(n),n.firstElementChild||this.#C(n)}#d(){if(this.#t.formAssociated||this.closest("form")===null)return;const t=this.#t.name;throw new Q(`inside form, class ${t} requires "static formAssociated = true;"`)}static get observedAttributes(){const t=Object.keys(this.properties||{}).map(e=>F.getAttrName(e));return t.includes("disabled")||t.push("disabled"),t}propertyChangedCallback(t,e,n){}#T(t,e){if(!e||!qt.test(e))return;const n=Lt(e);return this[n]===void 0&&this.#a(t,"",n),n}#E(t){const s=this.#t.propToExprsMap.get(t)||[];for(const i of s){let c=this.#o(i);const u=this.#n.get(i)??[];for(const p of u)if(p instanceof HTMLElement)this.#_(p,c);else if(!(p instanceof CSSStyleRule)){const{element:h,attrName:m}=p;h instanceof CSSStyleRule?h.style.setProperty(m,c):te(h,m,c)}}}#L(t,e){const{computed:n,uses:s}=e,i=this.#t.propToComputedMap;function c(p,h){let m=i.get(p);m||(m=[],i.set(p,m)),m.push([t,h])}const u=n.match(Kt)||[];for(const p of u){const h=p.substring(xe);this[h]===void 0&&this.#a(null,t,h),typeof this[h]!="function"&&c(h,n)}if(s)for(const p of s.split(","))c(p,n)}#r(t,e,n=void 0){if(!t)return;const s=this.#p(e,n,t);if(!s){const p=t.replaceAll("this..","this.");n?te(e,n,p):"textContent"in e&&(e.textContent=p);return}const i=this.#t;s.forEach(p=>{const h=Lt(p);if(typeof this[h]=="function")return;const m=i.propToExprsMap;let y=m.get(h);y||(y=[],m.set(h,y)),y.includes(t)||y.push(t)});for(const[p,h]of this.#n.entries())for(const m of h){const y=m instanceof HTMLElement||m instanceof CSSStyleRule?m:m.element;y instanceof CSSStyleRule||y.isConnected||this.#n.set(p,h.filter(V=>V!==m))}let c=this.#n.get(t);c||(c=[],this.#n.set(t,c)),c.push(n?{element:e,attrName:n}:e),e instanceof HTMLElement&&this.#M(e,n,s);const u=this.#o(t);n?te(e,n,u):this.#_(e,u)}setAttributeSafe(t,e){this.hasAttribute(t)||this.setAttribute(t,e)}setFormValue(t,e){!this.#s||!Zt(e)||(this.#s.set(t,e),this.#f?.setFormValue(this.#s))}#e(t,e,n){const s=t instanceof HTMLElement?t.localName:"CSS rule";throw new Q(`component ${this.#t.elementName}`+(t?`, element "${s}"`:"")+(e?`, attribute "${e}"`:"")+` ${n}`)}#a(t,e,n){this.#e(t,e,`refers to missing property "${n}"`)}#g(t,e){return this.#A(t,this.getAttribute(e))}#A(t,e){if(e?.match(Kt))return e;const n=this.#t,{type:s}=n.properties[t];if(s||this.#e(null,t,"does not specify its type"),s===String)return e;if(s===Number)return Qt(e);if(s===Boolean)return e==="true"?!0:e==="false"||e==="null"?!1:(e&&e!==t&&this.#e(null,t,"is a Boolean attribute, so its value must match attribute name or be missing"),e===t)}#N(t,e,n,s){if(Zt(n)&&this.hasAttribute(s)){const i=e===Boolean?this.hasAttribute(s):this.#g(t,s);n!==i&&Ue(this,t,n)}}#D(t){const n=this.#t.propToComputedMap.get(t)||[];for(const[s,i]of n)this[s]=this.#o(i)}#_(t,e){if(e===void 0)return;const n=t instanceof HTMLElement,s=typeof e;if(s!=="string"&&s!=="number"&&this.#e(t,void 0," computed content is not a string or number"),t instanceof HTMLElement&&dt(t))t.value=e;else if(n&&s==="string"&&e.trim().startsWith("<")){const i=Bn(e);t.replaceChildren(...i),this.#b(t),this.#m(t)}else n&&(t.textContent=e)}#I(t,e){const n=this.#u.get(t);if(!n)return;const s=this.getRootNode();if(!(s instanceof ShadowRoot))return;const{host:i}=s;if(!i)return;const c=i;c[n]=e}useState(t,e){if(!e){e={};for(const n of Object.keys(t))e[n]=n}this.#v(t,e);for(const[n,s]of Object.entries(e))if(this.#i(s)){const i=Le(t,n);i!==void 0&&(this[s]=i);const c=this.#t.properties[s];c.state=t,c.stateProp=n}t.addListener(this,e)}#P(){const t=this.#t,e=new Set(Object.keys(t.properties));for(const n of e)Hn.has(n)&&this.#e(null,"",`property "${n}" is not allowed because it is a reserved attribute`);for(const n of this.getAttributeNames())if(n!=="class"&&n!=="id"&&n!=="disabled"&&!n.startsWith("on")){if(n==="form-assoc"){this.#d();continue}if(!e.has(F.getPropName(n))){if(n==="name"){this.#d();continue}this.#e(null,n,"is not a supported attribute")}}}#p(t,e,n){const s=n.match(Kt);if(s)return s.forEach(i=>{const c=Lt(i);this[c]===void 0&&this.#a(t,e,c)}),s}#v(t,e){for(const[n,s]of Object.entries(e)){let i=Le(t,n);if(i===void 0)throw new Q(`invalid state path "${n}"`);i=this[s],this.#i(s)||this.#e(null,s,"refers to missing property in useState map")}}#x(t,e,n){if(n instanceof e)return;let s=typeof n;if(s==="object"){const{constructor:i}=n;s=i.name,i!==e&&this.#e(null,t,`was set to a ${s}, but must be a ${e.name}`)}s!==e.name.toLowerCase()&&this.#e(null,t,`was set to a ${s}, but must be a ${e.name}`)}#b(t){const e=Array.from(t.querySelectorAll("*"));for(const n of e){const s=[];for(const i of Array.from(n.attributes)){const c=i.name;if(c.startsWith("on")){let u=c.slice(2);u=u[0].toLowerCase()+u.slice(1).toLowerCase();const p=i.value;this.#p(n,c,p);let h;typeof this[p]=="function"?h=m=>this[p](m):(this.#p(n,c,p),h=()=>this.#o(p)),n.addEventListener(u,h),s.push(c)}}for(const i of s)n.removeAttribute(i)}}}function Yn(r,...t){let e=ke(r,t);for(;;){const n=xn.exec(e);if(!n)break;const s=n[2];if(ve.test(s)){const i=n[1];if(!i.startsWith("--")){const c=`--${i}: ${s};
5
+ ${i}: var(--${i})`;e=Fe(e,n.index,n[0].length,c)}}}return e}function Vn(r,...t){let e=ke(r,t);for(;;){const n=Un.exec(e);if(!n||n[1]==="style")break;const s=Gn(n[2]);if(ve.test(s)){const i=`<!-- ${s.trim()} -->`,c=n.index+n[0].indexOf(">")+1;e=Fe(e,c,s.length,i)}}return e}T.Wrec=F,T.WrecState=Ct,T.createElement=$n,T.css=Yn,T.html=Vn,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "wrec",
3
3
  "description": "a small library that greatly simplifies building web components",
4
4
  "author": "R. Mark Volkmann",
5
- "version": "0.20.0",
5
+ "version": "0.20.2",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -13,7 +13,7 @@
13
13
  "component"
14
14
  ],
15
15
  "type": "module",
16
- "browser": "dist/wrec.min.js",
16
+ "types": "./dist/wrec.d.ts",
17
17
  "main": "dist/wrec.umd.js",
18
18
  "module": "dist/wrec.es.js",
19
19
  "exports": {
@@ -32,19 +32,19 @@
32
32
  "clean": "rm -rf dist",
33
33
  "preview": "vite preview",
34
34
  "lint": "oxlint",
35
- "minify": "tsc && terser dist/wrec.js dist/wrec-state.js -c -m -o dist/wrec.min.js",
36
35
  "reinstall": "rm -rf node_modules package-lock.json && npm install",
37
36
  "test": "playwright test",
38
37
  "testui": "playwright test --ui",
39
38
  "unittest": "vitest"
40
39
  },
41
40
  "devDependencies": {
41
+ "@microsoft/api-extractor": "7.56.3",
42
42
  "@playwright/test": "^1.57.0",
43
43
  "@types/node": "^25.0.6",
44
44
  "oxlint": "^1.38.0",
45
- "terser": "^5.44.1",
46
45
  "typescript": "^5.9.3",
47
- "vite": "^7.3.1"
46
+ "vite": "^7.3.1",
47
+ "vite-plugin-dts": "^4.5.4"
48
48
  },
49
49
  "dependencies": {
50
50
  "dompurify": "^3.3.1"
@@ -1,104 +0,0 @@
1
- import { css, html, Wrec } from '../wrec';
2
- class TableWired extends Wrec {
3
- static properties = {
4
- headings: { type: (Array) },
5
- propNames: { type: (Array) },
6
- data: { type: (Array) }
7
- };
8
- static css = css `
9
- .sort-indicator {
10
- color: white;
11
- display: inline-block;
12
- line-height: 1rem;
13
- margin-left: 0.5rem;
14
- width: 1rem;
15
- }
16
- table {
17
- border-collapse: collapse;
18
- }
19
- td,
20
- th {
21
- border: 2px solid gray;
22
- padding: 0.5rem;
23
- }
24
- th {
25
- background-color: cornflowerblue;
26
- color: white;
27
- cursor: pointer;
28
- > span {
29
- pointer-events: none;
30
- }
31
- }
32
- `;
33
- // bind is needed here because makeTh uses "this".
34
- static html = html `
35
- <table>
36
- <thead>
37
- <tr>
38
- this.headings.map(this.makeTh.bind(this))
39
- </tr>
40
- </thead>
41
- <tbody>
42
- this.data.map((_obj, index) => this.makeTr(index))
43
- </tbody>
44
- </table>
45
- `;
46
- sortAscending = true;
47
- sortHeader = null;
48
- makeTd(dataIndex, prop) {
49
- const value = this.data[dataIndex][prop];
50
- return html `<td>${value}</td>`;
51
- }
52
- makeTh(heading, index) {
53
- return html `
54
- <th
55
- aria-label="sort by ${heading}"
56
- data-property="${this.propNames[index]}"
57
- onclick="sort"
58
- role="button"
59
- tabindex="0"
60
- >
61
- <span>${heading}</span>
62
- <span class="sort-indicator"></span>
63
- </th>
64
- `;
65
- }
66
- makeTr(dataIndex) {
67
- return html `
68
- <tr>
69
- this.propNames.map(propName => this.makeTd(${dataIndex}, propName))
70
- </tr>
71
- `;
72
- }
73
- sort(event) {
74
- let th = event.target;
75
- const property = th.getAttribute('data-property');
76
- this.sortAscending = th === this.sortHeader ? !this.sortAscending : true;
77
- this.data.sort((a, b) => {
78
- const aValue = a[property];
79
- const bValue = b[property];
80
- let compare = typeof aValue === 'string'
81
- ? aValue.localeCompare(bValue)
82
- : typeof aValue === 'number'
83
- ? aValue - bValue
84
- : 0;
85
- return this.sortAscending ? compare : -compare;
86
- });
87
- // Trigger the property set method by assigning a clone.
88
- this.data = [...this.data];
89
- // Clear sort indicator from previously selected header.
90
- if (this.sortHeader) {
91
- const sortIndicator = this.sortHeader.querySelector('.sort-indicator');
92
- if (sortIndicator)
93
- sortIndicator.textContent = '';
94
- }
95
- // Add sort indicator to currently selected header.
96
- const sortIndicator = th.querySelector('.sort-indicator');
97
- if (sortIndicator) {
98
- sortIndicator.textContent = this.sortAscending ? '\u25B2' : '\u25BC';
99
- }
100
- this.sortHeader = th;
101
- }
102
- }
103
- TableWired.define('table-wired');
104
- //# sourceMappingURL=table-wired.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table-wired.js","sourceRoot":"","sources":["../../src/examples/table-wired.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,SAAS,CAAC;AAIxC,MAAM,UAAW,SAAQ,IAAI;IAC3B,MAAM,CAAC,UAAU,GAAG;QAClB,QAAQ,EAAE,EAAC,IAAI,EAAE,CAAA,KAAa,CAAA,EAAC;QAC/B,SAAS,EAAE,EAAC,IAAI,EAAE,CAAA,KAAa,CAAA,EAAC;QAChC,IAAI,EAAE,EAAC,IAAI,EAAE,CAAA,KAAa,CAAA,EAAC;KAC5B,CAAC;IAEF,MAAM,CAAC,GAAG,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBf,CAAC;IAEF,kDAAkD;IAClD,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;;;;;;;;;;;GAWjB,CAAC;IAEF,aAAa,GAAG,IAAI,CAAC;IACrB,UAAU,GAAgC,IAAI,CAAC;IAE/C,MAAM,CAAC,SAAiB,EAAE,IAAY;QACpC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC;QACzC,OAAO,IAAI,CAAA,OAAO,KAAK,OAAO,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,OAAe,EAAE,KAAa;QACnC,OAAO,IAAI,CAAA;;8BAEe,OAAO;yBACZ,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;;;;;gBAK9B,OAAO;;;KAGlB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,SAAiB;QACtB,OAAO,IAAI,CAAA;;qDAEsC,SAAS;;KAEzD,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,KAAY;QACf,IAAI,EAAE,GAAG,KAAK,CAAC,MAA+B,CAAC;QAC/C,MAAM,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,eAAe,CAAE,CAAC;QACnD,IAAI,CAAC,aAAa,GAAG,EAAE,KAAK,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC;QAEzE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAc,EAAE,CAAc,EAAE,EAAE;YAChD,MAAM,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;YAC3B,MAAM,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;YAC3B,IAAI,OAAO,GACT,OAAO,MAAM,KAAK,QAAQ;gBACxB,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,MAAgB,CAAC;gBACxC,CAAC,CAAC,OAAO,MAAM,KAAK,QAAQ;oBAC1B,CAAC,CAAC,MAAM,GAAI,MAAiB;oBAC7B,CAAC,CAAC,CAAC,CAAC;YACV,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,wDAAwD;QACxD,IAAI,CAAC,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QAE3B,wDAAwD;QACxD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;YACvE,IAAI,aAAa;gBAAE,aAAa,CAAC,WAAW,GAAG,EAAE,CAAC;QACpD,CAAC;QAED,mDAAmD;QACnD,MAAM,aAAa,GAAG,EAAE,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;QAC1D,IAAI,aAAa,EAAE,CAAC;YAClB,aAAa,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC;QACvE,CAAC;QAED,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;;AAGH,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC"}
package/dist/paths.js DELETED
@@ -1,21 +0,0 @@
1
- export function getPathValue(obj, path) {
2
- let value = obj;
3
- for (const key of path.split('.')) {
4
- value = value[key];
5
- }
6
- return value;
7
- }
8
- export function setPathValue(obj, path, value) {
9
- const keys = path.split('.');
10
- const lastIndex = keys.length - 1;
11
- let target = obj;
12
- keys.forEach((key, index) => {
13
- if (index === lastIndex) {
14
- target[key] = value;
15
- }
16
- else {
17
- target = target[key];
18
- }
19
- });
20
- }
21
- //# sourceMappingURL=paths.js.map
package/dist/paths.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY,CAAC,GAAgB,EAAE,IAAY;IACzD,IAAI,KAAK,GAAsB,GAAG,CAAC;IACnC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAClC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAgB,EAAE,IAAY,EAAE,KAAc;IACzE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClC,IAAI,MAAM,GAAQ,GAAG,CAAC;IACtB,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAC1B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
package/dist/proxies.js DELETED
@@ -1,53 +0,0 @@
1
- /**
2
- * Creates a recursive Proxy to monitor deep property changes,
3
- * passing the dot-separated path to the callback.
4
- * @param {Object} target object to proxy
5
- * @param {ProxyCallback} callback function to call when any property changes
6
- * @param {string} [path=''] current path prefix, used internally for recursion
7
- * @returns {Proxy} deep proxy
8
- */
9
- export function createDeepProxy(target, callback, path = '') {
10
- // Use a WeakMap to cache proxies and
11
- // avoid infinite recursion or memory leaks.
12
- const proxyCache = new WeakMap();
13
- const deepHandler = {
14
- // Intercept property reads.
15
- // This creates nested proxies lazily.
16
- get(target, key) {
17
- const value = Reflect.get(target, key);
18
- // If the value is a primitive, return it.
19
- if (value === null || typeof value !== 'object')
20
- return value;
21
- // If a proxy for this object has already been created, return it.
22
- const proxy = proxyCache.get(value);
23
- if (proxy)
24
- return proxy;
25
- // Wrap the nested object in a new proxy and return it.
26
- const newPath = path ? `${path}.${key}` : key;
27
- const nestedProxy = createDeepProxy(value, callback, newPath);
28
- proxyCache.set(value, nestedProxy);
29
- return nestedProxy;
30
- },
31
- // Intercept property writes.
32
- set(target, key, newValue) {
33
- const oldValue = Reflect.get(target, key);
34
- if (oldValue !== newValue) {
35
- Reflect.set(target, key, newValue);
36
- const newPath = path ? `${path}.${key}` : key;
37
- callback(newPath, oldValue, newValue);
38
- }
39
- return true;
40
- }
41
- };
42
- return new Proxy(target, deepHandler);
43
- }
44
- // This converts a deep proxy to a plain object.
45
- export function proxyToPlainObject(obj) {
46
- const clone = {};
47
- for (const [key, value] of Object.entries(obj)) {
48
- const isObject = typeof value === 'object' && value !== null;
49
- clone[key] = isObject ? proxyToPlainObject(value) : value;
50
- }
51
- return clone;
52
- }
53
- //# sourceMappingURL=proxies.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"proxies.js","sourceRoot":"","sources":["../src/proxies.ts"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAmB,EACnB,QAAuB,EACvB,IAAI,GAAG,EAAE;IAET,qCAAqC;IACrC,4CAA4C;IAC5C,MAAM,UAAU,GAAG,IAAI,OAAO,EAAE,CAAC;IAEjC,MAAM,WAAW,GAAG;QAClB,4BAA4B;QAC5B,sCAAsC;QACtC,GAAG,CAAC,MAA2B,EAAE,GAAW;YAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAEvC,0CAA0C;YAC1C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;gBAAE,OAAO,KAAK,CAAC;YAE9D,kEAAkE;YAClE,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACpC,IAAI,KAAK;gBAAE,OAAO,KAAK,CAAC;YAExB,uDAAuD;YACvD,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;YAC9C,MAAM,WAAW,GAAG,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC9D,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;YACnC,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,6BAA6B;QAC7B,GAAG,CAAC,MAA2B,EAAE,GAAW,EAAE,QAAa;YACzD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAC1C,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBAC1B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;gBACnC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;gBAC9C,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACxC,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;IAEF,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACxC,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,kBAAkB,CAAC,GAAgB;IACjD,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,MAAM,QAAQ,GAAG,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;QAC7D,KAAK,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAoB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC3E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,160 +0,0 @@
1
- import { createDeepProxy, proxyToPlainObject } from './proxies.js';
2
- const inBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
3
- class WrecError extends Error {
4
- }
5
- // JavaScript does not allow creating a subclass of the Proxy class.
6
- export class WrecState {
7
- static #stateMap = new Map();
8
- static {
9
- if (inBrowser) {
10
- window.addEventListener('beforeunload', () => {
11
- // This persists the data in all WrecState objects
12
- // created with the "persist" option set to true
13
- // to sessionStorage as JSON strings so they can be
14
- // restored after the user refreshes the page.
15
- for (const [name, state] of this.#stateMap.entries()) {
16
- if (state.#persist) {
17
- const obj = proxyToPlainObject(state);
18
- sessionStorage.setItem('wrec-state-' + name, JSON.stringify(obj));
19
- }
20
- }
21
- });
22
- }
23
- }
24
- // This static method is useful for accessing a specific WrecState object
25
- // from the DevTools console. For example:
26
- // state = WrecState.get('vault');
27
- //
28
- // WrecState object properties are accessed via nested Proxy objects
29
- // so all changes can be monitored.
30
- //
31
- // Properties can be directly modified as follows:
32
- // state.color = 'blue';
33
- // state.team.leader.name = 'Mark';
34
- static get(name) {
35
- return this.#stateMap.get(name);
36
- }
37
- #id = Symbol('objectId');
38
- // This cannot be replaced by a WeakMap<ChangeListener, Set<string>>
39
- // because there is no way to iterate over the keys of a WeakMap.
40
- #listenerHolders = [];
41
- #name;
42
- #persist;
43
- #proxy;
44
- constructor(name, persist, initial) {
45
- if (!name)
46
- throw new WrecError('name cannot be empty');
47
- if (WrecState.#stateMap.has(name)) {
48
- throw new WrecError(`WrecState with name "${name}" already exists`);
49
- }
50
- this.#name = name;
51
- this.#persist = persist;
52
- this.#proxy = createDeepProxy({}, this.#notifyListeners.bind(this));
53
- // If there is existing state data in sessionStorage,
54
- // use that instead of the supplied initial data.
55
- if (persist && inBrowser) {
56
- const json = sessionStorage.getItem('wrec-state-' + name);
57
- const existingState = json ? JSON.parse(json) : undefined;
58
- if (existingState)
59
- initial = existingState;
60
- }
61
- if (initial) {
62
- for (const [key, value] of Object.entries(initial)) {
63
- this.addProperty(key, value);
64
- }
65
- }
66
- WrecState.#stateMap.set(name, this);
67
- }
68
- /**
69
- * @param listener - object that has a "changed" method
70
- * @param map - map from state property paths to component properties
71
- */
72
- addListener(listener, map = {}) {
73
- // Check if the listener was already added.
74
- const listenerHolder = this.#listenerHolders.find(listenerHolder => listenerHolder.listenerRef.deref() === listener);
75
- if (listenerHolder) {
76
- // Add properties to existing propertyMap.
77
- const { propertyMap } = listenerHolder;
78
- for (const [key, value] of Object.entries(map)) {
79
- propertyMap[key] = value;
80
- }
81
- }
82
- else {
83
- // Add a new listener.
84
- this.#listenerHolders.push({
85
- listenerRef: new WeakRef(listener),
86
- propertyMap: map
87
- });
88
- }
89
- }
90
- addProperty(propName, initialValue) {
91
- Object.defineProperty(this, propName, {
92
- enumerable: true,
93
- get() {
94
- return this.#proxy[propName];
95
- },
96
- set(newValue) {
97
- this.#proxy[propName] = newValue;
98
- }
99
- });
100
- this.#proxy[propName] = initialValue;
101
- }
102
- get id() {
103
- return this.#id;
104
- }
105
- // This is useful for debugging from the DevTools console.
106
- // For example: state.log()
107
- log() {
108
- console.log('WrecState:', this.#name);
109
- for (const [key, value] of Object.entries(this.#proxy)) {
110
- console.log(` ${key} = ${JSON.stringify(value)}`);
111
- }
112
- }
113
- #notifyListeners(statePath, oldValue, newValue) {
114
- /* For debugging ...
115
- console.log(
116
- `state.ts: path ${statePath} changed from`,
117
- `${JSON.stringify(oldValue)} to ${JSON.stringify(newValue)}`
118
- );
119
- */
120
- const staleHolders = new Set();
121
- for (const holder of this.#listenerHolders) {
122
- const listener = holder.listenerRef.deref();
123
- // If the WeakRef no longer refers to a valid object ...
124
- if (!listener) {
125
- staleHolders.add(holder);
126
- // If the listener is an HTMLElement
127
- // that is disconnected from the DOM ...
128
- }
129
- else if (inBrowser &&
130
- listener instanceof HTMLElement &&
131
- !listener.isConnected) {
132
- staleHolders.add(holder);
133
- }
134
- else {
135
- const { propertyMap } = holder;
136
- const keys = Object.keys(propertyMap);
137
- if (keys.length === 0 || keys.includes(statePath)) {
138
- listener.changed(statePath, propertyMap[statePath], newValue, oldValue, this);
139
- }
140
- }
141
- }
142
- // WARNING: If the element is connected again later,
143
- // the WrecState useState method must be called again
144
- // to re-add the element as a listener.
145
- this.#listenerHolders = this.#listenerHolders.filter(holder => !staleHolders.has(holder));
146
- }
147
- removeListener(listener) {
148
- this.#listenerHolders = this.#listenerHolders.filter(holder => {
149
- return holder.listenerRef.deref() !== listener;
150
- });
151
- }
152
- }
153
- if (inBrowser) {
154
- const inDevelopment = process.env.NODE_ENV === 'development';
155
- if (inDevelopment) {
156
- // This makes the WrecState class available in the DevTools console.
157
- window.WrecState = WrecState;
158
- }
159
- }
160
- //# sourceMappingURL=wrec-state.js.map