@gramlot/gramlot 0.3.8 → 0.3.10

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.
Files changed (55) hide show
  1. package/dist/components/editors.js +116578 -0
  2. package/dist/components/inputs.js +24509 -0
  3. package/dist/components/layout.js +3385 -0
  4. package/dist/components/tree.js +24538 -0
  5. package/dist/components/typst.js +4 -0
  6. package/dist/gramlot.js +791 -37
  7. package/dist/gramlot.min.js +27 -24
  8. package/dist/runtime-notices.json +208 -0
  9. package/dist/typst-worker-source.js +4 -0
  10. package/package.json +34 -3
  11. package/src/binding/hooks.js +14 -0
  12. package/src/binding/providers.js +4 -0
  13. package/src/binding/remote.js +11 -2
  14. package/src/binding/runtime.js +10 -7
  15. package/src/builder/source.js +8 -3
  16. package/src/components/bases.js +1 -0
  17. package/src/components/border-container.js +7 -1
  18. package/src/components/buttons.js +3 -0
  19. package/src/components/choice-editor.js +17 -3
  20. package/src/components/choices.js +3 -2
  21. package/src/components/code-mirror-engine.js +91 -0
  22. package/src/components/code-mirror.js +88 -0
  23. package/src/components/editor-options.d.ts +9 -0
  24. package/src/components/editor-options.js +21 -0
  25. package/src/components/editors.js +10 -0
  26. package/src/components/html-document.js +56 -0
  27. package/src/components/html-editor.js +68 -0
  28. package/src/components/html-preview.js +33 -0
  29. package/src/components/inputs.js +2 -2
  30. package/src/components/jodit-engine.js +89 -0
  31. package/src/components/markdown-codec.js +35 -0
  32. package/src/components/markdown-document.js +14 -0
  33. package/src/components/markdown-editor.js +68 -0
  34. package/src/components/prose-mirror-engine.js +65 -0
  35. package/src/components/typst-client.js +38 -0
  36. package/src/components/typst-preview.js +88 -0
  37. package/src/components/typst-worker.js +49 -0
  38. package/src/components/typst.js +4 -0
  39. package/src/components/validation.js +1 -1
  40. package/src/filesystem.d.ts +22 -0
  41. package/src/filesystem.js +122 -0
  42. package/src/ide-documents.js +153 -0
  43. package/src/ide-runtime.d.ts +18 -0
  44. package/src/ide-runtime.js +238 -0
  45. package/src/index.d.ts +4 -1
  46. package/src/index.js +4 -1
  47. package/src/renderer/attributes.js +11 -2
  48. package/src/renderer/gramlot-renderer.js +3 -2
  49. package/src/server/assets.js +2 -2
  50. package/src/server/page.d.ts +5 -0
  51. package/src/server/page.js +4 -0
  52. package/src/view/button.js +2 -1
  53. package/src/view/controls.js +7 -11
  54. package/src/view/events.js +4 -8
  55. package/src/view/html.js +7 -0
@@ -6,22 +6,22 @@
6
6
  *
7
7
  * @module
8
8
  */
9
- var dc=Object.create;var vi=Object.defineProperty;var fc=Object.getOwnPropertyDescriptor;var hc=Object.getOwnPropertyNames;var pc=Object.getPrototypeOf,mc=Object.prototype.hasOwnProperty;var at=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},gc=(r,e)=>{for(var t in e)vi(r,t,{get:e[t],enumerable:!0})},_c=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of hc(e))!mc.call(r,s)&&s!==t&&vi(r,s,{get:()=>e[s],enumerable:!(n=fc(e,s))||n.enumerable});return r};var Ya=(r,e,t)=>(t=r!=null?dc(pc(r)):{},_c(e||!r||!r.__esModule?vi(t,"default",{value:r,enumerable:!0}):t,r));var Mt=at(ce=>{"use strict";function jd(r,e,t){if(t===void 0&&(t=Array.prototype),r&&typeof t.find=="function")return t.find.call(r,e);for(var n=0;n<r.length;n++)if(Rt(r,n)){var s=r[n];if(e.call(void 0,s,n,r))return s}}function lr(r,e){return e===void 0&&(e=Object),e&&typeof e.getOwnPropertyDescriptors=="function"&&(r=e.create(null,e.getOwnPropertyDescriptors(r))),e&&typeof e.freeze=="function"?e.freeze(r):r}function Rt(r,e){return Object.prototype.hasOwnProperty.call(r,e)}function Ud(r,e){if(r===null||typeof r!="object")throw new TypeError("target is not an object");for(var t in e)Rt(e,t)&&(r[t]=e[t]);return r}var Oo=lr({allowfullscreen:!0,async:!0,autofocus:!0,autoplay:!0,checked:!0,controls:!0,default:!0,defer:!0,disabled:!0,formnovalidate:!0,hidden:!0,ismap:!0,itemscope:!0,loop:!0,multiple:!0,muted:!0,nomodule:!0,novalidate:!0,open:!0,playsinline:!0,readonly:!0,required:!0,reversed:!0,selected:!0});function qd(r){return Rt(Oo,r.toLowerCase())}var Io=lr({area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Vd(r){return Rt(Io,r.toLowerCase())}var Zr=lr({script:!1,style:!1,textarea:!0,title:!0});function zd(r){var e=r.toLowerCase();return Rt(Zr,e)&&!Zr[e]}function Hd(r){var e=r.toLowerCase();return Rt(Zr,e)&&Zr[e]}function Bo(r){return r===Jr.HTML}function Wd(r){return Bo(r)||r===Jr.XML_XHTML_APPLICATION}var Jr=lr({HTML:"text/html",XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),Gd=Object.keys(Jr).map(function(r){return Jr[r]});function Xd(r){return Gd.indexOf(r)>-1}var Yd=lr({HTML:"http://www.w3.org/1999/xhtml",SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});ce.assign=Ud;ce.find=jd;ce.freeze=lr;ce.HTML_BOOLEAN_ATTRIBUTES=Oo;ce.HTML_RAW_TEXT_ELEMENTS=Zr;ce.HTML_VOID_ELEMENTS=Io;ce.hasDefaultHTMLNamespace=Wd;ce.hasOwn=Rt;ce.isHTMLBooleanAttribute=qd;ce.isHTMLRawTextElement=zd;ce.isHTMLEscapableRawTextElement=Hd;ce.isHTMLMimeType=Bo;ce.isHTMLVoidElement=Vd;ce.isValidMimeType=Xd;ce.MIME_TYPE=Jr;ce.NAMESPACE=Yd});var rn=at(tn=>{"use strict";var Zd=Mt();function Mo(r,e){r.prototype=Object.create(Error.prototype,{constructor:{value:r},name:{value:r.name,enumerable:!0,writable:e}})}var Qr=Zd.freeze({Error:"Error",IndexSizeError:"IndexSizeError",DomstringSizeError:"DomstringSizeError",HierarchyRequestError:"HierarchyRequestError",WrongDocumentError:"WrongDocumentError",InvalidCharacterError:"InvalidCharacterError",NoDataAllowedError:"NoDataAllowedError",NoModificationAllowedError:"NoModificationAllowedError",NotFoundError:"NotFoundError",NotSupportedError:"NotSupportedError",InUseAttributeError:"InUseAttributeError",InvalidStateError:"InvalidStateError",SyntaxError:"SyntaxError",InvalidModificationError:"InvalidModificationError",NamespaceError:"NamespaceError",InvalidAccessError:"InvalidAccessError",ValidationError:"ValidationError",TypeMismatchError:"TypeMismatchError",SecurityError:"SecurityError",NetworkError:"NetworkError",AbortError:"AbortError",URLMismatchError:"URLMismatchError",QuotaExceededError:"QuotaExceededError",TimeoutError:"TimeoutError",InvalidNodeTypeError:"InvalidNodeTypeError",DataCloneError:"DataCloneError",EncodingError:"EncodingError",NotReadableError:"NotReadableError",UnknownError:"UnknownError",ConstraintError:"ConstraintError",DataError:"DataError",TransactionInactiveError:"TransactionInactiveError",ReadOnlyError:"ReadOnlyError",VersionError:"VersionError",OperationError:"OperationError",NotAllowedError:"NotAllowedError",OptOutError:"OptOutError"}),$o=Object.keys(Qr);function Lo(r){return typeof r=="number"&&r>=1&&r<=25}function Jd(r){return typeof r=="string"&&r.substring(r.length-Qr.Error.length)===Qr.Error}function en(r,e){Lo(r)?(this.name=$o[r],this.message=e||""):(this.message=r,this.name=Jd(e)?e:Qr.Error),Error.captureStackTrace&&Error.captureStackTrace(this,en)}Mo(en,!0);Object.defineProperties(en.prototype,{code:{enumerable:!0,get:function(){var r=$o.indexOf(this.name);return Lo(r)?r:0}}});var Po={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25},Pi=Object.entries(Po);for(Kr=0;Kr<Pi.length;Kr++)Ro=Pi[Kr][0],en[Ro]=Pi[Kr][1];var Ro,Kr;function Fi(r,e,t){this.message=r,this.locator=e,this.cause=t,Error.captureStackTrace&&Error.captureStackTrace(this,Fi)}Mo(Fi);tn.DOMException=en;tn.DOMExceptionName=Qr;tn.ExceptionCode=Po;tn.ParseError=Fi});var Wi=at(I=>{"use strict";function zo(r){try{typeof r!="function"&&(r=RegExp);var e=new r("\u{1D306}","u").exec("\u{1D306}");return!!e&&e[0].length===2}catch{}return!1}var dr=zo();function ht(r){if(r.source[0]!=="[")throw new Error(r+" can not be used with chars");return r.source.slice(1,r.source.lastIndexOf("]"))}function ur(r,e){if(r.source[0]!=="[")throw new Error("/"+r.source+"/ can not be used with chars_without");if(!e||typeof e!="string")throw new Error(JSON.stringify(e)+" is not a valid search");if(r.source.indexOf(e)===-1)throw new Error('"'+e+'" is not is /'+r.source+"/");if(e==="-"&&r.source.indexOf(e)!==1)throw new Error('"'+e+'" is not at the first postion of /'+r.source+"/");return new RegExp(r.source.replace(e,""),dr?"u":"")}function $(r){var e=this;return new RegExp(Array.prototype.slice.call(arguments).map(function(t){var n=typeof t=="string";if(n&&e===void 0&&t==="|")throw new Error("use regg instead of reg to wrap expressions with `|`!");return n?t:t.source}).join(""),dr?"u":"")}function C(r){if(arguments.length===0)throw new Error("no parameters provided");return $.apply(C,["(?:"].concat(Array.prototype.slice.call(arguments),[")"]))}var Kd="\uFFFD",pt=/[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/;dr&&(pt=$("[",ht(pt),"\\u{10000}-\\u{10FFFF}","]"));var Qd=new RegExp("[^"+ht(pt)+"]",dr?"u":""),ms=/[\x20\x09\x0D\x0A]/,ef=ht(ms),H=$(ms,"+"),J=$(ms,"*"),nn=/[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;dr&&(nn=$("[",ht(nn),"\\u{10000}-\\u{10FFFF}","]"));var tf=ht(nn),qi=$("[",tf,ht(/[-.0-9\xB7]/),ht(/[\u0300-\u036F\u203F-\u2040]/),"]"),xe=$(nn,qi,"*"),rf=$("^",xe,"$"),Fo=$(qi,"+"),nf=$("&",xe,";"),sf=C(/&#[0-9]+;|&#x[0-9a-fA-F]+;/),sn=C(nf,"|",sf),an=$("%",xe,";"),Vi=C($('"',C(/[^%&"]/,"|",an,"|",sn),"*",'"'),"|",$("'",C(/[^%&']/,"|",an,"|",sn),"*","'")),af=C('"',C(/[^<&"]/,"|",sn),"*",'"',"|","'",C(/[^<&']/,"|",sn),"*","'"),of=ur(nn,":"),lf=ur(qi,":"),ji=$(of,lf,"*"),uf=$("^",ji,"$"),on=$(ji,C(":",ji),"?"),cf=$("^",on,"$"),df=$("(",on,")"),cr=C(/"[^"]*"|'[^']*'/),ff=$(/^<\?/,"(",xe,")",C(H,"(?!",ms,")(",pt,"*?)"),"?",/\?>/),jo=/[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/,ln=C('"',jo,'*"',"|","'",ur(jo,"'"),"*'"),Ho="<!--",Wo="-->",hf=$(Ho,C(ur(pt,"-"),"|",$("-",ur(pt,"-"))),"*",Wo),Uo="#PCDATA",pf=C($(/\(/,J,Uo,C(J,/\|/,J,on),"*",J,/\)\*/),"|",$(/\(/,J,Uo,J,/\)/)),mf=/[?*+]?/,gf=$(/\([^>]+\)/,mf),_f=C("EMPTY","|","ANY","|",pf,"|",gf),bf="<!ELEMENT",wf=$(bf,H,C(on,"|",an),H,C(_f,"|",an),J,">"),yf=$("NOTATION",H,/\(/,J,xe,C(J,/\|/,J,xe),"*",J,/\)/),vf=$(/\(/,J,Fo,C(J,/\|/,J,Fo),"*",J,/\)/),Ef=C(yf,"|",vf),kf=C(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/,"|",Ef),Af=C(/#REQUIRED|#IMPLIED/,"|",C(C("#FIXED",H),"?",af)),Tf=C(H,xe,H,kf,H,Af),Df="<!ATTLIST",xf=$(Df,H,xe,Tf,"*",J,">"),Ui="about:legacy-compat",Sf=C('"'+Ui+'"',"|","'"+Ui+"'"),zi="SYSTEM",gs="PUBLIC",_s=C(C(zi,H,cr),"|",C(gs,H,ln,H,cr)),Cf=$("^",C(C(zi,H,"(?<SystemLiteralOnly>",cr,")"),"|",C(gs,H,"(?<PubidLiteral>",ln,")",H,"(?<SystemLiteral>",cr,")"))),Nf=$("^",ln,"$"),Of=$("^",cr,"$"),If=C(H,"NDATA",H,xe),Bf=C(Vi,"|",C(_s,If,"?")),Go="<!ENTITY",Rf=$(Go,H,xe,H,Bf,J,">"),Mf=C(Vi,"|",_s),$f=$(Go,H,"%",H,xe,H,Mf,J,">"),Lf=C(Rf,"|",$f),Pf=$(gs,H,ln),Ff=$("<!NOTATION",H,xe,H,C(_s,"|",Pf),J,">"),Hi=$(J,"=",J),qo=/1[.]\d+/,jf=$(H,"version",Hi,C("'",qo,"'","|",'"',qo,'"')),Vo=/[A-Za-z][-A-Za-z0-9._]*/,Uf=C(H,"encoding",Hi,C('"',Vo,'"',"|","'",Vo,"'")),qf=C(H,"standalone",Hi,C("'",C("yes","|","no"),"'","|",'"',C("yes","|","no"),'"')),Vf=$(/^<\?xml/,jf,Uf,"?",qf,"?",J,/\?>/),zf="<!DOCTYPE",Hf="<![CDATA[",Wf="]]>",Gf=/<!\[CDATA\[/,Xf=/\]\]>/,Yf=$(pt,"*?",Xf),Zf=$(Gf,Yf);I.chars=ht;I.chars_without=ur;I.detectUnicodeSupport=zo;I.reg=$;I.regg=C;I.ABOUT_LEGACY_COMPAT=Ui;I.ABOUT_LEGACY_COMPAT_SystemLiteral=Sf;I.AttlistDecl=xf;I.CDATA_START=Hf;I.CDATA_END=Wf;I.CDSect=Zf;I.Char=pt;I.Comment=hf;I.COMMENT_START=Ho;I.COMMENT_END=Wo;I.DOCTYPE_DECL_START=zf;I.elementdecl=wf;I.EntityDecl=Lf;I.EntityValue=Vi;I.ExternalID=_s;I.ExternalID_match=Cf;I.Name=xe;I.Name_exact=rf;I.NCName_exact=uf;I.NotationDecl=Ff;I.Reference=sn;I.PEReference=an;I.PI=ff;I.PUBLIC=gs;I.PubidLiteral=ln;I.PubidLiteral_match=Nf;I.QName=on;I.QName_exact=cf;I.QName_group=df;I.S=H;I.SChar_s=ef;I.S_OPT=J;I.SYSTEM=zi;I.SystemLiteral=cr;I.SystemLiteral_match=Of;I.InvalidChar=Qd;I.UNICODE_REPLACEMENT_CHARACTER=Kd;I.UNICODE_SUPPORT=dr;I.XMLDecl=Vf});var ra=at(ee=>{"use strict";var Be=Mt(),Xe=Be.find,Jf=Be.hasDefaultHTMLNamespace,hr=Be.hasOwn,Kf=Be.isHTMLMimeType,Qf=Be.isHTMLRawTextElement,eh=Be.isHTMLVoidElement,un=Be.MIME_TYPE,Ye=Be.NAMESPACE,be=Symbol(),el=rn(),E=el.DOMException,me=el.DOMExceptionName,Q=Wi();function ke(r){if(r!==be)throw new TypeError("Illegal constructor")}function th(r){return r!==""}function rh(r){return r?r.split(/[\t\n\f\r ]+/).filter(th):[]}function nh(r,e){return hr(r,e)||(r[e]=!0),r}function Xo(r){if(!r)return[];var e=rh(r);return Object.keys(e.reduce(nh,{}))}function sh(r){return function(e){return r&&r.indexOf(e)!==-1}}function tl(r){if(!Q.QName_exact.test(r))throw new E(E.INVALID_CHARACTER_ERR,'invalid character in qualified name "'+r+'"')}function Xi(r,e){tl(e),r=r||null;var t=null,n=e;if(e.indexOf(":")>=0){var s=e.split(":");t=s[0],n=s[1]}if(t!==null&&r===null)throw new E(E.NAMESPACE_ERR,"prefix is non-null and namespace is null");if(t==="xml"&&r!==Be.NAMESPACE.XML)throw new E(E.NAMESPACE_ERR,'prefix is "xml" and namespace is not the XML namespace');if((t==="xmlns"||e==="xmlns")&&r!==Be.NAMESPACE.XMLNS)throw new E(E.NAMESPACE_ERR,'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace');if(r===Be.NAMESPACE.XMLNS&&t!=="xmlns"&&e!=="xmlns")throw new E(E.NAMESPACE_ERR,'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"');return[r,t,n]}function gr(r,e){for(var t in r)hr(r,t)&&(e[t]=r[t])}function Ae(r,e){var t=r.prototype;if(!(t instanceof e)){let n=function(){};n.prototype=e.prototype,n=new n,gr(t,n),r.prototype=t=n}t.constructor!=r&&(typeof r!="function"&&console.error("unknown Class:"+r),t.constructor=r)}var Te={},Ie=Te.ELEMENT_NODE=1,pr=Te.ATTRIBUTE_NODE=2,cn=Te.TEXT_NODE=3,rl=Te.CDATA_SECTION_NODE=4,nl=Te.ENTITY_REFERENCE_NODE=5,ih=Te.ENTITY_NODE=6,Yi=Te.PROCESSING_INSTRUCTION_NODE=7,Zi=Te.COMMENT_NODE=8,fr=Te.DOCUMENT_NODE=9,sl=Te.DOCUMENT_TYPE_NODE=10,mt=Te.DOCUMENT_FRAGMENT_NODE=11,ah=Te.NOTATION_NODE=12,K=Be.freeze({DOCUMENT_POSITION_DISCONNECTED:1,DOCUMENT_POSITION_PRECEDING:2,DOCUMENT_POSITION_FOLLOWING:4,DOCUMENT_POSITION_CONTAINS:8,DOCUMENT_POSITION_CONTAINED_BY:16,DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:32});function il(r,e){if(e.length<r.length)return il(e,r);var t=null;for(var n in r){if(r[n]!==e[n])return t;t=r[n]}return t}function Yo(r){return r.guid||(r.guid=Math.random()),r.guid}function ae(){}ae.prototype={length:0,item:function(r){return r>=0&&r<this.length?this[r]:null},toString:function(r){var e;typeof r=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:r}:r?e={requireWellFormed:!!r.requireWellFormed,splitCDATASections:r.splitCDATASections!==!1,nodeFilter:r.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};for(var t=[],n=0;n<this.length;n++)ta(this[n],t,null,e);return t.join("")},filter:function(r){return Array.prototype.filter.call(this,r)},indexOf:function(r){return Array.prototype.indexOf.call(this,r)}};ae.prototype[Symbol.iterator]=function(){var r=this,e=0;return{next:function(){return e<r.length?{value:r[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function Ge(r,e){this._node=r,this._refresh=e,vs(this)}function vs(r){var e=r._node._inc||r._node.ownerDocument._inc;if(r._inc!==e){var t=r._refresh(r._node);if(gl(r,"length",t.length),!r.$$length||t.length<r.$$length)for(var n=t.length;n in r;n++)hr(r,n)&&delete r[n];gr(t,r),r._inc=e}}Ge.prototype.item=function(r){return vs(this),this[r]||null};Ae(Ge,ae);function mr(){this._nsIndex=Object.create(null),this._noNsIndex=Object.create(null)}function al(r,e){for(var t=0;t<r.length;){if(r[t]===e)return t;t++}}function Ji(r,e,t){if(!e)return r._noNsIndex;var n=r._nsIndex[e];return!n&&t&&(n=r._nsIndex[e]=Object.create(null)),n}function oh(r,e,t){var n=Ji(r,e,!1),s=n&&n[t];return s||null}function lh(r,e){Ji(r,e.namespaceURI,!0)[e.localName]=e}function uh(r,e){var t=Ji(r,e.namespaceURI,!1);t&&delete t[e.localName]}function ch(r,e,t,n){if(n?e[al(e,n)]=t:(e[e.length]=t,e.length++),lh(e,t),r){t.ownerElement=r;var s=r.ownerDocument;s&&(n&&ul(s,r,n),dh(s,r,t))}}function Zo(r,e,t){var n=al(e,t);if(n>=0){for(var s=e.length-1;n<=s;)e[n]=e[++n];if(e.length=s,uh(e,t),r){var i=r.ownerDocument;i&&ul(i,r,t),t.ownerElement=null}}}mr.prototype={length:0,item:ae.prototype.item,getNamedItem:function(r){this._ownerElement&&this._ownerElement._isInHTMLDocumentAndNamespace()&&(r=r.toLowerCase());for(var e=0;e<this.length;){var t=this[e];if(t.nodeName===r)return t;e++}return null},setNamedItem:function(r){var e=r.ownerElement;if(e&&e!==this._ownerElement)throw new E(E.INUSE_ATTRIBUTE_ERR);var t=oh(this,r.namespaceURI,r.localName);return t===r?r:(ch(this._ownerElement,this,r,t),t)},setNamedItemNS:function(r){return this.setNamedItem(r)},removeNamedItem:function(r){var e=this.getNamedItem(r);if(!e)throw new E(E.NOT_FOUND_ERR,r);return Zo(this._ownerElement,this,e),e},removeNamedItemNS:function(r,e){var t=this.getNamedItemNS(r,e);if(!t)throw new E(E.NOT_FOUND_ERR,r?r+" : "+e:e);return Zo(this._ownerElement,this,t),t},getNamedItemNS:function(r,e){r||(r=null);for(var t=0;t<this.length;){var n=this[t];if(n.localName===e&&n.namespaceURI===r)return n;t++}return null}};mr.prototype[Symbol.iterator]=function(){var r=this,e=0;return{next:function(){return e<r.length?{value:r[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function ol(){}ol.prototype={hasFeature:function(r,e){return!0},createDocument:function(r,e,t){var n=un.XML_APPLICATION;r===Ye.HTML?n=un.XML_XHTML_APPLICATION:r===Ye.SVG&&(n=un.XML_SVG_IMAGE);var s=new tt(be,{contentType:n});if(s.implementation=this,s.childNodes=new ae,s.doctype=t||null,t&&s.appendChild(t),e){var i=s.createElementNS(r,e);s.appendChild(i)}return s},createDocumentType:function(r,e,t,n){tl(r);var s=new As(be);return s.name=r,s.nodeName=r,s.publicId=e||"",s.systemId=t||"",s.internalSubset=n||"",s.childNodes=new ae,s},createHTMLDocument:function(r){var e=new tt(be,{contentType:un.HTML});if(e.implementation=this,e.childNodes=new ae,r!==!1){e.doctype=this.createDocumentType("html"),e.doctype.ownerDocument=e,e.appendChild(e.doctype);var t=e.createElement("html");e.appendChild(t);var n=e.createElement("head");if(t.appendChild(n),typeof r=="string"){var s=e.createElement("title");s.appendChild(e.createTextNode(r)),n.appendChild(s)}t.appendChild(e.createElement("body"))}return e}};function F(r){ke(r)}F.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,parentNode:null,get parentElement(){return this.parentNode&&this.parentNode.nodeType===this.ELEMENT_NODE?this.parentNode:null},childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,baseURI:"about:blank",get isConnected(){var r=this.getRootNode();return r&&r.nodeType===r.DOCUMENT_NODE},contains:function(r){if(!r)return!1;var e=r;do{if(this===e)return!0;e=e.parentNode}while(e);return!1},getRootNode:function(r){var e=this;do{if(!e.parentNode)return e;e=e.parentNode}while(e)},isEqualNode:function(r){if(!r)return!1;for(var e=[{node:this,other:r}];e.length>0;){var t=e.pop(),n=t.node,s=t.other;if(n.nodeType!==s.nodeType)return!1;switch(n.nodeType){case n.DOCUMENT_TYPE_NODE:if(n.name!==s.name||n.publicId!==s.publicId||n.systemId!==s.systemId)return!1;break;case n.ELEMENT_NODE:if(n.namespaceURI!==s.namespaceURI||n.prefix!==s.prefix||n.localName!==s.localName||n.attributes.length!==s.attributes.length)return!1;for(var i=0;i<n.attributes.length;i++){var a=n.attributes.item(i),o=s.getAttributeNodeNS(a.namespaceURI,a.localName);if(!o)return!1;e.push({node:a,other:o})}break;case n.ATTRIBUTE_NODE:if(n.namespaceURI!==s.namespaceURI||n.localName!==s.localName||n.value!==s.value)return!1;break;case n.PROCESSING_INSTRUCTION_NODE:if(n.target!==s.target||n.data!==s.data)return!1;break;case n.TEXT_NODE:case n.CDATA_SECTION_NODE:case n.COMMENT_NODE:if(n.data!==s.data)return!1;break}if(n.childNodes.length!==s.childNodes.length)return!1;for(var i=n.childNodes.length-1;i>=0;i--)e.push({node:n.childNodes[i],other:s.childNodes[i]})}return!0},isSameNode:function(r){return this===r},insertBefore:function(r,e){return ys(this,r,e)},replaceChild:function(r,e){ys(this,r,e,fl),e&&this.removeChild(e)},removeChild:function(r){return cl(this,r)},appendChild:function(r){return this.insertBefore(r,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(r){return ml(this.ownerDocument||this,this,r)},normalize:function(){de(this,null,{enter:function(r){for(var e=r.firstChild;e;){var t=e.nextSibling;if(t!==null&&t.nodeType===cn&&e.nodeType===cn){for(var n=[],s=t;s!==null&&s.nodeType===cn;)n.push(s.data),s=s.nextSibling;for(var i=e.nextSibling;i!==s;){var a=i.nextSibling;i.parentNode=null,i.previousSibling=null,i.nextSibling=null,i=a}e.nextSibling=s,s!==null?s.previousSibling=e:r.lastChild=e,e.appendData(n.join("")),Ki(r.ownerDocument,r),e=s}else e=t}return!0}})},isSupported:function(r,e){return this.ownerDocument.implementation.hasFeature(r,e)},lookupPrefix:function(r){for(var e=this;e;){var t=e._nsMap;if(t){for(var n in t)if(hr(t,n)&&t[n]===r)return n}e=e.nodeType==pr?e.ownerDocument:e.parentNode}return null},lookupNamespaceURI:function(r){for(var e=this;e;){var t=e._nsMap;if(t&&hr(t,r))return t[r];e=e.nodeType==pr?e.ownerDocument:e.parentNode}return null},isDefaultNamespace:function(r){var e=this.lookupPrefix(r);return e==null},compareDocumentPosition:function(r){if(this===r)return 0;var e=r,t=this,n=null,s=null;if(e instanceof $t&&(n=e,e=n.ownerElement),t instanceof $t&&(s=t,t=s.ownerElement,n&&e&&t===e))for(var i=0,a;a=t.attributes[i];i++){if(a===n)return K.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+K.DOCUMENT_POSITION_PRECEDING;if(a===s)return K.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+K.DOCUMENT_POSITION_FOLLOWING}if(!e||!t||t.ownerDocument!==e.ownerDocument)return K.DOCUMENT_POSITION_DISCONNECTED+K.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+(Yo(t.ownerDocument)>Yo(e.ownerDocument)?K.DOCUMENT_POSITION_FOLLOWING:K.DOCUMENT_POSITION_PRECEDING);if(s&&e===t)return K.DOCUMENT_POSITION_CONTAINS+K.DOCUMENT_POSITION_PRECEDING;if(n&&e===t)return K.DOCUMENT_POSITION_CONTAINED_BY+K.DOCUMENT_POSITION_FOLLOWING;for(var o=[],l=e.parentNode;l;){if(!s&&l===t)return K.DOCUMENT_POSITION_CONTAINED_BY+K.DOCUMENT_POSITION_FOLLOWING;o.push(l),l=l.parentNode}o.reverse();for(var u=[],c=t.parentNode;c;){if(!n&&c===e)return K.DOCUMENT_POSITION_CONTAINS+K.DOCUMENT_POSITION_PRECEDING;u.push(c),c=c.parentNode}u.reverse();var d=il(o,u);for(var f in d.childNodes){var h=d.childNodes[f];if(h===t)return K.DOCUMENT_POSITION_FOLLOWING;if(h===e)return K.DOCUMENT_POSITION_PRECEDING;if(u.indexOf(h)>=0)return K.DOCUMENT_POSITION_FOLLOWING;if(o.indexOf(h)>=0)return K.DOCUMENT_POSITION_PRECEDING}return 0}};function ll(r){return r=="<"&&"&lt;"||r==">"&&"&gt;"||r=="&"&&"&amp;"||r=='"'&&"&quot;"||"&#"+r.charCodeAt()+";"}gr(Te,F);gr(Te,F.prototype);gr(K,F);gr(K,F.prototype);function ws(r,e){de(r,null,{enter:function(t){return e(t)?de.STOP:!0}})}function de(r,e,t){for(var n=[{node:r,context:e,phase:de.ENTER}];n.length>0;){var s=n.pop();if(s.phase===de.ENTER){var i=t.enter(s.node,s.context);if(i===de.STOP)return de.STOP;if(n.push({node:s.node,context:i,phase:de.EXIT}),i==null)continue;for(var a=s.node.lastChild;a;)n.push({node:a,context:i,phase:de.ENTER}),a=a.previousSibling}else t.exit&&t.exit(s.node,s.context)}}de.STOP=Symbol("walkDOM.STOP");de.ENTER=0;de.EXIT=1;function tt(r,e){ke(r);var t=e||{};this.ownerDocument=this,this.contentType=t.contentType||un.XML_APPLICATION,this.type=Kf(this.contentType)?"html":"xml"}function dh(r,e,t){r&&r._inc++;var n=t.namespaceURI;n===Ye.XMLNS&&(e._nsMap[t.prefix?t.localName:""]=t.value)}function ul(r,e,t,n){r&&r._inc++;var s=t.namespaceURI;s===Ye.XMLNS&&delete e._nsMap[t.prefix?t.localName:""]}function Ki(r,e,t){if(r&&r._inc){r._inc++;var n=e.childNodes;if(t&&!t.nextSibling)n[n.length++]=t;else{for(var s=e.firstChild,i=0;s;)n[i++]=s,s=s.nextSibling;n.length=i,delete n[n.length]}}}function cl(r,e){if(r!==e.parentNode)throw new E(E.NOT_FOUND_ERR,"child's parent is not parent");var t=e.previousSibling,n=e.nextSibling;return t?t.nextSibling=n:r.firstChild=n,n?n.previousSibling=t:r.lastChild=t,Ki(r.ownerDocument,r),e.parentNode=null,e.previousSibling=null,e.nextSibling=null,e}function fh(r){return r&&(r.nodeType===F.DOCUMENT_NODE||r.nodeType===F.DOCUMENT_FRAGMENT_NODE||r.nodeType===F.ELEMENT_NODE)}function hh(r){return r&&(r.nodeType===F.CDATA_SECTION_NODE||r.nodeType===F.COMMENT_NODE||r.nodeType===F.DOCUMENT_FRAGMENT_NODE||r.nodeType===F.DOCUMENT_TYPE_NODE||r.nodeType===F.ELEMENT_NODE||r.nodeType===F.PROCESSING_INSTRUCTION_NODE||r.nodeType===F.TEXT_NODE)}function gt(r){return r&&r.nodeType===F.DOCUMENT_TYPE_NODE}function et(r){return r&&r.nodeType===F.ELEMENT_NODE}function dl(r){return r&&r.nodeType===F.TEXT_NODE}function Jo(r,e){var t=r.childNodes||[];if(Xe(t,et)||gt(e))return!1;var n=Xe(t,gt);return!(e&&n&&t.indexOf(n)>t.indexOf(e))}function Ko(r,e){var t=r.childNodes||[];function n(i){return et(i)&&i!==e}if(Xe(t,n))return!1;var s=Xe(t,gt);return!(e&&s&&t.indexOf(s)>t.indexOf(e))}function ph(r,e,t){if(!fh(r))throw new E(E.HIERARCHY_REQUEST_ERR,"Unexpected parent node type "+r.nodeType);if(t&&t.parentNode!==r)throw new E(E.NOT_FOUND_ERR,"child not in parent");if(!hh(e)||gt(e)&&r.nodeType!==F.DOCUMENT_NODE)throw new E(E.HIERARCHY_REQUEST_ERR,"Unexpected node type "+e.nodeType+" for parent node type "+r.nodeType)}function mh(r,e,t){var n=r.childNodes||[],s=e.childNodes||[];if(e.nodeType===F.DOCUMENT_FRAGMENT_NODE){var i=s.filter(et);if(i.length>1||Xe(s,dl))throw new E(E.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(i.length===1&&!Jo(r,t))throw new E(E.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(et(e)&&!Jo(r,t))throw new E(E.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(gt(e)){if(Xe(n,gt))throw new E(E.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var a=Xe(n,et);if(t&&n.indexOf(a)<n.indexOf(t))throw new E(E.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element");if(!t&&a)throw new E(E.HIERARCHY_REQUEST_ERR,"Doctype can not be appended since element is present")}}function fl(r,e,t){var n=r.childNodes||[],s=e.childNodes||[];if(e.nodeType===F.DOCUMENT_FRAGMENT_NODE){var i=s.filter(et);if(i.length>1||Xe(s,dl))throw new E(E.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(i.length===1&&!Ko(r,t))throw new E(E.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(et(e)&&!Ko(r,t))throw new E(E.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(gt(e)){if(Xe(n,function(l){return gt(l)&&l!==t}))throw new E(E.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var a=Xe(n,et);if(t&&n.indexOf(a)<n.indexOf(t))throw new E(E.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element")}}function ys(r,e,t,n){ph(r,e,t),r.nodeType===F.DOCUMENT_NODE&&(n||mh)(r,e,t);var s=e.parentNode;if(s&&s.removeChild(e),e.nodeType===mt){var i=e.firstChild;if(i==null)return e;var a=e.lastChild}else i=a=e;var o=t?t.previousSibling:r.lastChild;i.previousSibling=o,a.nextSibling=t,o?o.nextSibling=i:r.firstChild=i,t==null?r.lastChild=a:t.previousSibling=a;do i.parentNode=r;while(i!==a&&(i=i.nextSibling));return Ki(r.ownerDocument||r,r,e),e.nodeType==mt&&(e.firstChild=e.lastChild=null),e}tt.prototype={implementation:null,nodeName:"#document",nodeType:fr,doctype:null,documentElement:null,_inc:1,insertBefore:function(r,e){if(r.nodeType===mt){for(var t=r.firstChild;t;){var n=t.nextSibling;this.insertBefore(t,e),t=n}return r}return ys(this,r,e),r.ownerDocument=this,this.documentElement===null&&r.nodeType===Ie&&(this.documentElement=r),r},removeChild:function(r){var e=cl(this,r);return e===this.documentElement&&(this.documentElement=null),e},replaceChild:function(r,e){ys(this,r,e,fl),r.ownerDocument=this,e&&this.removeChild(e),et(r)&&(this.documentElement=r)},importNode:function(r,e){return gh(this,r,e)},getElementById:function(r){var e=null;return ws(this.documentElement,function(t){if(t.nodeType==Ie&&t.getAttribute("id")==r)return e=t,!0}),e},createElement:function(r){var e=new rt(be);e.ownerDocument=this,this.type==="html"&&(r=r.toLowerCase()),Jf(this.contentType)&&(e.namespaceURI=Ye.HTML),e.nodeName=r,e.tagName=r,e.localName=r,e.childNodes=new ae;var t=e.attributes=new mr;return t._ownerElement=e,e},createDocumentFragment:function(){var r=new _r(be);return r.ownerDocument=this,r.childNodes=new ae,r},createTextNode:function(r){var e=new dn(be);return e.ownerDocument=this,e.childNodes=new ae,e.appendData(r),e},createComment:function(r){var e=new Es(be);return e.ownerDocument=this,e.childNodes=new ae,e.appendData(r),e},createCDATASection:function(r){if(r.indexOf("]]>")!==-1)throw new E(E.INVALID_CHARACTER_ERR,'data contains "]]>"');var e=new ks(be);return e.ownerDocument=this,e.childNodes=new ae,e.appendData(r),e},createProcessingInstruction:function(r,e){var t=new Ds(be);return t.ownerDocument=this,t.childNodes=new ae,t.nodeName=t.target=r,t.nodeValue=t.data=e,t},createAttribute:function(r){if(!Q.QName_exact.test(r))throw new E(E.INVALID_CHARACTER_ERR,'invalid character in name "'+r+'"');return this.type==="html"&&(r=r.toLowerCase()),this._createAttribute(r)},_createAttribute:function(r){var e=new $t(be);return e.ownerDocument=this,e.childNodes=new ae,e.name=r,e.nodeName=r,e.localName=r,e.specified=!0,e},createEntityReference:function(r){if(!Q.Name_exact.test(r))throw new E(E.INVALID_CHARACTER_ERR,'not a valid xml name "'+r+'"');if(this.type==="html")throw new E("document is an html document",me.NotSupportedError);var e=new Ts(be);return e.ownerDocument=this,e.childNodes=new ae,e.nodeName=r,e},createElementNS:function(r,e){var t=Xi(r,e),n=new rt(be),s=n.attributes=new mr;return n.childNodes=new ae,n.ownerDocument=this,n.nodeName=e,n.tagName=e,n.namespaceURI=t[0],n.prefix=t[1],n.localName=t[2],s._ownerElement=n,n},createAttributeNS:function(r,e){var t=Xi(r,e),n=new $t(be);return n.ownerDocument=this,n.childNodes=new ae,n.nodeName=e,n.name=e,n.specified=!0,n.namespaceURI=t[0],n.prefix=t[1],n.localName=t[2],n}};Ae(tt,F);function rt(r){ke(r),this._nsMap=Object.create(null)}rt.prototype={nodeType:Ie,attributes:null,getQualifiedName:function(){return this.prefix?this.prefix+":"+this.localName:this.localName},_isInHTMLDocumentAndNamespace:function(){return this.ownerDocument.type==="html"&&this.namespaceURI===Ye.HTML},hasAttributes:function(){return!!(this.attributes&&this.attributes.length)},hasAttribute:function(r){return!!this.getAttributeNode(r)},getAttribute:function(r){var e=this.getAttributeNode(r);return e?e.value:null},getAttributeNode:function(r){return this._isInHTMLDocumentAndNamespace()&&(r=r.toLowerCase()),this.attributes.getNamedItem(r)},setAttribute:function(r,e){this._isInHTMLDocumentAndNamespace()&&(r=r.toLowerCase());var t=this.getAttributeNode(r);t?t.value=t.nodeValue=""+e:(t=this.ownerDocument._createAttribute(r),t.value=t.nodeValue=""+e,this.setAttributeNode(t))},removeAttribute:function(r){var e=this.getAttributeNode(r);e&&this.removeAttributeNode(e)},setAttributeNode:function(r){return this.attributes.setNamedItem(r)},setAttributeNodeNS:function(r){return this.attributes.setNamedItemNS(r)},removeAttributeNode:function(r){return this.attributes.removeNamedItem(r.nodeName)},removeAttributeNS:function(r,e){var t=this.getAttributeNodeNS(r,e);t&&this.removeAttributeNode(t)},hasAttributeNS:function(r,e){return this.getAttributeNodeNS(r,e)!=null},getAttributeNS:function(r,e){var t=this.getAttributeNodeNS(r,e);return t?t.value:null},setAttributeNS:function(r,e,t){var n=Xi(r,e),s=n[2],i=this.getAttributeNodeNS(r,s);i?i.value=i.nodeValue=""+t:(i=this.ownerDocument.createAttributeNS(r,e),i.value=i.nodeValue=""+t,this.setAttributeNode(i))},getAttributeNodeNS:function(r,e){return this.attributes.getNamedItemNS(r,e)},getElementsByClassName:function(r){var e=Xo(r);return new Ge(this,function(t){var n=[];return e.length>0&&ws(t,function(s){if(s!==t&&s.nodeType===Ie){var i=s.getAttribute("class");if(i){var a=r===i;if(!a){var o=Xo(i);a=e.every(sh(o))}a&&n.push(s)}}}),n})},getElementsByTagName:function(r){var e=(this.nodeType===fr?this:this.ownerDocument).type==="html",t=r.toLowerCase();return new Ge(this,function(n){var s=[];return ws(n,function(i){if(!(i===n||i.nodeType!==Ie))if(r==="*")s.push(i);else{var a=i.getQualifiedName(),o=e&&i.namespaceURI===Ye.HTML?t:r;a===o&&s.push(i)}}),s})},getElementsByTagNameNS:function(r,e){return new Ge(this,function(t){var n=[];return ws(t,function(s){s!==t&&s.nodeType===Ie&&(r==="*"||s.namespaceURI===r)&&(e==="*"||s.localName==e)&&n.push(s)}),n})}};tt.prototype.getElementsByClassName=rt.prototype.getElementsByClassName;tt.prototype.getElementsByTagName=rt.prototype.getElementsByTagName;tt.prototype.getElementsByTagNameNS=rt.prototype.getElementsByTagNameNS;Ae(rt,F);function $t(r){ke(r),this.namespaceURI=null,this.prefix=null,this.ownerElement=null}$t.prototype.nodeType=pr;Ae($t,F);function _t(r){ke(r)}_t.prototype={data:"",substringData:function(r,e){return this.data.substring(r,r+e)},appendData:function(r){r=this.data+r,this.nodeValue=this.data=r,this.length=r.length},insertData:function(r,e){this.replaceData(r,0,e)},deleteData:function(r,e){this.replaceData(r,e,"")},replaceData:function(r,e,t){var n=this.data.substring(0,r),s=this.data.substring(r+e);t=n+t+s,this.nodeValue=this.data=t,this.length=t.length}};Ae(_t,F);function dn(r){ke(r)}dn.prototype={nodeName:"#text",nodeType:cn,splitText:function(r){var e=this.data,t=e.substring(r);e=e.substring(0,r),this.data=this.nodeValue=e,this.length=e.length;var n=this.ownerDocument.createTextNode(t);return this.parentNode&&this.parentNode.insertBefore(n,this.nextSibling),n}};Ae(dn,_t);function Es(r){ke(r)}Es.prototype={nodeName:"#comment",nodeType:Zi};Ae(Es,_t);function ks(r){ke(r)}ks.prototype={nodeName:"#cdata-section",nodeType:rl};Ae(ks,dn);function As(r){ke(r)}As.prototype.nodeType=sl;Ae(As,F);function Qi(r){ke(r)}Qi.prototype.nodeType=ah;Ae(Qi,F);function ea(r){ke(r)}ea.prototype.nodeType=ih;Ae(ea,F);function Ts(r){ke(r)}Ts.prototype.nodeType=nl;Ae(Ts,F);function _r(r){ke(r)}_r.prototype.nodeName="#document-fragment";_r.prototype.nodeType=mt;Ae(_r,F);function Ds(r){ke(r)}Ds.prototype.nodeType=Yi;Ae(Ds,_t);function hl(){}hl.prototype.serializeToString=function(r,e){return pl.call(r,e)};F.prototype.toString=pl;function pl(r){var e;typeof r=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:r}:r!=null?e={requireWellFormed:!!r.requireWellFormed,splitCDATASections:r.splitCDATASections!==!1,nodeFilter:r.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};var t=[],n=this.nodeType===fr&&this.documentElement||this,s=n.prefix,i=n.namespaceURI;if(i&&s==null){var s=n.lookupPrefix(i);if(s==null)var a=[{namespace:i,prefix:null}]}return ta(this,t,a,e),t.join("")}function Qo(r,e,t){var n=r.prefix||"",s=r.namespaceURI;if(!s||n==="xml"&&s===Ye.XML||s===Ye.XMLNS)return!1;for(var i=t.length;i--;){var a=t[i];if(a.prefix===n)return a.namespace!==s}return!0}function bs(r,e,t,n){if(n&&!Q.QName_exact.test(e))throw new E('The attribute name "'+e+'" is not a valid XML QName',me.InvalidStateError);r.push(" ",e,'="',t.replace(/[<>&"\t\n\r]/g,ll),'"')}function ta(r,e,t,n){t||(t=[]);var s=n.nodeFilter,i=n.requireWellFormed,a=n.splitCDATASections,o=r.nodeType===fr?r:r.ownerDocument,l=o.type==="html";de(r,{ns:t},{enter:function(u,c){var d=c.ns;if(s)if(u=s(u),u){if(typeof u=="string")return e.push(u),null}else return null;switch(u.nodeType){case Ie:var f=u.attributes,h=f.length,p=u.tagName,m=p;if(!l&&!u.prefix&&u.namespaceURI){for(var g,_=0;_<f.length;_++)if(f.item(_).name==="xmlns"){g=f.item(_).value;break}if(!g)for(var w=d.length-1;w>=0;w--){var y=d[w];if(y.prefix===""&&y.namespace===u.namespaceURI){g=y.namespace;break}}if(g!==u.namespaceURI)for(var w=d.length-1;w>=0;w--){var y=d[w];if(y.namespace===u.namespaceURI){y.prefix&&(m=y.prefix+":"+p);break}}}if(i&&!Q.QName_exact.test(m))throw new E('The element name "'+m+'" is not a valid XML QName',me.InvalidStateError);e.push("<",m);for(var k=d.slice(),T=0;T<h;T++){var v=f.item(T);v.prefix=="xmlns"?k.push({prefix:v.localName,namespace:v.value}):v.nodeName=="xmlns"&&k.push({prefix:"",namespace:v.value})}for(var T=0;T<h;T++){var v=f.item(T);if(Qo(v,l,k)){var N=v.prefix||"",L=v.namespaceURI;bs(e,N?"xmlns:"+N:"xmlns",L,i),k.push({prefix:N,namespace:L})}var U=s?s(v):v;U&&(typeof U=="string"?e.push(U):bs(e,U.name,U.value,i))}if(p===m&&Qo(u,l,k)){var ve=u.prefix||"",L=u.namespaceURI;bs(e,ve?"xmlns:"+ve:"xmlns",L,i),k.push({prefix:ve,namespace:L})}var Y=!u.firstChild;if(Y&&(l||u.namespaceURI===Ye.HTML)&&(Y=eh(p)),Y)return e.push("/>"),null;if(e.push(">"),l&&Qf(p)){for(var re=u.firstChild;re;)re.data?e.push(re.data):ta(re,e,k.slice(),n),re=re.nextSibling;return e.push("</",m,">"),null}return{ns:k,tag:m};case fr:case mt:if(i&&u.nodeType===fr&&u.documentElement==null)throw new E("The Document has no documentElement",me.InvalidStateError);return{ns:d};case pr:return bs(e,u.name,u.value,i),null;case cn:if(i&&Q.InvalidChar.test(u.data))throw new E("The Text node data contains characters outside the XML Char production",me.InvalidStateError);return e.push(u.data.replace(/[<&>]/g,ll)),null;case rl:if(i&&u.data.indexOf("]]>")!==-1)throw new E('The CDATASection data contains "]]>"',me.InvalidStateError);return a?e.push(Q.CDATA_START,u.data.replace(/]]>/g,"]]]]><![CDATA[>"),Q.CDATA_END):e.push(Q.CDATA_START,u.data,Q.CDATA_END),null;case Zi:if(i){if(Q.InvalidChar.test(u.data))throw new E("The comment node data contains characters outside the XML Char production",me.InvalidStateError);if(u.data.indexOf("--")!==-1||u.data[u.data.length-1]==="-")throw new E('The comment node data contains "--" or ends with "-"',me.InvalidStateError)}return e.push(Q.COMMENT_START,u.data,Q.COMMENT_END),null;case sl:var Ne=u.publicId,G=u.systemId;if(i){if(!Q.Name_exact.test(u.name))throw new E('The doctype name "'+u.name+'" is not a valid XML Name',me.InvalidStateError);if(Ne&&!Q.PubidLiteral_match.test(Ne))throw new E("DocumentType publicId is not a valid PubidLiteral",me.InvalidStateError);if(G&&G!=="."&&!Q.SystemLiteral_match.test(G))throw new E("DocumentType systemId is not a valid SystemLiteral",me.InvalidStateError);if(u.internalSubset&&u.internalSubset.indexOf("]>")!==-1)throw new E('DocumentType internalSubset contains "]>"',me.InvalidStateError)}return e.push(Q.DOCTYPE_DECL_START," ",u.name),Ne?(e.push(" ",Q.PUBLIC," ",Ne),G&&G!=="."&&e.push(" ",G)):G&&G!=="."&&e.push(" ",Q.SYSTEM," ",G),u.internalSubset&&e.push(" [",u.internalSubset,"]"),e.push(">"),null;case Yi:if(i){if(!Q.NCName_exact.test(u.target)||u.target.toLowerCase()==="xml")throw new E('The processing instruction target "'+u.target+'" is not a valid XML NCName or is reserved',me.InvalidStateError);if(Q.InvalidChar.test(u.data))throw new E("The ProcessingInstruction data contains characters outside the XML Char production",me.InvalidStateError);if(u.data.indexOf("?>")!==-1)throw new E('The ProcessingInstruction data contains "?>"',me.InvalidStateError)}return e.push("<?",u.target," ",u.data,"?>"),null;case nl:if(i&&!Q.Name_exact.test(u.nodeName))throw new E('The entity reference name "'+u.nodeName+'" is not a valid XML Name',me.InvalidStateError);return e.push("&",u.nodeName,";"),null;default:return e.push("??",u.nodeName),null}},exit:function(u,c){c&&c.tag&&e.push("</",c.tag,">")}})}function gh(r,e,t){var n;return de(e,null,{enter:function(s,i){var a=s.cloneNode(!1);a.ownerDocument=r,a.parentNode=null,i===null?n=a:i.appendChild(a);var o=s.nodeType===pr||t;return o?a:null}}),n}function ml(r,e,t){var n;return de(e,null,{enter:function(s,i){var a=new s.constructor(be);for(var o in s)if(hr(s,o)){var l=s[o];typeof l!="object"&&l!=a[o]&&(a[o]=l)}s.childNodes&&(a.childNodes=new ae),a.ownerDocument=r;var u=t;switch(a.nodeType){case Ie:var c=s.attributes,d=a.attributes=new mr,f=c.length;d._ownerElement=a;for(var h=0;h<f;h++)a.setAttributeNode(ml(r,c.item(h),!0));break;case pr:u=!0}return i!==null?i.appendChild(a):n=a,u?a:null}}),n}function gl(r,e,t){r[e]=t}function Gi(r){for(var e=[],t=r.firstChild;t;)t.nodeType===Ie&&e.push(t),t=t.nextSibling;return e}try{Object.defineProperty&&(Object.defineProperty(Ge.prototype,"length",{get:function(){return vs(this),this.$$length}}),Object.defineProperty(F.prototype,"textContent",{get:function(){if(this.nodeType===Ie||this.nodeType===mt){var r=[];return de(this,null,{enter:function(e){if(e.nodeType===Ie||e.nodeType===mt)return!0;if(e.nodeType===Yi||e.nodeType===Zi)return null;r.push(e.nodeValue)}}),r.join("")}return this.nodeValue},set:function(r){switch(this.nodeType){case Ie:case mt:for(;this.firstChild;)this.removeChild(this.firstChild);(r||String(r))&&this.appendChild(this.ownerDocument.createTextNode(r));break;default:this.data=r,this.value=r,this.nodeValue=r}}}),Object.defineProperty(_t.prototype,"data",{get:function(){return this._data!=null?this._data:""},set:function(r){this._data=r,this.length=typeof r=="string"?r.length:0}}),Object.defineProperty(_t.prototype,"nodeValue",{get:function(){return this.data},set:function(r){this.data=r},enumerable:!0,configurable:!0}),Object.defineProperty(rt.prototype,"children",{get:function(){return new Ge(this,Gi)}}),Object.defineProperty(tt.prototype,"children",{get:function(){return new Ge(this,Gi)}}),Object.defineProperty(_r.prototype,"children",{get:function(){return new Ge(this,Gi)}}),gl=function(r,e,t){r["$$"+e]=t})}catch{}ee._updateLiveList=vs;ee.Attr=$t;ee.CDATASection=ks;ee.CharacterData=_t;ee.Comment=Es;ee.Document=tt;ee.DocumentFragment=_r;ee.DocumentType=As;ee.DOMImplementation=ol;ee.Element=rt;ee.Entity=ea;ee.EntityReference=Ts;ee.LiveNodeList=Ge;ee.NamedNodeMap=mr;ee.Node=F;ee.NodeList=ae;ee.Notation=Qi;ee.Text=dn;ee.ProcessingInstruction=Ds;ee.walkDOM=de;ee.XMLSerializer=hl});var bl=at(fn=>{"use strict";var _l=Mt().freeze;fn.XML_ENTITIES=_l({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});fn.HTML_ENTITIES=_l({Aacute:"\xC1",aacute:"\xE1",Abreve:"\u0102",abreve:"\u0103",ac:"\u223E",acd:"\u223F",acE:"\u223E\u0333",Acirc:"\xC2",acirc:"\xE2",acute:"\xB4",Acy:"\u0410",acy:"\u0430",AElig:"\xC6",aelig:"\xE6",af:"\u2061",Afr:"\u{1D504}",afr:"\u{1D51E}",Agrave:"\xC0",agrave:"\xE0",alefsym:"\u2135",aleph:"\u2135",Alpha:"\u0391",alpha:"\u03B1",Amacr:"\u0100",amacr:"\u0101",amalg:"\u2A3F",AMP:"&",amp:"&",And:"\u2A53",and:"\u2227",andand:"\u2A55",andd:"\u2A5C",andslope:"\u2A58",andv:"\u2A5A",ang:"\u2220",ange:"\u29A4",angle:"\u2220",angmsd:"\u2221",angmsdaa:"\u29A8",angmsdab:"\u29A9",angmsdac:"\u29AA",angmsdad:"\u29AB",angmsdae:"\u29AC",angmsdaf:"\u29AD",angmsdag:"\u29AE",angmsdah:"\u29AF",angrt:"\u221F",angrtvb:"\u22BE",angrtvbd:"\u299D",angsph:"\u2222",angst:"\xC5",angzarr:"\u237C",Aogon:"\u0104",aogon:"\u0105",Aopf:"\u{1D538}",aopf:"\u{1D552}",ap:"\u2248",apacir:"\u2A6F",apE:"\u2A70",ape:"\u224A",apid:"\u224B",apos:"'",ApplyFunction:"\u2061",approx:"\u2248",approxeq:"\u224A",Aring:"\xC5",aring:"\xE5",Ascr:"\u{1D49C}",ascr:"\u{1D4B6}",Assign:"\u2254",ast:"*",asymp:"\u2248",asympeq:"\u224D",Atilde:"\xC3",atilde:"\xE3",Auml:"\xC4",auml:"\xE4",awconint:"\u2233",awint:"\u2A11",backcong:"\u224C",backepsilon:"\u03F6",backprime:"\u2035",backsim:"\u223D",backsimeq:"\u22CD",Backslash:"\u2216",Barv:"\u2AE7",barvee:"\u22BD",Barwed:"\u2306",barwed:"\u2305",barwedge:"\u2305",bbrk:"\u23B5",bbrktbrk:"\u23B6",bcong:"\u224C",Bcy:"\u0411",bcy:"\u0431",bdquo:"\u201E",becaus:"\u2235",Because:"\u2235",because:"\u2235",bemptyv:"\u29B0",bepsi:"\u03F6",bernou:"\u212C",Bernoullis:"\u212C",Beta:"\u0392",beta:"\u03B2",beth:"\u2136",between:"\u226C",Bfr:"\u{1D505}",bfr:"\u{1D51F}",bigcap:"\u22C2",bigcirc:"\u25EF",bigcup:"\u22C3",bigodot:"\u2A00",bigoplus:"\u2A01",bigotimes:"\u2A02",bigsqcup:"\u2A06",bigstar:"\u2605",bigtriangledown:"\u25BD",bigtriangleup:"\u25B3",biguplus:"\u2A04",bigvee:"\u22C1",bigwedge:"\u22C0",bkarow:"\u290D",blacklozenge:"\u29EB",blacksquare:"\u25AA",blacktriangle:"\u25B4",blacktriangledown:"\u25BE",blacktriangleleft:"\u25C2",blacktriangleright:"\u25B8",blank:"\u2423",blk12:"\u2592",blk14:"\u2591",blk34:"\u2593",block:"\u2588",bne:"=\u20E5",bnequiv:"\u2261\u20E5",bNot:"\u2AED",bnot:"\u2310",Bopf:"\u{1D539}",bopf:"\u{1D553}",bot:"\u22A5",bottom:"\u22A5",bowtie:"\u22C8",boxbox:"\u29C9",boxDL:"\u2557",boxDl:"\u2556",boxdL:"\u2555",boxdl:"\u2510",boxDR:"\u2554",boxDr:"\u2553",boxdR:"\u2552",boxdr:"\u250C",boxH:"\u2550",boxh:"\u2500",boxHD:"\u2566",boxHd:"\u2564",boxhD:"\u2565",boxhd:"\u252C",boxHU:"\u2569",boxHu:"\u2567",boxhU:"\u2568",boxhu:"\u2534",boxminus:"\u229F",boxplus:"\u229E",boxtimes:"\u22A0",boxUL:"\u255D",boxUl:"\u255C",boxuL:"\u255B",boxul:"\u2518",boxUR:"\u255A",boxUr:"\u2559",boxuR:"\u2558",boxur:"\u2514",boxV:"\u2551",boxv:"\u2502",boxVH:"\u256C",boxVh:"\u256B",boxvH:"\u256A",boxvh:"\u253C",boxVL:"\u2563",boxVl:"\u2562",boxvL:"\u2561",boxvl:"\u2524",boxVR:"\u2560",boxVr:"\u255F",boxvR:"\u255E",boxvr:"\u251C",bprime:"\u2035",Breve:"\u02D8",breve:"\u02D8",brvbar:"\xA6",Bscr:"\u212C",bscr:"\u{1D4B7}",bsemi:"\u204F",bsim:"\u223D",bsime:"\u22CD",bsol:"\\",bsolb:"\u29C5",bsolhsub:"\u27C8",bull:"\u2022",bullet:"\u2022",bump:"\u224E",bumpE:"\u2AAE",bumpe:"\u224F",Bumpeq:"\u224E",bumpeq:"\u224F",Cacute:"\u0106",cacute:"\u0107",Cap:"\u22D2",cap:"\u2229",capand:"\u2A44",capbrcup:"\u2A49",capcap:"\u2A4B",capcup:"\u2A47",capdot:"\u2A40",CapitalDifferentialD:"\u2145",caps:"\u2229\uFE00",caret:"\u2041",caron:"\u02C7",Cayleys:"\u212D",ccaps:"\u2A4D",Ccaron:"\u010C",ccaron:"\u010D",Ccedil:"\xC7",ccedil:"\xE7",Ccirc:"\u0108",ccirc:"\u0109",Cconint:"\u2230",ccups:"\u2A4C",ccupssm:"\u2A50",Cdot:"\u010A",cdot:"\u010B",cedil:"\xB8",Cedilla:"\xB8",cemptyv:"\u29B2",cent:"\xA2",CenterDot:"\xB7",centerdot:"\xB7",Cfr:"\u212D",cfr:"\u{1D520}",CHcy:"\u0427",chcy:"\u0447",check:"\u2713",checkmark:"\u2713",Chi:"\u03A7",chi:"\u03C7",cir:"\u25CB",circ:"\u02C6",circeq:"\u2257",circlearrowleft:"\u21BA",circlearrowright:"\u21BB",circledast:"\u229B",circledcirc:"\u229A",circleddash:"\u229D",CircleDot:"\u2299",circledR:"\xAE",circledS:"\u24C8",CircleMinus:"\u2296",CirclePlus:"\u2295",CircleTimes:"\u2297",cirE:"\u29C3",cire:"\u2257",cirfnint:"\u2A10",cirmid:"\u2AEF",cirscir:"\u29C2",ClockwiseContourIntegral:"\u2232",CloseCurlyDoubleQuote:"\u201D",CloseCurlyQuote:"\u2019",clubs:"\u2663",clubsuit:"\u2663",Colon:"\u2237",colon:":",Colone:"\u2A74",colone:"\u2254",coloneq:"\u2254",comma:",",commat:"@",comp:"\u2201",compfn:"\u2218",complement:"\u2201",complexes:"\u2102",cong:"\u2245",congdot:"\u2A6D",Congruent:"\u2261",Conint:"\u222F",conint:"\u222E",ContourIntegral:"\u222E",Copf:"\u2102",copf:"\u{1D554}",coprod:"\u2210",Coproduct:"\u2210",COPY:"\xA9",copy:"\xA9",copysr:"\u2117",CounterClockwiseContourIntegral:"\u2233",crarr:"\u21B5",Cross:"\u2A2F",cross:"\u2717",Cscr:"\u{1D49E}",cscr:"\u{1D4B8}",csub:"\u2ACF",csube:"\u2AD1",csup:"\u2AD0",csupe:"\u2AD2",ctdot:"\u22EF",cudarrl:"\u2938",cudarrr:"\u2935",cuepr:"\u22DE",cuesc:"\u22DF",cularr:"\u21B6",cularrp:"\u293D",Cup:"\u22D3",cup:"\u222A",cupbrcap:"\u2A48",CupCap:"\u224D",cupcap:"\u2A46",cupcup:"\u2A4A",cupdot:"\u228D",cupor:"\u2A45",cups:"\u222A\uFE00",curarr:"\u21B7",curarrm:"\u293C",curlyeqprec:"\u22DE",curlyeqsucc:"\u22DF",curlyvee:"\u22CE",curlywedge:"\u22CF",curren:"\xA4",curvearrowleft:"\u21B6",curvearrowright:"\u21B7",cuvee:"\u22CE",cuwed:"\u22CF",cwconint:"\u2232",cwint:"\u2231",cylcty:"\u232D",Dagger:"\u2021",dagger:"\u2020",daleth:"\u2138",Darr:"\u21A1",dArr:"\u21D3",darr:"\u2193",dash:"\u2010",Dashv:"\u2AE4",dashv:"\u22A3",dbkarow:"\u290F",dblac:"\u02DD",Dcaron:"\u010E",dcaron:"\u010F",Dcy:"\u0414",dcy:"\u0434",DD:"\u2145",dd:"\u2146",ddagger:"\u2021",ddarr:"\u21CA",DDotrahd:"\u2911",ddotseq:"\u2A77",deg:"\xB0",Del:"\u2207",Delta:"\u0394",delta:"\u03B4",demptyv:"\u29B1",dfisht:"\u297F",Dfr:"\u{1D507}",dfr:"\u{1D521}",dHar:"\u2965",dharl:"\u21C3",dharr:"\u21C2",DiacriticalAcute:"\xB4",DiacriticalDot:"\u02D9",DiacriticalDoubleAcute:"\u02DD",DiacriticalGrave:"`",DiacriticalTilde:"\u02DC",diam:"\u22C4",Diamond:"\u22C4",diamond:"\u22C4",diamondsuit:"\u2666",diams:"\u2666",die:"\xA8",DifferentialD:"\u2146",digamma:"\u03DD",disin:"\u22F2",div:"\xF7",divide:"\xF7",divideontimes:"\u22C7",divonx:"\u22C7",DJcy:"\u0402",djcy:"\u0452",dlcorn:"\u231E",dlcrop:"\u230D",dollar:"$",Dopf:"\u{1D53B}",dopf:"\u{1D555}",Dot:"\xA8",dot:"\u02D9",DotDot:"\u20DC",doteq:"\u2250",doteqdot:"\u2251",DotEqual:"\u2250",dotminus:"\u2238",dotplus:"\u2214",dotsquare:"\u22A1",doublebarwedge:"\u2306",DoubleContourIntegral:"\u222F",DoubleDot:"\xA8",DoubleDownArrow:"\u21D3",DoubleLeftArrow:"\u21D0",DoubleLeftRightArrow:"\u21D4",DoubleLeftTee:"\u2AE4",DoubleLongLeftArrow:"\u27F8",DoubleLongLeftRightArrow:"\u27FA",DoubleLongRightArrow:"\u27F9",DoubleRightArrow:"\u21D2",DoubleRightTee:"\u22A8",DoubleUpArrow:"\u21D1",DoubleUpDownArrow:"\u21D5",DoubleVerticalBar:"\u2225",DownArrow:"\u2193",Downarrow:"\u21D3",downarrow:"\u2193",DownArrowBar:"\u2913",DownArrowUpArrow:"\u21F5",DownBreve:"\u0311",downdownarrows:"\u21CA",downharpoonleft:"\u21C3",downharpoonright:"\u21C2",DownLeftRightVector:"\u2950",DownLeftTeeVector:"\u295E",DownLeftVector:"\u21BD",DownLeftVectorBar:"\u2956",DownRightTeeVector:"\u295F",DownRightVector:"\u21C1",DownRightVectorBar:"\u2957",DownTee:"\u22A4",DownTeeArrow:"\u21A7",drbkarow:"\u2910",drcorn:"\u231F",drcrop:"\u230C",Dscr:"\u{1D49F}",dscr:"\u{1D4B9}",DScy:"\u0405",dscy:"\u0455",dsol:"\u29F6",Dstrok:"\u0110",dstrok:"\u0111",dtdot:"\u22F1",dtri:"\u25BF",dtrif:"\u25BE",duarr:"\u21F5",duhar:"\u296F",dwangle:"\u29A6",DZcy:"\u040F",dzcy:"\u045F",dzigrarr:"\u27FF",Eacute:"\xC9",eacute:"\xE9",easter:"\u2A6E",Ecaron:"\u011A",ecaron:"\u011B",ecir:"\u2256",Ecirc:"\xCA",ecirc:"\xEA",ecolon:"\u2255",Ecy:"\u042D",ecy:"\u044D",eDDot:"\u2A77",Edot:"\u0116",eDot:"\u2251",edot:"\u0117",ee:"\u2147",efDot:"\u2252",Efr:"\u{1D508}",efr:"\u{1D522}",eg:"\u2A9A",Egrave:"\xC8",egrave:"\xE8",egs:"\u2A96",egsdot:"\u2A98",el:"\u2A99",Element:"\u2208",elinters:"\u23E7",ell:"\u2113",els:"\u2A95",elsdot:"\u2A97",Emacr:"\u0112",emacr:"\u0113",empty:"\u2205",emptyset:"\u2205",EmptySmallSquare:"\u25FB",emptyv:"\u2205",EmptyVerySmallSquare:"\u25AB",emsp:"\u2003",emsp13:"\u2004",emsp14:"\u2005",ENG:"\u014A",eng:"\u014B",ensp:"\u2002",Eogon:"\u0118",eogon:"\u0119",Eopf:"\u{1D53C}",eopf:"\u{1D556}",epar:"\u22D5",eparsl:"\u29E3",eplus:"\u2A71",epsi:"\u03B5",Epsilon:"\u0395",epsilon:"\u03B5",epsiv:"\u03F5",eqcirc:"\u2256",eqcolon:"\u2255",eqsim:"\u2242",eqslantgtr:"\u2A96",eqslantless:"\u2A95",Equal:"\u2A75",equals:"=",EqualTilde:"\u2242",equest:"\u225F",Equilibrium:"\u21CC",equiv:"\u2261",equivDD:"\u2A78",eqvparsl:"\u29E5",erarr:"\u2971",erDot:"\u2253",Escr:"\u2130",escr:"\u212F",esdot:"\u2250",Esim:"\u2A73",esim:"\u2242",Eta:"\u0397",eta:"\u03B7",ETH:"\xD0",eth:"\xF0",Euml:"\xCB",euml:"\xEB",euro:"\u20AC",excl:"!",exist:"\u2203",Exists:"\u2203",expectation:"\u2130",ExponentialE:"\u2147",exponentiale:"\u2147",fallingdotseq:"\u2252",Fcy:"\u0424",fcy:"\u0444",female:"\u2640",ffilig:"\uFB03",fflig:"\uFB00",ffllig:"\uFB04",Ffr:"\u{1D509}",ffr:"\u{1D523}",filig:"\uFB01",FilledSmallSquare:"\u25FC",FilledVerySmallSquare:"\u25AA",fjlig:"fj",flat:"\u266D",fllig:"\uFB02",fltns:"\u25B1",fnof:"\u0192",Fopf:"\u{1D53D}",fopf:"\u{1D557}",ForAll:"\u2200",forall:"\u2200",fork:"\u22D4",forkv:"\u2AD9",Fouriertrf:"\u2131",fpartint:"\u2A0D",frac12:"\xBD",frac13:"\u2153",frac14:"\xBC",frac15:"\u2155",frac16:"\u2159",frac18:"\u215B",frac23:"\u2154",frac25:"\u2156",frac34:"\xBE",frac35:"\u2157",frac38:"\u215C",frac45:"\u2158",frac56:"\u215A",frac58:"\u215D",frac78:"\u215E",frasl:"\u2044",frown:"\u2322",Fscr:"\u2131",fscr:"\u{1D4BB}",gacute:"\u01F5",Gamma:"\u0393",gamma:"\u03B3",Gammad:"\u03DC",gammad:"\u03DD",gap:"\u2A86",Gbreve:"\u011E",gbreve:"\u011F",Gcedil:"\u0122",Gcirc:"\u011C",gcirc:"\u011D",Gcy:"\u0413",gcy:"\u0433",Gdot:"\u0120",gdot:"\u0121",gE:"\u2267",ge:"\u2265",gEl:"\u2A8C",gel:"\u22DB",geq:"\u2265",geqq:"\u2267",geqslant:"\u2A7E",ges:"\u2A7E",gescc:"\u2AA9",gesdot:"\u2A80",gesdoto:"\u2A82",gesdotol:"\u2A84",gesl:"\u22DB\uFE00",gesles:"\u2A94",Gfr:"\u{1D50A}",gfr:"\u{1D524}",Gg:"\u22D9",gg:"\u226B",ggg:"\u22D9",gimel:"\u2137",GJcy:"\u0403",gjcy:"\u0453",gl:"\u2277",gla:"\u2AA5",glE:"\u2A92",glj:"\u2AA4",gnap:"\u2A8A",gnapprox:"\u2A8A",gnE:"\u2269",gne:"\u2A88",gneq:"\u2A88",gneqq:"\u2269",gnsim:"\u22E7",Gopf:"\u{1D53E}",gopf:"\u{1D558}",grave:"`",GreaterEqual:"\u2265",GreaterEqualLess:"\u22DB",GreaterFullEqual:"\u2267",GreaterGreater:"\u2AA2",GreaterLess:"\u2277",GreaterSlantEqual:"\u2A7E",GreaterTilde:"\u2273",Gscr:"\u{1D4A2}",gscr:"\u210A",gsim:"\u2273",gsime:"\u2A8E",gsiml:"\u2A90",Gt:"\u226B",GT:">",gt:">",gtcc:"\u2AA7",gtcir:"\u2A7A",gtdot:"\u22D7",gtlPar:"\u2995",gtquest:"\u2A7C",gtrapprox:"\u2A86",gtrarr:"\u2978",gtrdot:"\u22D7",gtreqless:"\u22DB",gtreqqless:"\u2A8C",gtrless:"\u2277",gtrsim:"\u2273",gvertneqq:"\u2269\uFE00",gvnE:"\u2269\uFE00",Hacek:"\u02C7",hairsp:"\u200A",half:"\xBD",hamilt:"\u210B",HARDcy:"\u042A",hardcy:"\u044A",hArr:"\u21D4",harr:"\u2194",harrcir:"\u2948",harrw:"\u21AD",Hat:"^",hbar:"\u210F",Hcirc:"\u0124",hcirc:"\u0125",hearts:"\u2665",heartsuit:"\u2665",hellip:"\u2026",hercon:"\u22B9",Hfr:"\u210C",hfr:"\u{1D525}",HilbertSpace:"\u210B",hksearow:"\u2925",hkswarow:"\u2926",hoarr:"\u21FF",homtht:"\u223B",hookleftarrow:"\u21A9",hookrightarrow:"\u21AA",Hopf:"\u210D",hopf:"\u{1D559}",horbar:"\u2015",HorizontalLine:"\u2500",Hscr:"\u210B",hscr:"\u{1D4BD}",hslash:"\u210F",Hstrok:"\u0126",hstrok:"\u0127",HumpDownHump:"\u224E",HumpEqual:"\u224F",hybull:"\u2043",hyphen:"\u2010",Iacute:"\xCD",iacute:"\xED",ic:"\u2063",Icirc:"\xCE",icirc:"\xEE",Icy:"\u0418",icy:"\u0438",Idot:"\u0130",IEcy:"\u0415",iecy:"\u0435",iexcl:"\xA1",iff:"\u21D4",Ifr:"\u2111",ifr:"\u{1D526}",Igrave:"\xCC",igrave:"\xEC",ii:"\u2148",iiiint:"\u2A0C",iiint:"\u222D",iinfin:"\u29DC",iiota:"\u2129",IJlig:"\u0132",ijlig:"\u0133",Im:"\u2111",Imacr:"\u012A",imacr:"\u012B",image:"\u2111",ImaginaryI:"\u2148",imagline:"\u2110",imagpart:"\u2111",imath:"\u0131",imof:"\u22B7",imped:"\u01B5",Implies:"\u21D2",in:"\u2208",incare:"\u2105",infin:"\u221E",infintie:"\u29DD",inodot:"\u0131",Int:"\u222C",int:"\u222B",intcal:"\u22BA",integers:"\u2124",Integral:"\u222B",intercal:"\u22BA",Intersection:"\u22C2",intlarhk:"\u2A17",intprod:"\u2A3C",InvisibleComma:"\u2063",InvisibleTimes:"\u2062",IOcy:"\u0401",iocy:"\u0451",Iogon:"\u012E",iogon:"\u012F",Iopf:"\u{1D540}",iopf:"\u{1D55A}",Iota:"\u0399",iota:"\u03B9",iprod:"\u2A3C",iquest:"\xBF",Iscr:"\u2110",iscr:"\u{1D4BE}",isin:"\u2208",isindot:"\u22F5",isinE:"\u22F9",isins:"\u22F4",isinsv:"\u22F3",isinv:"\u2208",it:"\u2062",Itilde:"\u0128",itilde:"\u0129",Iukcy:"\u0406",iukcy:"\u0456",Iuml:"\xCF",iuml:"\xEF",Jcirc:"\u0134",jcirc:"\u0135",Jcy:"\u0419",jcy:"\u0439",Jfr:"\u{1D50D}",jfr:"\u{1D527}",jmath:"\u0237",Jopf:"\u{1D541}",jopf:"\u{1D55B}",Jscr:"\u{1D4A5}",jscr:"\u{1D4BF}",Jsercy:"\u0408",jsercy:"\u0458",Jukcy:"\u0404",jukcy:"\u0454",Kappa:"\u039A",kappa:"\u03BA",kappav:"\u03F0",Kcedil:"\u0136",kcedil:"\u0137",Kcy:"\u041A",kcy:"\u043A",Kfr:"\u{1D50E}",kfr:"\u{1D528}",kgreen:"\u0138",KHcy:"\u0425",khcy:"\u0445",KJcy:"\u040C",kjcy:"\u045C",Kopf:"\u{1D542}",kopf:"\u{1D55C}",Kscr:"\u{1D4A6}",kscr:"\u{1D4C0}",lAarr:"\u21DA",Lacute:"\u0139",lacute:"\u013A",laemptyv:"\u29B4",lagran:"\u2112",Lambda:"\u039B",lambda:"\u03BB",Lang:"\u27EA",lang:"\u27E8",langd:"\u2991",langle:"\u27E8",lap:"\u2A85",Laplacetrf:"\u2112",laquo:"\xAB",Larr:"\u219E",lArr:"\u21D0",larr:"\u2190",larrb:"\u21E4",larrbfs:"\u291F",larrfs:"\u291D",larrhk:"\u21A9",larrlp:"\u21AB",larrpl:"\u2939",larrsim:"\u2973",larrtl:"\u21A2",lat:"\u2AAB",lAtail:"\u291B",latail:"\u2919",late:"\u2AAD",lates:"\u2AAD\uFE00",lBarr:"\u290E",lbarr:"\u290C",lbbrk:"\u2772",lbrace:"{",lbrack:"[",lbrke:"\u298B",lbrksld:"\u298F",lbrkslu:"\u298D",Lcaron:"\u013D",lcaron:"\u013E",Lcedil:"\u013B",lcedil:"\u013C",lceil:"\u2308",lcub:"{",Lcy:"\u041B",lcy:"\u043B",ldca:"\u2936",ldquo:"\u201C",ldquor:"\u201E",ldrdhar:"\u2967",ldrushar:"\u294B",ldsh:"\u21B2",lE:"\u2266",le:"\u2264",LeftAngleBracket:"\u27E8",LeftArrow:"\u2190",Leftarrow:"\u21D0",leftarrow:"\u2190",LeftArrowBar:"\u21E4",LeftArrowRightArrow:"\u21C6",leftarrowtail:"\u21A2",LeftCeiling:"\u2308",LeftDoubleBracket:"\u27E6",LeftDownTeeVector:"\u2961",LeftDownVector:"\u21C3",LeftDownVectorBar:"\u2959",LeftFloor:"\u230A",leftharpoondown:"\u21BD",leftharpoonup:"\u21BC",leftleftarrows:"\u21C7",LeftRightArrow:"\u2194",Leftrightarrow:"\u21D4",leftrightarrow:"\u2194",leftrightarrows:"\u21C6",leftrightharpoons:"\u21CB",leftrightsquigarrow:"\u21AD",LeftRightVector:"\u294E",LeftTee:"\u22A3",LeftTeeArrow:"\u21A4",LeftTeeVector:"\u295A",leftthreetimes:"\u22CB",LeftTriangle:"\u22B2",LeftTriangleBar:"\u29CF",LeftTriangleEqual:"\u22B4",LeftUpDownVector:"\u2951",LeftUpTeeVector:"\u2960",LeftUpVector:"\u21BF",LeftUpVectorBar:"\u2958",LeftVector:"\u21BC",LeftVectorBar:"\u2952",lEg:"\u2A8B",leg:"\u22DA",leq:"\u2264",leqq:"\u2266",leqslant:"\u2A7D",les:"\u2A7D",lescc:"\u2AA8",lesdot:"\u2A7F",lesdoto:"\u2A81",lesdotor:"\u2A83",lesg:"\u22DA\uFE00",lesges:"\u2A93",lessapprox:"\u2A85",lessdot:"\u22D6",lesseqgtr:"\u22DA",lesseqqgtr:"\u2A8B",LessEqualGreater:"\u22DA",LessFullEqual:"\u2266",LessGreater:"\u2276",lessgtr:"\u2276",LessLess:"\u2AA1",lesssim:"\u2272",LessSlantEqual:"\u2A7D",LessTilde:"\u2272",lfisht:"\u297C",lfloor:"\u230A",Lfr:"\u{1D50F}",lfr:"\u{1D529}",lg:"\u2276",lgE:"\u2A91",lHar:"\u2962",lhard:"\u21BD",lharu:"\u21BC",lharul:"\u296A",lhblk:"\u2584",LJcy:"\u0409",ljcy:"\u0459",Ll:"\u22D8",ll:"\u226A",llarr:"\u21C7",llcorner:"\u231E",Lleftarrow:"\u21DA",llhard:"\u296B",lltri:"\u25FA",Lmidot:"\u013F",lmidot:"\u0140",lmoust:"\u23B0",lmoustache:"\u23B0",lnap:"\u2A89",lnapprox:"\u2A89",lnE:"\u2268",lne:"\u2A87",lneq:"\u2A87",lneqq:"\u2268",lnsim:"\u22E6",loang:"\u27EC",loarr:"\u21FD",lobrk:"\u27E6",LongLeftArrow:"\u27F5",Longleftarrow:"\u27F8",longleftarrow:"\u27F5",LongLeftRightArrow:"\u27F7",Longleftrightarrow:"\u27FA",longleftrightarrow:"\u27F7",longmapsto:"\u27FC",LongRightArrow:"\u27F6",Longrightarrow:"\u27F9",longrightarrow:"\u27F6",looparrowleft:"\u21AB",looparrowright:"\u21AC",lopar:"\u2985",Lopf:"\u{1D543}",lopf:"\u{1D55D}",loplus:"\u2A2D",lotimes:"\u2A34",lowast:"\u2217",lowbar:"_",LowerLeftArrow:"\u2199",LowerRightArrow:"\u2198",loz:"\u25CA",lozenge:"\u25CA",lozf:"\u29EB",lpar:"(",lparlt:"\u2993",lrarr:"\u21C6",lrcorner:"\u231F",lrhar:"\u21CB",lrhard:"\u296D",lrm:"\u200E",lrtri:"\u22BF",lsaquo:"\u2039",Lscr:"\u2112",lscr:"\u{1D4C1}",Lsh:"\u21B0",lsh:"\u21B0",lsim:"\u2272",lsime:"\u2A8D",lsimg:"\u2A8F",lsqb:"[",lsquo:"\u2018",lsquor:"\u201A",Lstrok:"\u0141",lstrok:"\u0142",Lt:"\u226A",LT:"<",lt:"<",ltcc:"\u2AA6",ltcir:"\u2A79",ltdot:"\u22D6",lthree:"\u22CB",ltimes:"\u22C9",ltlarr:"\u2976",ltquest:"\u2A7B",ltri:"\u25C3",ltrie:"\u22B4",ltrif:"\u25C2",ltrPar:"\u2996",lurdshar:"\u294A",luruhar:"\u2966",lvertneqq:"\u2268\uFE00",lvnE:"\u2268\uFE00",macr:"\xAF",male:"\u2642",malt:"\u2720",maltese:"\u2720",Map:"\u2905",map:"\u21A6",mapsto:"\u21A6",mapstodown:"\u21A7",mapstoleft:"\u21A4",mapstoup:"\u21A5",marker:"\u25AE",mcomma:"\u2A29",Mcy:"\u041C",mcy:"\u043C",mdash:"\u2014",mDDot:"\u223A",measuredangle:"\u2221",MediumSpace:"\u205F",Mellintrf:"\u2133",Mfr:"\u{1D510}",mfr:"\u{1D52A}",mho:"\u2127",micro:"\xB5",mid:"\u2223",midast:"*",midcir:"\u2AF0",middot:"\xB7",minus:"\u2212",minusb:"\u229F",minusd:"\u2238",minusdu:"\u2A2A",MinusPlus:"\u2213",mlcp:"\u2ADB",mldr:"\u2026",mnplus:"\u2213",models:"\u22A7",Mopf:"\u{1D544}",mopf:"\u{1D55E}",mp:"\u2213",Mscr:"\u2133",mscr:"\u{1D4C2}",mstpos:"\u223E",Mu:"\u039C",mu:"\u03BC",multimap:"\u22B8",mumap:"\u22B8",nabla:"\u2207",Nacute:"\u0143",nacute:"\u0144",nang:"\u2220\u20D2",nap:"\u2249",napE:"\u2A70\u0338",napid:"\u224B\u0338",napos:"\u0149",napprox:"\u2249",natur:"\u266E",natural:"\u266E",naturals:"\u2115",nbsp:"\xA0",nbump:"\u224E\u0338",nbumpe:"\u224F\u0338",ncap:"\u2A43",Ncaron:"\u0147",ncaron:"\u0148",Ncedil:"\u0145",ncedil:"\u0146",ncong:"\u2247",ncongdot:"\u2A6D\u0338",ncup:"\u2A42",Ncy:"\u041D",ncy:"\u043D",ndash:"\u2013",ne:"\u2260",nearhk:"\u2924",neArr:"\u21D7",nearr:"\u2197",nearrow:"\u2197",nedot:"\u2250\u0338",NegativeMediumSpace:"\u200B",NegativeThickSpace:"\u200B",NegativeThinSpace:"\u200B",NegativeVeryThinSpace:"\u200B",nequiv:"\u2262",nesear:"\u2928",nesim:"\u2242\u0338",NestedGreaterGreater:"\u226B",NestedLessLess:"\u226A",NewLine:`
10
- `,nexist:"\u2204",nexists:"\u2204",Nfr:"\u{1D511}",nfr:"\u{1D52B}",ngE:"\u2267\u0338",nge:"\u2271",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",nGg:"\u22D9\u0338",ngsim:"\u2275",nGt:"\u226B\u20D2",ngt:"\u226F",ngtr:"\u226F",nGtv:"\u226B\u0338",nhArr:"\u21CE",nharr:"\u21AE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",NJcy:"\u040A",njcy:"\u045A",nlArr:"\u21CD",nlarr:"\u219A",nldr:"\u2025",nlE:"\u2266\u0338",nle:"\u2270",nLeftarrow:"\u21CD",nleftarrow:"\u219A",nLeftrightarrow:"\u21CE",nleftrightarrow:"\u21AE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nLl:"\u22D8\u0338",nlsim:"\u2274",nLt:"\u226A\u20D2",nlt:"\u226E",nltri:"\u22EA",nltrie:"\u22EC",nLtv:"\u226A\u0338",nmid:"\u2224",NoBreak:"\u2060",NonBreakingSpace:"\xA0",Nopf:"\u2115",nopf:"\u{1D55F}",Not:"\u2AEC",not:"\xAC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",notin:"\u2209",notindot:"\u22F5\u0338",notinE:"\u22F9\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrArr:"\u21CF",nrarr:"\u219B",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nRightarrow:"\u21CF",nrightarrow:"\u219B",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",Nscr:"\u{1D4A9}",nscr:"\u{1D4C3}",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsubE:"\u2AC5\u0338",nsube:"\u2288",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupE:"\u2AC6\u0338",nsupe:"\u2289",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",Ntilde:"\xD1",ntilde:"\xF1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",Nu:"\u039D",nu:"\u03BD",num:"#",numero:"\u2116",numsp:"\u2007",nvap:"\u224D\u20D2",nVDash:"\u22AF",nVdash:"\u22AE",nvDash:"\u22AD",nvdash:"\u22AC",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvHarr:"\u2904",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwarhk:"\u2923",nwArr:"\u21D6",nwarr:"\u2196",nwarrow:"\u2196",nwnear:"\u2927",Oacute:"\xD3",oacute:"\xF3",oast:"\u229B",ocir:"\u229A",Ocirc:"\xD4",ocirc:"\xF4",Ocy:"\u041E",ocy:"\u043E",odash:"\u229D",Odblac:"\u0150",odblac:"\u0151",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",OElig:"\u0152",oelig:"\u0153",ofcir:"\u29BF",Ofr:"\u{1D512}",ofr:"\u{1D52C}",ogon:"\u02DB",Ograve:"\xD2",ograve:"\xF2",ogt:"\u29C1",ohbar:"\u29B5",ohm:"\u03A9",oint:"\u222E",olarr:"\u21BA",olcir:"\u29BE",olcross:"\u29BB",oline:"\u203E",olt:"\u29C0",Omacr:"\u014C",omacr:"\u014D",Omega:"\u03A9",omega:"\u03C9",Omicron:"\u039F",omicron:"\u03BF",omid:"\u29B6",ominus:"\u2296",Oopf:"\u{1D546}",oopf:"\u{1D560}",opar:"\u29B7",OpenCurlyDoubleQuote:"\u201C",OpenCurlyQuote:"\u2018",operp:"\u29B9",oplus:"\u2295",Or:"\u2A54",or:"\u2228",orarr:"\u21BB",ord:"\u2A5D",order:"\u2134",orderof:"\u2134",ordf:"\xAA",ordm:"\xBA",origof:"\u22B6",oror:"\u2A56",orslope:"\u2A57",orv:"\u2A5B",oS:"\u24C8",Oscr:"\u{1D4AA}",oscr:"\u2134",Oslash:"\xD8",oslash:"\xF8",osol:"\u2298",Otilde:"\xD5",otilde:"\xF5",Otimes:"\u2A37",otimes:"\u2297",otimesas:"\u2A36",Ouml:"\xD6",ouml:"\xF6",ovbar:"\u233D",OverBar:"\u203E",OverBrace:"\u23DE",OverBracket:"\u23B4",OverParenthesis:"\u23DC",par:"\u2225",para:"\xB6",parallel:"\u2225",parsim:"\u2AF3",parsl:"\u2AFD",part:"\u2202",PartialD:"\u2202",Pcy:"\u041F",pcy:"\u043F",percnt:"%",period:".",permil:"\u2030",perp:"\u22A5",pertenk:"\u2031",Pfr:"\u{1D513}",pfr:"\u{1D52D}",Phi:"\u03A6",phi:"\u03C6",phiv:"\u03D5",phmmat:"\u2133",phone:"\u260E",Pi:"\u03A0",pi:"\u03C0",pitchfork:"\u22D4",piv:"\u03D6",planck:"\u210F",planckh:"\u210E",plankv:"\u210F",plus:"+",plusacir:"\u2A23",plusb:"\u229E",pluscir:"\u2A22",plusdo:"\u2214",plusdu:"\u2A25",pluse:"\u2A72",PlusMinus:"\xB1",plusmn:"\xB1",plussim:"\u2A26",plustwo:"\u2A27",pm:"\xB1",Poincareplane:"\u210C",pointint:"\u2A15",Popf:"\u2119",popf:"\u{1D561}",pound:"\xA3",Pr:"\u2ABB",pr:"\u227A",prap:"\u2AB7",prcue:"\u227C",prE:"\u2AB3",pre:"\u2AAF",prec:"\u227A",precapprox:"\u2AB7",preccurlyeq:"\u227C",Precedes:"\u227A",PrecedesEqual:"\u2AAF",PrecedesSlantEqual:"\u227C",PrecedesTilde:"\u227E",preceq:"\u2AAF",precnapprox:"\u2AB9",precneqq:"\u2AB5",precnsim:"\u22E8",precsim:"\u227E",Prime:"\u2033",prime:"\u2032",primes:"\u2119",prnap:"\u2AB9",prnE:"\u2AB5",prnsim:"\u22E8",prod:"\u220F",Product:"\u220F",profalar:"\u232E",profline:"\u2312",profsurf:"\u2313",prop:"\u221D",Proportion:"\u2237",Proportional:"\u221D",propto:"\u221D",prsim:"\u227E",prurel:"\u22B0",Pscr:"\u{1D4AB}",pscr:"\u{1D4C5}",Psi:"\u03A8",psi:"\u03C8",puncsp:"\u2008",Qfr:"\u{1D514}",qfr:"\u{1D52E}",qint:"\u2A0C",Qopf:"\u211A",qopf:"\u{1D562}",qprime:"\u2057",Qscr:"\u{1D4AC}",qscr:"\u{1D4C6}",quaternions:"\u210D",quatint:"\u2A16",quest:"?",questeq:"\u225F",QUOT:'"',quot:'"',rAarr:"\u21DB",race:"\u223D\u0331",Racute:"\u0154",racute:"\u0155",radic:"\u221A",raemptyv:"\u29B3",Rang:"\u27EB",rang:"\u27E9",rangd:"\u2992",range:"\u29A5",rangle:"\u27E9",raquo:"\xBB",Rarr:"\u21A0",rArr:"\u21D2",rarr:"\u2192",rarrap:"\u2975",rarrb:"\u21E5",rarrbfs:"\u2920",rarrc:"\u2933",rarrfs:"\u291E",rarrhk:"\u21AA",rarrlp:"\u21AC",rarrpl:"\u2945",rarrsim:"\u2974",Rarrtl:"\u2916",rarrtl:"\u21A3",rarrw:"\u219D",rAtail:"\u291C",ratail:"\u291A",ratio:"\u2236",rationals:"\u211A",RBarr:"\u2910",rBarr:"\u290F",rbarr:"\u290D",rbbrk:"\u2773",rbrace:"}",rbrack:"]",rbrke:"\u298C",rbrksld:"\u298E",rbrkslu:"\u2990",Rcaron:"\u0158",rcaron:"\u0159",Rcedil:"\u0156",rcedil:"\u0157",rceil:"\u2309",rcub:"}",Rcy:"\u0420",rcy:"\u0440",rdca:"\u2937",rdldhar:"\u2969",rdquo:"\u201D",rdquor:"\u201D",rdsh:"\u21B3",Re:"\u211C",real:"\u211C",realine:"\u211B",realpart:"\u211C",reals:"\u211D",rect:"\u25AD",REG:"\xAE",reg:"\xAE",ReverseElement:"\u220B",ReverseEquilibrium:"\u21CB",ReverseUpEquilibrium:"\u296F",rfisht:"\u297D",rfloor:"\u230B",Rfr:"\u211C",rfr:"\u{1D52F}",rHar:"\u2964",rhard:"\u21C1",rharu:"\u21C0",rharul:"\u296C",Rho:"\u03A1",rho:"\u03C1",rhov:"\u03F1",RightAngleBracket:"\u27E9",RightArrow:"\u2192",Rightarrow:"\u21D2",rightarrow:"\u2192",RightArrowBar:"\u21E5",RightArrowLeftArrow:"\u21C4",rightarrowtail:"\u21A3",RightCeiling:"\u2309",RightDoubleBracket:"\u27E7",RightDownTeeVector:"\u295D",RightDownVector:"\u21C2",RightDownVectorBar:"\u2955",RightFloor:"\u230B",rightharpoondown:"\u21C1",rightharpoonup:"\u21C0",rightleftarrows:"\u21C4",rightleftharpoons:"\u21CC",rightrightarrows:"\u21C9",rightsquigarrow:"\u219D",RightTee:"\u22A2",RightTeeArrow:"\u21A6",RightTeeVector:"\u295B",rightthreetimes:"\u22CC",RightTriangle:"\u22B3",RightTriangleBar:"\u29D0",RightTriangleEqual:"\u22B5",RightUpDownVector:"\u294F",RightUpTeeVector:"\u295C",RightUpVector:"\u21BE",RightUpVectorBar:"\u2954",RightVector:"\u21C0",RightVectorBar:"\u2953",ring:"\u02DA",risingdotseq:"\u2253",rlarr:"\u21C4",rlhar:"\u21CC",rlm:"\u200F",rmoust:"\u23B1",rmoustache:"\u23B1",rnmid:"\u2AEE",roang:"\u27ED",roarr:"\u21FE",robrk:"\u27E7",ropar:"\u2986",Ropf:"\u211D",ropf:"\u{1D563}",roplus:"\u2A2E",rotimes:"\u2A35",RoundImplies:"\u2970",rpar:")",rpargt:"\u2994",rppolint:"\u2A12",rrarr:"\u21C9",Rrightarrow:"\u21DB",rsaquo:"\u203A",Rscr:"\u211B",rscr:"\u{1D4C7}",Rsh:"\u21B1",rsh:"\u21B1",rsqb:"]",rsquo:"\u2019",rsquor:"\u2019",rthree:"\u22CC",rtimes:"\u22CA",rtri:"\u25B9",rtrie:"\u22B5",rtrif:"\u25B8",rtriltri:"\u29CE",RuleDelayed:"\u29F4",ruluhar:"\u2968",rx:"\u211E",Sacute:"\u015A",sacute:"\u015B",sbquo:"\u201A",Sc:"\u2ABC",sc:"\u227B",scap:"\u2AB8",Scaron:"\u0160",scaron:"\u0161",sccue:"\u227D",scE:"\u2AB4",sce:"\u2AB0",Scedil:"\u015E",scedil:"\u015F",Scirc:"\u015C",scirc:"\u015D",scnap:"\u2ABA",scnE:"\u2AB6",scnsim:"\u22E9",scpolint:"\u2A13",scsim:"\u227F",Scy:"\u0421",scy:"\u0441",sdot:"\u22C5",sdotb:"\u22A1",sdote:"\u2A66",searhk:"\u2925",seArr:"\u21D8",searr:"\u2198",searrow:"\u2198",sect:"\xA7",semi:";",seswar:"\u2929",setminus:"\u2216",setmn:"\u2216",sext:"\u2736",Sfr:"\u{1D516}",sfr:"\u{1D530}",sfrown:"\u2322",sharp:"\u266F",SHCHcy:"\u0429",shchcy:"\u0449",SHcy:"\u0428",shcy:"\u0448",ShortDownArrow:"\u2193",ShortLeftArrow:"\u2190",shortmid:"\u2223",shortparallel:"\u2225",ShortRightArrow:"\u2192",ShortUpArrow:"\u2191",shy:"\xAD",Sigma:"\u03A3",sigma:"\u03C3",sigmaf:"\u03C2",sigmav:"\u03C2",sim:"\u223C",simdot:"\u2A6A",sime:"\u2243",simeq:"\u2243",simg:"\u2A9E",simgE:"\u2AA0",siml:"\u2A9D",simlE:"\u2A9F",simne:"\u2246",simplus:"\u2A24",simrarr:"\u2972",slarr:"\u2190",SmallCircle:"\u2218",smallsetminus:"\u2216",smashp:"\u2A33",smeparsl:"\u29E4",smid:"\u2223",smile:"\u2323",smt:"\u2AAA",smte:"\u2AAC",smtes:"\u2AAC\uFE00",SOFTcy:"\u042C",softcy:"\u044C",sol:"/",solb:"\u29C4",solbar:"\u233F",Sopf:"\u{1D54A}",sopf:"\u{1D564}",spades:"\u2660",spadesuit:"\u2660",spar:"\u2225",sqcap:"\u2293",sqcaps:"\u2293\uFE00",sqcup:"\u2294",sqcups:"\u2294\uFE00",Sqrt:"\u221A",sqsub:"\u228F",sqsube:"\u2291",sqsubset:"\u228F",sqsubseteq:"\u2291",sqsup:"\u2290",sqsupe:"\u2292",sqsupset:"\u2290",sqsupseteq:"\u2292",squ:"\u25A1",Square:"\u25A1",square:"\u25A1",SquareIntersection:"\u2293",SquareSubset:"\u228F",SquareSubsetEqual:"\u2291",SquareSuperset:"\u2290",SquareSupersetEqual:"\u2292",SquareUnion:"\u2294",squarf:"\u25AA",squf:"\u25AA",srarr:"\u2192",Sscr:"\u{1D4AE}",sscr:"\u{1D4C8}",ssetmn:"\u2216",ssmile:"\u2323",sstarf:"\u22C6",Star:"\u22C6",star:"\u2606",starf:"\u2605",straightepsilon:"\u03F5",straightphi:"\u03D5",strns:"\xAF",Sub:"\u22D0",sub:"\u2282",subdot:"\u2ABD",subE:"\u2AC5",sube:"\u2286",subedot:"\u2AC3",submult:"\u2AC1",subnE:"\u2ACB",subne:"\u228A",subplus:"\u2ABF",subrarr:"\u2979",Subset:"\u22D0",subset:"\u2282",subseteq:"\u2286",subseteqq:"\u2AC5",SubsetEqual:"\u2286",subsetneq:"\u228A",subsetneqq:"\u2ACB",subsim:"\u2AC7",subsub:"\u2AD5",subsup:"\u2AD3",succ:"\u227B",succapprox:"\u2AB8",succcurlyeq:"\u227D",Succeeds:"\u227B",SucceedsEqual:"\u2AB0",SucceedsSlantEqual:"\u227D",SucceedsTilde:"\u227F",succeq:"\u2AB0",succnapprox:"\u2ABA",succneqq:"\u2AB6",succnsim:"\u22E9",succsim:"\u227F",SuchThat:"\u220B",Sum:"\u2211",sum:"\u2211",sung:"\u266A",Sup:"\u22D1",sup:"\u2283",sup1:"\xB9",sup2:"\xB2",sup3:"\xB3",supdot:"\u2ABE",supdsub:"\u2AD8",supE:"\u2AC6",supe:"\u2287",supedot:"\u2AC4",Superset:"\u2283",SupersetEqual:"\u2287",suphsol:"\u27C9",suphsub:"\u2AD7",suplarr:"\u297B",supmult:"\u2AC2",supnE:"\u2ACC",supne:"\u228B",supplus:"\u2AC0",Supset:"\u22D1",supset:"\u2283",supseteq:"\u2287",supseteqq:"\u2AC6",supsetneq:"\u228B",supsetneqq:"\u2ACC",supsim:"\u2AC8",supsub:"\u2AD4",supsup:"\u2AD6",swarhk:"\u2926",swArr:"\u21D9",swarr:"\u2199",swarrow:"\u2199",swnwar:"\u292A",szlig:"\xDF",Tab:" ",target:"\u2316",Tau:"\u03A4",tau:"\u03C4",tbrk:"\u23B4",Tcaron:"\u0164",tcaron:"\u0165",Tcedil:"\u0162",tcedil:"\u0163",Tcy:"\u0422",tcy:"\u0442",tdot:"\u20DB",telrec:"\u2315",Tfr:"\u{1D517}",tfr:"\u{1D531}",there4:"\u2234",Therefore:"\u2234",therefore:"\u2234",Theta:"\u0398",theta:"\u03B8",thetasym:"\u03D1",thetav:"\u03D1",thickapprox:"\u2248",thicksim:"\u223C",ThickSpace:"\u205F\u200A",thinsp:"\u2009",ThinSpace:"\u2009",thkap:"\u2248",thksim:"\u223C",THORN:"\xDE",thorn:"\xFE",Tilde:"\u223C",tilde:"\u02DC",TildeEqual:"\u2243",TildeFullEqual:"\u2245",TildeTilde:"\u2248",times:"\xD7",timesb:"\u22A0",timesbar:"\u2A31",timesd:"\u2A30",tint:"\u222D",toea:"\u2928",top:"\u22A4",topbot:"\u2336",topcir:"\u2AF1",Topf:"\u{1D54B}",topf:"\u{1D565}",topfork:"\u2ADA",tosa:"\u2929",tprime:"\u2034",TRADE:"\u2122",trade:"\u2122",triangle:"\u25B5",triangledown:"\u25BF",triangleleft:"\u25C3",trianglelefteq:"\u22B4",triangleq:"\u225C",triangleright:"\u25B9",trianglerighteq:"\u22B5",tridot:"\u25EC",trie:"\u225C",triminus:"\u2A3A",TripleDot:"\u20DB",triplus:"\u2A39",trisb:"\u29CD",tritime:"\u2A3B",trpezium:"\u23E2",Tscr:"\u{1D4AF}",tscr:"\u{1D4C9}",TScy:"\u0426",tscy:"\u0446",TSHcy:"\u040B",tshcy:"\u045B",Tstrok:"\u0166",tstrok:"\u0167",twixt:"\u226C",twoheadleftarrow:"\u219E",twoheadrightarrow:"\u21A0",Uacute:"\xDA",uacute:"\xFA",Uarr:"\u219F",uArr:"\u21D1",uarr:"\u2191",Uarrocir:"\u2949",Ubrcy:"\u040E",ubrcy:"\u045E",Ubreve:"\u016C",ubreve:"\u016D",Ucirc:"\xDB",ucirc:"\xFB",Ucy:"\u0423",ucy:"\u0443",udarr:"\u21C5",Udblac:"\u0170",udblac:"\u0171",udhar:"\u296E",ufisht:"\u297E",Ufr:"\u{1D518}",ufr:"\u{1D532}",Ugrave:"\xD9",ugrave:"\xF9",uHar:"\u2963",uharl:"\u21BF",uharr:"\u21BE",uhblk:"\u2580",ulcorn:"\u231C",ulcorner:"\u231C",ulcrop:"\u230F",ultri:"\u25F8",Umacr:"\u016A",umacr:"\u016B",uml:"\xA8",UnderBar:"_",UnderBrace:"\u23DF",UnderBracket:"\u23B5",UnderParenthesis:"\u23DD",Union:"\u22C3",UnionPlus:"\u228E",Uogon:"\u0172",uogon:"\u0173",Uopf:"\u{1D54C}",uopf:"\u{1D566}",UpArrow:"\u2191",Uparrow:"\u21D1",uparrow:"\u2191",UpArrowBar:"\u2912",UpArrowDownArrow:"\u21C5",UpDownArrow:"\u2195",Updownarrow:"\u21D5",updownarrow:"\u2195",UpEquilibrium:"\u296E",upharpoonleft:"\u21BF",upharpoonright:"\u21BE",uplus:"\u228E",UpperLeftArrow:"\u2196",UpperRightArrow:"\u2197",Upsi:"\u03D2",upsi:"\u03C5",upsih:"\u03D2",Upsilon:"\u03A5",upsilon:"\u03C5",UpTee:"\u22A5",UpTeeArrow:"\u21A5",upuparrows:"\u21C8",urcorn:"\u231D",urcorner:"\u231D",urcrop:"\u230E",Uring:"\u016E",uring:"\u016F",urtri:"\u25F9",Uscr:"\u{1D4B0}",uscr:"\u{1D4CA}",utdot:"\u22F0",Utilde:"\u0168",utilde:"\u0169",utri:"\u25B5",utrif:"\u25B4",uuarr:"\u21C8",Uuml:"\xDC",uuml:"\xFC",uwangle:"\u29A7",vangrt:"\u299C",varepsilon:"\u03F5",varkappa:"\u03F0",varnothing:"\u2205",varphi:"\u03D5",varpi:"\u03D6",varpropto:"\u221D",vArr:"\u21D5",varr:"\u2195",varrho:"\u03F1",varsigma:"\u03C2",varsubsetneq:"\u228A\uFE00",varsubsetneqq:"\u2ACB\uFE00",varsupsetneq:"\u228B\uFE00",varsupsetneqq:"\u2ACC\uFE00",vartheta:"\u03D1",vartriangleleft:"\u22B2",vartriangleright:"\u22B3",Vbar:"\u2AEB",vBar:"\u2AE8",vBarv:"\u2AE9",Vcy:"\u0412",vcy:"\u0432",VDash:"\u22AB",Vdash:"\u22A9",vDash:"\u22A8",vdash:"\u22A2",Vdashl:"\u2AE6",Vee:"\u22C1",vee:"\u2228",veebar:"\u22BB",veeeq:"\u225A",vellip:"\u22EE",Verbar:"\u2016",verbar:"|",Vert:"\u2016",vert:"|",VerticalBar:"\u2223",VerticalLine:"|",VerticalSeparator:"\u2758",VerticalTilde:"\u2240",VeryThinSpace:"\u200A",Vfr:"\u{1D519}",vfr:"\u{1D533}",vltri:"\u22B2",vnsub:"\u2282\u20D2",vnsup:"\u2283\u20D2",Vopf:"\u{1D54D}",vopf:"\u{1D567}",vprop:"\u221D",vrtri:"\u22B3",Vscr:"\u{1D4B1}",vscr:"\u{1D4CB}",vsubnE:"\u2ACB\uFE00",vsubne:"\u228A\uFE00",vsupnE:"\u2ACC\uFE00",vsupne:"\u228B\uFE00",Vvdash:"\u22AA",vzigzag:"\u299A",Wcirc:"\u0174",wcirc:"\u0175",wedbar:"\u2A5F",Wedge:"\u22C0",wedge:"\u2227",wedgeq:"\u2259",weierp:"\u2118",Wfr:"\u{1D51A}",wfr:"\u{1D534}",Wopf:"\u{1D54E}",wopf:"\u{1D568}",wp:"\u2118",wr:"\u2240",wreath:"\u2240",Wscr:"\u{1D4B2}",wscr:"\u{1D4CC}",xcap:"\u22C2",xcirc:"\u25EF",xcup:"\u22C3",xdtri:"\u25BD",Xfr:"\u{1D51B}",xfr:"\u{1D535}",xhArr:"\u27FA",xharr:"\u27F7",Xi:"\u039E",xi:"\u03BE",xlArr:"\u27F8",xlarr:"\u27F5",xmap:"\u27FC",xnis:"\u22FB",xodot:"\u2A00",Xopf:"\u{1D54F}",xopf:"\u{1D569}",xoplus:"\u2A01",xotime:"\u2A02",xrArr:"\u27F9",xrarr:"\u27F6",Xscr:"\u{1D4B3}",xscr:"\u{1D4CD}",xsqcup:"\u2A06",xuplus:"\u2A04",xutri:"\u25B3",xvee:"\u22C1",xwedge:"\u22C0",Yacute:"\xDD",yacute:"\xFD",YAcy:"\u042F",yacy:"\u044F",Ycirc:"\u0176",ycirc:"\u0177",Ycy:"\u042B",ycy:"\u044B",yen:"\xA5",Yfr:"\u{1D51C}",yfr:"\u{1D536}",YIcy:"\u0407",yicy:"\u0457",Yopf:"\u{1D550}",yopf:"\u{1D56A}",Yscr:"\u{1D4B4}",yscr:"\u{1D4CE}",YUcy:"\u042E",yucy:"\u044E",Yuml:"\u0178",yuml:"\xFF",Zacute:"\u0179",zacute:"\u017A",Zcaron:"\u017D",zcaron:"\u017E",Zcy:"\u0417",zcy:"\u0437",Zdot:"\u017B",zdot:"\u017C",zeetrf:"\u2128",ZeroWidthSpace:"\u200B",Zeta:"\u0396",zeta:"\u03B6",Zfr:"\u2128",zfr:"\u{1D537}",ZHcy:"\u0416",zhcy:"\u0436",zigrarr:"\u21DD",Zopf:"\u2124",zopf:"\u{1D56B}",Zscr:"\u{1D4B5}",zscr:"\u{1D4CF}",zwj:"\u200D",zwnj:"\u200C"});fn.entityMap=fn.HTML_ENTITIES});var xl=at(Ss=>{"use strict";var Er=Mt(),B=Wi(),El=rn(),_h=Er.isHTMLEscapableRawTextElement,bh=Er.isHTMLMimeType,wh=Er.isHTMLRawTextElement,mn=Er.hasOwn,wl=Er.NAMESPACE,yh=El.ParseError,vh=El.DOMException,br=0,bt=1,wr=2,hn=3,yr=4,vr=5,pn=6,xs=7;function kl(){}kl.prototype={parse:function(r,e,t){var n=this.domBuilder;n.startDocument(),Th(e,e=Object.create(null)),Eh(r,e,t,n,this.errorHandler),n.endDocument()}};var na=/&#?\w+;?/g;function Eh(r,e,t,n,s){var i=bh(n.mimeType);r.indexOf(B.UNICODE_REPLACEMENT_CHARACTER)>=0&&s.warning("Unicode replacement character detected, source encoding issues?");function a(q){if(q>65535){q-=65536;var Oe=55296+(q>>10),Kn=56320+(q&1023);return String.fromCharCode(Oe,Kn)}else return String.fromCharCode(q)}function o(q){var Oe=q[q.length-1]===";"?q:q+";";if(!i&&Oe!==q)return s.error("EntityRef: expecting ;"),q;var Kn=B.Reference.exec(Oe);if(!Kn||Kn[0].length!==Oe.length)return s.error("entity not matching Reference production: "+q),q;var Qn=Oe.slice(1,-1);return mn(t,Qn)?t[Qn]:Qn.charAt(0)==="#"?a(parseInt(Qn.substring(1).replace("x","0x"))):(s.error("entity not found:"+q),q)}function l(q){if(q>g){var Oe=r.substring(g,q).replace(na,o);f&&h(g),n.characters(Oe,0,q-g),g=q}}var u=0,c=0,d=/\r\n?|\n|$/g,f=n.locator;function h(q,Oe){for(;q>=c&&(Oe=d.exec(r));)u=c,c=Oe.index+Oe[0].length,f.lineNumber++;f.columnNumber=q-u+1}for(var p=[{currentNSMap:e}],m=[],g=0;;){try{var _=r.indexOf("<",g);if(_<0){if(!i&&m.length>0)return s.fatalError("unclosed xml tag(s): "+m.join(", "));if(!r.substring(g).match(/^\s*$/)){var w=n.doc,y=w.createTextNode(r.substring(g));if(w.documentElement)return s.error("Extra content at the end of the document");w.appendChild(y),n.currentElement=y}return}if(_>g){var k=r.substring(g,_);!i&&m.length===0&&(k=k.replace(new RegExp(B.S_OPT.source,"g"),""),k&&s.error("Unexpected content outside root element: '"+k+"'")),l(_)}switch(r.charAt(_+1)){case"/":var M=r.indexOf(">",_+2),T=r.substring(_+2,M>0?M:void 0);if(!T)return s.fatalError("end tag name missing");var v=B.reg("^",B.QName_group,B.S_OPT,"$"),N=M>0&&v.exec(T);if(!N){var L=M>0&&B.reg("^",B.QName_group).exec(T);if(i&&L)s.warning('end tag name contains invalid trailing characters: "'+T+'"'),N=L;else if(L&&new RegExp(v.source,v.flags+"m").test(T))s.error('end tag name is followed by a line break and trailing content: "'+T+'"'),N=L;else return s.fatalError('end tag name contains invalid characters: "'+T+'"')}if(!n.currentElement&&!n.doc.documentElement)return;var U=m[m.length-1]||n.currentElement.tagName||n.doc.documentElement.tagName||"";if(U!==N[1]){var ve=N[1].toLowerCase();if(!i||U.toLowerCase()!==ve)return s.fatalError('Opening and ending tag mismatch: "'+U+'" != "'+T+'"')}var Y=p.pop();m.pop();var re=Y.localNSMap;if(n.endElement(Y.uri,Y.localName,U),re)for(var Ne in re)mn(re,Ne)&&n.endPrefixMapping(Ne);M++;break;case"?":f&&h(_),M=xh(r,_,n,s);break;case"!":f&&h(_),M=Tl(r,_,n,s,i);break;default:f&&h(_);var G=new Dl,ne=p[p.length-1].currentNSMap,M=kh(r,_,G,ne,o,s,i),Ga=G.length;if(G.closed||(i&&Er.isHTMLVoidElement(G.tagName)?G.closed=!0:m.push(G.tagName)),f&&Ga){for(var cc=yl(f,{}),yi=0;yi<Ga;yi++){var Xa=G[yi];h(Xa.offset),Xa.locator=yl(f,{})}n.locator=cc,vl(G,n,ne)&&p.push(G),n.locator=f}else vl(G,n,ne)&&p.push(G);i&&!G.closed?M=Ah(r,M,G.tagName,o,n):M++}}catch(q){if(q instanceof yh)throw q;if(q instanceof vh)return s.fatalError("Error constructing the DOM: "+q.name+": "+q.message,q);s.error("element parse error: "+q),M=-1}M>g?g=M:l(Math.max(_,g)+1)}}function yl(r,e){return e.lineNumber=r.lineNumber,e.columnNumber=r.columnNumber,e}function kh(r,e,t,n,s,i,a){function o(h,p,m){if(mn(t.attributeNames,h))return i.fatalError("Attribute "+h+" redefined");if(!a&&p.indexOf("<")>=0)return i.fatalError("Unescaped '<' not allowed in attributes values");t.addValue(h,p.replace(/[\t\n\r]/g," ").replace(na,s),m)}for(var l,u,c=++e,d=br;;){var f=r.charAt(c);if(d===br&&f==="<")throw new Error("unexpected < in tag name: "+r.slice(e,c));switch(f){case"=":if(d===bt)l=r.slice(e,c),d=hn;else if(d===wr)d=hn;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(d===hn||d===bt)if(d===bt&&(i.warning('attribute value must after "="'),l=r.slice(e,c)),e=c+1,c=r.indexOf(f,e),c>0)u=r.slice(e,c),o(l,u,e-1),d=vr;else throw new Error("attribute value no end '"+f+"' match");else if(d==yr)u=r.slice(e,c),o(l,u,e),i.warning('attribute "'+l+'" missed start quot('+f+")!!"),e=c+1,d=vr;else throw new Error('attribute value must after "="');break;case"/":switch(d){case br:t.setTagName(r.slice(e,c));case vr:case pn:case xs:d=xs,t.closed=!0;case yr:case bt:break;case wr:t.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return i.error("unexpected end of input"),d==br&&t.setTagName(r.slice(e,c)),c;case">":switch(d){case br:t.setTagName(r.slice(e,c));case vr:case pn:case xs:break;case yr:case bt:u=r.slice(e,c),u.slice(-1)==="/"&&(t.closed=!0,u=u.slice(0,-1));case wr:d===wr&&(u=l),d==yr?(i.warning('attribute "'+u+'" missed quot(")!'),o(l,u,e)):(a||i.warning('attribute "'+u+'" missed value!! "'+u+'" instead!!'),o(u,u,e));break;case hn:if(!a)return i.fatalError(`AttValue: ' or " expected`)}return c;case"\x80":f=" ";default:if(f<=" ")switch(d){case br:t.setTagName(r.slice(e,c)),d=pn;break;case bt:l=r.slice(e,c),d=wr;break;case yr:var u=r.slice(e,c);i.warning('attribute "'+u+'" missed quot(")!!'),o(l,u,e);case vr:d=pn;break}else switch(d){case wr:a||i.warning('attribute "'+l+'" missed value!! "'+l+'" instead2!!'),o(l,l,e),e=c,d=bt;break;case vr:i.warning('attribute space is required"'+l+'"!!');case pn:d=bt,e=c;break;case hn:d=yr,e=c;break;case xs:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function vl(r,e,t){for(var n=r.tagName,s=null,d=r.length;d--;){var i=r[d],a=i.qName,o=i.value,f=a.indexOf(":");if(f>0)var l=i.prefix=a.slice(0,f),u=a.slice(f+1),c=l==="xmlns"&&u;else u=a,l=null,c=a==="xmlns"&&"";i.localName=u,c!==!1&&(s==null&&(s=Object.create(null),t=Object.create(t)),t[c]=s[c]=o,i.uri=wl.XMLNS,e.startPrefixMapping(c,o))}for(var d=r.length;d--;)i=r[d],i.prefix&&(i.prefix==="xml"&&(i.uri=wl.XML),i.prefix!=="xmlns"&&(i.uri=t[i.prefix]));var f=n.indexOf(":");f>0?(l=r.prefix=n.slice(0,f),u=r.localName=n.slice(f+1)):(l=null,u=r.localName=n);var h=r.uri=t[l||""];if(e.startElement(h,u,n,r),r.closed){if(e.endElement(h,u,n),s)for(l in s)mn(s,l)&&e.endPrefixMapping(l)}else return r.currentNSMap=t,r.localNSMap=s,!0}function Ah(r,e,t,n,s){var i=_h(t);if(i||wh(t)){var a=new RegExp("</"+t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+">","ig");a.lastIndex=e;var o=a.exec(r),l=o?o.index:-1;if(l<0)return e+1;var u=r.substring(e+1,l);return i&&(u=u.replace(na,n)),s.characters(u,0,u.length),l}return e+1}function Th(r,e){for(var t in r)mn(r,t)&&(e[t]=r[t])}function Al(r,e){var t=e;function n(c){return c=c||0,r.charAt(t+c)}function s(c){c=c||1,t+=c}function i(){for(var c=0;t<r.length;){var d=n();if(d!==" "&&d!==`
11
- `&&d!==" "&&d!=="\r")return c;c++,s()}return-1}function a(){return r.substring(t)}function o(c){return r.substring(t,t+c.length)===c}function l(c){return r.substring(t,t+c.length).toUpperCase()===c.toUpperCase()}function u(c){var d=B.reg("^",c),f=d.exec(a());return f?(s(f[0].length),f[0]):null}return{char:n,getIndex:function(){return t},getMatch:u,getSource:function(){return r},skip:s,skipBlanks:i,substringFromIndex:a,substringStartsWith:o,substringStartsWithCaseInsensitive:l}}function Dh(r,e){function t(o,l){var u=B.PI.exec(o.substringFromIndex());return u?u[1].toLowerCase()==="xml"?l.fatalError("xml declaration is only allowed at the start of the document, but found at position "+o.getIndex()):(o.skip(u[0].length),u[0]):l.fatalError("processing instruction is not well-formed at position "+o.getIndex())}var n=r.getSource();if(r.char()==="["){r.skip(1);for(var s=r.getIndex();r.getIndex()<n.length;){if(r.skipBlanks(),r.char()==="]"){var i=n.substring(s,r.getIndex());return r.skip(1),i}var a=null;if(r.char()==="<"&&r.char(1)==="!")switch(r.char(2)){case"E":r.char(3)==="L"?a=r.getMatch(B.elementdecl):r.char(3)==="N"&&(a=r.getMatch(B.EntityDecl));break;case"A":a=r.getMatch(B.AttlistDecl);break;case"N":a=r.getMatch(B.NotationDecl);break;case"-":a=r.getMatch(B.Comment);break}else if(r.char()==="<"&&r.char(1)==="?")a=t(r,e);else if(r.char()==="%")a=r.getMatch(B.PEReference);else return e.fatalError("Error detected in Markup declaration");if(!a)return e.fatalError("Error in internal subset at position "+r.getIndex())}return e.fatalError("doctype internal subset is not well-formed, missing ]")}}function Tl(r,e,t,n,s){var i=Al(r,e);switch(s?i.char(2).toUpperCase():i.char(2)){case"-":var a=i.getMatch(B.Comment);return a?(t.comment(a,B.COMMENT_START.length,a.length-B.COMMENT_START.length-B.COMMENT_END.length),i.getIndex()):n.fatalError("comment is not well-formed at position "+i.getIndex());case"[":var o=i.getMatch(B.CDSect);return o?!s&&!t.currentElement?n.fatalError("CDATA outside of element"):(t.startCDATA(),t.characters(o,B.CDATA_START.length,o.length-B.CDATA_START.length-B.CDATA_END.length),t.endCDATA(),i.getIndex()):n.fatalError("Invalid CDATA starting at position "+e);case"D":{if(t.doc&&t.doc.documentElement)return n.fatalError("Doctype not allowed inside or after documentElement at position "+i.getIndex());if(s?!i.substringStartsWithCaseInsensitive(B.DOCTYPE_DECL_START):!i.substringStartsWith(B.DOCTYPE_DECL_START))return n.fatalError("Expected "+B.DOCTYPE_DECL_START+" at position "+i.getIndex());if(i.skip(B.DOCTYPE_DECL_START.length),i.skipBlanks()<1)return n.fatalError("Expected whitespace after "+B.DOCTYPE_DECL_START+" at position "+i.getIndex());var l={name:void 0,publicId:void 0,systemId:void 0,internalSubset:void 0};if(l.name=i.getMatch(B.Name),!l.name)return n.fatalError("doctype name missing or contains unexpected characters at position "+i.getIndex());if(s&&l.name.toLowerCase()!=="html"&&n.warning("Unexpected DOCTYPE in HTML document at position "+i.getIndex()),i.skipBlanks(),i.substringStartsWith(B.PUBLIC)||i.substringStartsWith(B.SYSTEM)){var u=B.ExternalID_match.exec(i.substringFromIndex());if(!u)return n.fatalError("doctype external id is not well-formed at position "+i.getIndex());u.groups.SystemLiteralOnly!==void 0?l.systemId=u.groups.SystemLiteralOnly:(l.systemId=u.groups.SystemLiteral,l.publicId=u.groups.PubidLiteral),i.skip(u[0].length)}else if(s&&i.substringStartsWithCaseInsensitive(B.SYSTEM)){if(i.skip(B.SYSTEM.length),i.skipBlanks()<1)return n.fatalError("Expected whitespace after "+B.SYSTEM+" at position "+i.getIndex());if(l.systemId=i.getMatch(B.ABOUT_LEGACY_COMPAT_SystemLiteral),!l.systemId)return n.fatalError("Expected "+B.ABOUT_LEGACY_COMPAT+" in single or double quotes after "+B.SYSTEM+" at position "+i.getIndex())}return s&&l.systemId&&!B.ABOUT_LEGACY_COMPAT_SystemLiteral.test(l.systemId)&&n.warning("Unexpected doctype.systemId in HTML document at position "+i.getIndex()),s||(i.skipBlanks(),l.internalSubset=Dh(i,n)),i.skipBlanks(),i.char()!==">"?n.fatalError("doctype not terminated with > at position "+i.getIndex()):(i.skip(1),t.startDTD(l.name,l.publicId,l.systemId,l.internalSubset),t.endDTD(),i.getIndex())}default:return n.fatalError('Not well-formed XML starting with "<!" at position '+e)}}function xh(r,e,t,n){var s=r.substring(e).match(B.PI);if(!s)return n.fatalError("Invalid processing instruction starting at position "+e);if(s[1].toLowerCase()==="xml"){if(e>0)return n.fatalError("processing instruction at position "+e+" is an xml declaration which is only at the start of the document");if(!B.XMLDecl.test(r.substring(e)))return n.fatalError("xml declaration is not well-formed")}return t.processingInstruction(s[1],s[2]),e+s[0].length}function Dl(){this.attributeNames=Object.create(null)}Dl.prototype={setTagName:function(r){if(!B.QName_exact.test(r))throw new Error("invalid tagName:"+r);this.tagName=r},addValue:function(r,e,t){if(!B.QName_exact.test(r))throw new Error("invalid attribute:"+r);this.attributeNames[r]=this.length,this[this.length++]={qName:r,value:e,offset:t}},length:0,getLocalName:function(r){return this[r].localName},getLocator:function(r){return this[r].locator},getQName:function(r){return this[r].qName},getURI:function(r){return this[r].uri},getValue:function(r){return this[r].value}};Ss.XMLReader=kl;Ss.parseUtils=Al;Ss.parseDoctypeCommentOrCData=Tl});var Rl=at(Ar=>{"use strict";var Lt=Mt(),Sh=ra(),Ch=rn(),Sl=bl(),Nh=xl(),Oh=Sh.DOMImplementation,Ih=Lt.hasDefaultHTMLNamespace,Bh=Lt.isHTMLMimeType,Rh=Lt.isValidMimeType,Ol=Lt.MIME_TYPE,sa=Lt.NAMESPACE,Cl=Ch.ParseError,Mh=Nh.XMLReader;function Il(r){return r.replace(/\r[\n\u0085]/g,`
9
+ var Ec=Object.create;var Ii=Object.defineProperty;var kc=Object.getOwnPropertyDescriptor;var Ac=Object.getOwnPropertyNames;var Tc=Object.getPrototypeOf,xc=Object.prototype.hasOwnProperty;var lt=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Dc=(r,e)=>{for(var t in e)Ii(r,t,{get:e[t],enumerable:!0})},Sc=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ac(e))!xc.call(r,s)&&s!==t&&Ii(r,s,{get:()=>e[s],enumerable:!(n=kc(e,s))||n.enumerable});return r};var oa=(r,e,t)=>(t=r!=null?Ec(Tc(r)):{},Sc(e||!r||!r.__esModule?Ii(t,"default",{value:r,enumerable:!0}):t,r));var $t=lt(ce=>{"use strict";function Jd(r,e,t){if(t===void 0&&(t=Array.prototype),r&&typeof t.find=="function")return t.find.call(r,e);for(var n=0;n<r.length;n++)if(Mt(r,n)){var s=r[n];if(e.call(void 0,s,n,r))return s}}function dr(r,e){return e===void 0&&(e=Object),e&&typeof e.getOwnPropertyDescriptors=="function"&&(r=e.create(null,e.getOwnPropertyDescriptors(r))),e&&typeof e.freeze=="function"?e.freeze(r):r}function Mt(r,e){return Object.prototype.hasOwnProperty.call(r,e)}function Kd(r,e){if(r===null||typeof r!="object")throw new TypeError("target is not an object");for(var t in e)Mt(e,t)&&(r[t]=e[t]);return r}var Ua=dr({allowfullscreen:!0,async:!0,autofocus:!0,autoplay:!0,checked:!0,controls:!0,default:!0,defer:!0,disabled:!0,formnovalidate:!0,hidden:!0,ismap:!0,itemscope:!0,loop:!0,multiple:!0,muted:!0,nomodule:!0,novalidate:!0,open:!0,playsinline:!0,readonly:!0,required:!0,reversed:!0,selected:!0});function Qd(r){return Mt(Ua,r.toLowerCase())}var qa=dr({area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ef(r){return Mt(qa,r.toLowerCase())}var Qr=dr({script:!1,style:!1,textarea:!0,title:!0});function tf(r){var e=r.toLowerCase();return Mt(Qr,e)&&!Qr[e]}function rf(r){var e=r.toLowerCase();return Mt(Qr,e)&&Qr[e]}function Va(r){return r===en.HTML}function nf(r){return Va(r)||r===en.XML_XHTML_APPLICATION}var en=dr({HTML:"text/html",XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),sf=Object.keys(en).map(function(r){return en[r]});function of(r){return sf.indexOf(r)>-1}var af=dr({HTML:"http://www.w3.org/1999/xhtml",SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"});ce.assign=Kd;ce.find=Jd;ce.freeze=dr;ce.HTML_BOOLEAN_ATTRIBUTES=Ua;ce.HTML_RAW_TEXT_ELEMENTS=Qr;ce.HTML_VOID_ELEMENTS=qa;ce.hasDefaultHTMLNamespace=nf;ce.hasOwn=Mt;ce.isHTMLBooleanAttribute=Qd;ce.isHTMLRawTextElement=tf;ce.isHTMLEscapableRawTextElement=rf;ce.isHTMLMimeType=Va;ce.isHTMLVoidElement=ef;ce.isValidMimeType=of;ce.MIME_TYPE=en;ce.NAMESPACE=af});var on=lt(sn=>{"use strict";var lf=$t();function za(r,e){r.prototype=Object.create(Error.prototype,{constructor:{value:r},name:{value:r.name,enumerable:!0,writable:e}})}var rn=lf.freeze({Error:"Error",IndexSizeError:"IndexSizeError",DomstringSizeError:"DomstringSizeError",HierarchyRequestError:"HierarchyRequestError",WrongDocumentError:"WrongDocumentError",InvalidCharacterError:"InvalidCharacterError",NoDataAllowedError:"NoDataAllowedError",NoModificationAllowedError:"NoModificationAllowedError",NotFoundError:"NotFoundError",NotSupportedError:"NotSupportedError",InUseAttributeError:"InUseAttributeError",InvalidStateError:"InvalidStateError",SyntaxError:"SyntaxError",InvalidModificationError:"InvalidModificationError",NamespaceError:"NamespaceError",InvalidAccessError:"InvalidAccessError",ValidationError:"ValidationError",TypeMismatchError:"TypeMismatchError",SecurityError:"SecurityError",NetworkError:"NetworkError",AbortError:"AbortError",URLMismatchError:"URLMismatchError",QuotaExceededError:"QuotaExceededError",TimeoutError:"TimeoutError",InvalidNodeTypeError:"InvalidNodeTypeError",DataCloneError:"DataCloneError",EncodingError:"EncodingError",NotReadableError:"NotReadableError",UnknownError:"UnknownError",ConstraintError:"ConstraintError",DataError:"DataError",TransactionInactiveError:"TransactionInactiveError",ReadOnlyError:"ReadOnlyError",VersionError:"VersionError",OperationError:"OperationError",NotAllowedError:"NotAllowedError",OptOutError:"OptOutError"}),Wa=Object.keys(rn);function Ga(r){return typeof r=="number"&&r>=1&&r<=25}function uf(r){return typeof r=="string"&&r.substring(r.length-rn.Error.length)===rn.Error}function nn(r,e){Ga(r)?(this.name=Wa[r],this.message=e||""):(this.message=r,this.name=uf(e)?e:rn.Error),Error.captureStackTrace&&Error.captureStackTrace(this,nn)}za(nn,!0);Object.defineProperties(nn.prototype,{code:{enumerable:!0,get:function(){var r=Wa.indexOf(this.name);return Ga(r)?r:0}}});var Xa={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25},Xi=Object.entries(Xa);for(tn=0;tn<Xi.length;tn++)Ha=Xi[tn][0],nn[Ha]=Xi[tn][1];var Ha,tn;function Yi(r,e,t){this.message=r,this.locator=e,this.cause=t,Error.captureStackTrace&&Error.captureStackTrace(this,Yi)}za(Yi);sn.DOMException=nn;sn.DOMExceptionName=rn;sn.ExceptionCode=Xa;sn.ParseError=Yi});var ro=lt(B=>{"use strict";function el(r){try{typeof r!="function"&&(r=RegExp);var e=new r("\u{1D306}","u").exec("\u{1D306}");return!!e&&e[0].length===2}catch{}return!1}var pr=el();function mt(r){if(r.source[0]!=="[")throw new Error(r+" can not be used with chars");return r.source.slice(1,r.source.lastIndexOf("]"))}function fr(r,e){if(r.source[0]!=="[")throw new Error("/"+r.source+"/ can not be used with chars_without");if(!e||typeof e!="string")throw new Error(JSON.stringify(e)+" is not a valid search");if(r.source.indexOf(e)===-1)throw new Error('"'+e+'" is not is /'+r.source+"/");if(e==="-"&&r.source.indexOf(e)!==1)throw new Error('"'+e+'" is not at the first postion of /'+r.source+"/");return new RegExp(r.source.replace(e,""),pr?"u":"")}function $(r){var e=this;return new RegExp(Array.prototype.slice.call(arguments).map(function(t){var n=typeof t=="string";if(n&&e===void 0&&t==="|")throw new Error("use regg instead of reg to wrap expressions with `|`!");return n?t:t.source}).join(""),pr?"u":"")}function I(r){if(arguments.length===0)throw new Error("no parameters provided");return $.apply(I,["(?:"].concat(Array.prototype.slice.call(arguments),[")"]))}var cf="\uFFFD",gt=/[-\x09\x0A\x0D\x20-\x2C\x2E-\uD7FF\uE000-\uFFFD]/;pr&&(gt=$("[",mt(gt),"\\u{10000}-\\u{10FFFF}","]"));var df=new RegExp("[^"+mt(gt)+"]",pr?"u":""),vs=/[\x20\x09\x0D\x0A]/,ff=mt(vs),z=$(vs,"+"),J=$(vs,"*"),an=/[:_a-zA-Z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;pr&&(an=$("[",mt(an),"\\u{10000}-\\u{10FFFF}","]"));var hf=mt(an),Ki=$("[",hf,mt(/[-.0-9\xB7]/),mt(/[\u0300-\u036F\u203F-\u2040]/),"]"),De=$(an,Ki,"*"),pf=$("^",De,"$"),Ya=$(Ki,"+"),mf=$("&",De,";"),gf=I(/&#[0-9]+;|&#x[0-9a-fA-F]+;/),ln=I(mf,"|",gf),un=$("%",De,";"),Qi=I($('"',I(/[^%&"]/,"|",un,"|",ln),"*",'"'),"|",$("'",I(/[^%&']/,"|",un,"|",ln),"*","'")),bf=I('"',I(/[^<&"]/,"|",ln),"*",'"',"|","'",I(/[^<&']/,"|",ln),"*","'"),_f=fr(an,":"),wf=fr(Ki,":"),Zi=$(_f,wf,"*"),yf=$("^",Zi,"$"),cn=$(Zi,I(":",Zi),"?"),vf=$("^",cn,"$"),Ef=$("(",cn,")"),hr=I(/"[^"]*"|'[^']*'/),kf=$(/^<\?/,"(",De,")",I(z,"(?!",vs,")(",gt,"*?)"),"?",/\?>/),Za=/[\x20\x0D\x0Aa-zA-Z0-9-'()+,./:=?;!*#@$_%]/,dn=I('"',Za,'*"',"|","'",fr(Za,"'"),"*'"),tl="<!--",rl="-->",Af=$(tl,I(fr(gt,"-"),"|",$("-",fr(gt,"-"))),"*",rl),Ja="#PCDATA",Tf=I($(/\(/,J,Ja,I(J,/\|/,J,cn),"*",J,/\)\*/),"|",$(/\(/,J,Ja,J,/\)/)),xf=/[?*+]?/,Df=$(/\([^>]+\)/,xf),Sf=I("EMPTY","|","ANY","|",Tf,"|",Df),Cf="<!ELEMENT",Nf=$(Cf,z,I(cn,"|",un),z,I(Sf,"|",un),J,">"),If=$("NOTATION",z,/\(/,J,De,I(J,/\|/,J,De),"*",J,/\)/),Of=$(/\(/,J,Ya,I(J,/\|/,J,Ya),"*",J,/\)/),Bf=I(If,"|",Of),Rf=I(/CDATA|ID|IDREF|IDREFS|ENTITY|ENTITIES|NMTOKEN|NMTOKENS/,"|",Bf),Mf=I(/#REQUIRED|#IMPLIED/,"|",I(I("#FIXED",z),"?",bf)),$f=I(z,De,z,Rf,z,Mf),Lf="<!ATTLIST",Pf=$(Lf,z,De,$f,"*",J,">"),Ji="about:legacy-compat",Ff=I('"'+Ji+'"',"|","'"+Ji+"'"),eo="SYSTEM",Es="PUBLIC",ks=I(I(eo,z,hr),"|",I(Es,z,dn,z,hr)),jf=$("^",I(I(eo,z,"(?<SystemLiteralOnly>",hr,")"),"|",I(Es,z,"(?<PubidLiteral>",dn,")",z,"(?<SystemLiteral>",hr,")"))),Uf=$("^",dn,"$"),qf=$("^",hr,"$"),Vf=I(z,"NDATA",z,De),Hf=I(Qi,"|",I(ks,Vf,"?")),nl="<!ENTITY",zf=$(nl,z,De,z,Hf,J,">"),Wf=I(Qi,"|",ks),Gf=$(nl,z,"%",z,De,z,Wf,J,">"),Xf=I(zf,"|",Gf),Yf=$(Es,z,dn),Zf=$("<!NOTATION",z,De,z,I(ks,"|",Yf),J,">"),to=$(J,"=",J),Ka=/1[.]\d+/,Jf=$(z,"version",to,I("'",Ka,"'","|",'"',Ka,'"')),Qa=/[A-Za-z][-A-Za-z0-9._]*/,Kf=I(z,"encoding",to,I('"',Qa,'"',"|","'",Qa,"'")),Qf=I(z,"standalone",to,I("'",I("yes","|","no"),"'","|",'"',I("yes","|","no"),'"')),eh=$(/^<\?xml/,Jf,Kf,"?",Qf,"?",J,/\?>/),th="<!DOCTYPE",rh="<![CDATA[",nh="]]>",sh=/<!\[CDATA\[/,ih=/\]\]>/,oh=$(gt,"*?",ih),ah=$(sh,oh);B.chars=mt;B.chars_without=fr;B.detectUnicodeSupport=el;B.reg=$;B.regg=I;B.ABOUT_LEGACY_COMPAT=Ji;B.ABOUT_LEGACY_COMPAT_SystemLiteral=Ff;B.AttlistDecl=Pf;B.CDATA_START=rh;B.CDATA_END=nh;B.CDSect=ah;B.Char=gt;B.Comment=Af;B.COMMENT_START=tl;B.COMMENT_END=rl;B.DOCTYPE_DECL_START=th;B.elementdecl=Nf;B.EntityDecl=Xf;B.EntityValue=Qi;B.ExternalID=ks;B.ExternalID_match=jf;B.Name=De;B.Name_exact=pf;B.NCName_exact=yf;B.NotationDecl=Zf;B.Reference=ln;B.PEReference=un;B.PI=kf;B.PUBLIC=Es;B.PubidLiteral=dn;B.PubidLiteral_match=Uf;B.QName=cn;B.QName_exact=vf;B.QName_group=Ef;B.S=z;B.SChar_s=ff;B.S_OPT=J;B.SYSTEM=eo;B.SystemLiteral=hr;B.SystemLiteral_match=qf;B.InvalidChar=df;B.UNICODE_REPLACEMENT_CHARACTER=cf;B.UNICODE_SUPPORT=pr;B.XMLDecl=eh});var ho=lt(ee=>{"use strict";var Be=$t(),Ye=Be.find,lh=Be.hasDefaultHTMLNamespace,gr=Be.hasOwn,uh=Be.isHTMLMimeType,ch=Be.isHTMLRawTextElement,dh=Be.isHTMLVoidElement,fn=Be.MIME_TYPE,Ze=Be.NAMESPACE,_e=Symbol(),cl=on(),E=cl.DOMException,ge=cl.DOMExceptionName,Q=ro();function ke(r){if(r!==_e)throw new TypeError("Illegal constructor")}function fh(r){return r!==""}function hh(r){return r?r.split(/[\t\n\f\r ]+/).filter(fh):[]}function ph(r,e){return gr(r,e)||(r[e]=!0),r}function sl(r){if(!r)return[];var e=hh(r);return Object.keys(e.reduce(ph,{}))}function mh(r){return function(e){return r&&r.indexOf(e)!==-1}}function dl(r){if(!Q.QName_exact.test(r))throw new E(E.INVALID_CHARACTER_ERR,'invalid character in qualified name "'+r+'"')}function so(r,e){dl(e),r=r||null;var t=null,n=e;if(e.indexOf(":")>=0){var s=e.split(":");t=s[0],n=s[1]}if(t!==null&&r===null)throw new E(E.NAMESPACE_ERR,"prefix is non-null and namespace is null");if(t==="xml"&&r!==Be.NAMESPACE.XML)throw new E(E.NAMESPACE_ERR,'prefix is "xml" and namespace is not the XML namespace');if((t==="xmlns"||e==="xmlns")&&r!==Be.NAMESPACE.XMLNS)throw new E(E.NAMESPACE_ERR,'either qualifiedName or prefix is "xmlns" and namespace is not the XMLNS namespace');if(r===Be.NAMESPACE.XMLNS&&t!=="xmlns"&&e!=="xmlns")throw new E(E.NAMESPACE_ERR,'namespace is the XMLNS namespace and neither qualifiedName nor prefix is "xmlns"');return[r,t,n]}function wr(r,e){for(var t in r)gr(r,t)&&(e[t]=r[t])}function Ae(r,e){var t=r.prototype;if(!(t instanceof e)){let n=function(){};n.prototype=e.prototype,n=new n,wr(t,n),r.prototype=t=n}t.constructor!=r&&(typeof r!="function"&&console.error("unknown Class:"+r),t.constructor=r)}var Te={},Oe=Te.ELEMENT_NODE=1,br=Te.ATTRIBUTE_NODE=2,hn=Te.TEXT_NODE=3,fl=Te.CDATA_SECTION_NODE=4,hl=Te.ENTITY_REFERENCE_NODE=5,gh=Te.ENTITY_NODE=6,io=Te.PROCESSING_INSTRUCTION_NODE=7,oo=Te.COMMENT_NODE=8,mr=Te.DOCUMENT_NODE=9,pl=Te.DOCUMENT_TYPE_NODE=10,bt=Te.DOCUMENT_FRAGMENT_NODE=11,bh=Te.NOTATION_NODE=12,K=Be.freeze({DOCUMENT_POSITION_DISCONNECTED:1,DOCUMENT_POSITION_PRECEDING:2,DOCUMENT_POSITION_FOLLOWING:4,DOCUMENT_POSITION_CONTAINS:8,DOCUMENT_POSITION_CONTAINED_BY:16,DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:32});function ml(r,e){if(e.length<r.length)return ml(e,r);var t=null;for(var n in r){if(r[n]!==e[n])return t;t=r[n]}return t}function il(r){return r.guid||(r.guid=Math.random()),r.guid}function oe(){}oe.prototype={length:0,item:function(r){return r>=0&&r<this.length?this[r]:null},toString:function(r){var e;typeof r=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:r}:r?e={requireWellFormed:!!r.requireWellFormed,splitCDATASections:r.splitCDATASections!==!1,nodeFilter:r.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};for(var t=[],n=0;n<this.length;n++)fo(this[n],t,null,e);return t.join("")},filter:function(r){return Array.prototype.filter.call(this,r)},indexOf:function(r){return Array.prototype.indexOf.call(this,r)}};oe.prototype[Symbol.iterator]=function(){var r=this,e=0;return{next:function(){return e<r.length?{value:r[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function Xe(r,e){this._node=r,this._refresh=e,Ds(this)}function Ds(r){var e=r._node._inc||r._node.ownerDocument._inc;if(r._inc!==e){var t=r._refresh(r._node);if(xl(r,"length",t.length),!r.$$length||t.length<r.$$length)for(var n=t.length;n in r;n++)gr(r,n)&&delete r[n];wr(t,r),r._inc=e}}Xe.prototype.item=function(r){return Ds(this),this[r]||null};Ae(Xe,oe);function _r(){this._nsIndex=Object.create(null),this._noNsIndex=Object.create(null)}function gl(r,e){for(var t=0;t<r.length;){if(r[t]===e)return t;t++}}function ao(r,e,t){if(!e)return r._noNsIndex;var n=r._nsIndex[e];return!n&&t&&(n=r._nsIndex[e]=Object.create(null)),n}function _h(r,e,t){var n=ao(r,e,!1),s=n&&n[t];return s||null}function wh(r,e){ao(r,e.namespaceURI,!0)[e.localName]=e}function yh(r,e){var t=ao(r,e.namespaceURI,!1);t&&delete t[e.localName]}function vh(r,e,t,n){if(n?e[gl(e,n)]=t:(e[e.length]=t,e.length++),wh(e,t),r){t.ownerElement=r;var s=r.ownerDocument;s&&(n&&wl(s,r,n),Eh(s,r,t))}}function ol(r,e,t){var n=gl(e,t);if(n>=0){for(var s=e.length-1;n<=s;)e[n]=e[++n];if(e.length=s,yh(e,t),r){var i=r.ownerDocument;i&&wl(i,r,t),t.ownerElement=null}}}_r.prototype={length:0,item:oe.prototype.item,getNamedItem:function(r){this._ownerElement&&this._ownerElement._isInHTMLDocumentAndNamespace()&&(r=r.toLowerCase());for(var e=0;e<this.length;){var t=this[e];if(t.nodeName===r)return t;e++}return null},setNamedItem:function(r){var e=r.ownerElement;if(e&&e!==this._ownerElement)throw new E(E.INUSE_ATTRIBUTE_ERR);var t=_h(this,r.namespaceURI,r.localName);return t===r?r:(vh(this._ownerElement,this,r,t),t)},setNamedItemNS:function(r){return this.setNamedItem(r)},removeNamedItem:function(r){var e=this.getNamedItem(r);if(!e)throw new E(E.NOT_FOUND_ERR,r);return ol(this._ownerElement,this,e),e},removeNamedItemNS:function(r,e){var t=this.getNamedItemNS(r,e);if(!t)throw new E(E.NOT_FOUND_ERR,r?r+" : "+e:e);return ol(this._ownerElement,this,t),t},getNamedItemNS:function(r,e){r||(r=null);for(var t=0;t<this.length;){var n=this[t];if(n.localName===e&&n.namespaceURI===r)return n;t++}return null}};_r.prototype[Symbol.iterator]=function(){var r=this,e=0;return{next:function(){return e<r.length?{value:r[e++],done:!1}:{done:!0}},return:function(){return{done:!0}}}};function bl(){}bl.prototype={hasFeature:function(r,e){return!0},createDocument:function(r,e,t){var n=fn.XML_APPLICATION;r===Ze.HTML?n=fn.XML_XHTML_APPLICATION:r===Ze.SVG&&(n=fn.XML_SVG_IMAGE);var s=new nt(_e,{contentType:n});if(s.implementation=this,s.childNodes=new oe,s.doctype=t||null,t&&s.appendChild(t),e){var i=s.createElementNS(r,e);s.appendChild(i)}return s},createDocumentType:function(r,e,t,n){dl(r);var s=new Ns(_e);return s.name=r,s.nodeName=r,s.publicId=e||"",s.systemId=t||"",s.internalSubset=n||"",s.childNodes=new oe,s},createHTMLDocument:function(r){var e=new nt(_e,{contentType:fn.HTML});if(e.implementation=this,e.childNodes=new oe,r!==!1){e.doctype=this.createDocumentType("html"),e.doctype.ownerDocument=e,e.appendChild(e.doctype);var t=e.createElement("html");e.appendChild(t);var n=e.createElement("head");if(t.appendChild(n),typeof r=="string"){var s=e.createElement("title");s.appendChild(e.createTextNode(r)),n.appendChild(s)}t.appendChild(e.createElement("body"))}return e}};function F(r){ke(r)}F.prototype={firstChild:null,lastChild:null,previousSibling:null,nextSibling:null,parentNode:null,get parentElement(){return this.parentNode&&this.parentNode.nodeType===this.ELEMENT_NODE?this.parentNode:null},childNodes:null,ownerDocument:null,nodeValue:null,namespaceURI:null,prefix:null,localName:null,baseURI:"about:blank",get isConnected(){var r=this.getRootNode();return r&&r.nodeType===r.DOCUMENT_NODE},contains:function(r){if(!r)return!1;var e=r;do{if(this===e)return!0;e=e.parentNode}while(e);return!1},getRootNode:function(r){var e=this;do{if(!e.parentNode)return e;e=e.parentNode}while(e)},isEqualNode:function(r){if(!r)return!1;for(var e=[{node:this,other:r}];e.length>0;){var t=e.pop(),n=t.node,s=t.other;if(n.nodeType!==s.nodeType)return!1;switch(n.nodeType){case n.DOCUMENT_TYPE_NODE:if(n.name!==s.name||n.publicId!==s.publicId||n.systemId!==s.systemId)return!1;break;case n.ELEMENT_NODE:if(n.namespaceURI!==s.namespaceURI||n.prefix!==s.prefix||n.localName!==s.localName||n.attributes.length!==s.attributes.length)return!1;for(var i=0;i<n.attributes.length;i++){var o=n.attributes.item(i),a=s.getAttributeNodeNS(o.namespaceURI,o.localName);if(!a)return!1;e.push({node:o,other:a})}break;case n.ATTRIBUTE_NODE:if(n.namespaceURI!==s.namespaceURI||n.localName!==s.localName||n.value!==s.value)return!1;break;case n.PROCESSING_INSTRUCTION_NODE:if(n.target!==s.target||n.data!==s.data)return!1;break;case n.TEXT_NODE:case n.CDATA_SECTION_NODE:case n.COMMENT_NODE:if(n.data!==s.data)return!1;break}if(n.childNodes.length!==s.childNodes.length)return!1;for(var i=n.childNodes.length-1;i>=0;i--)e.push({node:n.childNodes[i],other:s.childNodes[i]})}return!0},isSameNode:function(r){return this===r},insertBefore:function(r,e){return xs(this,r,e)},replaceChild:function(r,e){xs(this,r,e,El),e&&this.removeChild(e)},removeChild:function(r){return yl(this,r)},appendChild:function(r){return this.insertBefore(r,null)},hasChildNodes:function(){return this.firstChild!=null},cloneNode:function(r){return Tl(this.ownerDocument||this,this,r)},normalize:function(){de(this,null,{enter:function(r){for(var e=r.firstChild;e;){var t=e.nextSibling;if(t!==null&&t.nodeType===hn&&e.nodeType===hn){for(var n=[],s=t;s!==null&&s.nodeType===hn;)n.push(s.data),s=s.nextSibling;for(var i=e.nextSibling;i!==s;){var o=i.nextSibling;i.parentNode=null,i.previousSibling=null,i.nextSibling=null,i=o}e.nextSibling=s,s!==null?s.previousSibling=e:r.lastChild=e,e.appendData(n.join("")),lo(r.ownerDocument,r),e=s}else e=t}return!0}})},isSupported:function(r,e){return this.ownerDocument.implementation.hasFeature(r,e)},lookupPrefix:function(r){for(var e=this;e;){var t=e._nsMap;if(t){for(var n in t)if(gr(t,n)&&t[n]===r)return n}e=e.nodeType==br?e.ownerDocument:e.parentNode}return null},lookupNamespaceURI:function(r){for(var e=this;e;){var t=e._nsMap;if(t&&gr(t,r))return t[r];e=e.nodeType==br?e.ownerDocument:e.parentNode}return null},isDefaultNamespace:function(r){var e=this.lookupPrefix(r);return e==null},compareDocumentPosition:function(r){if(this===r)return 0;var e=r,t=this,n=null,s=null;if(e instanceof Lt&&(n=e,e=n.ownerElement),t instanceof Lt&&(s=t,t=s.ownerElement,n&&e&&t===e))for(var i=0,o;o=t.attributes[i];i++){if(o===n)return K.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+K.DOCUMENT_POSITION_PRECEDING;if(o===s)return K.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+K.DOCUMENT_POSITION_FOLLOWING}if(!e||!t||t.ownerDocument!==e.ownerDocument)return K.DOCUMENT_POSITION_DISCONNECTED+K.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC+(il(t.ownerDocument)>il(e.ownerDocument)?K.DOCUMENT_POSITION_FOLLOWING:K.DOCUMENT_POSITION_PRECEDING);if(s&&e===t)return K.DOCUMENT_POSITION_CONTAINS+K.DOCUMENT_POSITION_PRECEDING;if(n&&e===t)return K.DOCUMENT_POSITION_CONTAINED_BY+K.DOCUMENT_POSITION_FOLLOWING;for(var a=[],l=e.parentNode;l;){if(!s&&l===t)return K.DOCUMENT_POSITION_CONTAINED_BY+K.DOCUMENT_POSITION_FOLLOWING;a.push(l),l=l.parentNode}a.reverse();for(var u=[],c=t.parentNode;c;){if(!n&&c===e)return K.DOCUMENT_POSITION_CONTAINS+K.DOCUMENT_POSITION_PRECEDING;u.push(c),c=c.parentNode}u.reverse();var d=ml(a,u);for(var f in d.childNodes){var h=d.childNodes[f];if(h===t)return K.DOCUMENT_POSITION_FOLLOWING;if(h===e)return K.DOCUMENT_POSITION_PRECEDING;if(u.indexOf(h)>=0)return K.DOCUMENT_POSITION_FOLLOWING;if(a.indexOf(h)>=0)return K.DOCUMENT_POSITION_PRECEDING}return 0}};function _l(r){return r=="<"&&"&lt;"||r==">"&&"&gt;"||r=="&"&&"&amp;"||r=='"'&&"&quot;"||"&#"+r.charCodeAt()+";"}wr(Te,F);wr(Te,F.prototype);wr(K,F);wr(K,F.prototype);function Ts(r,e){de(r,null,{enter:function(t){return e(t)?de.STOP:!0}})}function de(r,e,t){for(var n=[{node:r,context:e,phase:de.ENTER}];n.length>0;){var s=n.pop();if(s.phase===de.ENTER){var i=t.enter(s.node,s.context);if(i===de.STOP)return de.STOP;if(n.push({node:s.node,context:i,phase:de.EXIT}),i==null)continue;for(var o=s.node.lastChild;o;)n.push({node:o,context:i,phase:de.ENTER}),o=o.previousSibling}else t.exit&&t.exit(s.node,s.context)}}de.STOP=Symbol("walkDOM.STOP");de.ENTER=0;de.EXIT=1;function nt(r,e){ke(r);var t=e||{};this.ownerDocument=this,this.contentType=t.contentType||fn.XML_APPLICATION,this.type=uh(this.contentType)?"html":"xml"}function Eh(r,e,t){r&&r._inc++;var n=t.namespaceURI;n===Ze.XMLNS&&(e._nsMap[t.prefix?t.localName:""]=t.value)}function wl(r,e,t,n){r&&r._inc++;var s=t.namespaceURI;s===Ze.XMLNS&&delete e._nsMap[t.prefix?t.localName:""]}function lo(r,e,t){if(r&&r._inc){r._inc++;var n=e.childNodes;if(t&&!t.nextSibling)n[n.length++]=t;else{for(var s=e.firstChild,i=0;s;)n[i++]=s,s=s.nextSibling;n.length=i,delete n[n.length]}}}function yl(r,e){if(r!==e.parentNode)throw new E(E.NOT_FOUND_ERR,"child's parent is not parent");var t=e.previousSibling,n=e.nextSibling;return t?t.nextSibling=n:r.firstChild=n,n?n.previousSibling=t:r.lastChild=t,lo(r.ownerDocument,r),e.parentNode=null,e.previousSibling=null,e.nextSibling=null,e}function kh(r){return r&&(r.nodeType===F.DOCUMENT_NODE||r.nodeType===F.DOCUMENT_FRAGMENT_NODE||r.nodeType===F.ELEMENT_NODE)}function Ah(r){return r&&(r.nodeType===F.CDATA_SECTION_NODE||r.nodeType===F.COMMENT_NODE||r.nodeType===F.DOCUMENT_FRAGMENT_NODE||r.nodeType===F.DOCUMENT_TYPE_NODE||r.nodeType===F.ELEMENT_NODE||r.nodeType===F.PROCESSING_INSTRUCTION_NODE||r.nodeType===F.TEXT_NODE)}function _t(r){return r&&r.nodeType===F.DOCUMENT_TYPE_NODE}function rt(r){return r&&r.nodeType===F.ELEMENT_NODE}function vl(r){return r&&r.nodeType===F.TEXT_NODE}function al(r,e){var t=r.childNodes||[];if(Ye(t,rt)||_t(e))return!1;var n=Ye(t,_t);return!(e&&n&&t.indexOf(n)>t.indexOf(e))}function ll(r,e){var t=r.childNodes||[];function n(i){return rt(i)&&i!==e}if(Ye(t,n))return!1;var s=Ye(t,_t);return!(e&&s&&t.indexOf(s)>t.indexOf(e))}function Th(r,e,t){if(!kh(r))throw new E(E.HIERARCHY_REQUEST_ERR,"Unexpected parent node type "+r.nodeType);if(t&&t.parentNode!==r)throw new E(E.NOT_FOUND_ERR,"child not in parent");if(!Ah(e)||_t(e)&&r.nodeType!==F.DOCUMENT_NODE)throw new E(E.HIERARCHY_REQUEST_ERR,"Unexpected node type "+e.nodeType+" for parent node type "+r.nodeType)}function xh(r,e,t){var n=r.childNodes||[],s=e.childNodes||[];if(e.nodeType===F.DOCUMENT_FRAGMENT_NODE){var i=s.filter(rt);if(i.length>1||Ye(s,vl))throw new E(E.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(i.length===1&&!al(r,t))throw new E(E.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(rt(e)&&!al(r,t))throw new E(E.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(_t(e)){if(Ye(n,_t))throw new E(E.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=Ye(n,rt);if(t&&n.indexOf(o)<n.indexOf(t))throw new E(E.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element");if(!t&&o)throw new E(E.HIERARCHY_REQUEST_ERR,"Doctype can not be appended since element is present")}}function El(r,e,t){var n=r.childNodes||[],s=e.childNodes||[];if(e.nodeType===F.DOCUMENT_FRAGMENT_NODE){var i=s.filter(rt);if(i.length>1||Ye(s,vl))throw new E(E.HIERARCHY_REQUEST_ERR,"More than one element or text in fragment");if(i.length===1&&!ll(r,t))throw new E(E.HIERARCHY_REQUEST_ERR,"Element in fragment can not be inserted before doctype")}if(rt(e)&&!ll(r,t))throw new E(E.HIERARCHY_REQUEST_ERR,"Only one element can be added and only after doctype");if(_t(e)){if(Ye(n,function(l){return _t(l)&&l!==t}))throw new E(E.HIERARCHY_REQUEST_ERR,"Only one doctype is allowed");var o=Ye(n,rt);if(t&&n.indexOf(o)<n.indexOf(t))throw new E(E.HIERARCHY_REQUEST_ERR,"Doctype can only be inserted before an element")}}function xs(r,e,t,n){Th(r,e,t),r.nodeType===F.DOCUMENT_NODE&&(n||xh)(r,e,t);var s=e.parentNode;if(s&&s.removeChild(e),e.nodeType===bt){var i=e.firstChild;if(i==null)return e;var o=e.lastChild}else i=o=e;var a=t?t.previousSibling:r.lastChild;i.previousSibling=a,o.nextSibling=t,a?a.nextSibling=i:r.firstChild=i,t==null?r.lastChild=o:t.previousSibling=o;do i.parentNode=r;while(i!==o&&(i=i.nextSibling));return lo(r.ownerDocument||r,r,e),e.nodeType==bt&&(e.firstChild=e.lastChild=null),e}nt.prototype={implementation:null,nodeName:"#document",nodeType:mr,doctype:null,documentElement:null,_inc:1,insertBefore:function(r,e){if(r.nodeType===bt){for(var t=r.firstChild;t;){var n=t.nextSibling;this.insertBefore(t,e),t=n}return r}return xs(this,r,e),r.ownerDocument=this,this.documentElement===null&&r.nodeType===Oe&&(this.documentElement=r),r},removeChild:function(r){var e=yl(this,r);return e===this.documentElement&&(this.documentElement=null),e},replaceChild:function(r,e){xs(this,r,e,El),r.ownerDocument=this,e&&this.removeChild(e),rt(r)&&(this.documentElement=r)},importNode:function(r,e){return Dh(this,r,e)},getElementById:function(r){var e=null;return Ts(this.documentElement,function(t){if(t.nodeType==Oe&&t.getAttribute("id")==r)return e=t,!0}),e},createElement:function(r){var e=new st(_e);e.ownerDocument=this,this.type==="html"&&(r=r.toLowerCase()),lh(this.contentType)&&(e.namespaceURI=Ze.HTML),e.nodeName=r,e.tagName=r,e.localName=r,e.childNodes=new oe;var t=e.attributes=new _r;return t._ownerElement=e,e},createDocumentFragment:function(){var r=new yr(_e);return r.ownerDocument=this,r.childNodes=new oe,r},createTextNode:function(r){var e=new pn(_e);return e.ownerDocument=this,e.childNodes=new oe,e.appendData(r),e},createComment:function(r){var e=new Ss(_e);return e.ownerDocument=this,e.childNodes=new oe,e.appendData(r),e},createCDATASection:function(r){if(r.indexOf("]]>")!==-1)throw new E(E.INVALID_CHARACTER_ERR,'data contains "]]>"');var e=new Cs(_e);return e.ownerDocument=this,e.childNodes=new oe,e.appendData(r),e},createProcessingInstruction:function(r,e){var t=new Os(_e);return t.ownerDocument=this,t.childNodes=new oe,t.nodeName=t.target=r,t.nodeValue=t.data=e,t},createAttribute:function(r){if(!Q.QName_exact.test(r))throw new E(E.INVALID_CHARACTER_ERR,'invalid character in name "'+r+'"');return this.type==="html"&&(r=r.toLowerCase()),this._createAttribute(r)},_createAttribute:function(r){var e=new Lt(_e);return e.ownerDocument=this,e.childNodes=new oe,e.name=r,e.nodeName=r,e.localName=r,e.specified=!0,e},createEntityReference:function(r){if(!Q.Name_exact.test(r))throw new E(E.INVALID_CHARACTER_ERR,'not a valid xml name "'+r+'"');if(this.type==="html")throw new E("document is an html document",ge.NotSupportedError);var e=new Is(_e);return e.ownerDocument=this,e.childNodes=new oe,e.nodeName=r,e},createElementNS:function(r,e){var t=so(r,e),n=new st(_e),s=n.attributes=new _r;return n.childNodes=new oe,n.ownerDocument=this,n.nodeName=e,n.tagName=e,n.namespaceURI=t[0],n.prefix=t[1],n.localName=t[2],s._ownerElement=n,n},createAttributeNS:function(r,e){var t=so(r,e),n=new Lt(_e);return n.ownerDocument=this,n.childNodes=new oe,n.nodeName=e,n.name=e,n.specified=!0,n.namespaceURI=t[0],n.prefix=t[1],n.localName=t[2],n}};Ae(nt,F);function st(r){ke(r),this._nsMap=Object.create(null)}st.prototype={nodeType:Oe,attributes:null,getQualifiedName:function(){return this.prefix?this.prefix+":"+this.localName:this.localName},_isInHTMLDocumentAndNamespace:function(){return this.ownerDocument.type==="html"&&this.namespaceURI===Ze.HTML},hasAttributes:function(){return!!(this.attributes&&this.attributes.length)},hasAttribute:function(r){return!!this.getAttributeNode(r)},getAttribute:function(r){var e=this.getAttributeNode(r);return e?e.value:null},getAttributeNode:function(r){return this._isInHTMLDocumentAndNamespace()&&(r=r.toLowerCase()),this.attributes.getNamedItem(r)},setAttribute:function(r,e){this._isInHTMLDocumentAndNamespace()&&(r=r.toLowerCase());var t=this.getAttributeNode(r);t?t.value=t.nodeValue=""+e:(t=this.ownerDocument._createAttribute(r),t.value=t.nodeValue=""+e,this.setAttributeNode(t))},removeAttribute:function(r){var e=this.getAttributeNode(r);e&&this.removeAttributeNode(e)},setAttributeNode:function(r){return this.attributes.setNamedItem(r)},setAttributeNodeNS:function(r){return this.attributes.setNamedItemNS(r)},removeAttributeNode:function(r){return this.attributes.removeNamedItem(r.nodeName)},removeAttributeNS:function(r,e){var t=this.getAttributeNodeNS(r,e);t&&this.removeAttributeNode(t)},hasAttributeNS:function(r,e){return this.getAttributeNodeNS(r,e)!=null},getAttributeNS:function(r,e){var t=this.getAttributeNodeNS(r,e);return t?t.value:null},setAttributeNS:function(r,e,t){var n=so(r,e),s=n[2],i=this.getAttributeNodeNS(r,s);i?i.value=i.nodeValue=""+t:(i=this.ownerDocument.createAttributeNS(r,e),i.value=i.nodeValue=""+t,this.setAttributeNode(i))},getAttributeNodeNS:function(r,e){return this.attributes.getNamedItemNS(r,e)},getElementsByClassName:function(r){var e=sl(r);return new Xe(this,function(t){var n=[];return e.length>0&&Ts(t,function(s){if(s!==t&&s.nodeType===Oe){var i=s.getAttribute("class");if(i){var o=r===i;if(!o){var a=sl(i);o=e.every(mh(a))}o&&n.push(s)}}}),n})},getElementsByTagName:function(r){var e=(this.nodeType===mr?this:this.ownerDocument).type==="html",t=r.toLowerCase();return new Xe(this,function(n){var s=[];return Ts(n,function(i){if(!(i===n||i.nodeType!==Oe))if(r==="*")s.push(i);else{var o=i.getQualifiedName(),a=e&&i.namespaceURI===Ze.HTML?t:r;o===a&&s.push(i)}}),s})},getElementsByTagNameNS:function(r,e){return new Xe(this,function(t){var n=[];return Ts(t,function(s){s!==t&&s.nodeType===Oe&&(r==="*"||s.namespaceURI===r)&&(e==="*"||s.localName==e)&&n.push(s)}),n})}};nt.prototype.getElementsByClassName=st.prototype.getElementsByClassName;nt.prototype.getElementsByTagName=st.prototype.getElementsByTagName;nt.prototype.getElementsByTagNameNS=st.prototype.getElementsByTagNameNS;Ae(st,F);function Lt(r){ke(r),this.namespaceURI=null,this.prefix=null,this.ownerElement=null}Lt.prototype.nodeType=br;Ae(Lt,F);function wt(r){ke(r)}wt.prototype={data:"",substringData:function(r,e){return this.data.substring(r,r+e)},appendData:function(r){r=this.data+r,this.nodeValue=this.data=r,this.length=r.length},insertData:function(r,e){this.replaceData(r,0,e)},deleteData:function(r,e){this.replaceData(r,e,"")},replaceData:function(r,e,t){var n=this.data.substring(0,r),s=this.data.substring(r+e);t=n+t+s,this.nodeValue=this.data=t,this.length=t.length}};Ae(wt,F);function pn(r){ke(r)}pn.prototype={nodeName:"#text",nodeType:hn,splitText:function(r){var e=this.data,t=e.substring(r);e=e.substring(0,r),this.data=this.nodeValue=e,this.length=e.length;var n=this.ownerDocument.createTextNode(t);return this.parentNode&&this.parentNode.insertBefore(n,this.nextSibling),n}};Ae(pn,wt);function Ss(r){ke(r)}Ss.prototype={nodeName:"#comment",nodeType:oo};Ae(Ss,wt);function Cs(r){ke(r)}Cs.prototype={nodeName:"#cdata-section",nodeType:fl};Ae(Cs,pn);function Ns(r){ke(r)}Ns.prototype.nodeType=pl;Ae(Ns,F);function uo(r){ke(r)}uo.prototype.nodeType=bh;Ae(uo,F);function co(r){ke(r)}co.prototype.nodeType=gh;Ae(co,F);function Is(r){ke(r)}Is.prototype.nodeType=hl;Ae(Is,F);function yr(r){ke(r)}yr.prototype.nodeName="#document-fragment";yr.prototype.nodeType=bt;Ae(yr,F);function Os(r){ke(r)}Os.prototype.nodeType=io;Ae(Os,wt);function kl(){}kl.prototype.serializeToString=function(r,e){return Al.call(r,e)};F.prototype.toString=Al;function Al(r){var e;typeof r=="function"?e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:r}:r!=null?e={requireWellFormed:!!r.requireWellFormed,splitCDATASections:r.splitCDATASections!==!1,nodeFilter:r.nodeFilter||null}:e={requireWellFormed:!1,splitCDATASections:!0,nodeFilter:null};var t=[],n=this.nodeType===mr&&this.documentElement||this,s=n.prefix,i=n.namespaceURI;if(i&&s==null){var s=n.lookupPrefix(i);if(s==null)var o=[{namespace:i,prefix:null}]}return fo(this,t,o,e),t.join("")}function ul(r,e,t){var n=r.prefix||"",s=r.namespaceURI;if(!s||n==="xml"&&s===Ze.XML||s===Ze.XMLNS)return!1;for(var i=t.length;i--;){var o=t[i];if(o.prefix===n)return o.namespace!==s}return!0}function As(r,e,t,n){if(n&&!Q.QName_exact.test(e))throw new E('The attribute name "'+e+'" is not a valid XML QName',ge.InvalidStateError);r.push(" ",e,'="',t.replace(/[<>&"\t\n\r]/g,_l),'"')}function fo(r,e,t,n){t||(t=[]);var s=n.nodeFilter,i=n.requireWellFormed,o=n.splitCDATASections,a=r.nodeType===mr?r:r.ownerDocument,l=a.type==="html";de(r,{ns:t},{enter:function(u,c){var d=c.ns;if(s)if(u=s(u),u){if(typeof u=="string")return e.push(u),null}else return null;switch(u.nodeType){case Oe:var f=u.attributes,h=f.length,p=u.tagName,m=p;if(!l&&!u.prefix&&u.namespaceURI){for(var g,b=0;b<f.length;b++)if(f.item(b).name==="xmlns"){g=f.item(b).value;break}if(!g)for(var y=d.length-1;y>=0;y--){var w=d[y];if(w.prefix===""&&w.namespace===u.namespaceURI){g=w.namespace;break}}if(g!==u.namespaceURI)for(var y=d.length-1;y>=0;y--){var w=d[y];if(w.namespace===u.namespaceURI){w.prefix&&(m=w.prefix+":"+p);break}}}if(i&&!Q.QName_exact.test(m))throw new E('The element name "'+m+'" is not a valid XML QName',ge.InvalidStateError);e.push("<",m);for(var k=d.slice(),A=0;A<h;A++){var v=f.item(A);v.prefix=="xmlns"?k.push({prefix:v.localName,namespace:v.value}):v.nodeName=="xmlns"&&k.push({prefix:"",namespace:v.value})}for(var A=0;A<h;A++){var v=f.item(A);if(ul(v,l,k)){var N=v.prefix||"",L=v.namespaceURI;As(e,N?"xmlns:"+N:"xmlns",L,i),k.push({prefix:N,namespace:L})}var U=s?s(v):v;U&&(typeof U=="string"?e.push(U):As(e,U.name,U.value,i))}if(p===m&&ul(u,l,k)){var ve=u.prefix||"",L=u.namespaceURI;As(e,ve?"xmlns:"+ve:"xmlns",L,i),k.push({prefix:ve,namespace:L})}var Y=!u.firstChild;if(Y&&(l||u.namespaceURI===Ze.HTML)&&(Y=dh(p)),Y)return e.push("/>"),null;if(e.push(">"),l&&ch(p)){for(var ne=u.firstChild;ne;)ne.data?e.push(ne.data):fo(ne,e,k.slice(),n),ne=ne.nextSibling;return e.push("</",m,">"),null}return{ns:k,tag:m};case mr:case bt:if(i&&u.nodeType===mr&&u.documentElement==null)throw new E("The Document has no documentElement",ge.InvalidStateError);return{ns:d};case br:return As(e,u.name,u.value,i),null;case hn:if(i&&Q.InvalidChar.test(u.data))throw new E("The Text node data contains characters outside the XML Char production",ge.InvalidStateError);return e.push(u.data.replace(/[<&>]/g,_l)),null;case fl:if(i&&u.data.indexOf("]]>")!==-1)throw new E('The CDATASection data contains "]]>"',ge.InvalidStateError);return o?e.push(Q.CDATA_START,u.data.replace(/]]>/g,"]]]]><![CDATA[>"),Q.CDATA_END):e.push(Q.CDATA_START,u.data,Q.CDATA_END),null;case oo:if(i){if(Q.InvalidChar.test(u.data))throw new E("The comment node data contains characters outside the XML Char production",ge.InvalidStateError);if(u.data.indexOf("--")!==-1||u.data[u.data.length-1]==="-")throw new E('The comment node data contains "--" or ends with "-"',ge.InvalidStateError)}return e.push(Q.COMMENT_START,u.data,Q.COMMENT_END),null;case pl:var Ne=u.publicId,G=u.systemId;if(i){if(!Q.Name_exact.test(u.name))throw new E('The doctype name "'+u.name+'" is not a valid XML Name',ge.InvalidStateError);if(Ne&&!Q.PubidLiteral_match.test(Ne))throw new E("DocumentType publicId is not a valid PubidLiteral",ge.InvalidStateError);if(G&&G!=="."&&!Q.SystemLiteral_match.test(G))throw new E("DocumentType systemId is not a valid SystemLiteral",ge.InvalidStateError);if(u.internalSubset&&u.internalSubset.indexOf("]>")!==-1)throw new E('DocumentType internalSubset contains "]>"',ge.InvalidStateError)}return e.push(Q.DOCTYPE_DECL_START," ",u.name),Ne?(e.push(" ",Q.PUBLIC," ",Ne),G&&G!=="."&&e.push(" ",G)):G&&G!=="."&&e.push(" ",Q.SYSTEM," ",G),u.internalSubset&&e.push(" [",u.internalSubset,"]"),e.push(">"),null;case io:if(i){if(!Q.NCName_exact.test(u.target)||u.target.toLowerCase()==="xml")throw new E('The processing instruction target "'+u.target+'" is not a valid XML NCName or is reserved',ge.InvalidStateError);if(Q.InvalidChar.test(u.data))throw new E("The ProcessingInstruction data contains characters outside the XML Char production",ge.InvalidStateError);if(u.data.indexOf("?>")!==-1)throw new E('The ProcessingInstruction data contains "?>"',ge.InvalidStateError)}return e.push("<?",u.target," ",u.data,"?>"),null;case hl:if(i&&!Q.Name_exact.test(u.nodeName))throw new E('The entity reference name "'+u.nodeName+'" is not a valid XML Name',ge.InvalidStateError);return e.push("&",u.nodeName,";"),null;default:return e.push("??",u.nodeName),null}},exit:function(u,c){c&&c.tag&&e.push("</",c.tag,">")}})}function Dh(r,e,t){var n;return de(e,null,{enter:function(s,i){var o=s.cloneNode(!1);o.ownerDocument=r,o.parentNode=null,i===null?n=o:i.appendChild(o);var a=s.nodeType===br||t;return a?o:null}}),n}function Tl(r,e,t){var n;return de(e,null,{enter:function(s,i){var o=new s.constructor(_e);for(var a in s)if(gr(s,a)){var l=s[a];typeof l!="object"&&l!=o[a]&&(o[a]=l)}s.childNodes&&(o.childNodes=new oe),o.ownerDocument=r;var u=t;switch(o.nodeType){case Oe:var c=s.attributes,d=o.attributes=new _r,f=c.length;d._ownerElement=o;for(var h=0;h<f;h++)o.setAttributeNode(Tl(r,c.item(h),!0));break;case br:u=!0}return i!==null?i.appendChild(o):n=o,u?o:null}}),n}function xl(r,e,t){r[e]=t}function no(r){for(var e=[],t=r.firstChild;t;)t.nodeType===Oe&&e.push(t),t=t.nextSibling;return e}try{Object.defineProperty&&(Object.defineProperty(Xe.prototype,"length",{get:function(){return Ds(this),this.$$length}}),Object.defineProperty(F.prototype,"textContent",{get:function(){if(this.nodeType===Oe||this.nodeType===bt){var r=[];return de(this,null,{enter:function(e){if(e.nodeType===Oe||e.nodeType===bt)return!0;if(e.nodeType===io||e.nodeType===oo)return null;r.push(e.nodeValue)}}),r.join("")}return this.nodeValue},set:function(r){switch(this.nodeType){case Oe:case bt:for(;this.firstChild;)this.removeChild(this.firstChild);(r||String(r))&&this.appendChild(this.ownerDocument.createTextNode(r));break;default:this.data=r,this.value=r,this.nodeValue=r}}}),Object.defineProperty(wt.prototype,"data",{get:function(){return this._data!=null?this._data:""},set:function(r){this._data=r,this.length=typeof r=="string"?r.length:0}}),Object.defineProperty(wt.prototype,"nodeValue",{get:function(){return this.data},set:function(r){this.data=r},enumerable:!0,configurable:!0}),Object.defineProperty(st.prototype,"children",{get:function(){return new Xe(this,no)}}),Object.defineProperty(nt.prototype,"children",{get:function(){return new Xe(this,no)}}),Object.defineProperty(yr.prototype,"children",{get:function(){return new Xe(this,no)}}),xl=function(r,e,t){r["$$"+e]=t})}catch{}ee._updateLiveList=Ds;ee.Attr=Lt;ee.CDATASection=Cs;ee.CharacterData=wt;ee.Comment=Ss;ee.Document=nt;ee.DocumentFragment=yr;ee.DocumentType=Ns;ee.DOMImplementation=bl;ee.Element=st;ee.Entity=co;ee.EntityReference=Is;ee.LiveNodeList=Xe;ee.NamedNodeMap=_r;ee.Node=F;ee.NodeList=oe;ee.Notation=uo;ee.Text=pn;ee.ProcessingInstruction=Os;ee.walkDOM=de;ee.XMLSerializer=kl});var Sl=lt(mn=>{"use strict";var Dl=$t().freeze;mn.XML_ENTITIES=Dl({amp:"&",apos:"'",gt:">",lt:"<",quot:'"'});mn.HTML_ENTITIES=Dl({Aacute:"\xC1",aacute:"\xE1",Abreve:"\u0102",abreve:"\u0103",ac:"\u223E",acd:"\u223F",acE:"\u223E\u0333",Acirc:"\xC2",acirc:"\xE2",acute:"\xB4",Acy:"\u0410",acy:"\u0430",AElig:"\xC6",aelig:"\xE6",af:"\u2061",Afr:"\u{1D504}",afr:"\u{1D51E}",Agrave:"\xC0",agrave:"\xE0",alefsym:"\u2135",aleph:"\u2135",Alpha:"\u0391",alpha:"\u03B1",Amacr:"\u0100",amacr:"\u0101",amalg:"\u2A3F",AMP:"&",amp:"&",And:"\u2A53",and:"\u2227",andand:"\u2A55",andd:"\u2A5C",andslope:"\u2A58",andv:"\u2A5A",ang:"\u2220",ange:"\u29A4",angle:"\u2220",angmsd:"\u2221",angmsdaa:"\u29A8",angmsdab:"\u29A9",angmsdac:"\u29AA",angmsdad:"\u29AB",angmsdae:"\u29AC",angmsdaf:"\u29AD",angmsdag:"\u29AE",angmsdah:"\u29AF",angrt:"\u221F",angrtvb:"\u22BE",angrtvbd:"\u299D",angsph:"\u2222",angst:"\xC5",angzarr:"\u237C",Aogon:"\u0104",aogon:"\u0105",Aopf:"\u{1D538}",aopf:"\u{1D552}",ap:"\u2248",apacir:"\u2A6F",apE:"\u2A70",ape:"\u224A",apid:"\u224B",apos:"'",ApplyFunction:"\u2061",approx:"\u2248",approxeq:"\u224A",Aring:"\xC5",aring:"\xE5",Ascr:"\u{1D49C}",ascr:"\u{1D4B6}",Assign:"\u2254",ast:"*",asymp:"\u2248",asympeq:"\u224D",Atilde:"\xC3",atilde:"\xE3",Auml:"\xC4",auml:"\xE4",awconint:"\u2233",awint:"\u2A11",backcong:"\u224C",backepsilon:"\u03F6",backprime:"\u2035",backsim:"\u223D",backsimeq:"\u22CD",Backslash:"\u2216",Barv:"\u2AE7",barvee:"\u22BD",Barwed:"\u2306",barwed:"\u2305",barwedge:"\u2305",bbrk:"\u23B5",bbrktbrk:"\u23B6",bcong:"\u224C",Bcy:"\u0411",bcy:"\u0431",bdquo:"\u201E",becaus:"\u2235",Because:"\u2235",because:"\u2235",bemptyv:"\u29B0",bepsi:"\u03F6",bernou:"\u212C",Bernoullis:"\u212C",Beta:"\u0392",beta:"\u03B2",beth:"\u2136",between:"\u226C",Bfr:"\u{1D505}",bfr:"\u{1D51F}",bigcap:"\u22C2",bigcirc:"\u25EF",bigcup:"\u22C3",bigodot:"\u2A00",bigoplus:"\u2A01",bigotimes:"\u2A02",bigsqcup:"\u2A06",bigstar:"\u2605",bigtriangledown:"\u25BD",bigtriangleup:"\u25B3",biguplus:"\u2A04",bigvee:"\u22C1",bigwedge:"\u22C0",bkarow:"\u290D",blacklozenge:"\u29EB",blacksquare:"\u25AA",blacktriangle:"\u25B4",blacktriangledown:"\u25BE",blacktriangleleft:"\u25C2",blacktriangleright:"\u25B8",blank:"\u2423",blk12:"\u2592",blk14:"\u2591",blk34:"\u2593",block:"\u2588",bne:"=\u20E5",bnequiv:"\u2261\u20E5",bNot:"\u2AED",bnot:"\u2310",Bopf:"\u{1D539}",bopf:"\u{1D553}",bot:"\u22A5",bottom:"\u22A5",bowtie:"\u22C8",boxbox:"\u29C9",boxDL:"\u2557",boxDl:"\u2556",boxdL:"\u2555",boxdl:"\u2510",boxDR:"\u2554",boxDr:"\u2553",boxdR:"\u2552",boxdr:"\u250C",boxH:"\u2550",boxh:"\u2500",boxHD:"\u2566",boxHd:"\u2564",boxhD:"\u2565",boxhd:"\u252C",boxHU:"\u2569",boxHu:"\u2567",boxhU:"\u2568",boxhu:"\u2534",boxminus:"\u229F",boxplus:"\u229E",boxtimes:"\u22A0",boxUL:"\u255D",boxUl:"\u255C",boxuL:"\u255B",boxul:"\u2518",boxUR:"\u255A",boxUr:"\u2559",boxuR:"\u2558",boxur:"\u2514",boxV:"\u2551",boxv:"\u2502",boxVH:"\u256C",boxVh:"\u256B",boxvH:"\u256A",boxvh:"\u253C",boxVL:"\u2563",boxVl:"\u2562",boxvL:"\u2561",boxvl:"\u2524",boxVR:"\u2560",boxVr:"\u255F",boxvR:"\u255E",boxvr:"\u251C",bprime:"\u2035",Breve:"\u02D8",breve:"\u02D8",brvbar:"\xA6",Bscr:"\u212C",bscr:"\u{1D4B7}",bsemi:"\u204F",bsim:"\u223D",bsime:"\u22CD",bsol:"\\",bsolb:"\u29C5",bsolhsub:"\u27C8",bull:"\u2022",bullet:"\u2022",bump:"\u224E",bumpE:"\u2AAE",bumpe:"\u224F",Bumpeq:"\u224E",bumpeq:"\u224F",Cacute:"\u0106",cacute:"\u0107",Cap:"\u22D2",cap:"\u2229",capand:"\u2A44",capbrcup:"\u2A49",capcap:"\u2A4B",capcup:"\u2A47",capdot:"\u2A40",CapitalDifferentialD:"\u2145",caps:"\u2229\uFE00",caret:"\u2041",caron:"\u02C7",Cayleys:"\u212D",ccaps:"\u2A4D",Ccaron:"\u010C",ccaron:"\u010D",Ccedil:"\xC7",ccedil:"\xE7",Ccirc:"\u0108",ccirc:"\u0109",Cconint:"\u2230",ccups:"\u2A4C",ccupssm:"\u2A50",Cdot:"\u010A",cdot:"\u010B",cedil:"\xB8",Cedilla:"\xB8",cemptyv:"\u29B2",cent:"\xA2",CenterDot:"\xB7",centerdot:"\xB7",Cfr:"\u212D",cfr:"\u{1D520}",CHcy:"\u0427",chcy:"\u0447",check:"\u2713",checkmark:"\u2713",Chi:"\u03A7",chi:"\u03C7",cir:"\u25CB",circ:"\u02C6",circeq:"\u2257",circlearrowleft:"\u21BA",circlearrowright:"\u21BB",circledast:"\u229B",circledcirc:"\u229A",circleddash:"\u229D",CircleDot:"\u2299",circledR:"\xAE",circledS:"\u24C8",CircleMinus:"\u2296",CirclePlus:"\u2295",CircleTimes:"\u2297",cirE:"\u29C3",cire:"\u2257",cirfnint:"\u2A10",cirmid:"\u2AEF",cirscir:"\u29C2",ClockwiseContourIntegral:"\u2232",CloseCurlyDoubleQuote:"\u201D",CloseCurlyQuote:"\u2019",clubs:"\u2663",clubsuit:"\u2663",Colon:"\u2237",colon:":",Colone:"\u2A74",colone:"\u2254",coloneq:"\u2254",comma:",",commat:"@",comp:"\u2201",compfn:"\u2218",complement:"\u2201",complexes:"\u2102",cong:"\u2245",congdot:"\u2A6D",Congruent:"\u2261",Conint:"\u222F",conint:"\u222E",ContourIntegral:"\u222E",Copf:"\u2102",copf:"\u{1D554}",coprod:"\u2210",Coproduct:"\u2210",COPY:"\xA9",copy:"\xA9",copysr:"\u2117",CounterClockwiseContourIntegral:"\u2233",crarr:"\u21B5",Cross:"\u2A2F",cross:"\u2717",Cscr:"\u{1D49E}",cscr:"\u{1D4B8}",csub:"\u2ACF",csube:"\u2AD1",csup:"\u2AD0",csupe:"\u2AD2",ctdot:"\u22EF",cudarrl:"\u2938",cudarrr:"\u2935",cuepr:"\u22DE",cuesc:"\u22DF",cularr:"\u21B6",cularrp:"\u293D",Cup:"\u22D3",cup:"\u222A",cupbrcap:"\u2A48",CupCap:"\u224D",cupcap:"\u2A46",cupcup:"\u2A4A",cupdot:"\u228D",cupor:"\u2A45",cups:"\u222A\uFE00",curarr:"\u21B7",curarrm:"\u293C",curlyeqprec:"\u22DE",curlyeqsucc:"\u22DF",curlyvee:"\u22CE",curlywedge:"\u22CF",curren:"\xA4",curvearrowleft:"\u21B6",curvearrowright:"\u21B7",cuvee:"\u22CE",cuwed:"\u22CF",cwconint:"\u2232",cwint:"\u2231",cylcty:"\u232D",Dagger:"\u2021",dagger:"\u2020",daleth:"\u2138",Darr:"\u21A1",dArr:"\u21D3",darr:"\u2193",dash:"\u2010",Dashv:"\u2AE4",dashv:"\u22A3",dbkarow:"\u290F",dblac:"\u02DD",Dcaron:"\u010E",dcaron:"\u010F",Dcy:"\u0414",dcy:"\u0434",DD:"\u2145",dd:"\u2146",ddagger:"\u2021",ddarr:"\u21CA",DDotrahd:"\u2911",ddotseq:"\u2A77",deg:"\xB0",Del:"\u2207",Delta:"\u0394",delta:"\u03B4",demptyv:"\u29B1",dfisht:"\u297F",Dfr:"\u{1D507}",dfr:"\u{1D521}",dHar:"\u2965",dharl:"\u21C3",dharr:"\u21C2",DiacriticalAcute:"\xB4",DiacriticalDot:"\u02D9",DiacriticalDoubleAcute:"\u02DD",DiacriticalGrave:"`",DiacriticalTilde:"\u02DC",diam:"\u22C4",Diamond:"\u22C4",diamond:"\u22C4",diamondsuit:"\u2666",diams:"\u2666",die:"\xA8",DifferentialD:"\u2146",digamma:"\u03DD",disin:"\u22F2",div:"\xF7",divide:"\xF7",divideontimes:"\u22C7",divonx:"\u22C7",DJcy:"\u0402",djcy:"\u0452",dlcorn:"\u231E",dlcrop:"\u230D",dollar:"$",Dopf:"\u{1D53B}",dopf:"\u{1D555}",Dot:"\xA8",dot:"\u02D9",DotDot:"\u20DC",doteq:"\u2250",doteqdot:"\u2251",DotEqual:"\u2250",dotminus:"\u2238",dotplus:"\u2214",dotsquare:"\u22A1",doublebarwedge:"\u2306",DoubleContourIntegral:"\u222F",DoubleDot:"\xA8",DoubleDownArrow:"\u21D3",DoubleLeftArrow:"\u21D0",DoubleLeftRightArrow:"\u21D4",DoubleLeftTee:"\u2AE4",DoubleLongLeftArrow:"\u27F8",DoubleLongLeftRightArrow:"\u27FA",DoubleLongRightArrow:"\u27F9",DoubleRightArrow:"\u21D2",DoubleRightTee:"\u22A8",DoubleUpArrow:"\u21D1",DoubleUpDownArrow:"\u21D5",DoubleVerticalBar:"\u2225",DownArrow:"\u2193",Downarrow:"\u21D3",downarrow:"\u2193",DownArrowBar:"\u2913",DownArrowUpArrow:"\u21F5",DownBreve:"\u0311",downdownarrows:"\u21CA",downharpoonleft:"\u21C3",downharpoonright:"\u21C2",DownLeftRightVector:"\u2950",DownLeftTeeVector:"\u295E",DownLeftVector:"\u21BD",DownLeftVectorBar:"\u2956",DownRightTeeVector:"\u295F",DownRightVector:"\u21C1",DownRightVectorBar:"\u2957",DownTee:"\u22A4",DownTeeArrow:"\u21A7",drbkarow:"\u2910",drcorn:"\u231F",drcrop:"\u230C",Dscr:"\u{1D49F}",dscr:"\u{1D4B9}",DScy:"\u0405",dscy:"\u0455",dsol:"\u29F6",Dstrok:"\u0110",dstrok:"\u0111",dtdot:"\u22F1",dtri:"\u25BF",dtrif:"\u25BE",duarr:"\u21F5",duhar:"\u296F",dwangle:"\u29A6",DZcy:"\u040F",dzcy:"\u045F",dzigrarr:"\u27FF",Eacute:"\xC9",eacute:"\xE9",easter:"\u2A6E",Ecaron:"\u011A",ecaron:"\u011B",ecir:"\u2256",Ecirc:"\xCA",ecirc:"\xEA",ecolon:"\u2255",Ecy:"\u042D",ecy:"\u044D",eDDot:"\u2A77",Edot:"\u0116",eDot:"\u2251",edot:"\u0117",ee:"\u2147",efDot:"\u2252",Efr:"\u{1D508}",efr:"\u{1D522}",eg:"\u2A9A",Egrave:"\xC8",egrave:"\xE8",egs:"\u2A96",egsdot:"\u2A98",el:"\u2A99",Element:"\u2208",elinters:"\u23E7",ell:"\u2113",els:"\u2A95",elsdot:"\u2A97",Emacr:"\u0112",emacr:"\u0113",empty:"\u2205",emptyset:"\u2205",EmptySmallSquare:"\u25FB",emptyv:"\u2205",EmptyVerySmallSquare:"\u25AB",emsp:"\u2003",emsp13:"\u2004",emsp14:"\u2005",ENG:"\u014A",eng:"\u014B",ensp:"\u2002",Eogon:"\u0118",eogon:"\u0119",Eopf:"\u{1D53C}",eopf:"\u{1D556}",epar:"\u22D5",eparsl:"\u29E3",eplus:"\u2A71",epsi:"\u03B5",Epsilon:"\u0395",epsilon:"\u03B5",epsiv:"\u03F5",eqcirc:"\u2256",eqcolon:"\u2255",eqsim:"\u2242",eqslantgtr:"\u2A96",eqslantless:"\u2A95",Equal:"\u2A75",equals:"=",EqualTilde:"\u2242",equest:"\u225F",Equilibrium:"\u21CC",equiv:"\u2261",equivDD:"\u2A78",eqvparsl:"\u29E5",erarr:"\u2971",erDot:"\u2253",Escr:"\u2130",escr:"\u212F",esdot:"\u2250",Esim:"\u2A73",esim:"\u2242",Eta:"\u0397",eta:"\u03B7",ETH:"\xD0",eth:"\xF0",Euml:"\xCB",euml:"\xEB",euro:"\u20AC",excl:"!",exist:"\u2203",Exists:"\u2203",expectation:"\u2130",ExponentialE:"\u2147",exponentiale:"\u2147",fallingdotseq:"\u2252",Fcy:"\u0424",fcy:"\u0444",female:"\u2640",ffilig:"\uFB03",fflig:"\uFB00",ffllig:"\uFB04",Ffr:"\u{1D509}",ffr:"\u{1D523}",filig:"\uFB01",FilledSmallSquare:"\u25FC",FilledVerySmallSquare:"\u25AA",fjlig:"fj",flat:"\u266D",fllig:"\uFB02",fltns:"\u25B1",fnof:"\u0192",Fopf:"\u{1D53D}",fopf:"\u{1D557}",ForAll:"\u2200",forall:"\u2200",fork:"\u22D4",forkv:"\u2AD9",Fouriertrf:"\u2131",fpartint:"\u2A0D",frac12:"\xBD",frac13:"\u2153",frac14:"\xBC",frac15:"\u2155",frac16:"\u2159",frac18:"\u215B",frac23:"\u2154",frac25:"\u2156",frac34:"\xBE",frac35:"\u2157",frac38:"\u215C",frac45:"\u2158",frac56:"\u215A",frac58:"\u215D",frac78:"\u215E",frasl:"\u2044",frown:"\u2322",Fscr:"\u2131",fscr:"\u{1D4BB}",gacute:"\u01F5",Gamma:"\u0393",gamma:"\u03B3",Gammad:"\u03DC",gammad:"\u03DD",gap:"\u2A86",Gbreve:"\u011E",gbreve:"\u011F",Gcedil:"\u0122",Gcirc:"\u011C",gcirc:"\u011D",Gcy:"\u0413",gcy:"\u0433",Gdot:"\u0120",gdot:"\u0121",gE:"\u2267",ge:"\u2265",gEl:"\u2A8C",gel:"\u22DB",geq:"\u2265",geqq:"\u2267",geqslant:"\u2A7E",ges:"\u2A7E",gescc:"\u2AA9",gesdot:"\u2A80",gesdoto:"\u2A82",gesdotol:"\u2A84",gesl:"\u22DB\uFE00",gesles:"\u2A94",Gfr:"\u{1D50A}",gfr:"\u{1D524}",Gg:"\u22D9",gg:"\u226B",ggg:"\u22D9",gimel:"\u2137",GJcy:"\u0403",gjcy:"\u0453",gl:"\u2277",gla:"\u2AA5",glE:"\u2A92",glj:"\u2AA4",gnap:"\u2A8A",gnapprox:"\u2A8A",gnE:"\u2269",gne:"\u2A88",gneq:"\u2A88",gneqq:"\u2269",gnsim:"\u22E7",Gopf:"\u{1D53E}",gopf:"\u{1D558}",grave:"`",GreaterEqual:"\u2265",GreaterEqualLess:"\u22DB",GreaterFullEqual:"\u2267",GreaterGreater:"\u2AA2",GreaterLess:"\u2277",GreaterSlantEqual:"\u2A7E",GreaterTilde:"\u2273",Gscr:"\u{1D4A2}",gscr:"\u210A",gsim:"\u2273",gsime:"\u2A8E",gsiml:"\u2A90",Gt:"\u226B",GT:">",gt:">",gtcc:"\u2AA7",gtcir:"\u2A7A",gtdot:"\u22D7",gtlPar:"\u2995",gtquest:"\u2A7C",gtrapprox:"\u2A86",gtrarr:"\u2978",gtrdot:"\u22D7",gtreqless:"\u22DB",gtreqqless:"\u2A8C",gtrless:"\u2277",gtrsim:"\u2273",gvertneqq:"\u2269\uFE00",gvnE:"\u2269\uFE00",Hacek:"\u02C7",hairsp:"\u200A",half:"\xBD",hamilt:"\u210B",HARDcy:"\u042A",hardcy:"\u044A",hArr:"\u21D4",harr:"\u2194",harrcir:"\u2948",harrw:"\u21AD",Hat:"^",hbar:"\u210F",Hcirc:"\u0124",hcirc:"\u0125",hearts:"\u2665",heartsuit:"\u2665",hellip:"\u2026",hercon:"\u22B9",Hfr:"\u210C",hfr:"\u{1D525}",HilbertSpace:"\u210B",hksearow:"\u2925",hkswarow:"\u2926",hoarr:"\u21FF",homtht:"\u223B",hookleftarrow:"\u21A9",hookrightarrow:"\u21AA",Hopf:"\u210D",hopf:"\u{1D559}",horbar:"\u2015",HorizontalLine:"\u2500",Hscr:"\u210B",hscr:"\u{1D4BD}",hslash:"\u210F",Hstrok:"\u0126",hstrok:"\u0127",HumpDownHump:"\u224E",HumpEqual:"\u224F",hybull:"\u2043",hyphen:"\u2010",Iacute:"\xCD",iacute:"\xED",ic:"\u2063",Icirc:"\xCE",icirc:"\xEE",Icy:"\u0418",icy:"\u0438",Idot:"\u0130",IEcy:"\u0415",iecy:"\u0435",iexcl:"\xA1",iff:"\u21D4",Ifr:"\u2111",ifr:"\u{1D526}",Igrave:"\xCC",igrave:"\xEC",ii:"\u2148",iiiint:"\u2A0C",iiint:"\u222D",iinfin:"\u29DC",iiota:"\u2129",IJlig:"\u0132",ijlig:"\u0133",Im:"\u2111",Imacr:"\u012A",imacr:"\u012B",image:"\u2111",ImaginaryI:"\u2148",imagline:"\u2110",imagpart:"\u2111",imath:"\u0131",imof:"\u22B7",imped:"\u01B5",Implies:"\u21D2",in:"\u2208",incare:"\u2105",infin:"\u221E",infintie:"\u29DD",inodot:"\u0131",Int:"\u222C",int:"\u222B",intcal:"\u22BA",integers:"\u2124",Integral:"\u222B",intercal:"\u22BA",Intersection:"\u22C2",intlarhk:"\u2A17",intprod:"\u2A3C",InvisibleComma:"\u2063",InvisibleTimes:"\u2062",IOcy:"\u0401",iocy:"\u0451",Iogon:"\u012E",iogon:"\u012F",Iopf:"\u{1D540}",iopf:"\u{1D55A}",Iota:"\u0399",iota:"\u03B9",iprod:"\u2A3C",iquest:"\xBF",Iscr:"\u2110",iscr:"\u{1D4BE}",isin:"\u2208",isindot:"\u22F5",isinE:"\u22F9",isins:"\u22F4",isinsv:"\u22F3",isinv:"\u2208",it:"\u2062",Itilde:"\u0128",itilde:"\u0129",Iukcy:"\u0406",iukcy:"\u0456",Iuml:"\xCF",iuml:"\xEF",Jcirc:"\u0134",jcirc:"\u0135",Jcy:"\u0419",jcy:"\u0439",Jfr:"\u{1D50D}",jfr:"\u{1D527}",jmath:"\u0237",Jopf:"\u{1D541}",jopf:"\u{1D55B}",Jscr:"\u{1D4A5}",jscr:"\u{1D4BF}",Jsercy:"\u0408",jsercy:"\u0458",Jukcy:"\u0404",jukcy:"\u0454",Kappa:"\u039A",kappa:"\u03BA",kappav:"\u03F0",Kcedil:"\u0136",kcedil:"\u0137",Kcy:"\u041A",kcy:"\u043A",Kfr:"\u{1D50E}",kfr:"\u{1D528}",kgreen:"\u0138",KHcy:"\u0425",khcy:"\u0445",KJcy:"\u040C",kjcy:"\u045C",Kopf:"\u{1D542}",kopf:"\u{1D55C}",Kscr:"\u{1D4A6}",kscr:"\u{1D4C0}",lAarr:"\u21DA",Lacute:"\u0139",lacute:"\u013A",laemptyv:"\u29B4",lagran:"\u2112",Lambda:"\u039B",lambda:"\u03BB",Lang:"\u27EA",lang:"\u27E8",langd:"\u2991",langle:"\u27E8",lap:"\u2A85",Laplacetrf:"\u2112",laquo:"\xAB",Larr:"\u219E",lArr:"\u21D0",larr:"\u2190",larrb:"\u21E4",larrbfs:"\u291F",larrfs:"\u291D",larrhk:"\u21A9",larrlp:"\u21AB",larrpl:"\u2939",larrsim:"\u2973",larrtl:"\u21A2",lat:"\u2AAB",lAtail:"\u291B",latail:"\u2919",late:"\u2AAD",lates:"\u2AAD\uFE00",lBarr:"\u290E",lbarr:"\u290C",lbbrk:"\u2772",lbrace:"{",lbrack:"[",lbrke:"\u298B",lbrksld:"\u298F",lbrkslu:"\u298D",Lcaron:"\u013D",lcaron:"\u013E",Lcedil:"\u013B",lcedil:"\u013C",lceil:"\u2308",lcub:"{",Lcy:"\u041B",lcy:"\u043B",ldca:"\u2936",ldquo:"\u201C",ldquor:"\u201E",ldrdhar:"\u2967",ldrushar:"\u294B",ldsh:"\u21B2",lE:"\u2266",le:"\u2264",LeftAngleBracket:"\u27E8",LeftArrow:"\u2190",Leftarrow:"\u21D0",leftarrow:"\u2190",LeftArrowBar:"\u21E4",LeftArrowRightArrow:"\u21C6",leftarrowtail:"\u21A2",LeftCeiling:"\u2308",LeftDoubleBracket:"\u27E6",LeftDownTeeVector:"\u2961",LeftDownVector:"\u21C3",LeftDownVectorBar:"\u2959",LeftFloor:"\u230A",leftharpoondown:"\u21BD",leftharpoonup:"\u21BC",leftleftarrows:"\u21C7",LeftRightArrow:"\u2194",Leftrightarrow:"\u21D4",leftrightarrow:"\u2194",leftrightarrows:"\u21C6",leftrightharpoons:"\u21CB",leftrightsquigarrow:"\u21AD",LeftRightVector:"\u294E",LeftTee:"\u22A3",LeftTeeArrow:"\u21A4",LeftTeeVector:"\u295A",leftthreetimes:"\u22CB",LeftTriangle:"\u22B2",LeftTriangleBar:"\u29CF",LeftTriangleEqual:"\u22B4",LeftUpDownVector:"\u2951",LeftUpTeeVector:"\u2960",LeftUpVector:"\u21BF",LeftUpVectorBar:"\u2958",LeftVector:"\u21BC",LeftVectorBar:"\u2952",lEg:"\u2A8B",leg:"\u22DA",leq:"\u2264",leqq:"\u2266",leqslant:"\u2A7D",les:"\u2A7D",lescc:"\u2AA8",lesdot:"\u2A7F",lesdoto:"\u2A81",lesdotor:"\u2A83",lesg:"\u22DA\uFE00",lesges:"\u2A93",lessapprox:"\u2A85",lessdot:"\u22D6",lesseqgtr:"\u22DA",lesseqqgtr:"\u2A8B",LessEqualGreater:"\u22DA",LessFullEqual:"\u2266",LessGreater:"\u2276",lessgtr:"\u2276",LessLess:"\u2AA1",lesssim:"\u2272",LessSlantEqual:"\u2A7D",LessTilde:"\u2272",lfisht:"\u297C",lfloor:"\u230A",Lfr:"\u{1D50F}",lfr:"\u{1D529}",lg:"\u2276",lgE:"\u2A91",lHar:"\u2962",lhard:"\u21BD",lharu:"\u21BC",lharul:"\u296A",lhblk:"\u2584",LJcy:"\u0409",ljcy:"\u0459",Ll:"\u22D8",ll:"\u226A",llarr:"\u21C7",llcorner:"\u231E",Lleftarrow:"\u21DA",llhard:"\u296B",lltri:"\u25FA",Lmidot:"\u013F",lmidot:"\u0140",lmoust:"\u23B0",lmoustache:"\u23B0",lnap:"\u2A89",lnapprox:"\u2A89",lnE:"\u2268",lne:"\u2A87",lneq:"\u2A87",lneqq:"\u2268",lnsim:"\u22E6",loang:"\u27EC",loarr:"\u21FD",lobrk:"\u27E6",LongLeftArrow:"\u27F5",Longleftarrow:"\u27F8",longleftarrow:"\u27F5",LongLeftRightArrow:"\u27F7",Longleftrightarrow:"\u27FA",longleftrightarrow:"\u27F7",longmapsto:"\u27FC",LongRightArrow:"\u27F6",Longrightarrow:"\u27F9",longrightarrow:"\u27F6",looparrowleft:"\u21AB",looparrowright:"\u21AC",lopar:"\u2985",Lopf:"\u{1D543}",lopf:"\u{1D55D}",loplus:"\u2A2D",lotimes:"\u2A34",lowast:"\u2217",lowbar:"_",LowerLeftArrow:"\u2199",LowerRightArrow:"\u2198",loz:"\u25CA",lozenge:"\u25CA",lozf:"\u29EB",lpar:"(",lparlt:"\u2993",lrarr:"\u21C6",lrcorner:"\u231F",lrhar:"\u21CB",lrhard:"\u296D",lrm:"\u200E",lrtri:"\u22BF",lsaquo:"\u2039",Lscr:"\u2112",lscr:"\u{1D4C1}",Lsh:"\u21B0",lsh:"\u21B0",lsim:"\u2272",lsime:"\u2A8D",lsimg:"\u2A8F",lsqb:"[",lsquo:"\u2018",lsquor:"\u201A",Lstrok:"\u0141",lstrok:"\u0142",Lt:"\u226A",LT:"<",lt:"<",ltcc:"\u2AA6",ltcir:"\u2A79",ltdot:"\u22D6",lthree:"\u22CB",ltimes:"\u22C9",ltlarr:"\u2976",ltquest:"\u2A7B",ltri:"\u25C3",ltrie:"\u22B4",ltrif:"\u25C2",ltrPar:"\u2996",lurdshar:"\u294A",luruhar:"\u2966",lvertneqq:"\u2268\uFE00",lvnE:"\u2268\uFE00",macr:"\xAF",male:"\u2642",malt:"\u2720",maltese:"\u2720",Map:"\u2905",map:"\u21A6",mapsto:"\u21A6",mapstodown:"\u21A7",mapstoleft:"\u21A4",mapstoup:"\u21A5",marker:"\u25AE",mcomma:"\u2A29",Mcy:"\u041C",mcy:"\u043C",mdash:"\u2014",mDDot:"\u223A",measuredangle:"\u2221",MediumSpace:"\u205F",Mellintrf:"\u2133",Mfr:"\u{1D510}",mfr:"\u{1D52A}",mho:"\u2127",micro:"\xB5",mid:"\u2223",midast:"*",midcir:"\u2AF0",middot:"\xB7",minus:"\u2212",minusb:"\u229F",minusd:"\u2238",minusdu:"\u2A2A",MinusPlus:"\u2213",mlcp:"\u2ADB",mldr:"\u2026",mnplus:"\u2213",models:"\u22A7",Mopf:"\u{1D544}",mopf:"\u{1D55E}",mp:"\u2213",Mscr:"\u2133",mscr:"\u{1D4C2}",mstpos:"\u223E",Mu:"\u039C",mu:"\u03BC",multimap:"\u22B8",mumap:"\u22B8",nabla:"\u2207",Nacute:"\u0143",nacute:"\u0144",nang:"\u2220\u20D2",nap:"\u2249",napE:"\u2A70\u0338",napid:"\u224B\u0338",napos:"\u0149",napprox:"\u2249",natur:"\u266E",natural:"\u266E",naturals:"\u2115",nbsp:"\xA0",nbump:"\u224E\u0338",nbumpe:"\u224F\u0338",ncap:"\u2A43",Ncaron:"\u0147",ncaron:"\u0148",Ncedil:"\u0145",ncedil:"\u0146",ncong:"\u2247",ncongdot:"\u2A6D\u0338",ncup:"\u2A42",Ncy:"\u041D",ncy:"\u043D",ndash:"\u2013",ne:"\u2260",nearhk:"\u2924",neArr:"\u21D7",nearr:"\u2197",nearrow:"\u2197",nedot:"\u2250\u0338",NegativeMediumSpace:"\u200B",NegativeThickSpace:"\u200B",NegativeThinSpace:"\u200B",NegativeVeryThinSpace:"\u200B",nequiv:"\u2262",nesear:"\u2928",nesim:"\u2242\u0338",NestedGreaterGreater:"\u226B",NestedLessLess:"\u226A",NewLine:`
10
+ `,nexist:"\u2204",nexists:"\u2204",Nfr:"\u{1D511}",nfr:"\u{1D52B}",ngE:"\u2267\u0338",nge:"\u2271",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",nGg:"\u22D9\u0338",ngsim:"\u2275",nGt:"\u226B\u20D2",ngt:"\u226F",ngtr:"\u226F",nGtv:"\u226B\u0338",nhArr:"\u21CE",nharr:"\u21AE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",NJcy:"\u040A",njcy:"\u045A",nlArr:"\u21CD",nlarr:"\u219A",nldr:"\u2025",nlE:"\u2266\u0338",nle:"\u2270",nLeftarrow:"\u21CD",nleftarrow:"\u219A",nLeftrightarrow:"\u21CE",nleftrightarrow:"\u21AE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nLl:"\u22D8\u0338",nlsim:"\u2274",nLt:"\u226A\u20D2",nlt:"\u226E",nltri:"\u22EA",nltrie:"\u22EC",nLtv:"\u226A\u0338",nmid:"\u2224",NoBreak:"\u2060",NonBreakingSpace:"\xA0",Nopf:"\u2115",nopf:"\u{1D55F}",Not:"\u2AEC",not:"\xAC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",notin:"\u2209",notindot:"\u22F5\u0338",notinE:"\u22F9\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrArr:"\u21CF",nrarr:"\u219B",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nRightarrow:"\u21CF",nrightarrow:"\u219B",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",Nscr:"\u{1D4A9}",nscr:"\u{1D4C3}",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsubE:"\u2AC5\u0338",nsube:"\u2288",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupE:"\u2AC6\u0338",nsupe:"\u2289",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",Ntilde:"\xD1",ntilde:"\xF1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",Nu:"\u039D",nu:"\u03BD",num:"#",numero:"\u2116",numsp:"\u2007",nvap:"\u224D\u20D2",nVDash:"\u22AF",nVdash:"\u22AE",nvDash:"\u22AD",nvdash:"\u22AC",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvHarr:"\u2904",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwarhk:"\u2923",nwArr:"\u21D6",nwarr:"\u2196",nwarrow:"\u2196",nwnear:"\u2927",Oacute:"\xD3",oacute:"\xF3",oast:"\u229B",ocir:"\u229A",Ocirc:"\xD4",ocirc:"\xF4",Ocy:"\u041E",ocy:"\u043E",odash:"\u229D",Odblac:"\u0150",odblac:"\u0151",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",OElig:"\u0152",oelig:"\u0153",ofcir:"\u29BF",Ofr:"\u{1D512}",ofr:"\u{1D52C}",ogon:"\u02DB",Ograve:"\xD2",ograve:"\xF2",ogt:"\u29C1",ohbar:"\u29B5",ohm:"\u03A9",oint:"\u222E",olarr:"\u21BA",olcir:"\u29BE",olcross:"\u29BB",oline:"\u203E",olt:"\u29C0",Omacr:"\u014C",omacr:"\u014D",Omega:"\u03A9",omega:"\u03C9",Omicron:"\u039F",omicron:"\u03BF",omid:"\u29B6",ominus:"\u2296",Oopf:"\u{1D546}",oopf:"\u{1D560}",opar:"\u29B7",OpenCurlyDoubleQuote:"\u201C",OpenCurlyQuote:"\u2018",operp:"\u29B9",oplus:"\u2295",Or:"\u2A54",or:"\u2228",orarr:"\u21BB",ord:"\u2A5D",order:"\u2134",orderof:"\u2134",ordf:"\xAA",ordm:"\xBA",origof:"\u22B6",oror:"\u2A56",orslope:"\u2A57",orv:"\u2A5B",oS:"\u24C8",Oscr:"\u{1D4AA}",oscr:"\u2134",Oslash:"\xD8",oslash:"\xF8",osol:"\u2298",Otilde:"\xD5",otilde:"\xF5",Otimes:"\u2A37",otimes:"\u2297",otimesas:"\u2A36",Ouml:"\xD6",ouml:"\xF6",ovbar:"\u233D",OverBar:"\u203E",OverBrace:"\u23DE",OverBracket:"\u23B4",OverParenthesis:"\u23DC",par:"\u2225",para:"\xB6",parallel:"\u2225",parsim:"\u2AF3",parsl:"\u2AFD",part:"\u2202",PartialD:"\u2202",Pcy:"\u041F",pcy:"\u043F",percnt:"%",period:".",permil:"\u2030",perp:"\u22A5",pertenk:"\u2031",Pfr:"\u{1D513}",pfr:"\u{1D52D}",Phi:"\u03A6",phi:"\u03C6",phiv:"\u03D5",phmmat:"\u2133",phone:"\u260E",Pi:"\u03A0",pi:"\u03C0",pitchfork:"\u22D4",piv:"\u03D6",planck:"\u210F",planckh:"\u210E",plankv:"\u210F",plus:"+",plusacir:"\u2A23",plusb:"\u229E",pluscir:"\u2A22",plusdo:"\u2214",plusdu:"\u2A25",pluse:"\u2A72",PlusMinus:"\xB1",plusmn:"\xB1",plussim:"\u2A26",plustwo:"\u2A27",pm:"\xB1",Poincareplane:"\u210C",pointint:"\u2A15",Popf:"\u2119",popf:"\u{1D561}",pound:"\xA3",Pr:"\u2ABB",pr:"\u227A",prap:"\u2AB7",prcue:"\u227C",prE:"\u2AB3",pre:"\u2AAF",prec:"\u227A",precapprox:"\u2AB7",preccurlyeq:"\u227C",Precedes:"\u227A",PrecedesEqual:"\u2AAF",PrecedesSlantEqual:"\u227C",PrecedesTilde:"\u227E",preceq:"\u2AAF",precnapprox:"\u2AB9",precneqq:"\u2AB5",precnsim:"\u22E8",precsim:"\u227E",Prime:"\u2033",prime:"\u2032",primes:"\u2119",prnap:"\u2AB9",prnE:"\u2AB5",prnsim:"\u22E8",prod:"\u220F",Product:"\u220F",profalar:"\u232E",profline:"\u2312",profsurf:"\u2313",prop:"\u221D",Proportion:"\u2237",Proportional:"\u221D",propto:"\u221D",prsim:"\u227E",prurel:"\u22B0",Pscr:"\u{1D4AB}",pscr:"\u{1D4C5}",Psi:"\u03A8",psi:"\u03C8",puncsp:"\u2008",Qfr:"\u{1D514}",qfr:"\u{1D52E}",qint:"\u2A0C",Qopf:"\u211A",qopf:"\u{1D562}",qprime:"\u2057",Qscr:"\u{1D4AC}",qscr:"\u{1D4C6}",quaternions:"\u210D",quatint:"\u2A16",quest:"?",questeq:"\u225F",QUOT:'"',quot:'"',rAarr:"\u21DB",race:"\u223D\u0331",Racute:"\u0154",racute:"\u0155",radic:"\u221A",raemptyv:"\u29B3",Rang:"\u27EB",rang:"\u27E9",rangd:"\u2992",range:"\u29A5",rangle:"\u27E9",raquo:"\xBB",Rarr:"\u21A0",rArr:"\u21D2",rarr:"\u2192",rarrap:"\u2975",rarrb:"\u21E5",rarrbfs:"\u2920",rarrc:"\u2933",rarrfs:"\u291E",rarrhk:"\u21AA",rarrlp:"\u21AC",rarrpl:"\u2945",rarrsim:"\u2974",Rarrtl:"\u2916",rarrtl:"\u21A3",rarrw:"\u219D",rAtail:"\u291C",ratail:"\u291A",ratio:"\u2236",rationals:"\u211A",RBarr:"\u2910",rBarr:"\u290F",rbarr:"\u290D",rbbrk:"\u2773",rbrace:"}",rbrack:"]",rbrke:"\u298C",rbrksld:"\u298E",rbrkslu:"\u2990",Rcaron:"\u0158",rcaron:"\u0159",Rcedil:"\u0156",rcedil:"\u0157",rceil:"\u2309",rcub:"}",Rcy:"\u0420",rcy:"\u0440",rdca:"\u2937",rdldhar:"\u2969",rdquo:"\u201D",rdquor:"\u201D",rdsh:"\u21B3",Re:"\u211C",real:"\u211C",realine:"\u211B",realpart:"\u211C",reals:"\u211D",rect:"\u25AD",REG:"\xAE",reg:"\xAE",ReverseElement:"\u220B",ReverseEquilibrium:"\u21CB",ReverseUpEquilibrium:"\u296F",rfisht:"\u297D",rfloor:"\u230B",Rfr:"\u211C",rfr:"\u{1D52F}",rHar:"\u2964",rhard:"\u21C1",rharu:"\u21C0",rharul:"\u296C",Rho:"\u03A1",rho:"\u03C1",rhov:"\u03F1",RightAngleBracket:"\u27E9",RightArrow:"\u2192",Rightarrow:"\u21D2",rightarrow:"\u2192",RightArrowBar:"\u21E5",RightArrowLeftArrow:"\u21C4",rightarrowtail:"\u21A3",RightCeiling:"\u2309",RightDoubleBracket:"\u27E7",RightDownTeeVector:"\u295D",RightDownVector:"\u21C2",RightDownVectorBar:"\u2955",RightFloor:"\u230B",rightharpoondown:"\u21C1",rightharpoonup:"\u21C0",rightleftarrows:"\u21C4",rightleftharpoons:"\u21CC",rightrightarrows:"\u21C9",rightsquigarrow:"\u219D",RightTee:"\u22A2",RightTeeArrow:"\u21A6",RightTeeVector:"\u295B",rightthreetimes:"\u22CC",RightTriangle:"\u22B3",RightTriangleBar:"\u29D0",RightTriangleEqual:"\u22B5",RightUpDownVector:"\u294F",RightUpTeeVector:"\u295C",RightUpVector:"\u21BE",RightUpVectorBar:"\u2954",RightVector:"\u21C0",RightVectorBar:"\u2953",ring:"\u02DA",risingdotseq:"\u2253",rlarr:"\u21C4",rlhar:"\u21CC",rlm:"\u200F",rmoust:"\u23B1",rmoustache:"\u23B1",rnmid:"\u2AEE",roang:"\u27ED",roarr:"\u21FE",robrk:"\u27E7",ropar:"\u2986",Ropf:"\u211D",ropf:"\u{1D563}",roplus:"\u2A2E",rotimes:"\u2A35",RoundImplies:"\u2970",rpar:")",rpargt:"\u2994",rppolint:"\u2A12",rrarr:"\u21C9",Rrightarrow:"\u21DB",rsaquo:"\u203A",Rscr:"\u211B",rscr:"\u{1D4C7}",Rsh:"\u21B1",rsh:"\u21B1",rsqb:"]",rsquo:"\u2019",rsquor:"\u2019",rthree:"\u22CC",rtimes:"\u22CA",rtri:"\u25B9",rtrie:"\u22B5",rtrif:"\u25B8",rtriltri:"\u29CE",RuleDelayed:"\u29F4",ruluhar:"\u2968",rx:"\u211E",Sacute:"\u015A",sacute:"\u015B",sbquo:"\u201A",Sc:"\u2ABC",sc:"\u227B",scap:"\u2AB8",Scaron:"\u0160",scaron:"\u0161",sccue:"\u227D",scE:"\u2AB4",sce:"\u2AB0",Scedil:"\u015E",scedil:"\u015F",Scirc:"\u015C",scirc:"\u015D",scnap:"\u2ABA",scnE:"\u2AB6",scnsim:"\u22E9",scpolint:"\u2A13",scsim:"\u227F",Scy:"\u0421",scy:"\u0441",sdot:"\u22C5",sdotb:"\u22A1",sdote:"\u2A66",searhk:"\u2925",seArr:"\u21D8",searr:"\u2198",searrow:"\u2198",sect:"\xA7",semi:";",seswar:"\u2929",setminus:"\u2216",setmn:"\u2216",sext:"\u2736",Sfr:"\u{1D516}",sfr:"\u{1D530}",sfrown:"\u2322",sharp:"\u266F",SHCHcy:"\u0429",shchcy:"\u0449",SHcy:"\u0428",shcy:"\u0448",ShortDownArrow:"\u2193",ShortLeftArrow:"\u2190",shortmid:"\u2223",shortparallel:"\u2225",ShortRightArrow:"\u2192",ShortUpArrow:"\u2191",shy:"\xAD",Sigma:"\u03A3",sigma:"\u03C3",sigmaf:"\u03C2",sigmav:"\u03C2",sim:"\u223C",simdot:"\u2A6A",sime:"\u2243",simeq:"\u2243",simg:"\u2A9E",simgE:"\u2AA0",siml:"\u2A9D",simlE:"\u2A9F",simne:"\u2246",simplus:"\u2A24",simrarr:"\u2972",slarr:"\u2190",SmallCircle:"\u2218",smallsetminus:"\u2216",smashp:"\u2A33",smeparsl:"\u29E4",smid:"\u2223",smile:"\u2323",smt:"\u2AAA",smte:"\u2AAC",smtes:"\u2AAC\uFE00",SOFTcy:"\u042C",softcy:"\u044C",sol:"/",solb:"\u29C4",solbar:"\u233F",Sopf:"\u{1D54A}",sopf:"\u{1D564}",spades:"\u2660",spadesuit:"\u2660",spar:"\u2225",sqcap:"\u2293",sqcaps:"\u2293\uFE00",sqcup:"\u2294",sqcups:"\u2294\uFE00",Sqrt:"\u221A",sqsub:"\u228F",sqsube:"\u2291",sqsubset:"\u228F",sqsubseteq:"\u2291",sqsup:"\u2290",sqsupe:"\u2292",sqsupset:"\u2290",sqsupseteq:"\u2292",squ:"\u25A1",Square:"\u25A1",square:"\u25A1",SquareIntersection:"\u2293",SquareSubset:"\u228F",SquareSubsetEqual:"\u2291",SquareSuperset:"\u2290",SquareSupersetEqual:"\u2292",SquareUnion:"\u2294",squarf:"\u25AA",squf:"\u25AA",srarr:"\u2192",Sscr:"\u{1D4AE}",sscr:"\u{1D4C8}",ssetmn:"\u2216",ssmile:"\u2323",sstarf:"\u22C6",Star:"\u22C6",star:"\u2606",starf:"\u2605",straightepsilon:"\u03F5",straightphi:"\u03D5",strns:"\xAF",Sub:"\u22D0",sub:"\u2282",subdot:"\u2ABD",subE:"\u2AC5",sube:"\u2286",subedot:"\u2AC3",submult:"\u2AC1",subnE:"\u2ACB",subne:"\u228A",subplus:"\u2ABF",subrarr:"\u2979",Subset:"\u22D0",subset:"\u2282",subseteq:"\u2286",subseteqq:"\u2AC5",SubsetEqual:"\u2286",subsetneq:"\u228A",subsetneqq:"\u2ACB",subsim:"\u2AC7",subsub:"\u2AD5",subsup:"\u2AD3",succ:"\u227B",succapprox:"\u2AB8",succcurlyeq:"\u227D",Succeeds:"\u227B",SucceedsEqual:"\u2AB0",SucceedsSlantEqual:"\u227D",SucceedsTilde:"\u227F",succeq:"\u2AB0",succnapprox:"\u2ABA",succneqq:"\u2AB6",succnsim:"\u22E9",succsim:"\u227F",SuchThat:"\u220B",Sum:"\u2211",sum:"\u2211",sung:"\u266A",Sup:"\u22D1",sup:"\u2283",sup1:"\xB9",sup2:"\xB2",sup3:"\xB3",supdot:"\u2ABE",supdsub:"\u2AD8",supE:"\u2AC6",supe:"\u2287",supedot:"\u2AC4",Superset:"\u2283",SupersetEqual:"\u2287",suphsol:"\u27C9",suphsub:"\u2AD7",suplarr:"\u297B",supmult:"\u2AC2",supnE:"\u2ACC",supne:"\u228B",supplus:"\u2AC0",Supset:"\u22D1",supset:"\u2283",supseteq:"\u2287",supseteqq:"\u2AC6",supsetneq:"\u228B",supsetneqq:"\u2ACC",supsim:"\u2AC8",supsub:"\u2AD4",supsup:"\u2AD6",swarhk:"\u2926",swArr:"\u21D9",swarr:"\u2199",swarrow:"\u2199",swnwar:"\u292A",szlig:"\xDF",Tab:" ",target:"\u2316",Tau:"\u03A4",tau:"\u03C4",tbrk:"\u23B4",Tcaron:"\u0164",tcaron:"\u0165",Tcedil:"\u0162",tcedil:"\u0163",Tcy:"\u0422",tcy:"\u0442",tdot:"\u20DB",telrec:"\u2315",Tfr:"\u{1D517}",tfr:"\u{1D531}",there4:"\u2234",Therefore:"\u2234",therefore:"\u2234",Theta:"\u0398",theta:"\u03B8",thetasym:"\u03D1",thetav:"\u03D1",thickapprox:"\u2248",thicksim:"\u223C",ThickSpace:"\u205F\u200A",thinsp:"\u2009",ThinSpace:"\u2009",thkap:"\u2248",thksim:"\u223C",THORN:"\xDE",thorn:"\xFE",Tilde:"\u223C",tilde:"\u02DC",TildeEqual:"\u2243",TildeFullEqual:"\u2245",TildeTilde:"\u2248",times:"\xD7",timesb:"\u22A0",timesbar:"\u2A31",timesd:"\u2A30",tint:"\u222D",toea:"\u2928",top:"\u22A4",topbot:"\u2336",topcir:"\u2AF1",Topf:"\u{1D54B}",topf:"\u{1D565}",topfork:"\u2ADA",tosa:"\u2929",tprime:"\u2034",TRADE:"\u2122",trade:"\u2122",triangle:"\u25B5",triangledown:"\u25BF",triangleleft:"\u25C3",trianglelefteq:"\u22B4",triangleq:"\u225C",triangleright:"\u25B9",trianglerighteq:"\u22B5",tridot:"\u25EC",trie:"\u225C",triminus:"\u2A3A",TripleDot:"\u20DB",triplus:"\u2A39",trisb:"\u29CD",tritime:"\u2A3B",trpezium:"\u23E2",Tscr:"\u{1D4AF}",tscr:"\u{1D4C9}",TScy:"\u0426",tscy:"\u0446",TSHcy:"\u040B",tshcy:"\u045B",Tstrok:"\u0166",tstrok:"\u0167",twixt:"\u226C",twoheadleftarrow:"\u219E",twoheadrightarrow:"\u21A0",Uacute:"\xDA",uacute:"\xFA",Uarr:"\u219F",uArr:"\u21D1",uarr:"\u2191",Uarrocir:"\u2949",Ubrcy:"\u040E",ubrcy:"\u045E",Ubreve:"\u016C",ubreve:"\u016D",Ucirc:"\xDB",ucirc:"\xFB",Ucy:"\u0423",ucy:"\u0443",udarr:"\u21C5",Udblac:"\u0170",udblac:"\u0171",udhar:"\u296E",ufisht:"\u297E",Ufr:"\u{1D518}",ufr:"\u{1D532}",Ugrave:"\xD9",ugrave:"\xF9",uHar:"\u2963",uharl:"\u21BF",uharr:"\u21BE",uhblk:"\u2580",ulcorn:"\u231C",ulcorner:"\u231C",ulcrop:"\u230F",ultri:"\u25F8",Umacr:"\u016A",umacr:"\u016B",uml:"\xA8",UnderBar:"_",UnderBrace:"\u23DF",UnderBracket:"\u23B5",UnderParenthesis:"\u23DD",Union:"\u22C3",UnionPlus:"\u228E",Uogon:"\u0172",uogon:"\u0173",Uopf:"\u{1D54C}",uopf:"\u{1D566}",UpArrow:"\u2191",Uparrow:"\u21D1",uparrow:"\u2191",UpArrowBar:"\u2912",UpArrowDownArrow:"\u21C5",UpDownArrow:"\u2195",Updownarrow:"\u21D5",updownarrow:"\u2195",UpEquilibrium:"\u296E",upharpoonleft:"\u21BF",upharpoonright:"\u21BE",uplus:"\u228E",UpperLeftArrow:"\u2196",UpperRightArrow:"\u2197",Upsi:"\u03D2",upsi:"\u03C5",upsih:"\u03D2",Upsilon:"\u03A5",upsilon:"\u03C5",UpTee:"\u22A5",UpTeeArrow:"\u21A5",upuparrows:"\u21C8",urcorn:"\u231D",urcorner:"\u231D",urcrop:"\u230E",Uring:"\u016E",uring:"\u016F",urtri:"\u25F9",Uscr:"\u{1D4B0}",uscr:"\u{1D4CA}",utdot:"\u22F0",Utilde:"\u0168",utilde:"\u0169",utri:"\u25B5",utrif:"\u25B4",uuarr:"\u21C8",Uuml:"\xDC",uuml:"\xFC",uwangle:"\u29A7",vangrt:"\u299C",varepsilon:"\u03F5",varkappa:"\u03F0",varnothing:"\u2205",varphi:"\u03D5",varpi:"\u03D6",varpropto:"\u221D",vArr:"\u21D5",varr:"\u2195",varrho:"\u03F1",varsigma:"\u03C2",varsubsetneq:"\u228A\uFE00",varsubsetneqq:"\u2ACB\uFE00",varsupsetneq:"\u228B\uFE00",varsupsetneqq:"\u2ACC\uFE00",vartheta:"\u03D1",vartriangleleft:"\u22B2",vartriangleright:"\u22B3",Vbar:"\u2AEB",vBar:"\u2AE8",vBarv:"\u2AE9",Vcy:"\u0412",vcy:"\u0432",VDash:"\u22AB",Vdash:"\u22A9",vDash:"\u22A8",vdash:"\u22A2",Vdashl:"\u2AE6",Vee:"\u22C1",vee:"\u2228",veebar:"\u22BB",veeeq:"\u225A",vellip:"\u22EE",Verbar:"\u2016",verbar:"|",Vert:"\u2016",vert:"|",VerticalBar:"\u2223",VerticalLine:"|",VerticalSeparator:"\u2758",VerticalTilde:"\u2240",VeryThinSpace:"\u200A",Vfr:"\u{1D519}",vfr:"\u{1D533}",vltri:"\u22B2",vnsub:"\u2282\u20D2",vnsup:"\u2283\u20D2",Vopf:"\u{1D54D}",vopf:"\u{1D567}",vprop:"\u221D",vrtri:"\u22B3",Vscr:"\u{1D4B1}",vscr:"\u{1D4CB}",vsubnE:"\u2ACB\uFE00",vsubne:"\u228A\uFE00",vsupnE:"\u2ACC\uFE00",vsupne:"\u228B\uFE00",Vvdash:"\u22AA",vzigzag:"\u299A",Wcirc:"\u0174",wcirc:"\u0175",wedbar:"\u2A5F",Wedge:"\u22C0",wedge:"\u2227",wedgeq:"\u2259",weierp:"\u2118",Wfr:"\u{1D51A}",wfr:"\u{1D534}",Wopf:"\u{1D54E}",wopf:"\u{1D568}",wp:"\u2118",wr:"\u2240",wreath:"\u2240",Wscr:"\u{1D4B2}",wscr:"\u{1D4CC}",xcap:"\u22C2",xcirc:"\u25EF",xcup:"\u22C3",xdtri:"\u25BD",Xfr:"\u{1D51B}",xfr:"\u{1D535}",xhArr:"\u27FA",xharr:"\u27F7",Xi:"\u039E",xi:"\u03BE",xlArr:"\u27F8",xlarr:"\u27F5",xmap:"\u27FC",xnis:"\u22FB",xodot:"\u2A00",Xopf:"\u{1D54F}",xopf:"\u{1D569}",xoplus:"\u2A01",xotime:"\u2A02",xrArr:"\u27F9",xrarr:"\u27F6",Xscr:"\u{1D4B3}",xscr:"\u{1D4CD}",xsqcup:"\u2A06",xuplus:"\u2A04",xutri:"\u25B3",xvee:"\u22C1",xwedge:"\u22C0",Yacute:"\xDD",yacute:"\xFD",YAcy:"\u042F",yacy:"\u044F",Ycirc:"\u0176",ycirc:"\u0177",Ycy:"\u042B",ycy:"\u044B",yen:"\xA5",Yfr:"\u{1D51C}",yfr:"\u{1D536}",YIcy:"\u0407",yicy:"\u0457",Yopf:"\u{1D550}",yopf:"\u{1D56A}",Yscr:"\u{1D4B4}",yscr:"\u{1D4CE}",YUcy:"\u042E",yucy:"\u044E",Yuml:"\u0178",yuml:"\xFF",Zacute:"\u0179",zacute:"\u017A",Zcaron:"\u017D",zcaron:"\u017E",Zcy:"\u0417",zcy:"\u0437",Zdot:"\u017B",zdot:"\u017C",zeetrf:"\u2128",ZeroWidthSpace:"\u200B",Zeta:"\u0396",zeta:"\u03B6",Zfr:"\u2128",zfr:"\u{1D537}",ZHcy:"\u0416",zhcy:"\u0436",zigrarr:"\u21DD",Zopf:"\u2124",zopf:"\u{1D56B}",Zscr:"\u{1D4B5}",zscr:"\u{1D4CF}",zwj:"\u200D",zwnj:"\u200C"});mn.entityMap=mn.HTML_ENTITIES});var Ll=lt(Rs=>{"use strict";var Tr=$t(),R=ro(),Ol=on(),Sh=Tr.isHTMLEscapableRawTextElement,Ch=Tr.isHTMLMimeType,Nh=Tr.isHTMLRawTextElement,_n=Tr.hasOwn,Cl=Tr.NAMESPACE,Ih=Ol.ParseError,Oh=Ol.DOMException,vr=0,yt=1,Er=2,gn=3,kr=4,Ar=5,bn=6,Bs=7;function Bl(){}Bl.prototype={parse:function(r,e,t){var n=this.domBuilder;n.startDocument(),$h(e,e=Object.create(null)),Bh(r,e,t,n,this.errorHandler),n.endDocument()}};var po=/&#?\w+;?/g;function Bh(r,e,t,n,s){var i=Ch(n.mimeType);r.indexOf(R.UNICODE_REPLACEMENT_CHARACTER)>=0&&s.warning("Unicode replacement character detected, source encoding issues?");function o(q){if(q>65535){q-=65536;var Ie=55296+(q>>10),ss=56320+(q&1023);return String.fromCharCode(Ie,ss)}else return String.fromCharCode(q)}function a(q){var Ie=q[q.length-1]===";"?q:q+";";if(!i&&Ie!==q)return s.error("EntityRef: expecting ;"),q;var ss=R.Reference.exec(Ie);if(!ss||ss[0].length!==Ie.length)return s.error("entity not matching Reference production: "+q),q;var is=Ie.slice(1,-1);return _n(t,is)?t[is]:is.charAt(0)==="#"?o(parseInt(is.substring(1).replace("x","0x"))):(s.error("entity not found:"+q),q)}function l(q){if(q>g){var Ie=r.substring(g,q).replace(po,a);f&&h(g),n.characters(Ie,0,q-g),g=q}}var u=0,c=0,d=/\r\n?|\n|$/g,f=n.locator;function h(q,Ie){for(;q>=c&&(Ie=d.exec(r));)u=c,c=Ie.index+Ie[0].length,f.lineNumber++;f.columnNumber=q-u+1}for(var p=[{currentNSMap:e}],m=[],g=0;;){try{var b=r.indexOf("<",g);if(b<0){if(!i&&m.length>0)return s.fatalError("unclosed xml tag(s): "+m.join(", "));if(!r.substring(g).match(/^\s*$/)){var y=n.doc,w=y.createTextNode(r.substring(g));if(y.documentElement)return s.error("Extra content at the end of the document");y.appendChild(w),n.currentElement=w}return}if(b>g){var k=r.substring(g,b);!i&&m.length===0&&(k=k.replace(new RegExp(R.S_OPT.source,"g"),""),k&&s.error("Unexpected content outside root element: '"+k+"'")),l(b)}switch(r.charAt(b+1)){case"/":var M=r.indexOf(">",b+2),A=r.substring(b+2,M>0?M:void 0);if(!A)return s.fatalError("end tag name missing");var v=R.reg("^",R.QName_group,R.S_OPT,"$"),N=M>0&&v.exec(A);if(!N){var L=M>0&&R.reg("^",R.QName_group).exec(A);if(i&&L)s.warning('end tag name contains invalid trailing characters: "'+A+'"'),N=L;else if(L&&new RegExp(v.source,v.flags+"m").test(A))s.error('end tag name is followed by a line break and trailing content: "'+A+'"'),N=L;else return s.fatalError('end tag name contains invalid characters: "'+A+'"')}if(!n.currentElement&&!n.doc.documentElement)return;var U=m[m.length-1]||n.currentElement.tagName||n.doc.documentElement.tagName||"";if(U!==N[1]){var ve=N[1].toLowerCase();if(!i||U.toLowerCase()!==ve)return s.fatalError('Opening and ending tag mismatch: "'+U+'" != "'+A+'"')}var Y=p.pop();m.pop();var ne=Y.localNSMap;if(n.endElement(Y.uri,Y.localName,U),ne)for(var Ne in ne)_n(ne,Ne)&&n.endPrefixMapping(Ne);M++;break;case"?":f&&h(b),M=Ph(r,b,n,s);break;case"!":f&&h(b),M=Ml(r,b,n,s,i);break;default:f&&h(b);var G=new $l,se=p[p.length-1].currentNSMap,M=Rh(r,b,G,se,a,s,i),sa=G.length;if(G.closed||(i&&Tr.isHTMLVoidElement(G.tagName)?G.closed=!0:m.push(G.tagName)),f&&sa){for(var vc=Nl(f,{}),Ni=0;Ni<sa;Ni++){var ia=G[Ni];h(ia.offset),ia.locator=Nl(f,{})}n.locator=vc,Il(G,n,se)&&p.push(G),n.locator=f}else Il(G,n,se)&&p.push(G);i&&!G.closed?M=Mh(r,M,G.tagName,a,n):M++}}catch(q){if(q instanceof Ih)throw q;if(q instanceof Oh)return s.fatalError("Error constructing the DOM: "+q.name+": "+q.message,q);s.error("element parse error: "+q),M=-1}M>g?g=M:l(Math.max(b,g)+1)}}function Nl(r,e){return e.lineNumber=r.lineNumber,e.columnNumber=r.columnNumber,e}function Rh(r,e,t,n,s,i,o){function a(h,p,m){if(_n(t.attributeNames,h))return i.fatalError("Attribute "+h+" redefined");if(!o&&p.indexOf("<")>=0)return i.fatalError("Unescaped '<' not allowed in attributes values");t.addValue(h,p.replace(/[\t\n\r]/g," ").replace(po,s),m)}for(var l,u,c=++e,d=vr;;){var f=r.charAt(c);if(d===vr&&f==="<")throw new Error("unexpected < in tag name: "+r.slice(e,c));switch(f){case"=":if(d===yt)l=r.slice(e,c),d=gn;else if(d===Er)d=gn;else throw new Error("attribute equal must after attrName");break;case"'":case'"':if(d===gn||d===yt)if(d===yt&&(i.warning('attribute value must after "="'),l=r.slice(e,c)),e=c+1,c=r.indexOf(f,e),c>0)u=r.slice(e,c),a(l,u,e-1),d=Ar;else throw new Error("attribute value no end '"+f+"' match");else if(d==kr)u=r.slice(e,c),a(l,u,e),i.warning('attribute "'+l+'" missed start quot('+f+")!!"),e=c+1,d=Ar;else throw new Error('attribute value must after "="');break;case"/":switch(d){case vr:t.setTagName(r.slice(e,c));case Ar:case bn:case Bs:d=Bs,t.closed=!0;case kr:case yt:break;case Er:t.closed=!0;break;default:throw new Error("attribute invalid close char('/')")}break;case"":return i.error("unexpected end of input"),d==vr&&t.setTagName(r.slice(e,c)),c;case">":switch(d){case vr:t.setTagName(r.slice(e,c));case Ar:case bn:case Bs:break;case kr:case yt:u=r.slice(e,c),u.slice(-1)==="/"&&(t.closed=!0,u=u.slice(0,-1));case Er:d===Er&&(u=l),d==kr?(i.warning('attribute "'+u+'" missed quot(")!'),a(l,u,e)):(o||i.warning('attribute "'+u+'" missed value!! "'+u+'" instead!!'),a(u,u,e));break;case gn:if(!o)return i.fatalError(`AttValue: ' or " expected`)}return c;case"\x80":f=" ";default:if(f<=" ")switch(d){case vr:t.setTagName(r.slice(e,c)),d=bn;break;case yt:l=r.slice(e,c),d=Er;break;case kr:var u=r.slice(e,c);i.warning('attribute "'+u+'" missed quot(")!!'),a(l,u,e);case Ar:d=bn;break}else switch(d){case Er:o||i.warning('attribute "'+l+'" missed value!! "'+l+'" instead2!!'),a(l,l,e),e=c,d=yt;break;case Ar:i.warning('attribute space is required"'+l+'"!!');case bn:d=yt,e=c;break;case gn:d=kr,e=c;break;case Bs:throw new Error("elements closed character '/' and '>' must be connected to")}}c++}}function Il(r,e,t){for(var n=r.tagName,s=null,d=r.length;d--;){var i=r[d],o=i.qName,a=i.value,f=o.indexOf(":");if(f>0)var l=i.prefix=o.slice(0,f),u=o.slice(f+1),c=l==="xmlns"&&u;else u=o,l=null,c=o==="xmlns"&&"";i.localName=u,c!==!1&&(s==null&&(s=Object.create(null),t=Object.create(t)),t[c]=s[c]=a,i.uri=Cl.XMLNS,e.startPrefixMapping(c,a))}for(var d=r.length;d--;)i=r[d],i.prefix&&(i.prefix==="xml"&&(i.uri=Cl.XML),i.prefix!=="xmlns"&&(i.uri=t[i.prefix]));var f=n.indexOf(":");f>0?(l=r.prefix=n.slice(0,f),u=r.localName=n.slice(f+1)):(l=null,u=r.localName=n);var h=r.uri=t[l||""];if(e.startElement(h,u,n,r),r.closed){if(e.endElement(h,u,n),s)for(l in s)_n(s,l)&&e.endPrefixMapping(l)}else return r.currentNSMap=t,r.localNSMap=s,!0}function Mh(r,e,t,n,s){var i=Sh(t);if(i||Nh(t)){var o=new RegExp("</"+t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+">","ig");o.lastIndex=e;var a=o.exec(r),l=a?a.index:-1;if(l<0)return e+1;var u=r.substring(e+1,l);return i&&(u=u.replace(po,n)),s.characters(u,0,u.length),l}return e+1}function $h(r,e){for(var t in r)_n(r,t)&&(e[t]=r[t])}function Rl(r,e){var t=e;function n(c){return c=c||0,r.charAt(t+c)}function s(c){c=c||1,t+=c}function i(){for(var c=0;t<r.length;){var d=n();if(d!==" "&&d!==`
11
+ `&&d!==" "&&d!=="\r")return c;c++,s()}return-1}function o(){return r.substring(t)}function a(c){return r.substring(t,t+c.length)===c}function l(c){return r.substring(t,t+c.length).toUpperCase()===c.toUpperCase()}function u(c){var d=R.reg("^",c),f=d.exec(o());return f?(s(f[0].length),f[0]):null}return{char:n,getIndex:function(){return t},getMatch:u,getSource:function(){return r},skip:s,skipBlanks:i,substringFromIndex:o,substringStartsWith:a,substringStartsWithCaseInsensitive:l}}function Lh(r,e){function t(a,l){var u=R.PI.exec(a.substringFromIndex());return u?u[1].toLowerCase()==="xml"?l.fatalError("xml declaration is only allowed at the start of the document, but found at position "+a.getIndex()):(a.skip(u[0].length),u[0]):l.fatalError("processing instruction is not well-formed at position "+a.getIndex())}var n=r.getSource();if(r.char()==="["){r.skip(1);for(var s=r.getIndex();r.getIndex()<n.length;){if(r.skipBlanks(),r.char()==="]"){var i=n.substring(s,r.getIndex());return r.skip(1),i}var o=null;if(r.char()==="<"&&r.char(1)==="!")switch(r.char(2)){case"E":r.char(3)==="L"?o=r.getMatch(R.elementdecl):r.char(3)==="N"&&(o=r.getMatch(R.EntityDecl));break;case"A":o=r.getMatch(R.AttlistDecl);break;case"N":o=r.getMatch(R.NotationDecl);break;case"-":o=r.getMatch(R.Comment);break}else if(r.char()==="<"&&r.char(1)==="?")o=t(r,e);else if(r.char()==="%")o=r.getMatch(R.PEReference);else return e.fatalError("Error detected in Markup declaration");if(!o)return e.fatalError("Error in internal subset at position "+r.getIndex())}return e.fatalError("doctype internal subset is not well-formed, missing ]")}}function Ml(r,e,t,n,s){var i=Rl(r,e);switch(s?i.char(2).toUpperCase():i.char(2)){case"-":var o=i.getMatch(R.Comment);return o?(t.comment(o,R.COMMENT_START.length,o.length-R.COMMENT_START.length-R.COMMENT_END.length),i.getIndex()):n.fatalError("comment is not well-formed at position "+i.getIndex());case"[":var a=i.getMatch(R.CDSect);return a?!s&&!t.currentElement?n.fatalError("CDATA outside of element"):(t.startCDATA(),t.characters(a,R.CDATA_START.length,a.length-R.CDATA_START.length-R.CDATA_END.length),t.endCDATA(),i.getIndex()):n.fatalError("Invalid CDATA starting at position "+e);case"D":{if(t.doc&&t.doc.documentElement)return n.fatalError("Doctype not allowed inside or after documentElement at position "+i.getIndex());if(s?!i.substringStartsWithCaseInsensitive(R.DOCTYPE_DECL_START):!i.substringStartsWith(R.DOCTYPE_DECL_START))return n.fatalError("Expected "+R.DOCTYPE_DECL_START+" at position "+i.getIndex());if(i.skip(R.DOCTYPE_DECL_START.length),i.skipBlanks()<1)return n.fatalError("Expected whitespace after "+R.DOCTYPE_DECL_START+" at position "+i.getIndex());var l={name:void 0,publicId:void 0,systemId:void 0,internalSubset:void 0};if(l.name=i.getMatch(R.Name),!l.name)return n.fatalError("doctype name missing or contains unexpected characters at position "+i.getIndex());if(s&&l.name.toLowerCase()!=="html"&&n.warning("Unexpected DOCTYPE in HTML document at position "+i.getIndex()),i.skipBlanks(),i.substringStartsWith(R.PUBLIC)||i.substringStartsWith(R.SYSTEM)){var u=R.ExternalID_match.exec(i.substringFromIndex());if(!u)return n.fatalError("doctype external id is not well-formed at position "+i.getIndex());u.groups.SystemLiteralOnly!==void 0?l.systemId=u.groups.SystemLiteralOnly:(l.systemId=u.groups.SystemLiteral,l.publicId=u.groups.PubidLiteral),i.skip(u[0].length)}else if(s&&i.substringStartsWithCaseInsensitive(R.SYSTEM)){if(i.skip(R.SYSTEM.length),i.skipBlanks()<1)return n.fatalError("Expected whitespace after "+R.SYSTEM+" at position "+i.getIndex());if(l.systemId=i.getMatch(R.ABOUT_LEGACY_COMPAT_SystemLiteral),!l.systemId)return n.fatalError("Expected "+R.ABOUT_LEGACY_COMPAT+" in single or double quotes after "+R.SYSTEM+" at position "+i.getIndex())}return s&&l.systemId&&!R.ABOUT_LEGACY_COMPAT_SystemLiteral.test(l.systemId)&&n.warning("Unexpected doctype.systemId in HTML document at position "+i.getIndex()),s||(i.skipBlanks(),l.internalSubset=Lh(i,n)),i.skipBlanks(),i.char()!==">"?n.fatalError("doctype not terminated with > at position "+i.getIndex()):(i.skip(1),t.startDTD(l.name,l.publicId,l.systemId,l.internalSubset),t.endDTD(),i.getIndex())}default:return n.fatalError('Not well-formed XML starting with "<!" at position '+e)}}function Ph(r,e,t,n){var s=r.substring(e).match(R.PI);if(!s)return n.fatalError("Invalid processing instruction starting at position "+e);if(s[1].toLowerCase()==="xml"){if(e>0)return n.fatalError("processing instruction at position "+e+" is an xml declaration which is only at the start of the document");if(!R.XMLDecl.test(r.substring(e)))return n.fatalError("xml declaration is not well-formed")}return t.processingInstruction(s[1],s[2]),e+s[0].length}function $l(){this.attributeNames=Object.create(null)}$l.prototype={setTagName:function(r){if(!R.QName_exact.test(r))throw new Error("invalid tagName:"+r);this.tagName=r},addValue:function(r,e,t){if(!R.QName_exact.test(r))throw new Error("invalid attribute:"+r);this.attributeNames[r]=this.length,this[this.length++]={qName:r,value:e,offset:t}},length:0,getLocalName:function(r){return this[r].localName},getLocator:function(r){return this[r].locator},getQName:function(r){return this[r].qName},getURI:function(r){return this[r].uri},getValue:function(r){return this[r].value}};Rs.XMLReader=Bl;Rs.parseUtils=Rl;Rs.parseDoctypeCommentOrCData=Ml});var Hl=lt(Dr=>{"use strict";var Pt=$t(),Fh=ho(),jh=on(),Pl=Sl(),Uh=Ll(),qh=Fh.DOMImplementation,Vh=Pt.hasDefaultHTMLNamespace,Hh=Pt.isHTMLMimeType,zh=Pt.isValidMimeType,Ul=Pt.MIME_TYPE,mo=Pt.NAMESPACE,Fl=jh.ParseError,Wh=Uh.XMLReader;function ql(r){return r.replace(/\r[\n\u0085]/g,`
12
12
  `).replace(/[\r\u0085\u2028\u2029]/g,`
13
- `)}function Bl(r){if(r=r||{},r.locator===void 0&&(r.locator=!0),this.assign=r.assign||Lt.assign,this.domHandler=r.domHandler||Ns,this.onError=r.onError||r.errorHandler,r.errorHandler&&typeof r.errorHandler!="function")throw new TypeError("errorHandler object is no longer supported, switch to onError!");r.errorHandler&&r.errorHandler("warning","The `errorHandler` option has been deprecated, use `onError` instead!",this),this.normalizeLineEndings=r.normalizeLineEndings||Il,this.locator=!!r.locator,this.xmlns=this.assign(Object.create(null),r.xmlns)}Bl.prototype.parseFromString=function(r,e){if(!Rh(e))throw new TypeError('DOMParser.parseFromString: the provided mimeType "'+e+'" is not valid.');var t=this.assign(Object.create(null),this.xmlns),n=Sl.XML_ENTITIES,s=t[""]||null;Ih(e)?(n=Sl.HTML_ENTITIES,s=sa.HTML):e===Ol.XML_SVG_IMAGE&&(s=sa.SVG),t[""]=s,t.xml=t.xml||sa.XML;var i=new this.domHandler({mimeType:e,defaultNamespace:s,onError:this.onError}),a=this.locator?{}:void 0;this.locator&&i.setDocumentLocator(a);var o=new Mh;o.errorHandler=i,o.domBuilder=i;var l=!Lt.isHTMLMimeType(e);return l&&typeof r!="string"&&o.errorHandler.fatalError("source is not a string"),o.parse(this.normalizeLineEndings(String(r)),t,n),i.doc.documentElement||o.errorHandler.fatalError("missing root element"),i.doc};function Ns(r){var e=r||{};this.mimeType=e.mimeType||Ol.XML_APPLICATION,this.defaultNamespace=e.defaultNamespace||null,this.cdata=!1,this.currentElement=void 0,this.doc=void 0,this.locator=void 0,this.onError=e.onError}function kr(r,e){e.lineNumber=r.lineNumber,e.columnNumber=r.columnNumber}Ns.prototype={startDocument:function(){var r=new Oh;this.doc=Bh(this.mimeType)?r.createHTMLDocument(!1):r.createDocument(this.defaultNamespace,"")},startElement:function(r,e,t,n){var s=this.doc,i=s.createElementNS(r,t||e),a=n.length;Cs(this,i),this.currentElement=i,this.locator&&kr(this.locator,i);for(var o=0;o<a;o++){var r=n.getURI(o),l=n.getValue(o),t=n.getQName(o),u=s.createAttributeNS(r,t);this.locator&&kr(n.getLocator(o),u),u.value=u.nodeValue=l,i.setAttributeNode(u)}},endElement:function(r,e,t){this.currentElement=this.currentElement.parentNode},startPrefixMapping:function(r,e){},endPrefixMapping:function(r){},processingInstruction:function(r,e){var t=this.doc.createProcessingInstruction(r,e);this.locator&&kr(this.locator,t),Cs(this,t)},ignorableWhitespace:function(r,e,t){},characters:function(r,e,t){if(r=Nl.apply(this,arguments),r){if(this.cdata)var n=this.doc.createCDATASection(r);else var n=this.doc.createTextNode(r);this.currentElement?this.currentElement.appendChild(n):/^\s*$/.test(r)&&this.doc.appendChild(n),this.locator&&kr(this.locator,n)}},skippedEntity:function(r){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(r){r&&(r.lineNumber=0),this.locator=r},comment:function(r,e,t){r=Nl.apply(this,arguments);var n=this.doc.createComment(r);this.locator&&kr(this.locator,n),Cs(this,n)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(r,e,t,n){var s=this.doc.implementation;if(s&&s.createDocumentType){var i=s.createDocumentType(r,e,t,n);this.locator&&kr(this.locator,i),Cs(this,i),this.doc.doctype=i}},reportError:function(r,e){if(typeof this.onError=="function")try{this.onError(r,e,this)}catch(t){throw new Cl("Reporting "+r+' "'+e+'" caused '+t,this.locator)}else console.error("[xmldom "+r+"] "+e,$h(this.locator))},warning:function(r){this.reportError("warning",r)},error:function(r){this.reportError("error",r)},fatalError:function(r,e){throw this.reportError("fatalError",r),new Cl(r,this.locator,e)}};function $h(r){if(r)return`
14
- @#[line:`+r.lineNumber+",col:"+r.columnNumber+"]"}function Nl(r,e,t){return typeof r=="string"?r.substr(e,t):r.length>=e+t||e?new java.lang.String(r,e,t)+"":r}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(r){Ns.prototype[r]=function(){return null}});function Cs(r,e){r.currentElement?r.currentElement.appendChild(e):r.doc.appendChild(e)}function Lh(r){if(r==="error")throw"onErrorStopParsing"}function Ph(){throw"onWarningStopParsing"}Ar.__DOMHandler=Ns;Ar.DOMParser=Bl;Ar.normalizeLineEndings=Il;Ar.onErrorStopParsing=Lh;Ar.onWarningStopParsing=Ph});var ia=at(j=>{"use strict";var Tr=Mt();j.assign=Tr.assign;j.hasDefaultHTMLNamespace=Tr.hasDefaultHTMLNamespace;j.isHTMLMimeType=Tr.isHTMLMimeType;j.isValidMimeType=Tr.isValidMimeType;j.MIME_TYPE=Tr.MIME_TYPE;j.NAMESPACE=Tr.NAMESPACE;var Os=rn();j.DOMException=Os.DOMException;j.DOMExceptionName=Os.DOMExceptionName;j.ExceptionCode=Os.ExceptionCode;j.ParseError=Os.ParseError;var oe=ra();j.Attr=oe.Attr;j.CDATASection=oe.CDATASection;j.CharacterData=oe.CharacterData;j.Comment=oe.Comment;j.Document=oe.Document;j.DocumentFragment=oe.DocumentFragment;j.DocumentType=oe.DocumentType;j.DOMImplementation=oe.DOMImplementation;j.Element=oe.Element;j.Entity=oe.Entity;j.EntityReference=oe.EntityReference;j.LiveNodeList=oe.LiveNodeList;j.NamedNodeMap=oe.NamedNodeMap;j.Node=oe.Node;j.NodeList=oe.NodeList;j.Notation=oe.Notation;j.ProcessingInstruction=oe.ProcessingInstruction;j.Text=oe.Text;j.XMLSerializer=oe.XMLSerializer;var Is=Rl();j.DOMParser=Is.DOMParser;j.normalizeLineEndings=Is.normalizeLineEndings;j.onErrorStopParsing=Is.onErrorStopParsing;j.onWarningStopParsing=Is.onWarningStopParsing});var jr=class{constructor(e,{fetcher:t=globalThis.fetch?.bind(globalThis),closeUrl:n="/gramlot/close",navigator:s=globalThis.navigator,XMLHttpRequest:i=globalThis.XMLHttpRequest}={}){this.rpcUrl=e,this.fetcher=t,this.closeUrl=n,this.navigator=s,this.XMLHttpRequest=i}get supportsCallSync(){return!0}async call(e,t){let n=await this.fetcher(this.rpcUrl,{method:"POST",credentials:"same-origin",signal:t,headers:{"Content-Type":"application/json"},body:e});if(n.status!==200)throw new Error(`rpc failed: HTTP ${n.status}`);return n.text()}callSync(e){let t=new this.XMLHttpRequest;if(t.open("POST",this.rpcUrl,!1),t.setRequestHeader("Content-Type","application/json"),t.send(e),t.status!==200)throw new Error(`rpc failed: HTTP ${t.status}`);return t.responseText}close(e,{beacon:t=!1}={}){let n=JSON.stringify({pageId:e});t?this.navigator.sendBeacon(this.closeUrl,new Blob([n],{type:"application/json"})):this.fetcher(this.closeUrl,{method:"POST",credentials:"same-origin",keepalive:!0,headers:{"Content-Type":"application/json"},body:n})}dispose(){}};var ot=class{createTransport({rpcUrl:e,closeUrl:t,document:n}){let s=n.defaultView;return new jr(e,{closeUrl:t,navigator:s.navigator,XMLHttpRequest:s.XMLHttpRequest})}};function V(r){if(typeof r!="string"||!["^","="].includes(r[0])||r.startsWith("=="))return null;let e=r.indexOf(":");if(e<0)return null;let t=r[e+1]==="=";return{pointer:r.slice(0,e),expression:t,body:r.slice(e+(t?2:1))}}var Za=/^\{(\??[A-Za-z_][A-Za-z0-9_]*|\?)?\}/;function Ur(r,e){let t="",n=!1;for(let s=0;s<r.length;){if(r[s]!=="{"&&r[s]!=="}"){t+=r[s++];continue}let i=r.slice(s).match(Za);if(!i)throw new SyntaxError("Invalid pointer template placeholder");let a=i[1]??"",o=a.startsWith("?"),l=e(o?a.slice(1):a);l==null||l===""&&!o?n=!0:t+=String(l),s+=i[0].length}return n?null:t}function qr(r){let e=[],t=new Set,n="",s=!0;for(let i=0;i<r.length;){let a=i,o=r[i];if(o==='"'||o==="'"||o==="`"){for(i++;i<r.length;){if(r[i]==="\\"){i+=2;continue}if(r[i++]===o)break}n+=r.slice(a,i),s=!1;continue}if(r.startsWith("//",i)){i=r.indexOf(`
15
- `,i),i<0&&(i=r.length),n+=r.slice(a,i);continue}if(r.startsWith("/*",i)){let c=r.indexOf("*/",i+2);i=c<0?r.length:c+2,n+=r.slice(a,i);continue}if(o==="/"&&s){let c=!1;for(i++;i<r.length;){let d=r[i++];if(d==="\\"){i++;continue}if(d==="[")c=!0;else if(d==="]")c=!1;else if(d==="/"&&!c)break}for(;/[a-z]/i.test(r[i]??"")&&i<r.length;)i++;n+=r.slice(a,i),s=!1;continue}let l=o==="{"?r.slice(i).match(Za):null;if(l){let c=l[1]??"";if(c.startsWith("?"))throw new SyntaxError("Optional slots are supported in pointer templates only");n+=`_pointerValues[${e.length}]`,e.push(c),i+=l[0].length,s=!1;continue}let u=r.slice(i).match(/^[A-Za-z_$][\w$]*/);if(u){t.add(u[0]),n+=u[0],i+=u[0].length,s=["return","typeof","void","delete","new","in","instanceof","yield","await"].includes(u[0]);continue}n+=o,i++,/\s/.test(o)||(s=/[([{,:;=!?&|+*%~<>\/-]/.test(o))}return{text:n,slots:e,identifiers:t}}function Ja(r,e,t=()=>null){let n=new Map,s=[],i=a=>{if(n.has(a))return n.get(a);if(!r.has(a))throw new Error(`Referenced Source attribute '${a}' does not exist`);if(s.includes(a))throw new Error(`Cyclic attribute dependency: ${[...s,a].join(" -> ")}`);s.push(a);try{let o=r.get(a),l=typeof a=="string"?V(o):null,u=e.get(a);if(l){let c=d=>d?i(d):e.get(a);if(l.expression){let d=qr(l.body);u=t(a,o,d,d.slots.map(c))}else u=Ur(l.body,c),e.get(a)==null&&(u=null)}return n.set(a,u),u}finally{s.pop()}};return new Map([...r.keys()].map(a=>[a,i(a)]))}function Ve(r,e){let t=new Map([...Object.entries(r.getAttr()),...r.fixedAttrItems()]),n=new Set,s=[],i=a=>{let o=V(a);if(!o)return;let l=[];o.expression?l.push(...qr(o.body).slots):Ur(o.body,u=>(l.push(u),""));for(let u of l.filter(Boolean)){if(!t.has(u))throw new Error(`Referenced Source attribute '${u}' does not exist`);if(s.includes(u))throw new Error(`Cyclic attribute dependency: ${[...s,u].join(" -> ")}`);n.has(u)||(s.push(u),i(t.get(u)),s.pop(),n.add(u))}};return i(e),n}var ir=9e15,dt=1e9,Ei="0123456789abcdef",rs="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ns="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",ki={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ir,maxE:ir,crypto:!1},to,Qe,O=!0,is="[DecimalError] ",ct=is+"Invalid argument: ",ro=is+"Precision limit exceeded",no=is+"crypto unavailable",so="[object Decimal]",he=Math.floor,ie=Math.pow,bc=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,wc=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,yc=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,io=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Me=1e7,S=7,vc=9007199254740991,Ec=rs.length-1,Ai=ns.length-1,b={toStringTag:so};b.absoluteValue=b.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),D(r)};b.ceil=function(){return D(new this.constructor(this),this.e+1,2)};b.clampedTo=b.clamp=function(r,e){var t,n=this,s=n.constructor;if(r=new s(r),e=new s(e),!r.s||!e.s)return new s(NaN);if(r.gt(e))throw Error(ct+e);return t=n.cmp(r),t<0?r:n.cmp(e)>0?e:new s(n)};b.comparedTo=b.cmp=function(r){var e,t,n,s,i=this,a=i.d,o=(r=new i.constructor(r)).d,l=i.s,u=r.s;if(!a||!o)return!l||!u?NaN:l!==u?l:a===o?0:!a^l<0?1:-1;if(!a[0]||!o[0])return a[0]?l:o[0]?-u:0;if(l!==u)return l;if(i.e!==r.e)return i.e>r.e^l<0?1:-1;for(n=a.length,s=o.length,e=0,t=n<s?n:s;e<t;++e)if(a[e]!==o[e])return a[e]>o[e]^l<0?1:-1;return n===s?0:n>s^l<0?1:-1};b.cosine=b.cos=function(){var r,e,t=this,n=t.constructor;return t.d?t.d[0]?(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+S,n.rounding=1,t=kc(n,co(n,t)),n.precision=r,n.rounding=e,D(Qe==2||Qe==3?t.neg():t,r,e,!0)):new n(1):new n(NaN)};b.cubeRoot=b.cbrt=function(){var r,e,t,n,s,i,a,o,l,u,c=this,d=c.constructor;if(!c.isFinite()||c.isZero())return new d(c);for(O=!1,i=c.s*ie(c.s*c,1/3),!i||Math.abs(i)==1/0?(t=ue(c.d),r=c.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=ie(t,1/3),r=he((r+1)/3)-(r%3==(r<0?-1:2)),i==1/0?t="5e"+r:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),n=new d(t),n.s=c.s):n=new d(i.toString()),a=(r=d.precision)+3;;)if(o=n,l=o.times(o).times(o),u=l.plus(c),n=X(u.plus(c).times(o),u.plus(l),a+2,1),ue(o.d).slice(0,a)===(t=ue(n.d)).slice(0,a))if(t=t.slice(a-3,a+1),t=="9999"||!s&&t=="4999"){if(!s&&(D(o,r+1,0),o.times(o).times(o).eq(c))){n=o;break}a+=4,s=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(D(n,r+1,1),e=!n.times(n).times(n).eq(c));break}return O=!0,D(n,r,d.rounding,e)};b.decimalPlaces=b.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-he(this.e/S))*S,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t};b.dividedBy=b.div=function(r){return X(this,new this.constructor(r))};b.dividedToIntegerBy=b.divToInt=function(r){var e=this,t=e.constructor;return D(X(e,new t(r),0,1,1),t.precision,t.rounding)};b.equals=b.eq=function(r){return this.cmp(r)===0};b.floor=function(){return D(new this.constructor(this),this.e+1,3)};b.greaterThan=b.gt=function(r){return this.cmp(r)>0};b.greaterThanOrEqualTo=b.gte=function(r){var e=this.cmp(r);return e==1||e===0};b.hyperbolicCosine=b.cosh=function(){var r,e,t,n,s,i=this,a=i.constructor,o=new a(1);if(!i.isFinite())return new a(i.s?1/0:NaN);if(i.isZero())return o;t=a.precision,n=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,s=i.d.length,s<32?(r=Math.ceil(s/3),e=(1/os(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=ar(a,1,i.times(e),new a(1),!0);for(var l,u=r,c=new a(8);u--;)l=i.times(i),i=o.minus(l.times(c.minus(l.times(c))));return D(i,a.precision=t,a.rounding=n,!0)};b.hyperbolicSine=b.sinh=function(){var r,e,t,n,s=this,i=s.constructor;if(!s.isFinite()||s.isZero())return new i(s);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(s.e,s.sd())+4,i.rounding=1,n=s.d.length,n<3)s=ar(i,2,s,s,!0);else{r=1.4*Math.sqrt(n),r=r>16?16:r|0,s=s.times(1/os(5,r)),s=ar(i,2,s,s,!0);for(var a,o=new i(5),l=new i(16),u=new i(20);r--;)a=s.times(s),s=s.times(o.plus(a.times(l.times(a).plus(u))))}return i.precision=e,i.rounding=t,D(s,e,t,!0)};b.hyperbolicTangent=b.tanh=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+7,n.rounding=1,X(t.sinh(),t.cosh(),n.precision=r,n.rounding=e)):new n(t.s)};b.inverseCosine=b.acos=function(){var r=this,e=r.constructor,t=r.abs().cmp(1),n=e.precision,s=e.rounding;return t!==-1?t===0?r.isNeg()?ze(e,n,s):new e(0):new e(NaN):r.isZero()?ze(e,n+4,s).times(.5):(e.precision=n+6,e.rounding=1,r=new e(1).minus(r).div(r.plus(1)).sqrt().atan(),e.precision=n,e.rounding=s,r.times(2))};b.inverseHyperbolicCosine=b.acosh=function(){var r,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(r=n.precision,e=n.rounding,n.precision=r+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,O=!1,t=t.times(t).minus(1).sqrt().plus(t),O=!0,n.precision=r,n.rounding=e,t.ln()):new n(t)};b.inverseHyperbolicSine=b.asinh=function(){var r,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,O=!1,t=t.times(t).plus(1).sqrt().plus(t),O=!0,n.precision=r,n.rounding=e,t.ln())};b.inverseHyperbolicTangent=b.atanh=function(){var r,e,t,n,s=this,i=s.constructor;return s.isFinite()?s.e>=0?new i(s.abs().eq(1)?s.s/0:s.isZero()?s:NaN):(r=i.precision,e=i.rounding,n=s.sd(),Math.max(n,r)<2*-s.e-1?D(new i(s),r,e,!0):(i.precision=t=n-s.e,s=X(s.plus(1),new i(1).minus(s),t+r,1),i.precision=r+4,i.rounding=1,s=s.ln(),i.precision=r,i.rounding=e,s.times(.5))):new i(NaN)};b.inverseSine=b.asin=function(){var r,e,t,n,s=this,i=s.constructor;return s.isZero()?new i(s):(e=s.abs().cmp(1),t=i.precision,n=i.rounding,e!==-1?e===0?(r=ze(i,t+4,n).times(.5),r.s=s.s,r):new i(NaN):(i.precision=t+6,i.rounding=1,s=s.div(new i(1).minus(s.times(s)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=n,s.times(2)))};b.inverseTangent=b.atan=function(){var r,e,t,n,s,i,a,o,l,u=this,c=u.constructor,d=c.precision,f=c.rounding;if(u.isFinite()){if(u.isZero())return new c(u);if(u.abs().eq(1)&&d+4<=Ai)return a=ze(c,d+4,f).times(.25),a.s=u.s,a}else{if(!u.s)return new c(NaN);if(d+4<=Ai)return a=ze(c,d+4,f).times(.5),a.s=u.s,a}for(c.precision=o=d+10,c.rounding=1,t=Math.min(28,o/S+2|0),r=t;r;--r)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(O=!1,e=Math.ceil(o/S),n=1,l=u.times(u),a=new c(u),s=u;r!==-1;)if(s=s.times(l),i=a.minus(s.div(n+=2)),s=s.times(l),a=i.plus(s.div(n+=2)),a.d[e]!==void 0)for(r=e;a.d[r]===i.d[r]&&r--;);return t&&(a=a.times(2<<t-1)),O=!0,D(a,c.precision=d,c.rounding=f,!0)};b.isFinite=function(){return!!this.d};b.isInteger=b.isInt=function(){return!!this.d&&he(this.e/S)>this.d.length-2};b.isNaN=function(){return!this.s};b.isNegative=b.isNeg=function(){return this.s<0};b.isPositive=b.isPos=function(){return this.s>0};b.isZero=function(){return!!this.d&&this.d[0]===0};b.lessThan=b.lt=function(r){return this.cmp(r)<0};b.lessThanOrEqualTo=b.lte=function(r){return this.cmp(r)<1};b.logarithm=b.log=function(r){var e,t,n,s,i,a,o,l,u=this,c=u.constructor,d=c.precision,f=c.rounding,h=5;if(r==null)r=new c(10),e=!0;else{if(r=new c(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new c(NaN);e=r.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new c(t&&!t[0]?-1/0:u.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)i=!0;else{for(s=t[0];s%10===0;)s/=10;i=s!==1}if(O=!1,o=d+h,a=ut(u,o),n=e?ss(c,o+10):ut(r,o),l=X(a,n,o,1),Vr(l.d,s=d,f))do if(o+=10,a=ut(u,o),n=e?ss(c,o+10):ut(r,o),l=X(a,n,o,1),!i){+ue(l.d).slice(s+1,s+15)+1==1e14&&(l=D(l,d+1,0));break}while(Vr(l.d,s+=10,f));return O=!0,D(l,d,f)};b.minus=b.sub=function(r){var e,t,n,s,i,a,o,l,u,c,d,f,h=this,p=h.constructor;if(r=new p(r),!h.d||!r.d)return!h.s||!r.s?r=new p(NaN):h.d?r.s=-r.s:r=new p(r.d||h.s!==r.s?h:NaN),r;if(h.s!=r.s)return r.s=-r.s,h.plus(r);if(u=h.d,f=r.d,o=p.precision,l=p.rounding,!u[0]||!f[0]){if(f[0])r.s=-r.s;else if(u[0])r=new p(h);else return new p(l===3?-0:0);return O?D(r,o,l):r}if(t=he(r.e/S),c=he(h.e/S),u=u.slice(),i=c-t,i){for(d=i<0,d?(e=u,i=-i,a=f.length):(e=f,t=c,a=u.length),n=Math.max(Math.ceil(o/S),a)+2,i>n&&(i=n,e.length=1),e.reverse(),n=i;n--;)e.push(0);e.reverse()}else{for(n=u.length,a=f.length,d=n<a,d&&(a=n),n=0;n<a;n++)if(u[n]!=f[n]){d=u[n]<f[n];break}i=0}for(d&&(e=u,u=f,f=e,r.s=-r.s),a=u.length,n=f.length-a;n>0;--n)u[a++]=0;for(n=f.length;n>i;){if(u[--n]<f[n]){for(s=n;s&&u[--s]===0;)u[s]=Me-1;--u[s],u[n]+=Me}u[n]-=f[n]}for(;u[--a]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(r.d=u,r.e=as(u,t),O?D(r,o,l):r):new p(l===3?-0:0)};b.modulo=b.mod=function(r){var e,t=this,n=t.constructor;return r=new n(r),!t.d||!r.s||r.d&&!r.d[0]?new n(NaN):!r.d||t.d&&!t.d[0]?D(new n(t),n.precision,n.rounding):(O=!1,n.modulo==9?(e=X(t,r.abs(),0,3,1),e.s*=r.s):e=X(t,r,0,n.modulo,1),e=e.times(r),O=!0,t.minus(e))};b.naturalExponential=b.exp=function(){return Ti(this)};b.naturalLogarithm=b.ln=function(){return ut(this)};b.negated=b.neg=function(){var r=new this.constructor(this);return r.s=-r.s,D(r)};b.plus=b.add=function(r){var e,t,n,s,i,a,o,l,u,c,d=this,f=d.constructor;if(r=new f(r),!d.d||!r.d)return!d.s||!r.s?r=new f(NaN):d.d||(r=new f(r.d||d.s===r.s?d:NaN)),r;if(d.s!=r.s)return r.s=-r.s,d.minus(r);if(u=d.d,c=r.d,o=f.precision,l=f.rounding,!u[0]||!c[0])return c[0]||(r=new f(d)),O?D(r,o,l):r;if(i=he(d.e/S),n=he(r.e/S),u=u.slice(),s=i-n,s){for(s<0?(t=u,s=-s,a=c.length):(t=c,n=i,a=u.length),i=Math.ceil(o/S),a=i>a?i+1:a+1,s>a&&(s=a,t.length=1),t.reverse();s--;)t.push(0);t.reverse()}for(a=u.length,s=c.length,a-s<0&&(s=a,t=c,c=u,u=t),e=0;s;)e=(u[--s]=u[s]+c[s]+e)/Me|0,u[s]%=Me;for(e&&(u.unshift(e),++n),a=u.length;u[--a]==0;)u.pop();return r.d=u,r.e=as(u,n),O?D(r,o,l):r};b.precision=b.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(ct+r);return t.d?(e=ao(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e};b.round=function(){var r=this,e=r.constructor;return D(new e(r),r.e+1,e.rounding)};b.sine=b.sin=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+S,n.rounding=1,t=Tc(n,co(n,t)),n.precision=r,n.rounding=e,D(Qe>2?t.neg():t,r,e,!0)):new n(NaN)};b.squareRoot=b.sqrt=function(){var r,e,t,n,s,i,a=this,o=a.d,l=a.e,u=a.s,c=a.constructor;if(u!==1||!o||!o[0])return new c(!u||u<0&&(!o||o[0])?NaN:o?a:1/0);for(O=!1,u=Math.sqrt(+a),u==0||u==1/0?(e=ue(o),(e.length+l)%2==0&&(e+="0"),u=Math.sqrt(e),l=he((l+1)/2)-(l<0||l%2),u==1/0?e="5e"+l:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+l),n=new c(e)):n=new c(u.toString()),t=(l=c.precision)+3;;)if(i=n,n=i.plus(X(a,i,t+2,1)).times(.5),ue(i.d).slice(0,t)===(e=ue(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!s&&e=="4999"){if(!s&&(D(i,l+1,0),i.times(i).eq(a))){n=i;break}t+=4,s=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(D(n,l+1,1),r=!n.times(n).eq(a));break}return O=!0,D(n,l,c.rounding,r)};b.tangent=b.tan=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+10,n.rounding=1,t=t.sin(),t.s=1,t=X(t,new n(1).minus(t.times(t)).sqrt(),r+10,0),n.precision=r,n.rounding=e,D(Qe==2||Qe==4?t.neg():t,r,e,!0)):new n(NaN)};b.times=b.mul=function(r){var e,t,n,s,i,a,o,l,u,c=this,d=c.constructor,f=c.d,h=(r=new d(r)).d;if(r.s*=c.s,!f||!f[0]||!h||!h[0])return new d(!r.s||f&&!f[0]&&!h||h&&!h[0]&&!f?NaN:!f||!h?r.s/0:r.s*0);for(t=he(c.e/S)+he(r.e/S),l=f.length,u=h.length,l<u&&(i=f,f=h,h=i,a=l,l=u,u=a),i=[],a=l+u,n=a;n--;)i.push(0);for(n=u;--n>=0;){for(e=0,s=l+n;s>n;)o=i[s]+h[n]*f[s-n-1]+e,i[s--]=o%Me|0,e=o/Me|0;i[s]=(i[s]+e)%Me|0}for(;!i[--a];)i.pop();return e?++t:i.shift(),r.d=i,r.e=as(i,t),O?D(r,d.precision,d.rounding):r};b.toBinary=function(r,e){return Di(this,2,r,e)};b.toDecimalPlaces=b.toDP=function(r,e){var t=this,n=t.constructor;return t=new n(t),r===void 0?t:(Ee(r,0,dt),e===void 0?e=n.rounding:Ee(e,0,8),D(t,r+t.e+1,e))};b.toExponential=function(r,e){var t,n=this,s=n.constructor;return r===void 0?t=He(n,!0):(Ee(r,0,dt),e===void 0?e=s.rounding:Ee(e,0,8),n=D(new s(n),r+1,e),t=He(n,!0,r+1)),n.isNeg()&&!n.isZero()?"-"+t:t};b.toFixed=function(r,e){var t,n,s=this,i=s.constructor;return r===void 0?t=He(s):(Ee(r,0,dt),e===void 0?e=i.rounding:Ee(e,0,8),n=D(new i(s),r+s.e+1,e),t=He(n,!1,r+n.e+1)),s.isNeg()&&!s.isZero()?"-"+t:t};b.toFraction=function(r){var e,t,n,s,i,a,o,l,u,c,d,f,h=this,p=h.d,m=h.constructor;if(!p)return new m(h);if(u=t=new m(1),n=l=new m(0),e=new m(n),i=e.e=ao(p)-h.e-1,a=i%S,e.d[0]=ie(10,a<0?S+a:a),r==null)r=i>0?e:u;else{if(o=new m(r),!o.isInt()||o.lt(u))throw Error(ct+o);r=o.gt(e)?i>0?e:u:o}for(O=!1,o=new m(ue(p)),c=m.precision,m.precision=i=p.length*S*2;d=X(o,e,0,1,1),s=t.plus(d.times(n)),s.cmp(r)!=1;)t=n,n=s,s=u,u=l.plus(d.times(s)),l=s,s=e,e=o.minus(d.times(s)),o=s;return s=X(r.minus(t),n,0,1,1),l=l.plus(s.times(u)),t=t.plus(s.times(n)),l.s=u.s=h.s,f=X(u,n,i,1).minus(h).abs().cmp(X(l,t,i,1).minus(h).abs())<1?[u,n]:[l,t],m.precision=c,O=!0,f};b.toHexadecimal=b.toHex=function(r,e){return Di(this,16,r,e)};b.toNearest=function(r,e){var t=this,n=t.constructor;if(t=new n(t),r==null){if(!t.d)return t;r=new n(1),e=n.rounding}else{if(r=new n(r),e===void 0?e=n.rounding:Ee(e,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(O=!1,t=X(t,r,0,e,1).times(r),O=!0,D(t)):(r.s=t.s,t=r),t};b.toNumber=function(){return+this};b.toOctal=function(r,e){return Di(this,8,r,e)};b.toPower=b.pow=function(r){var e,t,n,s,i,a,o=this,l=o.constructor,u=+(r=new l(r));if(!o.d||!r.d||!o.d[0]||!r.d[0])return new l(ie(+o,u));if(o=new l(o),o.eq(1))return o;if(n=l.precision,i=l.rounding,r.eq(1))return D(o,n,i);if(e=he(r.e/S),e>=r.d.length-1&&(t=u<0?-u:u)<=vc)return s=oo(l,o,t,n),r.s<0?new l(1).div(s):D(s,n,i);if(a=o.s,a<0){if(e<r.d.length-1)return new l(NaN);if((r.d[e]&1)==0&&(a=1),o.e==0&&o.d[0]==1&&o.d.length==1)return o.s=a,o}return t=ie(+o,u),e=t==0||!isFinite(t)?he(u*(Math.log("0."+ue(o.d))/Math.LN10+o.e+1)):new l(t+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?a/0:0):(O=!1,l.rounding=o.s=1,t=Math.min(12,(e+"").length),s=Ti(r.times(ut(o,n+t)),n),s.d&&(s=D(s,n+5,1),Vr(s.d,n,i)&&(e=n+10,s=D(Ti(r.times(ut(o,e+t)),e),e+5,1),+ue(s.d).slice(n+1,n+15)+1==1e14&&(s=D(s,n+1,0)))),s.s=a,O=!0,l.rounding=i,D(s,n,i))};b.toPrecision=function(r,e){var t,n=this,s=n.constructor;return r===void 0?t=He(n,n.e<=s.toExpNeg||n.e>=s.toExpPos):(Ee(r,1,dt),e===void 0?e=s.rounding:Ee(e,0,8),n=D(new s(n),r,e),t=He(n,r<=n.e||n.e<=s.toExpNeg,r)),n.isNeg()&&!n.isZero()?"-"+t:t};b.toSignificantDigits=b.toSD=function(r,e){var t=this,n=t.constructor;return r===void 0?(r=n.precision,e=n.rounding):(Ee(r,1,dt),e===void 0?e=n.rounding:Ee(e,0,8)),D(new n(t),r,e)};b.toString=function(){var r=this,e=r.constructor,t=He(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t};b.truncated=b.trunc=function(){return D(new this.constructor(this),this.e+1,1)};b.valueOf=b.toJSON=function(){var r=this,e=r.constructor,t=He(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function ue(r){var e,t,n,s=r.length-1,i="",a=r[0];if(s>0){for(i+=a,e=1;e<s;e++)n=r[e]+"",t=S-n.length,t&&(i+=lt(t)),i+=n;a=r[e],n=a+"",t=S-n.length,t&&(i+=lt(t))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}function Ee(r,e,t){if(r!==~~r||r<e||r>t)throw Error(ct+r)}function Vr(r,e,t,n){var s,i,a,o;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=S,s=0):(s=Math.ceil((e+1)/S),e%=S),i=ie(10,S-e),o=r[s]%i|0,n==null?e<3?(e==0?o=o/100|0:e==1&&(o=o/10|0),a=t<4&&o==99999||t>3&&o==49999||o==5e4||o==0):a=(t<4&&o+1==i||t>3&&o+1==i/2)&&(r[s+1]/i/100|0)==ie(10,e-2)-1||(o==i/2||o==0)&&(r[s+1]/i/100|0)==0:e<4?(e==0?o=o/1e3|0:e==1?o=o/100|0:e==2&&(o=o/10|0),a=(n||t<4)&&o==9999||!n&&t>3&&o==4999):a=((n||t<4)&&o+1==i||!n&&t>3&&o+1==i/2)&&(r[s+1]/i/1e3|0)==ie(10,e-3)-1,a}function es(r,e,t){for(var n,s=[0],i,a=0,o=r.length;a<o;){for(i=s.length;i--;)s[i]*=e;for(s[0]+=Ei.indexOf(r.charAt(a++)),n=0;n<s.length;n++)s[n]>t-1&&(s[n+1]===void 0&&(s[n+1]=0),s[n+1]+=s[n]/t|0,s[n]%=t)}return s.reverse()}function kc(r,e){var t,n,s;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),s=(1/os(4,t)).toString()):(t=16,s="2.3283064365386962890625e-10"),r.precision+=t,e=ar(r,1,e.times(s),new r(1));for(var i=t;i--;){var a=e.times(e);e=a.times(a).minus(a).times(8).plus(1)}return r.precision-=t,e}var X=(function(){function r(n,s,i){var a,o=0,l=n.length;for(n=n.slice();l--;)a=n[l]*s+o,n[l]=a%i|0,o=a/i|0;return o&&n.unshift(o),n}function e(n,s,i,a){var o,l;if(i!=a)l=i>a?1:-1;else for(o=l=0;o<i;o++)if(n[o]!=s[o]){l=n[o]>s[o]?1:-1;break}return l}function t(n,s,i,a){for(var o=0;i--;)n[i]-=o,o=n[i]<s[i]?1:0,n[i]=o*a+n[i]-s[i];for(;!n[0]&&n.length>1;)n.shift()}return function(n,s,i,a,o,l){var u,c,d,f,h,p,m,g,_,w,y,k,T,v,N,L,U,ve,Y,re,Ne=n.constructor,G=n.s==s.s?1:-1,ne=n.d,M=s.d;if(!ne||!ne[0]||!M||!M[0])return new Ne(!n.s||!s.s||(ne?M&&ne[0]==M[0]:!M)?NaN:ne&&ne[0]==0||!M?G*0:G/0);for(l?(h=1,c=n.e-s.e):(l=Me,h=S,c=he(n.e/h)-he(s.e/h)),Y=M.length,U=ne.length,_=new Ne(G),w=_.d=[],d=0;M[d]==(ne[d]||0);d++);if(M[d]>(ne[d]||0)&&c--,i==null?(v=i=Ne.precision,a=Ne.rounding):o?v=i+(n.e-s.e)+1:v=i,v<0)w.push(1),p=!0;else{if(v=v/h+2|0,d=0,Y==1){for(f=0,M=M[0],v++;(d<U||f)&&v--;d++)N=f*l+(ne[d]||0),w[d]=N/M|0,f=N%M|0;p=f||d<U}else{for(f=l/(M[0]+1)|0,f>1&&(M=r(M,f,l),ne=r(ne,f,l),Y=M.length,U=ne.length),L=Y,y=ne.slice(0,Y),k=y.length;k<Y;)y[k++]=0;re=M.slice(),re.unshift(0),ve=M[0],M[1]>=l/2&&++ve;do f=0,u=e(M,y,Y,k),u<0?(T=y[0],Y!=k&&(T=T*l+(y[1]||0)),f=T/ve|0,f>1?(f>=l&&(f=l-1),m=r(M,f,l),g=m.length,k=y.length,u=e(m,y,g,k),u==1&&(f--,t(m,Y<g?re:M,g,l))):(f==0&&(u=f=1),m=M.slice()),g=m.length,g<k&&m.unshift(0),t(y,m,k,l),u==-1&&(k=y.length,u=e(M,y,Y,k),u<1&&(f++,t(y,Y<k?re:M,k,l))),k=y.length):u===0&&(f++,y=[0]),w[d++]=f,u&&y[0]?y[k++]=ne[L]||0:(y=[ne[L]],k=1);while((L++<U||y[0]!==void 0)&&v--);p=y[0]!==void 0}w[0]||w.shift()}if(h==1)_.e=c,to=p;else{for(d=1,f=w[0];f>=10;f/=10)d++;_.e=d+c*h-1,D(_,o?i+_.e+1:i,a,p)}return _}})();function D(r,e,t,n){var s,i,a,o,l,u,c,d,f,h=r.constructor;e:if(e!=null){if(d=r.d,!d)return r;for(s=1,o=d[0];o>=10;o/=10)s++;if(i=e-s,i<0)i+=S,a=e,c=d[f=0],l=c/ie(10,s-a-1)%10|0;else if(f=Math.ceil((i+1)/S),o=d.length,f>=o)if(n){for(;o++<=f;)d.push(0);c=l=0,s=1,i%=S,a=i-S+1}else break e;else{for(c=o=d[f],s=1;o>=10;o/=10)s++;i%=S,a=i-S+s,l=a<0?0:c/ie(10,s-a-1)%10|0}if(n=n||e<0||d[f+1]!==void 0||(a<0?c:c%ie(10,s-a-1)),u=t<4?(l||n)&&(t==0||t==(r.s<0?3:2)):l>5||l==5&&(t==4||n||t==6&&(i>0?a>0?c/ie(10,s-a):0:d[f-1])%10&1||t==(r.s<0?8:7)),e<1||!d[0])return d.length=0,u?(e-=r.e+1,d[0]=ie(10,(S-e%S)%S),r.e=-e||0):d[0]=r.e=0,r;if(i==0?(d.length=f,o=1,f--):(d.length=f+1,o=ie(10,S-i),d[f]=a>0?(c/ie(10,s-a)%ie(10,a)|0)*o:0),u)for(;;)if(f==0){for(i=1,a=d[0];a>=10;a/=10)i++;for(a=d[0]+=o,o=1;a>=10;a/=10)o++;i!=o&&(r.e++,d[0]==Me&&(d[0]=1));break}else{if(d[f]+=o,d[f]!=Me)break;d[f--]=0,o=1}for(i=d.length;d[--i]===0;)d.pop()}return O&&(r.e>h.maxE?(r.d=null,r.e=NaN):r.e<h.minE&&(r.e=0,r.d=[0])),r}function He(r,e,t){if(!r.isFinite())return uo(r);var n,s=r.e,i=ue(r.d),a=i.length;return e?(t&&(n=t-a)>0?i=i.charAt(0)+"."+i.slice(1)+lt(n):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):s<0?(i="0."+lt(-s-1)+i,t&&(n=t-a)>0&&(i+=lt(n))):s>=a?(i+=lt(s+1-a),t&&(n=t-s-1)>0&&(i=i+"."+lt(n))):((n=s+1)<a&&(i=i.slice(0,n)+"."+i.slice(n)),t&&(n=t-a)>0&&(s+1===a&&(i+="."),i+=lt(n))),i}function as(r,e){var t=r[0];for(e*=S;t>=10;t/=10)e++;return e}function ss(r,e,t){if(e>Ec)throw O=!0,t&&(r.precision=t),Error(ro);return D(new r(rs),e,1,!0)}function ze(r,e,t){if(e>Ai)throw Error(ro);return D(new r(ns),e,t,!0)}function ao(r){var e=r.length-1,t=e*S+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}function lt(r){for(var e="";r--;)e+="0";return e}function oo(r,e,t,n){var s,i=new r(1),a=Math.ceil(n/S+4);for(O=!1;;){if(t%2&&(i=i.times(e),Qa(i.d,a)&&(s=!0)),t=he(t/2),t===0){t=i.d.length-1,s&&i.d[t]===0&&++i.d[t];break}e=e.times(e),Qa(e.d,a)}return O=!0,i}function Ka(r){return r.d[r.d.length-1]&1}function lo(r,e,t){for(var n,s,i=new r(e[0]),a=0;++a<e.length;){if(s=new r(e[a]),!s.s){i=s;break}n=i.cmp(s),(n===t||n===0&&i.s===t)&&(i=s)}return i}function Ti(r,e){var t,n,s,i,a,o,l,u=0,c=0,d=0,f=r.constructor,h=f.rounding,p=f.precision;if(!r.d||!r.d[0]||r.e>17)return new f(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:NaN);for(e==null?(O=!1,l=p):l=e,o=new f(.03125);r.e>-2;)r=r.times(o),d+=5;for(n=Math.log(ie(2,d))/Math.LN10*2+5|0,l+=n,t=i=a=new f(1),f.precision=l;;){if(i=D(i.times(r),l,1),t=t.times(++c),o=a.plus(X(i,t,l,1)),ue(o.d).slice(0,l)===ue(a.d).slice(0,l)){for(s=d;s--;)a=D(a.times(a),l,1);if(e==null)if(u<3&&Vr(a.d,l-n,h,u))f.precision=l+=10,t=i=o=new f(1),c=0,u++;else return D(a,f.precision=p,h,O=!0);else return f.precision=p,a}a=o}}function ut(r,e){var t,n,s,i,a,o,l,u,c,d,f,h=1,p=10,m=r,g=m.d,_=m.constructor,w=_.rounding,y=_.precision;if(m.s<0||!g||!g[0]||!m.e&&g[0]==1&&g.length==1)return new _(g&&!g[0]?-1/0:m.s!=1?NaN:g?0:m);if(e==null?(O=!1,c=y):c=e,_.precision=c+=p,t=ue(g),n=t.charAt(0),Math.abs(i=m.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)m=m.times(r),t=ue(m.d),n=t.charAt(0),h++;i=m.e,n>1?(m=new _("0."+t),i++):m=new _(n+"."+t.slice(1))}else return u=ss(_,c+2,y).times(i+""),m=ut(new _(n+"."+t.slice(1)),c-p).plus(u),_.precision=y,e==null?D(m,y,w,O=!0):m;for(d=m,l=a=m=X(m.minus(1),m.plus(1),c,1),f=D(m.times(m),c,1),s=3;;){if(a=D(a.times(f),c,1),u=l.plus(X(a,new _(s),c,1)),ue(u.d).slice(0,c)===ue(l.d).slice(0,c))if(l=l.times(2),i!==0&&(l=l.plus(ss(_,c+2,y).times(i+""))),l=X(l,new _(h),c,1),e==null)if(Vr(l.d,c-p,w,o))_.precision=c+=p,u=a=m=X(d.minus(1),d.plus(1),c,1),f=D(m.times(m),c,1),s=o=1;else return D(l,_.precision=y,w,O=!0);else return _.precision=y,l;l=u,s+=2}}function uo(r){return String(r.s*r.s/0)}function ts(r,e){var t,n,s;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),n=0;e.charCodeAt(n)===48;n++);for(s=e.length;e.charCodeAt(s-1)===48;--s);if(e=e.slice(n,s),e){if(s-=n,r.e=t=t-n-1,r.d=[],n=(t+1)%S,t<0&&(n+=S),n<s){for(n&&r.d.push(+e.slice(0,n)),s-=S;n<s;)r.d.push(+e.slice(n,n+=S));e=e.slice(n),n=S-e.length}else n-=s;for(;n--;)e+="0";r.d.push(+e),O&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function Ac(r,e){var t,n,s,i,a,o,l,u,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),io.test(e))return ts(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(wc.test(e))t=16,e=e.toLowerCase();else if(bc.test(e))t=2;else if(yc.test(e))t=8;else throw Error(ct+e);for(i=e.search(/p/i),i>0?(l=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),a=i>=0,n=r.constructor,a&&(e=e.replace(".",""),o=e.length,i=o-i,s=oo(n,new n(t),i,i*2)),u=es(e,t,Me),c=u.length-1,i=c;u[i]===0;--i)u.pop();return i<0?new n(r.s*0):(r.e=as(u,c),r.d=u,O=!1,a&&(r=X(r,s,o*4)),l&&(r=r.times(Math.abs(l)<54?ie(2,l):zr.pow(2,l))),O=!0,r)}function Tc(r,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:ar(r,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/os(5,t)),e=ar(r,2,e,e);for(var s,i=new r(5),a=new r(16),o=new r(20);t--;)s=e.times(e),e=e.times(i.plus(s.times(a.times(s).minus(o))));return e}function ar(r,e,t,n,s){var i,a,o,l,u=1,c=r.precision,d=Math.ceil(c/S);for(O=!1,l=t.times(t),o=new r(n);;){if(a=X(o.times(l),new r(e++*e++),c,1),o=s?n.plus(a):n.minus(a),n=X(a.times(l),new r(e++*e++),c,1),a=o.plus(n),a.d[d]!==void 0){for(i=d;a.d[i]===o.d[i]&&i--;);if(i==-1)break}i=o,o=n,n=a,a=i,u++}return O=!0,a.d.length=d+1,a}function os(r,e){for(var t=r;--e;)t*=r;return t}function co(r,e){var t,n=e.s<0,s=ze(r,r.precision,1),i=s.times(.5);if(e=e.abs(),e.lte(i))return Qe=n?4:1,e;if(t=e.divToInt(s),t.isZero())Qe=n?3:2;else{if(e=e.minus(t.times(s)),e.lte(i))return Qe=Ka(t)?n?2:3:n?4:1,e;Qe=Ka(t)?n?1:4:n?3:2}return e.minus(s).abs()}function Di(r,e,t,n){var s,i,a,o,l,u,c,d,f,h=r.constructor,p=t!==void 0;if(p?(Ee(t,1,dt),n===void 0?n=h.rounding:Ee(n,0,8)):(t=h.precision,n=h.rounding),!r.isFinite())c=uo(r);else{for(c=He(r),a=c.indexOf("."),p?(s=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):s=e,a>=0&&(c=c.replace(".",""),f=new h(1),f.e=c.length-a,f.d=es(He(f),10,s),f.e=f.d.length),d=es(c,10,s),i=l=d.length;d[--l]==0;)d.pop();if(!d[0])c=p?"0p+0":"0";else{if(a<0?i--:(r=new h(r),r.d=d,r.e=i,r=X(r,f,t,n,0,s),d=r.d,i=r.e,u=to),a=d[t],o=s/2,u=u||d[t+1]!==void 0,u=n<4?(a!==void 0||u)&&(n===0||n===(r.s<0?3:2)):a>o||a===o&&(n===4||u||n===6&&d[t-1]&1||n===(r.s<0?8:7)),d.length=t,u)for(;++d[--t]>s-1;)d[t]=0,t||(++i,d.unshift(1));for(l=d.length;!d[l-1];--l);for(a=0,c="";a<l;a++)c+=Ei.charAt(d[a]);if(p){if(l>1)if(e==16||e==8){for(a=e==16?4:3,--l;l%a;l++)c+="0";for(d=es(c,s,e),l=d.length;!d[l-1];--l);for(a=1,c="1.";a<l;a++)c+=Ei.charAt(d[a])}else c=c.charAt(0)+"."+c.slice(1);c=c+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)c="0"+c;c="0."+c}else if(++i>l)for(i-=l;i--;)c+="0";else i<l&&(c=c.slice(0,i)+"."+c.slice(i))}c=(e==16?"0x":e==2?"0b":e==8?"0o":"")+c}return r.s<0?"-"+c:c}function Qa(r,e){if(r.length>e)return r.length=e,!0}function Dc(r){return new this(r).abs()}function xc(r){return new this(r).acos()}function Sc(r){return new this(r).acosh()}function Cc(r,e){return new this(r).plus(e)}function Nc(r){return new this(r).asin()}function Oc(r){return new this(r).asinh()}function Ic(r){return new this(r).atan()}function Bc(r){return new this(r).atanh()}function Rc(r,e){r=new this(r),e=new this(e);var t,n=this.precision,s=this.rounding,i=n+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=ze(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?ze(this,n,s):new this(0),t.s=r.s):!r.d||e.isZero()?(t=ze(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(X(r,e,i,1)),e=ze(this,i,1),this.precision=n,this.rounding=s,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(X(r,e,i,1)),t}function Mc(r){return new this(r).cbrt()}function $c(r){return D(r=new this(r),r.e+1,2)}function Lc(r,e,t){return new this(r).clamp(e,t)}function Pc(r){if(!r||typeof r!="object")throw Error(is+"Object expected");var e,t,n,s=r.defaults===!0,i=["precision",1,dt,"rounding",0,8,"toExpNeg",-ir,0,"toExpPos",0,ir,"maxE",0,ir,"minE",-ir,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],s&&(this[t]=ki[t]),(n=r[t])!==void 0)if(he(n)===n&&n>=i[e+1]&&n<=i[e+2])this[t]=n;else throw Error(ct+t+": "+n);if(t="crypto",s&&(this[t]=ki[t]),(n=r[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(no);else this[t]=!1;else throw Error(ct+t+": "+n);return this}function Fc(r){return new this(r).cos()}function jc(r){return new this(r).cosh()}function fo(r){var e,t,n;function s(i){var a,o,l,u=this;if(!(u instanceof s))return new s(i);if(u.constructor=s,eo(i)){u.s=i.s,O?!i.d||i.e>s.maxE?(u.e=NaN,u.d=null):i.e<s.minE?(u.e=0,u.d=[0]):(u.e=i.e,u.d=i.d.slice()):(u.e=i.e,u.d=i.d?i.d.slice():i.d);return}if(l=typeof i,l==="number"){if(i===0){u.s=1/i<0?-1:1,u.e=0,u.d=[0];return}if(i<0?(i=-i,u.s=-1):u.s=1,i===~~i&&i<1e7){for(a=0,o=i;o>=10;o/=10)a++;O?a>s.maxE?(u.e=NaN,u.d=null):a<s.minE?(u.e=0,u.d=[0]):(u.e=a,u.d=[i]):(u.e=a,u.d=[i]);return}if(i*0!==0){i||(u.s=NaN),u.e=NaN,u.d=null;return}return ts(u,i.toString())}if(l==="string")return(o=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(o===43&&(i=i.slice(1)),u.s=1),io.test(i)?ts(u,i):Ac(u,i);if(l==="bigint")return i<0?(i=-i,u.s=-1):u.s=1,ts(u,i.toString());throw Error(ct+i)}if(s.prototype=b,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=Pc,s.clone=fo,s.isDecimal=eo,s.abs=Dc,s.acos=xc,s.acosh=Sc,s.add=Cc,s.asin=Nc,s.asinh=Oc,s.atan=Ic,s.atanh=Bc,s.atan2=Rc,s.cbrt=Mc,s.ceil=$c,s.clamp=Lc,s.cos=Fc,s.cosh=jc,s.div=Uc,s.exp=qc,s.floor=Vc,s.hypot=zc,s.ln=Hc,s.log=Wc,s.log10=Xc,s.log2=Gc,s.max=Yc,s.min=Zc,s.mod=Jc,s.mul=Kc,s.pow=Qc,s.random=ed,s.round=td,s.sign=rd,s.sin=nd,s.sinh=sd,s.sqrt=id,s.sub=ad,s.sum=od,s.tan=ld,s.tanh=ud,s.trunc=cd,r===void 0&&(r={}),r&&r.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)r.hasOwnProperty(t=n[e++])||(r[t]=this[t]);return s.config(r),s}function Uc(r,e){return new this(r).div(e)}function qc(r){return new this(r).exp()}function Vc(r){return D(r=new this(r),r.e+1,3)}function zc(){var r,e,t=new this(0);for(O=!1,r=0;r<arguments.length;)if(e=new this(arguments[r++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return O=!0,new this(1/0);t=e}return O=!0,t.sqrt()}function eo(r){return r instanceof zr||r&&r.toStringTag===so||!1}function Hc(r){return new this(r).ln()}function Wc(r,e){return new this(r).log(e)}function Gc(r){return new this(r).log(2)}function Xc(r){return new this(r).log(10)}function Yc(){return lo(this,arguments,-1)}function Zc(){return lo(this,arguments,1)}function Jc(r,e){return new this(r).mod(e)}function Kc(r,e){return new this(r).mul(e)}function Qc(r,e){return new this(r).pow(e)}function ed(r){var e,t,n,s,i=0,a=new this(1),o=[];if(r===void 0?r=this.precision:Ee(r,1,dt),n=Math.ceil(r/S),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));i<n;)s=e[i],s>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:o[i++]=s%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);i<n;)s=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),s>=214e7?crypto.randomBytes(4).copy(e,i):(o.push(s%1e7),i+=4);i=n/4}else throw Error(no);else for(;i<n;)o[i++]=Math.random()*1e7|0;for(n=o[--i],r%=S,n&&r&&(s=ie(10,S-r),o[i]=(n/s|0)*s);o[i]===0;i--)o.pop();if(i<0)t=0,o=[0];else{for(t=-1;o[0]===0;t-=S)o.shift();for(n=1,s=o[0];s>=10;s/=10)n++;n<S&&(t-=S-n)}return a.e=t,a.d=o,a}function td(r){return D(r=new this(r),r.e+1,this.rounding)}function rd(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function nd(r){return new this(r).sin()}function sd(r){return new this(r).sinh()}function id(r){return new this(r).sqrt()}function ad(r,e){return new this(r).sub(e)}function od(){var r=0,e=arguments,t=new this(e[r]);for(O=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return O=!0,D(t,this.precision,this.rounding)}function ld(r){return new this(r).tan()}function ud(r){return new this(r).tanh()}function cd(r){return D(r=new this(r),r.e+1,1)}b[Symbol.for("nodejs.util.inspect.custom")]=b.toString;b[Symbol.toStringTag]="Decimal";var zr=b.constructor=fo(ki);rs=new zr(rs);ns=new zr(ns);var ho=zr;var dd=20,fd=1,Nt=1e6,po=1e6,hd=-7,pd=21,md=!1,Hr="[big.js] ",Ot=Hr+"Invalid ",ls=Ot+"decimal places",gd=Ot+"rounding mode",mo=Hr+"Division by zero",z={},We=void 0,_d=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function go(){function r(e){var t=this;if(!(t instanceof r))return e===We?go():new r(e);if(e instanceof r)t.s=e.s,t.e=e.e,t.c=e.c.slice();else{if(typeof e!="string"){if(r.strict===!0&&typeof e!="bigint")throw TypeError(Ot+"value");e=e===0&&1/e<0?"-0":String(e)}bd(t,e)}t.constructor=r}return r.prototype=z,r.DP=dd,r.RM=fd,r.NE=hd,r.PE=pd,r.strict=md,r.roundDown=0,r.roundHalfUp=1,r.roundHalfEven=2,r.roundUp=3,r}function bd(r,e){var t,n,s;if(!_d.test(e))throw Error(Ot+"number");for(r.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),s=e.length,n=0;n<s&&e.charAt(n)=="0";)++n;if(n==s)r.c=[r.e=0];else{for(;s>0&&e.charAt(--s)=="0";);for(r.e=t-n-1,r.c=[],t=0;n<=s;)r.c[t++]=+e.charAt(n++)}return r}function It(r,e,t,n){var s=r.c;if(t===We&&(t=r.constructor.RM),t!==0&&t!==1&&t!==2&&t!==3)throw Error(gd);if(e<1)n=t===3&&(n||!!s[0])||e===0&&(t===1&&s[0]>=5||t===2&&(s[0]>5||s[0]===5&&(n||s[1]!==We))),s.length=1,n?(r.e=r.e-e+1,s[0]=1):s[0]=r.e=0;else if(e<s.length){if(n=t===1&&s[e]>=5||t===2&&(s[e]>5||s[e]===5&&(n||s[e+1]!==We||s[e-1]&1))||t===3&&(n||!!s[0]),s.length=e,n){for(;++s[--e]>9;)if(s[e]=0,e===0){++r.e,s.unshift(1);break}}for(e=s.length;!s[--e];)s.pop()}return r}function Bt(r,e,t){var n=r.e,s=r.c.join(""),i=s.length;if(e)s=s.charAt(0)+(i>1?"."+s.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)s="0"+s;s="0."+s}else if(n>0)if(++n>i)for(n-=i;n--;)s+="0";else n<i&&(s=s.slice(0,n)+"."+s.slice(n));else i>1&&(s=s.charAt(0)+"."+s.slice(1));return r.s<0&&t?"-"+s:s}z.abs=function(){var r=new this.constructor(this);return r.s=1,r};z.cmp=function(r){var e,t=this,n=t.c,s=(r=new t.constructor(r)).c,i=t.s,a=r.s,o=t.e,l=r.e;if(!n[0]||!s[0])return n[0]?i:s[0]?-a:0;if(i!=a)return i;if(e=i<0,o!=l)return o>l^e?1:-1;for(a=(o=n.length)<(l=s.length)?o:l,i=-1;++i<a;)if(n[i]!=s[i])return n[i]>s[i]^e?1:-1;return o==l?0:o>l^e?1:-1};z.div=function(r){var e=this,t=e.constructor,n=e.c,s=(r=new t(r)).c,i=e.s==r.s?1:-1,a=t.DP;if(a!==~~a||a<0||a>Nt)throw Error(ls);if(!s[0])throw Error(mo);if(!n[0])return r.s=i,r.c=[r.e=0],r;var o,l,u,c,d,f=s.slice(),h=o=s.length,p=n.length,m=n.slice(0,o),g=m.length,_=r,w=_.c=[],y=0,k=a+(_.e=e.e-r.e)+1;for(_.s=i,i=k<0?0:k,f.unshift(0);g++<o;)m.push(0);do{for(u=0;u<10;u++){if(o!=(g=m.length))c=o>g?1:-1;else for(d=-1,c=0;++d<o;)if(s[d]!=m[d]){c=s[d]>m[d]?1:-1;break}if(c<0){for(l=g==o?s:f;g;){if(m[--g]<l[g]){for(d=g;d&&!m[--d];)m[d]=9;--m[d],m[g]+=10}m[g]-=l[g]}for(;!m[0];)m.shift()}else break}w[y++]=c?u:++u,m[0]&&c?m[g]=n[h]||0:m=[n[h]]}while((h++<p||m[0]!==We)&&i--);return!w[0]&&y!=1&&(w.shift(),_.e--,k--),y>k&&It(_,k,t.RM,m[0]!==We),_};z.eq=function(r){return this.cmp(r)===0};z.gt=function(r){return this.cmp(r)>0};z.gte=function(r){return this.cmp(r)>-1};z.lt=function(r){return this.cmp(r)<0};z.lte=function(r){return this.cmp(r)<1};z.minus=z.sub=function(r){var e,t,n,s,i=this,a=i.constructor,o=i.s,l=(r=new a(r)).s;if(o!=l)return r.s=-l,i.plus(r);var u=i.c.slice(),c=i.e,d=r.c,f=r.e;if(!u[0]||!d[0])return d[0]?r.s=-l:u[0]?r=new a(i):r.s=1,r;if(o=c-f){for((s=o<0)?(o=-o,n=u):(f=c,n=d),n.reverse(),l=o;l--;)n.push(0);n.reverse()}else for(t=((s=u.length<d.length)?u:d).length,o=l=0;l<t;l++)if(u[l]!=d[l]){s=u[l]<d[l];break}if(s&&(n=u,u=d,d=n,r.s=-r.s),(l=(t=d.length)-(e=u.length))>0)for(;l--;)u[e++]=0;for(l=e;t>o;){if(u[--t]<d[t]){for(e=t;e&&!u[--e];)u[e]=9;--u[e],u[t]+=10}u[t]-=d[t]}for(;u[--l]===0;)u.pop();for(;u[0]===0;)u.shift(),--f;return u[0]||(r.s=1,u=[f=0]),r.c=u,r.e=f,r};z.mod=function(r){var e,t=this,n=t.constructor,s=t.s,i=(r=new n(r)).s;if(!r.c[0])throw Error(mo);return t.s=r.s=1,e=r.cmp(t)==1,t.s=s,r.s=i,e?new n(t):(s=n.DP,i=n.RM,n.DP=n.RM=0,t=t.div(r),n.DP=s,n.RM=i,this.minus(t.times(r)))};z.neg=function(){var r=new this.constructor(this);return r.s=-r.s,r};z.plus=z.add=function(r){var e,t,n,s=this,i=s.constructor;if(r=new i(r),s.s!=r.s)return r.s=-r.s,s.minus(r);var a=s.e,o=s.c,l=r.e,u=r.c;if(!o[0]||!u[0])return u[0]||(o[0]?r=new i(s):r.s=s.s),r;if(o=o.slice(),e=a-l){for(e>0?(l=a,n=u):(e=-e,n=o),n.reverse();e--;)n.push(0);n.reverse()}for(o.length-u.length<0&&(n=u,u=o,o=n),e=u.length,t=0;e;o[e]%=10)t=(o[--e]=o[e]+u[e]+t)/10|0;for(t&&(o.unshift(t),++l),e=o.length;o[--e]===0;)o.pop();return r.c=o,r.e=l,r};z.pow=function(r){var e=this,t=new e.constructor("1"),n=t,s=r<0;if(r!==~~r||r<-po||r>po)throw Error(Ot+"exponent");for(s&&(r=-r);r&1&&(n=n.times(e)),r>>=1,!!r;)e=e.times(e);return s?t.div(n):n};z.prec=function(r,e){if(r!==~~r||r<1||r>Nt)throw Error(Ot+"precision");return It(new this.constructor(this),r,e)};z.round=function(r,e){if(r===We)r=0;else if(r!==~~r||r<-Nt||r>Nt)throw Error(ls);return It(new this.constructor(this),r+this.e+1,e)};z.sqrt=function(){var r,e,t,n=this,s=n.constructor,i=n.s,a=n.e,o=new s("0.5");if(!n.c[0])return new s(n);if(i<0)throw Error(Hr+"No square root");i=Math.sqrt(+Bt(n,!0,!0)),i===0||i===1/0?(e=n.c.join(""),e.length+a&1||(e+="0"),i=Math.sqrt(e),a=((a+1)/2|0)-(a<0||a&1),r=new s((i==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+a)):r=new s(i+""),a=r.e+(s.DP+=4);do t=r,r=o.times(t.plus(n.div(t)));while(t.c.slice(0,a).join("")!==r.c.slice(0,a).join(""));return It(r,(s.DP-=4)+r.e+1,s.RM)};z.times=z.mul=function(r){var e,t=this,n=t.constructor,s=t.c,i=(r=new n(r)).c,a=s.length,o=i.length,l=t.e,u=r.e;if(r.s=t.s==r.s?1:-1,!s[0]||!i[0])return r.c=[r.e=0],r;for(r.e=l+u,a<o&&(e=s,s=i,i=e,u=a,a=o,o=u),e=new Array(u=a+o);u--;)e[u]=0;for(l=o;l--;){for(o=0,u=a+l;u>l;)o=e[u]+i[l]*s[u-l-1]+o,e[u--]=o%10,o=o/10|0;e[u]=o}for(o?++r.e:e.shift(),l=e.length;!e[--l];)e.pop();return r.c=e,r};z.toExponential=function(r,e){var t=this,n=t.c[0];if(r!==We){if(r!==~~r||r<0||r>Nt)throw Error(ls);for(t=It(new t.constructor(t),++r,e);t.c.length<r;)t.c.push(0)}return Bt(t,!0,!!n)};z.toFixed=function(r,e){var t=this,n=t.c[0];if(r!==We){if(r!==~~r||r<0||r>Nt)throw Error(ls);for(t=It(new t.constructor(t),r+t.e+1,e),r=r+t.e+1;t.c.length<r;)t.c.push(0)}return Bt(t,!1,!!n)};z[Symbol.for("nodejs.util.inspect.custom")]=z.toJSON=z.toString=function(){var r=this,e=r.constructor;return Bt(r,r.e<=e.NE||r.e>=e.PE,!!r.c[0])};z.toNumber=function(){var r=+Bt(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(r.toString()))throw Error(Hr+"Imprecise conversion");return r};z.toPrecision=function(r,e){var t=this,n=t.constructor,s=t.c[0];if(r!==We){if(r!==~~r||r<1||r>Nt)throw Error(Ot+"precision");for(t=It(new n(t),r,e);t.c.length<r;)t.c.push(0)}return Bt(t,r<=t.e||t.e<=n.NE||t.e>=n.PE,!!s)};z.valueOf=function(){var r=this,e=r.constructor;if(e.strict===!0)throw Error(Hr+"valueOf disallowed");return Bt(r,r.e<=e.NE||r.e>=e.PE,!0)};var wd=go(),_o=wd;var Li={};gc(Li,{DecodeError:()=>pe,Decoder:()=>Le,EXT_TIMESTAMP:()=>Si,Encoder:()=>or,ExtData:()=>$e,ExtensionCodec:()=>ft,decode:()=>Do,decodeArrayStream:()=>Co,decodeAsync:()=>So,decodeMulti:()=>xo,decodeMultiStream:()=>No,decodeTimestampExtension:()=>Bi,decodeTimestampToTimeSpec:()=>Ii,encode:()=>ds,encodeDateToTimeSpec:()=>Ni,encodeTimeSpecToTimestamp:()=>Ci,encodeTimestampExtension:()=>Oi});function bo(r){let e=r.length,t=0,n=0;for(;n<e;){let s=r.charCodeAt(n++);if((s&4294967168)===0){t++;continue}else if((s&4294965248)===0)t+=2;else{if(s>=55296&&s<=56319&&n<e){let i=r.charCodeAt(n);(i&64512)===56320&&(++n,s=((s&1023)<<10)+(i&1023)+65536)}(s&4294901760)===0?t+=3:t+=4}}return t}function yd(r,e,t){let n=r.length,s=t,i=0;for(;i<n;){let a=r.charCodeAt(i++);if((a&4294967168)===0){e[s++]=a;continue}else if((a&4294965248)===0)e[s++]=a>>6&31|192;else{if(a>=55296&&a<=56319&&i<n){let o=r.charCodeAt(i);(o&64512)===56320&&(++i,a=((a&1023)<<10)+(o&1023)+65536)}(a&4294901760)===0?(e[s++]=a>>12&15|224,e[s++]=a>>6&63|128):(e[s++]=a>>18&7|240,e[s++]=a>>12&63|128,e[s++]=a>>6&63|128)}e[s++]=a&63|128}}var vd=new TextEncoder,Ed=50;function kd(r,e,t){vd.encodeInto(r,e.subarray(t))}function wo(r,e,t){r.length>Ed?kd(r,e,t):yd(r,e,t)}var Ad=4096;function xi(r,e,t){let n=e,s=n+t,i=[],a="";for(;n<s;){let o=r[n++];if((o&128)===0)i.push(o);else if((o&224)===192){let l=r[n++]&63;i.push((o&31)<<6|l)}else if((o&240)===224){let l=r[n++]&63,u=r[n++]&63;i.push((o&31)<<12|l<<6|u)}else if((o&248)===240){let l=r[n++]&63,u=r[n++]&63,c=r[n++]&63,d=(o&7)<<18|l<<12|u<<6|c;d>65535&&(d-=65536,i.push(d>>>10&1023|55296),d=56320|d&1023),i.push(d)}else i.push(o);i.length>=Ad&&(a+=String.fromCharCode(...i),i.length=0)}return i.length>0&&(a+=String.fromCharCode(...i)),a}var Td=new TextDecoder,Dd=200;function xd(r,e,t){let n=r.subarray(e,e+t);return Td.decode(n)}function yo(r,e,t){return t>Dd?xd(r,e,t):xi(r,e,t)}var $e=class{type;data;constructor(e,t){this.type=e,this.data=t}};var pe=class r extends Error{constructor(e){super(e);let t=Object.create(r.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:r.name})}};function vo(r,e,t){let n=t/4294967296,s=t;r.setUint32(e,n),r.setUint32(e+4,s)}function us(r,e,t){let n=Math.floor(t/4294967296),s=t;r.setUint32(e,n),r.setUint32(e+4,s)}function cs(r,e){let t=r.getInt32(e),n=r.getUint32(e+4);return t*4294967296+n}function Eo(r,e){let t=r.getUint32(e),n=r.getUint32(e+4);return t*4294967296+n}var Si=-1,Sd=4294967296-1,Cd=17179869184-1;function Ci({sec:r,nsec:e}){if(r>=0&&e>=0&&r<=Cd)if(e===0&&r<=Sd){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,r),t}else{let t=r/4294967296,n=r&4294967295,s=new Uint8Array(8),i=new DataView(s.buffer);return i.setUint32(0,e<<2|t&3),i.setUint32(4,n),s}else{let t=new Uint8Array(12),n=new DataView(t.buffer);return n.setUint32(0,e),us(n,4,r),t}}function Ni(r){let e=r.getTime(),t=Math.floor(e/1e3),n=(e-t*1e3)*1e6,s=Math.floor(n/1e9);return{sec:t+s,nsec:n-s*1e9}}function Oi(r){if(r instanceof Date){let e=Ni(r);return Ci(e)}else return null}function Ii(r){let e=new DataView(r.buffer,r.byteOffset,r.byteLength);switch(r.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),n=e.getUint32(4),s=(t&3)*4294967296+n,i=t>>>2;return{sec:s,nsec:i}}case 12:{let t=cs(e,4),n=e.getUint32(0);return{sec:t,nsec:n}}default:throw new pe(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${r.length}`)}}function Bi(r){let e=Ii(r);return new Date(e.sec*1e3+e.nsec/1e6)}var ko={type:Si,encode:Oi,decode:Bi};var ft=class r{static defaultCodec=new r;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(ko)}register({type:e,encode:t,decode:n}){if(e>=0)this.encoders[e]=t,this.decoders[e]=n;else{let s=-1-e;this.builtInEncoders[s]=t,this.builtInDecoders[s]=n}}tryToEncode(e,t){for(let n=0;n<this.builtInEncoders.length;n++){let s=this.builtInEncoders[n];if(s!=null){let i=s(e,t);if(i!=null){let a=-1-n;return new $e(a,i)}}}for(let n=0;n<this.encoders.length;n++){let s=this.encoders[n];if(s!=null){let i=s(e,t);if(i!=null){let a=n;return new $e(a,i)}}}return e instanceof $e?e:null}decode(e,t,n){let s=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return s?s(e,t,n):new $e(t,e)}};function Nd(r){return r instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&r instanceof SharedArrayBuffer}function Wr(r){return r instanceof Uint8Array?r:ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):Nd(r)?new Uint8Array(r):Uint8Array.from(r)}var Od=100,Id=2048,or=class r{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??ft.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??Od,this.initialBufferSize=e?.initialBufferSize??Id,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new r({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),n=new Uint8Array(t),s=new DataView(t);n.set(this.bytes),this.view=s,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let n=bo(e);this.ensureBufferSizeToWrite(5+n),this.writeStringHeader(n),wo(e,this.bytes,this.pos),this.pos+=n}encodeObject(e,t){let n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);let n=Wr(e);this.writeU8a(n)}encodeArray(e,t){let n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(let s of e)this.doEncode(s,t+1)}countWithoutUndefined(e,t){let n=0;for(let s of t)e[s]!==void 0&&n++;return n}encodeMap(e,t){let n=Object.keys(e);this.sortKeys&&n.sort();let s=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(s<16)this.writeU8(128+s);else if(s<65536)this.writeU8(222),this.writeU16(s);else if(s<4294967296)this.writeU8(223),this.writeU32(s);else throw new Error(`Too large map object: ${s}`);for(let i of n){let a=e[i];this.ignoreUndefined&&a===void 0||(this.encodeString(i),this.doEncode(a,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let n=e.data(this.pos+6),s=n.length;if(s>=4294967296)throw new Error(`Too large extension object: ${s}`);this.writeU8(201),this.writeU32(s),this.writeI8(e.type),this.writeU8a(n);return}let t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),vo(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),us(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function ds(r,e){return new or(e).encodeSharedRef(r)}function fs(r){return`${r<0?"-":""}0x${Math.abs(r).toString(16).padStart(2,"0")}`}var Bd=16,Rd=16,hs=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=Bd,t=Rd){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){let s=this.caches[n-1];e:for(let i of s){let a=i.bytes;for(let o=0;o<n;o++)if(a[o]!==e[t+o])continue e;return i.str}return null}store(e,t){let n=this.caches[e.length-1],s={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=s:n.push(s)}decode(e,t,n){let s=this.find(e,t,n);if(s!=null)return this.hit++,s;this.miss++;let i=xi(e,t,n),a=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(a,i),i}};var Ri="array",Yr="map_key",To="map_value",Md=r=>{if(typeof r=="string"||typeof r=="number")return r;throw new pe("The type of key must be string or number but "+typeof r)},Mi=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=Ri,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=Yr,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===Ri){let n=e;n.size=0,n.array=void 0,n.position=0,n.type=void 0}if(e.type===Yr||e.type===To){let n=e;n.size=0,n.map=void 0,n.readCount=0,n.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},Xr=-1,$i=new DataView(new ArrayBuffer(0)),$d=new Uint8Array($i.buffer);try{$i.getInt8(0)}catch(r){if(!(r instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var Ao=new RangeError("Insufficient data"),Ld=new hs,Le=class r{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=$i;bytes=$d;headByte=Xr;stack=new Mi;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??ft.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??4294967295,this.maxBinLength=e?.maxBinLength??4294967295,this.maxArrayLength=e?.maxArrayLength??4294967295,this.maxMapLength=e?.maxMapLength??4294967295,this.maxExtLength=e?.maxExtLength??4294967295,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:Ld,this.mapKeyConverter=e?.mapKeyConverter??Md}clone(){return new r({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Xr,this.stack.reset()}setBuffer(e){let t=Wr(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Xr&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=Wr(e),s=new Uint8Array(t.length+n.length);s.set(t),s.set(n,t.length),this.setBuffer(s)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:n}=this;return new RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(let o of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(o);try{n=this.doDecodeSync(),t=!0}catch(l){if(!(l instanceof RangeError))throw l}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:s,pos:i,totalPos:a}=this;throw new RangeError(`Insufficient data in parsing ${fs(s)} at ${a} (${i} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,s=-1;for await(let i of e){if(t&&s===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(i),n&&(s=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--s!==0;);}catch(a){if(!(a instanceof RangeError))throw a}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let s=e-128;if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(e<160){let s=e-144;if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else{let s=e-160;t=this.decodeString(s,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){let s=this.lookU8();t=this.decodeString(s,1)}else if(e===218){let s=this.lookU16();t=this.decodeString(s,2)}else if(e===219){let s=this.lookU32();t=this.decodeString(s,4)}else if(e===220){let s=this.readU16();if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else if(e===221){let s=this.readU32();if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else if(e===222){let s=this.readU16();if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(e===223){let s=this.readU32();if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(e===196){let s=this.lookU8();t=this.decodeBinary(s,1)}else if(e===197){let s=this.lookU16();t=this.decodeBinary(s,2)}else if(e===198){let s=this.lookU32();t=this.decodeBinary(s,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let s=this.lookU8();t=this.decodeExtension(s,1)}else if(e===200){let s=this.lookU16();t=this.decodeExtension(s,2)}else if(e===201){let s=this.lookU32();t=this.decodeExtension(s,4)}else throw new pe(`Unrecognized type byte: ${fs(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let s=n.top();if(s.type===Ri)if(s.array[s.position]=t,s.position++,s.position===s.size)t=s.array,n.release(s);else continue e;else if(s.type===Yr){if(t==="__proto__")throw new pe("The key __proto__ is not allowed");s.key=this.mapKeyConverter(t),s.type=To;continue e}else if(s.map[s.key]=t,s.readCount++,s.readCount===s.size)t=s.map,n.release(s);else{s.key=null,s.type=Yr;continue e}}return t}}readHeadByte(){return this.headByte===Xr&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Xr}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new pe(`Unrecognized array type byte: ${fs(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new pe(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new pe(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new pe(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw Ao;let n=this.pos+t,s;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?s=this.keyDecoder.decode(this.bytes,n,e):s=yo(this.bytes,n,e),this.pos+=t+e,s}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Yr:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new pe(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw Ao;let n=this.pos+t,s=this.bytes.subarray(n,n+e);return this.pos+=t+e,s}decodeExtension(e,t){if(e>this.maxExtLength)throw new pe(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),s=this.decodeBinary(e,t+1);return this.extensionCodec.decode(s,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=Eo(this.view,this.pos);return this.pos+=8,e}readI64(){let e=cs(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function Do(r,e){return new Le(e).decode(r)}function xo(r,e){return new Le(e).decodeMulti(r)}function Pd(r){return r[Symbol.asyncIterator]!=null}async function*Fd(r){let e=r.getReader();try{for(;;){let{done:t,value:n}=await e.read();if(t)return;yield n}}finally{e.releaseLock()}}function ps(r){return Pd(r)?r:Fd(r)}async function So(r,e){let t=ps(r);return new Le(e).decodeAsync(t)}function Co(r,e){let t=ps(r);return new Le(e).decodeArrayStream(t)}function No(r,e){let t=ps(r);return new Le(e).decodeStream(t)}var Bs=Ya(ia(),1),aa=ho,oa=_o,Ze=Li,Ml=Bs.DOMParser,$l=Bs.XMLSerializer;var Ll=Ze!==null;function Pl(){if(!Ll)throw new Error("@msgpack/msgpack is required for MessagePack support. Install with: npm install @msgpack/msgpack")}var Fl=Fh();function Fh(){if(!Ll)return null;let r=new TextEncoder,e=new TextDecoder,t=new Ze.ExtensionCodec;return t.register({type:-1,encode:n=>{if(n instanceof Date){let s=wt(n);if(s==="D"||s==="H")return null}return Ze.encodeTimestampExtension(n)},decode:n=>Ze.decodeTimestampExtension(n)}),t.register({type:1,encode:n=>fe(n)?r.encode(n.toString()):null,decode:n=>yt(e.decode(n))}),t.register({type:2,encode:n=>{if(n instanceof Date&&wt(n)==="D"){let s=n.getUTCFullYear(),i=String(n.getUTCMonth()+1).padStart(2,"0"),a=String(n.getUTCDate()).padStart(2,"0");return r.encode(`${s}-${i}-${a}`)}return null},decode:n=>new Date(e.decode(n)+"T00:00:00.000Z")}),t.register({type:3,encode:n=>{if(n instanceof Date&&wt(n)==="H"){let s=String(n.getUTCHours()).padStart(2,"0"),i=String(n.getUTCMinutes()).padStart(2,"0"),a=String(n.getUTCSeconds()).padStart(2,"0"),o=String(n.getUTCMilliseconds()).padStart(3,"0");return r.encode(`${s}:${i}:${a}.${o}`)}return null},decode:n=>{let s=e.decode(n),i=s.indexOf("."),a=i>=0?s.substring(0,i):s,o=i>=0?s.substring(i+1):"0",[l,u,c]=a.split(":"),d=Math.round(+o.substring(0,3));return new Date(Date.UTC(1970,0,1,+l,+u,+c,d))}}),t.register({type:4,encode:n=>{let s=la(n);if(s!==null){let[i,a]=s;return r.encode(`${i}:${a(n)}`)}return null},decode:n=>{let s=e.decode(n),i=s.indexOf(":"),a=s.slice(0,i),o=s.slice(i+1),l=vt[a];if(l!==void 0){let[,u]=l;return u(o)}return`${o}::${a}`}}),t}function jl(r){return Pl(),Ze.encode(r,{extensionCodec:Fl})}function Ul(r){return Pl(),Ze.decode(r,{extensionCodec:Fl})}function Ms(r,e=!1){let t=$s(r);if(t===null)return[!1,String(r)];let[n,s,i]=t;return i&&!e?[!1,String(r)]:[!0,`${s(r)}::${n}`]}function ua(r){if(!r.includes("::"))return[!1,r];let e=r.lastIndexOf("::"),t=r.slice(0,e),n=r.slice(e+2),s=vt[n];if(s===void 0)return[!1,r];let[,i]=s;return[!0,i(t)]}function Rs(r,e,t){if(r!==null&&typeof r=="object"&&!Array.isArray(r)){let n={};for(let[s,i]of Object.entries(r))n[s]=Rs(i,e,t);return n}return Array.isArray(r)?r.map(n=>Rs(n,e,t)):t(r)?e(r):r}function ca(r){let e=$s(r);if(e!==null){let[t,n,s]=e;return s?[r,!1]:[`${n(r)}::${t}`,!0]}if(Array.isArray(r)){let t=!1;return[r.map(s=>{let[i,a]=ca(s);return a&&(t=!0),i}),t]}if(r!==null&&typeof r=="object"){let t=!1,n={};for(let[s,i]of Object.entries(r)){let[a,o]=ca(i);o&&(t=!0),n[s]=a}return[n,t]}return[r,!1]}function jh(r,e=!1){let[t,n]=Ms(r,e);if(t)return n;let[s,i]=ca(r),a=JSON.stringify(s);return i?`${a}::JS`:a}function Uh(r){return JSON.stringify(r)}function qh(r){if(!Ze)throw new Error("@msgpack/msgpack is required for MessagePack support");return Ze.encode(r)}function W(r,e=null,{raw:t=!1,qs:n=!1,_forceSuffix:s=!1}={}){if(n)return`${Vl(r)}::QS`;if(t){if(e===null||e==="json")return Uh(r);if(e==="msgpack")return qh(r);throw e==="xml"?new Error("raw=true is not supported for XML transport"):new Error(`Unknown transport: ${e}`)}if(e===null||e==="json"){let i=jh(r,s);return e==="json"?`"${i}"`:i}else{if(e==="xml")return`<?xml version="1.0" ?><tytx_root>${ql(r)}</tytx_root>`;if(e==="msgpack")return jl(r);throw new Error(`Unknown transport: ${e}`)}}var Dr,da;typeof window<"u"&&window.DOMParser?(Dr=window.DOMParser,da=window.XMLSerializer):(Dr=Ml,da=$l);function zl(r){if(r===null||typeof r!="object"||Array.isArray(r))return!1;let e=Object.keys(r);if(e.length!==1)return!1;let t=r[e[0]];return t!==null&&typeof t=="object"&&"value"in t}function Hl(r,e,t){let n=r.createElement(e),s=t.attrs||{},i=t.value;for(let[a,o]of Object.entries(s))n.setAttribute(a,W(o,null,{_forceSuffix:!0}));if(Array.isArray(i))for(let a of i)if(zl(a)){let[o]=Object.keys(a),l=a[o],u=Hl(r,o,l);n.appendChild(u)}else{n.textContent=W(i);break}else n.textContent=W(i);return n}function ql(r){if(!Dr)throw new Error("XML support requires @xmldom/xmldom package in Node.js");if(zl(r)){let[e]=Object.keys(r),t=r[e],n=new Dr().parseFromString("<root/>","text/xml"),s=Hl(n,e,t);return new da().serializeToString(s)}else return W(r)}function fa(r){let e={};for(let n=0;n<r.attributes.length;n++){let s=r.attributes[n];e[s.name]=P(s.value)}let t=[];for(let n=0;n<r.childNodes.length;n++){let s=r.childNodes[n];s.nodeType===1&&t.push(s)}if(t.length>0)if(t.length===1){let n=t[0],s=fa(n);return{attrs:e,value:{[n.tagName]:s}}}else{let n=[];for(let s of t){let i=fa(s);n.push({[s.tagName]:i})}return{attrs:e,value:n}}return{attrs:e,value:P(r.textContent)}}function Wl(r){if(!Dr)throw new Error("XML support requires @xmldom/xmldom package in Node.js");let n=new Dr().parseFromString(r,"text/xml").documentElement;if(n.tagName==="tytx_root"){let i=null;for(let a=0;a<n.childNodes.length;a++)if(n.childNodes[a].nodeType===1){i=n.childNodes[a];break}if(!i)return P(n.textContent);n=i}let s=fa(n);return{[n.tagName]:s}}function Vh(r){return typeof r=="string"}function zh(r){let[e,t]=ua(r);if(e)return t;let n=r;n.endsWith("::JS")&&(n=n.slice(0,-4));let s;try{s=JSON.parse(n)}catch{return r}return Rs(s,Hh,Vh)}function Hh(r){return r.includes("::")?ua(r)[1]:r}function Wh(r){let e=Wl(r);return typeof e=="string"?P(e):e}function Gh(r){return Ul(r)}function P(r,e=null){if(r===null)return null;if(e===null||e==="json"){let t=r;return e==="json"&&r.startsWith('"')&&r.endsWith('"')&&(t=r.slice(1,-1)),zh(t)}else{if(e==="xml")return Wh(r);if(e==="msgpack")return Gh(r);throw new Error(`Unknown transport: ${e}`)}}function Vl(r){if(Array.isArray(r))return r.map(e=>String(e)).join("&");if(r!==null&&typeof r=="object"){let e=[];for(let[t,n]of Object.entries(r)){let[s,i]=Ms(n,!0);s?e.push(`${t}=${i}`):e.push(`${t}=${n}`)}return e.join("&")}throw new TypeError(`toQs expects object or array, got ${typeof r}`)}function Gl(r){if(!r)return[];let e=r.split("&"),t=e.map(a=>a.includes("=")),n=t.every(Boolean),s=!t.some(Boolean);if(!n&&!s)throw new Error("QS format error: mixed items with and without '='");if(s)return e.map(a=>P(a));let i={};for(let a of e){let o=a.indexOf("="),l=a.slice(0,o),u=a.slice(o+1);i[l]=P(u)}return i}var Yl=aa||oa||Number,Zl=aa?"decimal.js":oa?"big.js":"number";function pa(){return Zl}function yt(r){return new Yl(r)}function fe(r){return Zl==="number"?!1:r instanceof Yl}function wt(r){let e=r.getUTCFullYear()===1970&&r.getUTCMonth()===0&&r.getUTCDate()===1,t=r.getUTCHours()===0&&r.getUTCMinutes()===0&&r.getUTCSeconds()===0&&r.getUTCMilliseconds()===0;return e&&!t?"H":t&&!e?"D":"DHZ"}function Xh(r){return r.toString()}function Yh(r){let e=r.getUTCFullYear(),t=String(r.getUTCMonth()+1).padStart(2,"0"),n=String(r.getUTCDate()).padStart(2,"0");return`${e}-${t}-${n}`}function Zh(r){return r.toISOString()}function Jh(r){let e=String(r.getUTCHours()).padStart(2,"0"),t=String(r.getUTCMinutes()).padStart(2,"0"),n=String(r.getUTCSeconds()).padStart(2,"0"),s=String(r.getUTCMilliseconds()).padStart(3,"0");return`${e}:${t}:${n}.${s}`}function Kh(r){return r?"true":"false"}function Qh(r){return r.toString()}function ep(r){return r.toString()}function tp(r){let e="";for(let t=0;t<r.length;t+=32768)e+=String.fromCharCode.apply(null,r.subarray(t,t+32768));return btoa(e)}var Ls=[],ha=new Map;function la(r){if(r===null||typeof r!="object")return null;for(let e=Object.getPrototypeOf(r);e!==null;e=Object.getPrototypeOf(e))for(let[t,n,s,i]of Ls)if(t.prototype===e)return[n,s,i];return null}function $s(r){if(r===null)return["NN",()=>"",!0];if(fe(r))return["N",Xh,!1];if(r instanceof Uint8Array)return["RAW",tp,!1];if(r instanceof Date){let e=wt(r);return e==="D"?["D",Yh,!1]:e==="H"?["H",Jh,!1]:["DHZ",Zh,!1]}return typeof r=="boolean"?["B",Kh,!0]:typeof r=="number"?Number.isInteger(r)?["L",Qh,!0]:["R",ep,!0]:la(r)}function rp(r){return yt(r)}function np(r){let[e,t,n]=r.split("-").map(Number);return new Date(Date.UTC(e,t-1,n,0,0,0,0))}function Xl(r){return new Date(r)}function sp(r){let[e,t,n]=r.split(":"),[s,i]=n.split(".");return new Date(Date.UTC(1970,0,1,Number(e),Number(t),Number(s),Number(i||0)))}function ip(r){return r.toLowerCase()==="true"}function ap(r){return parseInt(r,10)}function op(r){return parseFloat(r)}function lp(r){return r}function up(r){return null}var cp=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function dp(r){if(!cp.test(r))throw new Error(`RAW payload is not standard padded base64: '${r}'`);let e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function fp(r){return Gl(r)}var hp=/^[A-Z]+$/,vt={N:[Object,rp],D:[Date,np],DH:[Date,Xl],DHZ:[Date,Xl],H:[Date,sp],L:[Number,ap],R:[Number,op],T:[String,lp],B:[Boolean,ip],QS:[Object,fp],NN:[null,up],RAW:[Uint8Array,dp]};function gn(r){return Object.hasOwn(vt,r)?vt[r][0]:null}function ma(r,e,t,n,s=!1){if(typeof e!="string"||!hp.test(e))throw new Error(`TYTX suffix '${e}' is invalid: expected uppercase ASCII letters only`);let i=vt[e];if(i!==void 0&&i[0]!==r){let a=i[0]===null?"null":i[0].name;throw new Error(`TYTX suffix '${e}' is already registered for ${a}`)}Ls=Ls.filter(([a])=>a!==r),Ls.push([r,e,t,s]),vt[e]=[r,n]}function Pt(r,e){ha.set(r,e)}function Re(r){return ha.has(r)?ha.get(r):{}}var Jl={network:{maxAttempts:3,delay:1,backoff:2,jitter:!0,on:["TypeError","NetworkError","AbortError"]},aggressive:{maxAttempts:5,delay:.5,backoff:2,jitter:!0,on:["Error"]},gentle:{maxAttempts:2,delay:2,backoff:1.5,jitter:!1,on:["TypeError","NetworkError"]}};function mp(r){let e=r._retryPolicy;return e==null?null:typeof e=="string"?Jl[e]||null:e}function gp(r,e){return e.some(t=>t==="Error"?!0:r.name===t||r.constructor.name===t)}function _p(r){return new Promise(e=>setTimeout(e,r))}async function bp(r,e){if(!e)return r();let t=e.maxAttempts||3,n=e.delay||1,s=e.backoff||2,i=e.jitter!==!1,a=e.on||["Error"],o=null,l=n*1e3;for(let u=0;u<t;u++)try{let c=r();return c instanceof Promise?await c:c}catch(c){if(o=c,u<t-1&&gp(c,a)){let d=l;i&&(d*=1+Math.random()*.1),await _p(d),l*=s}else throw c}throw o}var Z=class r{static classKwargs={cacheTime:0,readOnly:!1,asBag:null,retryPolicy:null};static classArgs=[];static internalParams=new Set(["cacheTime","readOnly","asBag","retryPolicy"]);constructor(e={}){let n={...this.constructor.classKwargs,...e};for(let i of["interval","reactive"])if(Object.hasOwn(n,i))throw new TypeError(`Removed resolver option: ${i}. Schedule updates in the application; use reset() and read explicitly.`);this.cacheTime=n.cacheTime,this._readOnly=n.readOnly,this._asBag=n.asBag,this._retryPolicy=n.retryPolicy,this._kw={};let s=this.constructor.internalParams;for(let[i,a]of Object.entries(n))s.has(i)||(this._kw[i]=a);this._lastUpdate=null,this._node=null,this._lastEffectiveFingerprint=null,this._cachedValue=null,this.init()}init(){}setNode(e){e!==this._node&&!this.readOnly&&this._lastUpdate!==null&&this.reset(),this._node=e,this.onSetResolver(e)}onSetResolver(e){}get node(){return this._node}get cacheTime(){return this._cacheTime}set cacheTime(e){if(typeof e=="boolean")throw new TypeError("cacheTime must be numeric; use a negative value for infinite caching");this._cacheTime=e}get readOnly(){return this._readOnly}get expired(){return this._cacheTime<0?this._lastUpdate===null:this._cacheTime===0||this._lastUpdate===null?!0:(Date.now()-this._lastUpdate)/1e3>this._cacheTime}reset(...e){if(e.length)throw new TypeError("reset() takes no arguments. It invalidates the cache for the next explicit read.");this._lastUpdate=null,this._lastEffectiveFingerprint=null}get cachedValue(){return!this.readOnly&&this._node?this._node._value:this._cachedValue}set cachedValue(e){!this.readOnly&&this._node?this._node.setValue(e,!1):this._cachedValue=e}_computeEffectiveFingerprint(e){return JSON.stringify(Object.entries(e).sort())}resolve(e={}){let{static:t=!1,...n}=e;if(t)return this._node?this._node._value:this.cachedValue;let s={...this._kw};if(this._node&&this._node.attr){let u=this.constructor.internalParams;for(let[c,d]of Object.entries(this._node.attr))u.has(c)||(s[c]=d)}Object.assign(s,n);let i=this._computeEffectiveFingerprint(s);if(i===this._lastEffectiveFingerprint&&!this.expired)return this.cachedValue;this._lastEffectiveFingerprint=i;let a=mp(this),o=()=>this.load(s);if(a)return bp(o,a).then(u=>this._finalize(u));let l=o();return l&&typeof l.then=="function"?l.then(u=>this._finalize(u)):this._finalize(l)}_finalize(e){let t;return this._asBag===!0?t=!0:this._asBag===!1?t=!1:t=!this._readOnly,t&&e!==null&&e!==void 0&&(e=this._convertToBag(e)),this._lastUpdate=Date.now(),(!this.readOnly||this.cacheTime!==0)&&(this.cachedValue=e),e}_convertToBag(e){let t=r._BagClass;if(!t||e&&typeof e._htraverse=="function")return e;if(typeof e=="string"){if(e=e.trim(),e.startsWith("<")&&t.fromXml)return t.fromXml(e);if((e.startsWith("{")||e.startsWith("["))&&t.fromTytx)return t.fromTytx(e)}return e}static registerBagClass(e){r._BagClass=e}load(e){return null}};Z._BagClass=null;var Ft=class extends Z{static classKwargs={cacheTime:0,readOnly:!1,asBag:!1,retryPolicy:null,callback:null};static classArgs=["callback"];static internalParams=new Set(["cacheTime","readOnly","asBag","retryPolicy","callback"]);constructor(e={}){typeof e=="function"&&(e={callback:e}),super(e),this._callback=e.callback||null}load(e){return this._callback?this._callback.call(this,e):null}};var Pe=class r{constructor(e,t,n=null,s=null,i=null,a=null,o=null,l=!0){this.label=t,this._value=null,this._attr={},this._parentBag=null,this._resolver=null,this._nodeSubscribers={},this._onChangedValue=null,this.nodeTag=a,this.xmlTag=o,this._compiled=null,this.parentBag=e,s&&this.setAttr(s,!1,!0,l),n!==null&&this.setValue(n,!1),i&&(this.resolver=i)}get parentBag(){return this._parentBag}set parentBag(e){e===null&&this._value?.parentNode===this&&this._value.setBackref(),this._parentBag=e,e?.backref&&this._value&&typeof this._value._htraverse=="function"&&this._value.setBackref(this,e)}get value(){return this.getValue()}set value(e){this.setValue(e)}getValue(e=!1,t=null,n={}){if(t!==null){let s=P(`${t}::QS`);if(Array.isArray(s)){let i=s.length?s:Object.keys(this._attr),a=i.map(l=>{let u=this.getAttr(l);return!e&&u instanceof Z?u.resolve():u}),o=l=>s.length===0?Object.fromEntries(i.map((u,c)=>[u,l[c]])):l.length===1?l[0]:l;return a.some(l=>l&&typeof l.then=="function")?Promise.all(a).then(o):o(a)}else{if(!this._resolver)throw new Error("Cannot use kwargs syntax without resolver");n={...n,...s}}}return this._resolver!==null?this._resolver.resolve({static:e,...n}):this._value}setValue(e,t=!0,n=null,s=null,i=!0,a=null,o=!1){e instanceof Z?(this.resolver=e,e=null):e instanceof r&&(n=n||{},Object.assign(n,e._attr),e.resolver&&(this.resolver=e.resolver),e=e._value);let l=this._value;l!==e&&l?.parentNode===this&&l.setBackref(),this._value=e;let u=l!==this._value,c=t??!0,d=null;if(n!==null){let h={...this._attr};this.setAttr(n,!1,s,i);let p=this._buildAttrDiff(h,this._attr);d=Object.keys(p).length>0?p:null}t=c&&(u||d!==null);let f=d?u?"upd_value_attr":"upd_attrs":"upd_value";if(this._onChangedValue&&this._onChangedValue(this,e,l,c),t){let h=d!==null?{oldvalue:l,attrs_diff:d}:{oldvalue:l};for(let p of Object.values(this._nodeSubscribers))p({node:this,info:h,evt:f})}this._parentBag!==null&&this._parentBag.backref&&(e&&typeof e._htraverse=="function"&&e.setBackref(this,this._parentBag),t&&this._parentBag._onNodeChanged(this,[this.label],f,l,d,a,o))}replace(e){if(!(e instanceof r))throw new TypeError("BagNode.replace expects a BagNode");if(e===this)return this;let t=e.staticValue;t&&typeof t._htraverse=="function"&&(t=t.createChildBag().replace(t));let n=null;e.resolver&&(n=Object.create(Object.getPrototypeOf(e.resolver),Object.getOwnPropertyDescriptors(e.resolver)),n._node=null,n._kw={...e.resolver._kw});let s=this._value,i={...this._attr},a=this.resolver;a&&a._node===this&&(a._node=null),this.resolver=n,this.setValue(t,!1,{...e.attr},!1,!1,null);let o=this._buildAttrDiff(i,this._attr),l=Object.keys(o).length?o:null,u=s!==t||a!==n;if(u||l){let c=l?u?"upd_value_attr":"upd_attrs":"upd_value",d=l?{oldvalue:s,attrs_diff:l}:{oldvalue:s};for(let f of Object.values(this._nodeSubscribers))f({node:this,info:d,evt:c});this._parentBag!==null&&this._parentBag.backref&&this._parentBag._onNodeChanged(this,[this.label],c,s,l)}return this}get staticValue(){return this._value}set staticValue(e){this._value=e}get resolver(){return this._resolver}set resolver(e){this._resolver=e,e&&e.setNode&&e.setNode(this)}resetResolver(){if(!this._resolver)throw new Error("Cannot reset resolver: node has no resolver");this._resolver.reset(),this.setValue(null)}get attr(){return this._attr}getAttr(e=null,t=null){return e?e in this._attr?this._attr[e]:t:this._attr}_buildAttrDiff(e,t){let n={},s=new Set([...Object.keys(e),...Object.keys(t)]);for(let i of s){let a=i in e?e[i]:null,o=i in t?t[i]:null;a!==o&&(n[i]={old:a,new:o})}return n}setAttr(e=null,t=!0,n=!0,s=!0){let i=e||{},a=Object.keys(this._nodeSubscribers).length>0,l=t&&(a||this._parentBag!==null&&this._parentBag.backref)?{...this._attr}:null;if(n?Object.assign(this._attr,i):this._attr={...i},s)for(let u of Object.keys(this._attr))this._attr[u]===null&&delete this._attr[u];if(t&&l!==null){let u=this._buildAttrDiff(l,this._attr);if(Object.keys(u).length>0&&a)for(let c of Object.values(this._nodeSubscribers))c({node:this,info:{attrs_diff:u},evt:"upd_attrs"});if(Object.keys(u).length>0&&this._parentBag!==null&&this._parentBag.backref){let c=t===!0?"true":String(t);this._parentBag._onNodeChanged(this,[this.label],"upd_attrs",null,u,c)}}}delAttr(...e){for(let t of e)if(typeof t=="string"&&t.includes(","))for(let n of t.split(","))delete this._attr[n.trim()];else delete this._attr[t]}hasAttr(e,t=null){return e in this._attr?t!==null?this._attr[e]===t:!0:!1}getInheritedAttributes(){let e={};return this._parentBag&&this._parentBag.parentNode&&(e=this._parentBag.parentNode.getInheritedAttributes()),{...e,...this._attr}}subscribe(e,t){this._nodeSubscribers[e]=t}unsubscribe(e){delete this._nodeSubscribers[e]}get compiled(){return this._compiled||(this._compiled={}),this._compiled}get isBranch(){return this._value!=null&&typeof this._value._htraverse=="function"}get position(){return this._parentBag===null?null:this._parentBag._nodes.index(this.label)}get fullpath(){if(this._parentBag!==null){let e=this._parentBag.fullpath;return e?`${e}.${this.label}`:this.label}return null}get parentNode(){return this._parentBag?this._parentBag.parentNode:null}attributeOwnerNode(e,t=null){let n=this;if(t===null)for(;n&&!(e in n._attr);)n=n.parentNode;else for(;n&&n._attr[e]!==t;)n=n.parentNode;return n}asTuple(){return[this.label,this.value,this._attr,this._resolver||null]}isEqual(e){if(!(e instanceof r)||this.label!==e.label)return!1;let t=Object.keys(this._attr),n=Object.keys(e._attr);if(t.length!==n.length)return!1;for(let s of t)if(this._attr[s]!==e._attr[s])return!1;return this._resolver!==null?this._resolver===e._resolver:this._value&&typeof this._value.equalTo=="function"?this._value.equalTo(e._value):this._value&&typeof this._value.isEqual=="function"?this._value.isEqual(e._value):this._value===e._value}diff(e){if(this.label!==e.label)return`Other label: ${e.label}`;let t=Object.keys(this._attr),n=Object.keys(e._attr);return t.length!==n.length||t.some(s=>this._attr[s]!==e._attr[s])?`attributes self:${JSON.stringify(this._attr)} --- other:${JSON.stringify(e._attr)}`:this._value!==e._value?`value self:${this._value} --- other:${e._value}`:null}toJson(e=!0){let t=this.value;return t&&typeof t.toJson=="function"&&(t=t.toJson(e,!0)),{label:this.label,value:t,attr:this._attr}}toString(){return`BagNode : ${this.label}`}};var _n=class r{constructor(){this._dict=Object.create(null),this._list=[],this._parentBag=null}index(e){if(e in this._dict)return this._list.findIndex(n=>n.label===e);let t=e.match(/^#(\d+)$/);if(t){let n=parseInt(t[1],10);return n<this._list.length?n:-1}if(t=e.match(/^#(\w*)=(.*)$/),t){let[,n,s]=t,i=s.includes("::")?P(s):s;return n?this._list.findIndex(a=>a.getAttr(n)===i):this._list.findIndex(a=>a._value===i)}return-1}_parsePosition(e){let t=this._list.length;if(e==null||e===">")return t;if(typeof e=="number")return e<0&&(e=t+e),Math.max(0,Math.min(e,t));if(e==="<")return 0;if(e.startsWith("#")){let n=this._parseSharpIndex(e.slice(1),e);return Math.min(n,t)}if(e.startsWith("<")){let n=e.slice(1);if(n.startsWith("#")){let i=this._parseSharpIndex(n.slice(1),e);return Math.min(i,t)}let s=this.index(n);if(s<0)throw new Error(`Invalid node_position '${e}': label '${n}' not found`);return s}if(e.startsWith(">")){let n=e.slice(1);if(n.startsWith("#")){let i=this._parseSharpIndex(n.slice(1),e);return Math.min(i+1,t)}let s=this.index(n);if(s<0)throw new Error(`Invalid node_position '${e}': label '${n}' not found`);return s+1}throw new Error(`Invalid node_position '${e}': unrecognized syntax`)}_parseSharpIndex(e,t){if(!/^-?\d+$/.test(e))throw new Error(`Invalid node_position '${t}': '${e}' is not an integer`);let n=parseInt(e,10);if(n<0)throw new Error(`Invalid node_position '${t}': negative index not allowed in '#n' syntax`);return n}get(e){if(typeof e=="number")return e>=0&&e<this._list.length?this._list[e]:null;if(e.startsWith("#")){let t=this.index(e);return t>=0?this._list[t]:null}return this._dict[e]||null}set(e,t,n=">",s=null,i=null,a=null,o=!1,l=!0,u=null,c=!0,d=!1,f=null){let h=null;if(e.includes("?")&&([e,h]=e.split("?",2)),e==null||e.startsWith("#"))throw new Error("Cannot create new node with #n syntax");if(h){let m=h.split("&");if(m.length===1)s={[m[0]]:t};else{if(!Array.isArray(t)||t.length!==m.length)throw new Error("Wrong attributes assignment");s={};for(let g=0;g<m.length;g++)s[m[g]]=t[g]}t=null}let p=this._dict[e];if(p)f&&(p.nodeTag=f),a!==null&&(a===!1?p.resolver=null:p.resolver=a),h?p.setAttr(s,c,!0,l):p.setValue(t,c,s,o,l,u,d);else{let m=i&&i.nodeClass?i.nodeClass:Pe;p=new m(i,e,h?null:t,s,a,f,null,l);let g=this._parsePosition(n);this._dict[e]=p,this._list.splice(g,0,p),c&&i&&i.backref&&i._onNodeInserted(p,g,null,u,d)}return d&&p.setValue(null,!1),p}pop(e){let t=this.get(e);if(t){delete this._dict[t.label];let n=this._list.indexOf(t);return n>=0&&this._list.splice(n,1),t}return null}has(e){return e in this._dict}get length(){return this._list.length}clear(){this._dict=Object.create(null),this._list=[]}keys(){return this._list.map(e=>e.label)}values(){return this._list.map(e=>e.getValue())}items(){return this._list.map(e=>[e.label,e.getValue()])}[Symbol.iterator](){return this._list[Symbol.iterator]()}move(e,t,n=!0){if(t<0)return;let s=Array.isArray(e)?e:[e];if(s.length===0||t>=this._list.length)return;let i=this._list[t].label;if(s.length>1){let a=[...s].sort((c,d)=>c-d),o=a[0]<t?1:0,l=[];for(let c=a.length-1;c>=0;c--){let d=a[c];if(d>=0&&d<this._list.length){let f=this._list[d];this._list.splice(d,1),l.push(f),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(f,d)}}let u=this.index(i);u<0&&(u=this._list.length),u+=o;for(let c of l)this._list.splice(u,0,c),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(c,u)}else{let a=s[0];if(a===t||a<0||a>=this._list.length)return;let o=this._list[a];this._list.splice(a,1),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(o,a),this._list.splice(t,0,o),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(o,t)}}isEqual(e){if(!(e instanceof r)||this._list.length!==e._list.length)return!1;for(let t=0;t<this._list.length;t++){let n=this._list[t],s=e._list[t];if(!n.isEqual(s))return!1}return!0}};var tu=Ya(ia(),1);var ga="::RSLV:",wp=new Map,yp=new Map,Ps=new WeakMap,te=class extends Error{constructor(e){super(e),this.name="BagSerializationError"}},bn=class extends Z{constructor(e){super({asBag:!1}),Ps.set(this,e)}get payload(){return Ps.get(this)}load(){throw new te("This resolver is opaque; local execution is unavailable")}};function Kl(r){if(!r||typeof r!="object"||Array.isArray(r)||typeof r.resolver_module!="string"||typeof r.resolver_class!="string"||!Array.isArray(r.args??[])||!r.kwargs||typeof r.kwargs!="object"||Array.isArray(r.kwargs))throw new te("Invalid resolver description")}function Ql(r,e=new Set){if(!(r===null||typeof r=="string"||typeof r=="boolean")&&!(typeof r=="number"&&Number.isFinite(r))){if(typeof r!="object"||e.has(r)||!Array.isArray(r)&&Object.getPrototypeOf(r)!==Object.prototype&&Object.getPrototypeOf(r)!==null)throw new te("Resolver parameters must be JSON data; callbacks cannot travel");e.add(r);for(let t of Object.values(r))Ql(t,e);e.delete(r)}}function wn(r){if(Ps.has(r))return Ps.get(r);let e=yp.get(r.constructor);if(!e)throw new te(`Unregistered resolver: ${r.constructor.name}`);let t=e.encode(r),n={resolver_module:e.module,resolver_class:e.name,args:t.args??[],kwargs:t.kwargs??{}};return Kl(n),Ql(n),ga+JSON.stringify(n)}function Fs(r){if(typeof r!="string"||!r.startsWith(ga))return null;let e=r.slice(ga.length);if(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+$/.test(e))return new bn(r);let t;try{t=JSON.parse(e)}catch{throw new te("Invalid resolver JSON or signed token")}Kl(t);let n=wp.get(JSON.stringify([t.resolver_module,t.resolver_class]));if(!n)return new bn(r);let s=n.decode({args:t.args??[],kwargs:t.kwargs});if(!(s instanceof n.cls))throw new te("Resolver decoder returned an incompatible instance");return s}function js(r){return Object.fromEntries(Object.entries(r||{}).map(([e,t])=>[e,t instanceof Z?wn(t):t]))}function _a(r){return Object.fromEntries(Object.entries(r||{}).map(([e,t])=>[e,Fs(t)??t]))}var Fe="__cls";function xr(r,e){return r!==null&&r.tytxSuffix===e?r:gn(e)}function vp(r){let e=r.tytxSuffix,t=Object.entries(Re(e)).filter(([,n])=>n===r).map(([n])=>n);if(t.length===0)throw new te(`${r.name} is not in the TYTX subtype dictionary of '${e}'`);if(t.length>1)throw new te(`${r.name} is in the TYTX subtype dictionary of '${e}' under several names: ${t.sort().join(", ")}`);return t[0]}function ba(r,e){let t=Re(r);if(!Object.hasOwn(t,e))throw new te(`Unknown Bag class '${e}' for TYTX type '${r}'`);return t[e]}function wa(r,e){return r===e?null:vp(r)}function*ru(r,e=[]){for(let t of r){let n=[...e,t.label];yield[n,t];let s=t.getValue(!0);!t.resolver&&s instanceof R&&(yield*ru(s,n))}}function Ep(r){let e=r.toISOString(),t=r.getUTCFullYear()===1970&&r.getUTCMonth()===0&&r.getUTCDate()===1,n=r.getUTCHours()===0&&r.getUTCMinutes()===0&&r.getUTCSeconds()===0&&r.getUTCMilliseconds()===0;if(n&&!t)return e.slice(0,e.indexOf("T"));let s=e.replace(/\.000Z$/,"Z");return t&&!n?s.slice(s.indexOf("T")+1):s}function Sr(r){if(r===null||typeof r!="object")return!1;let e=Object.getPrototypeOf(r);return e===Object.prototype||e===null}function Et(r){return typeof r=="string"?r.includes("::")?`${r}::T`:r:Array.isArray(r)?r.map(Et):Sr(r)?Object.fromEntries(Object.entries(r).map(([e,t])=>[e,Et(t)])):r}function ya(r){if(!Sr(r))throw new TypeError("Bag options must be an object");let{recursive:e=!0}=r;if(typeof e!="boolean")throw new TypeError("recursive must be a boolean");return e}var eu=!1,R=class r{static tytxSuffix="X";constructor(e=null,t={}){this._nodes=new _n,this._backref=!1,this._parent=null,this._parentNode=null,this._rootAttributes=null,this._updSubscribers={},this._insSubscribers={},this._delSubscribers={},ya(t),e!=null&&this.fillFrom(e,t)}get parent(){return this._parent}set parent(e){this._parent=e}get parentNode(){return this._parentNode}set parentNode(e){this._parentNode=e}get backref(){return!!this._backref}get nodeClass(){return Pe}createChildBag(){return new this.constructor}get fullpath(){if(this._parent!==null&&this._parentNode!==null){let e=this._parent.fullpath;return e?`${e}.${this._parentNode.label}`:this._parentNode.label}return null}relativePath(e){let t=[],n=e;for(;n!==null;){if(n.parentBag===this)return t.push(n.label),t.reverse(),t.join(".");t.push(n.label),n=n.parentNode}return null}get length(){return this._nodes.length}get root(){let e=this;for(;e.parent!==null;)e=e.parent;return e}get attributes(){return this._parentNode!==null?this._parentNode.getAttr():{}}get rootAttributes(){return this._rootAttributes}set rootAttributes(e){this._rootAttributes=e!==null?{...e}:null}_htraverseBefore(e){let t=this,n;for(typeof e=="string"?(e=e.replace(/\.\.\//g,"#parent."),n=e.split(".").filter(s=>s)):n=[...e];n.length&&n[0]==="#parent"&&t!==null;)n.shift(),t=t.parent;return[t,n]}_htraverse(e,t=!1,n=!0){let[s,i]=this._htraverseBefore(e);if(s===null)return[null,null];if(i.length===0)return[s,""];for(;i.length>1&&s instanceof r;){let a=i[0];if(a==="#parent"){if(s.parent===null||s.parent===void 0)break;i.shift(),s=s.parent;continue}let o=s._nodes.get(a);if(!o)break;let l=o.getValue(n);if(l instanceof r)i.shift(),s=l;else if(t){let u=s.createChildBag();o.setValue(u,!0,null,!0,!0,"autocreate"),i.shift(),s=u}else break}if(!t)return i.length>1?[null,null]:[s,i[0]];for(;i.length>1;){let a=i.shift();if(a.startsWith("#"))throw new yn("Not existing index in #n syntax");let o=s.createChildBag();s._nodes.set(a,o,">",null,s,null,!1,!0,"autocreate"),s=o}return[s,i[0]]}get(e,t=null,n=!0,s={}){if(!e)return this;if(e==="#parent")return this.parent;let i=null;e.includes("?")&&([e,i]=e.split("?",2));let a=this._nodes.get(e);return a?a.getValue(n,i,s):t}getItem(e,t=null,n=!1,s={}){if(!e)return this;let[i,a]=this._htraverse(e,!1,n);return i instanceof r?i.get(a,t,n,s):t}setItem(e,t,n=null,s=">",i=!1,a=!0,o=null,l=!1,u=!0,c=null,d=null){if(e==="")throw new RangeError("setItem requires a non-empty path");let[f,h]=this._htraverse(e,!0);return f._nodes.set(h,t,s,n,f,c,i,a,o,u,l,d)}_pop(e,t=null){let n=this._nodes.index(e);if(n>=0){let s=this._nodes.pop(n);return this.backref&&this._onNodeDeleted(s,n,t),s}return null}pop(e,t=null,n=null){let s=this.popNode(e,n);return s?s.value:t}delItem(e,t=null,n=null){return this.pop(e,t,n)}popNode(e,t=null){let[n,s]=this._htraverse(e,!1,!0);if(!n||!s)return null;let i=n._nodes.get(s);if(!i)return null;try{return n._pop(s,t)}finally{i.parentBag===n&&n._nodes._dict[i.label]!==i&&(i.parentBag=null)}}clear(){let e=[...this._nodes];this._nodes.clear(),this.backref&&this._onNodeDeleted(e,-1);for(let t of e)t.parentBag=null}getNode(e,t=!0,n=!1,s=null){if(e==null||e==="")return this.parentNode;if(typeof e=="number")return this._nodes.get(e);typeof e=="string"&&(e=e.split("?",1)[0]);let[i,a]=this._htraverse(e,n,t);if(i instanceof r&&a){let o=i._nodes.get(a);if(o)return o;if(n)return i._nodes.set(a,s,">",null,i,null,!1,!0,"autocreate"),i._nodes.get(a)}return null}setBackref(e=null,t=null){let n=this._backref;if(this._backref=!0,this._parent=t,this._parentNode=e,!n){this._nodes._parentBag=this;for(let s of this)s.parentBag=this}}delParentRef(){this._parent=null,this._parentNode=null,this._backref=!1}clearBackref(){if(this._backref){this._backref=!1,this._parent=null,this._parentNode=null,this._nodes._parentBag=null;for(let e of this){e.parentBag=null;let t=e.getValue(!0);t instanceof r&&t.clearBackref()}}}_onNodeChanged(e,t,n,s=null,i=null,a=null,o=!1){for(let l of Object.values(this._updSubscribers))l({node:e,pathlist:t,oldvalue:s,attrs_diff:i,evt:n,reason:a,fired:o});this._parent&&this._parentNode&&this._parent._onNodeChanged(e,[this._parentNode.label,...t],n,s,i,a,o)}_onNodeInserted(e,t,n=null,s=null,i=!1){let a=e.parentBag,o=e.getValue(!0);a!==null&&a.backref&&o instanceof r&&o.setBackref(e,a),n===null&&(n=[]);for(let l of Object.values(this._insSubscribers))l({node:e,pathlist:n,ind:t,evt:"ins",reason:s,fired:i});this._parent&&this._parentNode&&this._parent._onNodeInserted(e,t,[this._parentNode.label,...n],s,i)}_onNodeDeleted(e,t,n=null,s=null){for(let i of Object.values(this._delSubscribers))i({node:e,pathlist:n,ind:t,evt:"del",reason:s});this._parent&&this._parentNode&&(n===null&&(n=[]),this._parent._onNodeDeleted(e,t,[this._parentNode.label,...n],s))}_subscribe(e,t,n){n!=null&&(t[e]=n)}subscribe(e,t={}){if(Object.hasOwn(t,"timer")||Object.hasOwn(t,"interval"))throw new TypeError("Timer subscriptions were removed. Schedule polling in the application.");let{update:n=null,insert:s=null,delete:i=null,any:a=null}=t;this.backref||this.setBackref(),this._subscribe(e,this._updSubscribers,n||a),this._subscribe(e,this._insSubscribers,s||a),this._subscribe(e,this._delSubscribers,i||a)}unsubscribe(e,t={}){if(Object.hasOwn(t,"timer")||Object.hasOwn(t,"interval"))throw new TypeError("Timer subscriptions were removed. Schedule polling in the application.");let{update:n=!1,insert:s=!1,delete:i=!1,any:a=!1}=t;(n||a)&&delete this._updSubscribers[e],(s||a)&&delete this._insSubscribers[e],(i||a)&&delete this._delSubscribers[e]}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}keys(){return this._nodes.keys()}values(){return this._nodes.values()}items(){return[...this._nodes].map(e=>({key:e.label,value:e.getValue()}))}get nodes(){return this.getNodes()}node(e){return this._nodes.get(e)}setAttr(e=null,t=null,n=!0){let s=r.prototype.getNode.call(this,e,!0,!0);s&&s.setAttr(t,!0,!0,n)}getAttr(e=null,t=null,n=null){let s=this.getNode(e);return s?s.getAttr(t,n):n}delAttr(e=null,...t){let n=this.getNode(e);n&&n.delAttr(...t)}getInheritedAttributes(){return this._parentNode?this._parentNode.getInheritedAttributes():{}}getNodes(e=null){return e?[...this._nodes].filter(t=>e(t)):[...this._nodes]}getNodeByValue(e,t){for(let n of this._nodes){let s=n.value;if(s instanceof r){if(s.getItem(e)===t)return n}else if(s&&s.get&&s.get(e)===t)return n}return null}getNodeByAttr(e,t,n=!1,s=!1){let i=t===void 0,a=n&&typeof t=="string"?t.toLowerCase():t,o=l=>{let u=[];for(let c of l._nodes){if(e in c.attr){let d=n&&typeof c.attr[e]=="string"?c.attr[e].toLowerCase():c.attr[e];if(i||d==a)return c}if(c._value instanceof r)if(s){let d=o(c._value);if(d)return d}else u.push(c._value)}for(let c of u){let d=o(c);if(d)return d}return null};return o(this)}isEmpty(e=!1,t=!1){if(this._nodes.length===0)return!0;for(let n of this._nodes){if(n._resolver!==null)return!1;let s=n.getValue(!0);if(s!=null&&!(e&&s===0)&&!(t&&s===""))return!1}return!0}query(e=null,t=null,n=!1,s=!1,i=!0,a=!0,o=null,l=!0){e||(e="#k,#v,#a");let u=this,c;if(typeof e=="string"){if(e.includes(":")){let[h,p]=e.split(":");u=this.getItem(h),e=p}c=e.split(",").map(h=>h.trim())}else c=e;let d=(h,p,m,g,_)=>{if(p==="#k")return h.label;if(p==="#p")return m;if(p==="#n")return h;if(typeof p=="function")return p(h);if(p==="#v"){let w=_();return g&&w instanceof r?null:w}else if(p.startsWith("#v.")){let w=p.split(".").slice(1).join("."),y=_();return y&&y.getItem?y.getItem(w):null}else{if(p==="#__v")return h.getValue(!0);if(p.startsWith("#a")){let w=p.includes(".")?p.split(".").slice(1).join("."):null;return h.getAttr(w)}else{let w=_();return w&&w.getItem?w.getItem(p):null}}};function*f(){let h=0;function*p(m,g){for(let _ of m._nodes){let w=g?`${g}.${_.label}`:_.label,y=!1,k,T=()=>(y||(k=_.getValue(l),y=!0),k);if((i&&a||(T()instanceof r?a:i))&&(t===null||t(_))&&(yield c.length===1?d(_,c[0],w,s,T):c.map(N=>d(_,N,w,s,T)),h++,o!==null&&h>=o))return;if(s){let N=T();if(N instanceof r&&(yield*p(N,w),o!==null&&h>=o))return}}}yield*p(u,"")}return n?f():[...f()]}getLeaves(){let e=[],t=(n,s)=>{for(let i of n._nodes){let a=s?`${s}.${i.label}`:i.label,o=i.getValue(!1);o instanceof r?t(o,a):e.push([a,o])}};return t(this,""),e}digest(e=null,t=null,n=!1){typeof t=="boolean"&&(console.warn("Bag.digest(what, asColumns) is deprecated; use digest(what, null, asColumns)."),n=t,t=null);let s=this.query(e,t,!1,!1,!0,!0,null,!1);if(n){if(!s||s.length===0)return(typeof e=="string"?e:"#k,#v,#a").split(",").map(l=>l.trim()).map(()=>[]);let i=[...s];if(i.length&&Array.isArray(i[0])){let a=i[0].length,o=[];for(let l=0;l<a;l++)o.push(i.map(u=>u[l]));return o}return[i]}return[...s]}columns(e,t=!1){typeof e=="string"&&(e=e.split(","));let n=t?"#a.":"",s=e.map(i=>`${n}${i}`).join(",");return this.digest(s,null,!0)}sum(e="#v",t=!1,n=null){if(t!=null&&typeof t!="boolean")throw new TypeError("sum strict must be a boolean; pass condition as the third argument");if(n!=null&&typeof n!="function")throw new TypeError("sum condition must be callable; deep is no longer supported");let s=i=>{let a=0,o=!1;for(let l of this.query(i,n)){if(l==null||l===""){o=!0;continue}if(typeof l!="number"&&typeof l!="boolean"){if(t)throw new TypeError(`sum encountered non-numeric value: ${typeof l}`);continue}a+=l}return t&&o?null:a};return e.includes(",")?e.split(",").map(i=>s(i.trim())):s(e)}sort(e="#k:a"){let t=(s,i)=>s==null?[-1,""]:i&&typeof s=="string"?[0,s.toLowerCase()]:[0,s],n=(s,i)=>s[0]!==i[0]?s[0]-i[0]:s[1]<i[1]?-1:s[1]>i[1]?1:0;if(typeof e=="function")this._nodes._list.sort((s,i)=>{let a=e(s),o=e(i);return a<o?-1:a>o?1:0});else{let s=e.split(",");s.reverse();for(let i of s){let a,o;i.includes(":")?[a,o]=i.split(":",2):(a=i,o="a"),a=a.trim(),o=o.trim();let l=o==="d"||o==="D",u=o==="a"||o==="d",c;if(a.toLowerCase()==="#k")c=d=>t(d.label,u);else if(a.toLowerCase()==="#v")c=d=>t(d.value,u);else if(a.toLowerCase().startsWith("#a.")){let d=a.slice(3);c=f=>t(f.getAttr(d),u)}else c=d=>{let f=d.value,h=f instanceof r?f.getItem(a):f?f[a]:null;return t(h,u)};this._nodes._list.sort((d,f)=>{let h=n(c(d),c(f));return l?-h:h})}}return this}equalTo(e){return e instanceof r?this._nodes.isEqual(e._nodes):!1}has(e){if(typeof e=="string"){let t=null;e.includes("?")&&([e,t]=e.split("?",2));let n=this.getNode(e);return n===null?!1:t===null?!0:t.split("&").every(s=>s in n.attr)}else if(e&&e.label!==void 0)return[...this._nodes].includes(e);return!1}getResolver(e){let t=this.getNode(e);return t?t.resolver:null}setResolver(e,t){let n=this.getNode(e);n||(this.setItem(e,null),n=this.getNode(e)),n.resolver=t}setCallbackItem(e,t,n={}){let s=new Ft({callback:t,...n});this.setResolver(e,s)}move(e,t,n=!0){this._nodes.move(e,t,n)}asDict(e=!1,t=!1,n=!1,s=!1){let i={};for(let a of this._nodes){let o=a.value;if(s&&o==null)continue;let l=a.label;e&&(l=String(l)),t&&(l=l.toLowerCase()),n&&o instanceof r&&(o=r.prototype.asDict.call(o,e,t,n,s)),Object.defineProperty(i,l,{value:o,enumerable:!0,writable:!0,configurable:!0})}return i}setdefault(e,t=null){let n=this.getNode(e);return n?n.value:(this.setItem(e,t),t)}deepcopy(e=!1){let t=this.createChildBag();for(let n of this._nodes){let s=n.getValue(!e);s instanceof r&&(s=s.deepcopy(e));let i=new t.nodeClass(t,n.label,s);i.setAttr({...n.attr},!1,!1,!1),i.nodeTag=n.nodeTag,i.xmlTag=n.xmlTag,t._nodes._list.push(i),t._nodes._dict[i.label]=i}return t}update(e,t=null,n=null,s=!1){if(!(e instanceof r)){for(let i in e){let a=e[i];(!s||a!==null||!this._nodes.has(i))&&this.setItem(i,a,null,">",!1,!1,n,!1,n!==!1)}return}for(let i of[...e]){let a=i.label,o=t==="static"?i.resolver:null,l=o?null:i.getValue(),u=i.attr.__replace;delete i.attr.__replace;let c=this._nodes.get(a);if(c)if(c.setAttr(i.attr,n===null?!0:n,!0,!1),i.nodeTag!=null&&(c.nodeTag=i.nodeTag),i.xmlTag!=null&&(c.xmlTag=i.xmlTag),o)c.resolver=o,c.setValue(null,n===null?!0:n,null,null,!1,n);else{i.resolver&&(c.resolver=null);let d=c.getValue();l instanceof r&&d instanceof r&&!u?d.update(l,t,n,s):(!s||l!==null)&&c.setValue(l,n===null?!0:n,null,null,!1,n)}else{let d=this.setItem(a,o||l,i.attr,">",!1,!1,n,!1,n!==!1);d.nodeTag=i.nodeTag,d.xmlTag=i.xmlTag}}}_fillFromBag(e){this.clear();for(let t of e){let n=new this.nodeClass(this,t.label);n.replace(t),n.nodeTag=t.nodeTag,n.xmlTag=t.xmlTag,this._nodes._list.push(n),this._nodes._dict[n.label]=n}}_appendLiteral(e,t,n=null,s=null,i=null){if(typeof e!="string")throw new TypeError("Bag labels must be strings");let a=new this.nodeClass(this,e,null,n,s,i,null,!1);return t instanceof Z?a.resolver=t:a._value=t,this._nodes._dict[e]=a,this._nodes._list.push(a),a}fillFrom(e=null,t={}){let n=ya(t);if(e!=null&&!Sr(e)&&!Array.isArray(e))throw new TypeError("Bag source must be a dictionary, array or null");let s=this.createChildBag(),i=new Set,a=(o,l,u)=>{if(i.has(l))throw new TypeError(`Cyclic Bag source at ${u}`);i.add(l);try{let c=Array.isArray(l)?String(l.length).length+1:0,d=Array.isArray(l)?Array.from(l,(f,h)=>[`r_${String(h).padStart(c,"0")}`,f]):Object.entries(l);if(!Array.isArray(l)&&Object.getOwnPropertySymbols(l).some(f=>Object.prototype.propertyIsEnumerable.call(l,f)))throw new TypeError(`Bag labels must be strings at ${u}`);for(let[f,h]of d){let p=h;n&&(Sr(p)||Array.isArray(p))&&(p=this.createChildBag(),a(p,h,`${u}[${JSON.stringify(f)}]`)),o._appendLiteral(f,p)}}finally{i.delete(l)}};return e!=null&&a(s,e,"$"),this._replacePrepared(s)}_loadSource(e,t={}){return this.fillFrom(e,t)}replace(e){if(!(e instanceof r))throw new TypeError("Bag.replace expects a Bag");if(e===this)return this;let t=this.createChildBag();return t._fillFromBag(e),this._replacePrepared(t)}_replacePrepared(e){for(let n of this._nodes){n.parentBag=null;let s=n.getValue(!0);s instanceof r&&s.clearBackref()}let t=this._nodes;this._nodes=e._nodes,e._nodes=t,this._nodes._parentBag=this.backref?this:null,e._nodes._parentBag=null;for(let n of this._nodes)n.parentBag=this;for(let n of e._nodes)n._parentBag=e;return this.backref&&this.parent&&this.parentNode&&this.parent._onNodeChanged(this.parentNode,[this.parentNode.label],"upd_value",e),this}forEach(e,{static:t=!0,deep:n=!1,kwargs:s={}}={}){if(typeof e!="function")throw new TypeError("forEach requires a callback");let i=(a,o)=>{for(let l=0;l<a._nodes.length;l++){let u=a._nodes._list[l],c={...o};"_pathlist"in o&&(c._pathlist=[...o._pathlist,u.label]),"_indexlist"in o&&(c._indexlist=[...o._indexlist,l]);let d=e(u,c,l);if(d)return d;if(d==null&&n){let f=u.getValue(t);if(f instanceof r){let h=i(f,c);if(h)return h}}}return null};return i(this,s)}*traverse(){for(let e of this._nodes){yield e;let t=e.getValue(!0);t instanceof r&&(yield*t.traverse())}}*_iterNodesWithPaths(e=!0,t=""){for(let n of this._nodes){let s=t?`${t}.${n.label}`:n.label;yield[s,n];let i=n.getValue(e);i instanceof r&&(yield*i._iterNodesWithPaths(e,s))}}*_nodeFlattener(e=null){let t=e!==null,n=t?Object.create(null):null,s=0,i=new Map([["[]",this.constructor]]);for(let[a,o]of ru(this)){let l=a.slice(0,-1),u=JSON.stringify(a),c=JSON.stringify(l),d=o.getValue(!0),f,h=null;if(o.resolver)f=wn(o.resolver);else if(d instanceof r){let g=d.constructor,_=g.tytxSuffix;i.set(u,g),h=wa(g,xr(i.get(c),_)),f=`::${_}`}else d===null?f="::NN":f=Et(d);if(o.attr&&Object.hasOwn(o.attr,Fe))throw new te(`node '${a}': the attribute '${Fe}' is reserved for the Bag class name`);let p=js(Et(o.attr));h!==null&&(p[Fe]=h);let m=o.nodeTag;t?(yield[l.length?n[c]:null,o.label,m,f,p],d instanceof r&&(n[u]=s,e[s]=a,s++)):yield[l,o.label,m,f,p]}}toTytx(e="json",t=!1){let n=this._toTytxPayload(t),s=this.constructor.tytxSuffix;if(e==="json")return`${n}::${s}`;if(e==="msgpack")return ds(new $e(4,new TextEncoder().encode(`${s}:${n}`)));throw new TypeError(`Unsupported transport: ${e}`)}_toTytxPayload(e=!1){let t;if(e){let i={};t={rows:[...this._nodeFlattener(i)],paths:i}}else t={rows:[...this._nodeFlattener(null)]};let n=this.constructor,s=wa(n,xr(null,n.tytxSuffix));return s!==null&&(t[Fe]=s),t.rows=t.rows.map(([i,a,o,l,u])=>[Et(i),Et(a),Et(o),l,u]),t.paths&&(t.paths=Et(t.paths)),W(t)}static fromTytx(e,t="json",n={}){if(Sr(t)&&(n=t,t="json"),ya(n),typeof e!="string"&&!(e instanceof Uint8Array))throw new TypeError("fromTytx requires serialized text or bytes");if(t!=="json"&&t!=="msgpack")throw new TypeError(`Unsupported transport: ${t}`);t==="json"&&e instanceof Uint8Array&&(e=new TextDecoder().decode(e));let s=P(e,t==="json"?null:t);if(s instanceof r)return s;if(!Sr(s)&&!Array.isArray(s))throw new TypeError("fromTytx requires a dictionary, array or typed Bag root");return new this(s,n)}static _fromTytxPayload(e){let t=this.tytxSuffix;if(e==="")return new(xr(null,t));let n=P(e);if(!n||!Array.isArray(n.rows))throw new te("Invalid TYTX Bag: expected rows");let s=n.paths,i=s!=null,a=Object.hasOwn(n,Fe)?ba(t,n[Fe]):xr(null,t),o=new a,l=new Map([["[]",o]]);for(let u of n.rows){if(!Array.isArray(u)||u.length!==5)throw new te("Invalid TYTX Bag row");let[c,d,f,h,p]=u,m=c??"";if(i){if(c!==null&&!Object.hasOwn(s,c))throw new te(`Unknown TYTX parent reference: ${c}`);m=c===null?"":s[c]}if(typeof m=="string"&&(m=m?m.split("."):[]),!Array.isArray(m))throw new te("Invalid TYTX parent path");let g=JSON.stringify(m);if(!l.has(g))throw new te(`Missing or undecodable TYTX parent branch: ${m}`);let _=l.get(g),w=JSON.stringify([...m,d]),y=h,k=Fs(y),T=_a(p),v=Object.hasOwn(T,Fe)?T[Fe]:null;if(delete T[Fe],y instanceof r){let L=y.constructor.tytxSuffix,U=v!==null?ba(L,v):xr(_.constructor,L);y=new U,l.set(w,y)}else if(v!==null)throw new te(`node '${w}': the attribute '${Fe}' is reserved for the Bag class name of a branch`);let N=_._appendLiteral(d,k?null:y,T,k);N.nodeTag=f??null}return o}toXml(e={}){let{pretty:t=!1,encoding:n="UTF-8",docHeader:s=null,selfClosedTags:i=null}=e,a=this._bagToXml(i,t);return s===!0?a=`<?xml version='1.0' encoding='${n}'?>
16
- ${a}`:typeof s=="string"&&(a=`${s}
17
- ${a}`),a}_bagToXml(e=null,t=!1,n=0){let s=[];for(let i of this._nodes)s.push((t?" ".repeat(n):"")+this._nodeToXml(i,e,t,n));return s.join(t?`
18
- `:"")}_nodeToXml(e,t=null,n=!1,s=0){let i=e.xmlTag||e.nodeTag||e.label,a=this._sanitizeTag(i),o=[];if(a!==i&&o.push(`_tag="${this._escapeAttr(i)}"`),e.resolver&&o.push(`_resolver="${this._escapeAttr(wn(e.resolver))}"`),e.attr)for(let[f,h]of Object.entries(js(e.attr)))h!==null&&h!==!1&&h!==void 0&&o.push(`${f}="${this._escapeAttr(String(h))}"`);let l=o.length?" "+o.join(" "):"",u=e.resolver?null:e.getValue(!0);if(u&&typeof u._bagToXml=="function"){n=n&&e.attr?.["xml:space"]!=="preserve";let f=u._bagToXml(t,n,s+1);return f?n?`<${a}${l}>
13
+ `)}function Vl(r){if(r=r||{},r.locator===void 0&&(r.locator=!0),this.assign=r.assign||Pt.assign,this.domHandler=r.domHandler||$s,this.onError=r.onError||r.errorHandler,r.errorHandler&&typeof r.errorHandler!="function")throw new TypeError("errorHandler object is no longer supported, switch to onError!");r.errorHandler&&r.errorHandler("warning","The `errorHandler` option has been deprecated, use `onError` instead!",this),this.normalizeLineEndings=r.normalizeLineEndings||ql,this.locator=!!r.locator,this.xmlns=this.assign(Object.create(null),r.xmlns)}Vl.prototype.parseFromString=function(r,e){if(!zh(e))throw new TypeError('DOMParser.parseFromString: the provided mimeType "'+e+'" is not valid.');var t=this.assign(Object.create(null),this.xmlns),n=Pl.XML_ENTITIES,s=t[""]||null;Vh(e)?(n=Pl.HTML_ENTITIES,s=mo.HTML):e===Ul.XML_SVG_IMAGE&&(s=mo.SVG),t[""]=s,t.xml=t.xml||mo.XML;var i=new this.domHandler({mimeType:e,defaultNamespace:s,onError:this.onError}),o=this.locator?{}:void 0;this.locator&&i.setDocumentLocator(o);var a=new Wh;a.errorHandler=i,a.domBuilder=i;var l=!Pt.isHTMLMimeType(e);return l&&typeof r!="string"&&a.errorHandler.fatalError("source is not a string"),a.parse(this.normalizeLineEndings(String(r)),t,n),i.doc.documentElement||a.errorHandler.fatalError("missing root element"),i.doc};function $s(r){var e=r||{};this.mimeType=e.mimeType||Ul.XML_APPLICATION,this.defaultNamespace=e.defaultNamespace||null,this.cdata=!1,this.currentElement=void 0,this.doc=void 0,this.locator=void 0,this.onError=e.onError}function xr(r,e){e.lineNumber=r.lineNumber,e.columnNumber=r.columnNumber}$s.prototype={startDocument:function(){var r=new qh;this.doc=Hh(this.mimeType)?r.createHTMLDocument(!1):r.createDocument(this.defaultNamespace,"")},startElement:function(r,e,t,n){var s=this.doc,i=s.createElementNS(r,t||e),o=n.length;Ms(this,i),this.currentElement=i,this.locator&&xr(this.locator,i);for(var a=0;a<o;a++){var r=n.getURI(a),l=n.getValue(a),t=n.getQName(a),u=s.createAttributeNS(r,t);this.locator&&xr(n.getLocator(a),u),u.value=u.nodeValue=l,i.setAttributeNode(u)}},endElement:function(r,e,t){this.currentElement=this.currentElement.parentNode},startPrefixMapping:function(r,e){},endPrefixMapping:function(r){},processingInstruction:function(r,e){var t=this.doc.createProcessingInstruction(r,e);this.locator&&xr(this.locator,t),Ms(this,t)},ignorableWhitespace:function(r,e,t){},characters:function(r,e,t){if(r=jl.apply(this,arguments),r){if(this.cdata)var n=this.doc.createCDATASection(r);else var n=this.doc.createTextNode(r);this.currentElement?this.currentElement.appendChild(n):/^\s*$/.test(r)&&this.doc.appendChild(n),this.locator&&xr(this.locator,n)}},skippedEntity:function(r){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(r){r&&(r.lineNumber=0),this.locator=r},comment:function(r,e,t){r=jl.apply(this,arguments);var n=this.doc.createComment(r);this.locator&&xr(this.locator,n),Ms(this,n)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(r,e,t,n){var s=this.doc.implementation;if(s&&s.createDocumentType){var i=s.createDocumentType(r,e,t,n);this.locator&&xr(this.locator,i),Ms(this,i),this.doc.doctype=i}},reportError:function(r,e){if(typeof this.onError=="function")try{this.onError(r,e,this)}catch(t){throw new Fl("Reporting "+r+' "'+e+'" caused '+t,this.locator)}else console.error("[xmldom "+r+"] "+e,Gh(this.locator))},warning:function(r){this.reportError("warning",r)},error:function(r){this.reportError("error",r)},fatalError:function(r,e){throw this.reportError("fatalError",r),new Fl(r,this.locator,e)}};function Gh(r){if(r)return`
14
+ @#[line:`+r.lineNumber+",col:"+r.columnNumber+"]"}function jl(r,e,t){return typeof r=="string"?r.substr(e,t):r.length>=e+t||e?new java.lang.String(r,e,t)+"":r}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(r){$s.prototype[r]=function(){return null}});function Ms(r,e){r.currentElement?r.currentElement.appendChild(e):r.doc.appendChild(e)}function Xh(r){if(r==="error")throw"onErrorStopParsing"}function Yh(){throw"onWarningStopParsing"}Dr.__DOMHandler=$s;Dr.DOMParser=Vl;Dr.normalizeLineEndings=ql;Dr.onErrorStopParsing=Xh;Dr.onWarningStopParsing=Yh});var go=lt(j=>{"use strict";var Sr=$t();j.assign=Sr.assign;j.hasDefaultHTMLNamespace=Sr.hasDefaultHTMLNamespace;j.isHTMLMimeType=Sr.isHTMLMimeType;j.isValidMimeType=Sr.isValidMimeType;j.MIME_TYPE=Sr.MIME_TYPE;j.NAMESPACE=Sr.NAMESPACE;var Ls=on();j.DOMException=Ls.DOMException;j.DOMExceptionName=Ls.DOMExceptionName;j.ExceptionCode=Ls.ExceptionCode;j.ParseError=Ls.ParseError;var ae=ho();j.Attr=ae.Attr;j.CDATASection=ae.CDATASection;j.CharacterData=ae.CharacterData;j.Comment=ae.Comment;j.Document=ae.Document;j.DocumentFragment=ae.DocumentFragment;j.DocumentType=ae.DocumentType;j.DOMImplementation=ae.DOMImplementation;j.Element=ae.Element;j.Entity=ae.Entity;j.EntityReference=ae.EntityReference;j.LiveNodeList=ae.LiveNodeList;j.NamedNodeMap=ae.NamedNodeMap;j.Node=ae.Node;j.NodeList=ae.NodeList;j.Notation=ae.Notation;j.ProcessingInstruction=ae.ProcessingInstruction;j.Text=ae.Text;j.XMLSerializer=ae.XMLSerializer;var Ps=Hl();j.DOMParser=Ps.DOMParser;j.normalizeLineEndings=Ps.normalizeLineEndings;j.onErrorStopParsing=Ps.onErrorStopParsing;j.onWarningStopParsing=Ps.onWarningStopParsing});var Vr=class{constructor(e,{fetcher:t=globalThis.fetch?.bind(globalThis),closeUrl:n="/gramlot/close",navigator:s=globalThis.navigator,XMLHttpRequest:i=globalThis.XMLHttpRequest}={}){this.rpcUrl=e,this.fetcher=t,this.closeUrl=n,this.navigator=s,this.XMLHttpRequest=i}get supportsCallSync(){return!0}async call(e,t){let n=await this.fetcher(this.rpcUrl,{method:"POST",credentials:"same-origin",signal:t,headers:{"Content-Type":"application/json"},body:e});if(n.status!==200)throw new Error(`rpc failed: HTTP ${n.status}`);return n.text()}callSync(e){let t=new this.XMLHttpRequest;if(t.open("POST",this.rpcUrl,!1),t.setRequestHeader("Content-Type","application/json"),t.send(e),t.status!==200)throw new Error(`rpc failed: HTTP ${t.status}`);return t.responseText}close(e,{beacon:t=!1}={}){let n=JSON.stringify({pageId:e});t?this.navigator.sendBeacon(this.closeUrl,new Blob([n],{type:"application/json"})):this.fetcher(this.closeUrl,{method:"POST",credentials:"same-origin",keepalive:!0,headers:{"Content-Type":"application/json"},body:n})}dispose(){}};var ut=class{createTransport({rpcUrl:e,closeUrl:t,document:n}){let s=n.defaultView;return new Vr(e,{closeUrl:t,navigator:s.navigator,XMLHttpRequest:s.XMLHttpRequest})}};function V(r){if(typeof r!="string"||!["^","="].includes(r[0])||r.startsWith("=="))return null;let e=r.indexOf(":");if(e<0)return null;let t=r[e+1]==="=";return{pointer:r.slice(0,e),expression:t,body:r.slice(e+(t?2:1))}}var aa=/^\{(\??[A-Za-z_][A-Za-z0-9_]*|\?)?\}/;function Hr(r,e){let t="",n=!1;for(let s=0;s<r.length;){if(r[s]!=="{"&&r[s]!=="}"){t+=r[s++];continue}let i=r.slice(s).match(aa);if(!i)throw new SyntaxError("Invalid pointer template placeholder");let o=i[1]??"",a=o.startsWith("?"),l=e(a?o.slice(1):o);l==null||l===""&&!a?n=!0:t+=String(l),s+=i[0].length}return n?null:t}function zr(r){let e=[],t=new Set,n="",s=!0;for(let i=0;i<r.length;){let o=i,a=r[i];if(a==='"'||a==="'"||a==="`"){for(i++;i<r.length;){if(r[i]==="\\"){i+=2;continue}if(r[i++]===a)break}n+=r.slice(o,i),s=!1;continue}if(r.startsWith("//",i)){i=r.indexOf(`
15
+ `,i),i<0&&(i=r.length),n+=r.slice(o,i);continue}if(r.startsWith("/*",i)){let c=r.indexOf("*/",i+2);i=c<0?r.length:c+2,n+=r.slice(o,i);continue}if(a==="/"&&s){let c=!1;for(i++;i<r.length;){let d=r[i++];if(d==="\\"){i++;continue}if(d==="[")c=!0;else if(d==="]")c=!1;else if(d==="/"&&!c)break}for(;/[a-z]/i.test(r[i]??"")&&i<r.length;)i++;n+=r.slice(o,i),s=!1;continue}let l=a==="{"?r.slice(i).match(aa):null;if(l){let c=l[1]??"";if(c.startsWith("?"))throw new SyntaxError("Optional slots are supported in pointer templates only");n+=`_pointerValues[${e.length}]`,e.push(c),i+=l[0].length,s=!1;continue}let u=r.slice(i).match(/^[A-Za-z_$][\w$]*/);if(u){t.add(u[0]),n+=u[0],i+=u[0].length,s=["return","typeof","void","delete","new","in","instanceof","yield","await"].includes(u[0]);continue}n+=a,i++,/\s/.test(a)||(s=/[([{,:;=!?&|+*%~<>\/-]/.test(a))}return{text:n,slots:e,identifiers:t}}function la(r,e,t=()=>null){let n=new Map,s=[],i=o=>{if(n.has(o))return n.get(o);if(!r.has(o))throw new Error(`Referenced Source attribute '${o}' does not exist`);if(s.includes(o))throw new Error(`Cyclic attribute dependency: ${[...s,o].join(" -> ")}`);s.push(o);try{let a=r.get(o),l=typeof o=="string"?V(a):null,u=e.get(o);if(l){let c=d=>d?i(d):e.get(o);if(l.expression){let d=zr(l.body);u=t(o,a,d,d.slots.map(c))}else u=Hr(l.body,c),e.get(o)==null&&(u=null)}return n.set(o,u),u}finally{s.pop()}};return new Map([...r.keys()].map(o=>[o,i(o)]))}function He(r,e){let t=new Map([...Object.entries(r.getAttr()),...r.fixedAttrItems()]),n=new Set,s=[],i=o=>{let a=V(o);if(!a)return;let l=[];a.expression?l.push(...zr(a.body).slots):Hr(a.body,u=>(l.push(u),""));for(let u of l.filter(Boolean)){if(!t.has(u))throw new Error(`Referenced Source attribute '${u}' does not exist`);if(s.includes(u))throw new Error(`Cyclic attribute dependency: ${[...s,u].join(" -> ")}`);n.has(u)||(s.push(u),i(t.get(u)),s.pop(),n.add(u))}};return i(e),n}var lr=9e15,ht=1e9,Oi="0123456789abcdef",ls="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",us="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Bi={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-lr,maxE:lr,crypto:!1},fa,tt,O=!0,ds="[DecimalError] ",ft=ds+"Invalid argument: ",ha=ds+"Precision limit exceeded",pa=ds+"crypto unavailable",ma="[object Decimal]",pe=Math.floor,ie=Math.pow,Cc=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Nc=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ic=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ga=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,$e=1e7,S=7,Oc=9007199254740991,Bc=ls.length-1,Ri=us.length-1,_={toStringTag:ma};_.absoluteValue=_.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),x(r)};_.ceil=function(){return x(new this.constructor(this),this.e+1,2)};_.clampedTo=_.clamp=function(r,e){var t,n=this,s=n.constructor;if(r=new s(r),e=new s(e),!r.s||!e.s)return new s(NaN);if(r.gt(e))throw Error(ft+e);return t=n.cmp(r),t<0?r:n.cmp(e)>0?e:new s(n)};_.comparedTo=_.cmp=function(r){var e,t,n,s,i=this,o=i.d,a=(r=new i.constructor(r)).d,l=i.s,u=r.s;if(!o||!a)return!l||!u?NaN:l!==u?l:o===a?0:!o^l<0?1:-1;if(!o[0]||!a[0])return o[0]?l:a[0]?-u:0;if(l!==u)return l;if(i.e!==r.e)return i.e>r.e^l<0?1:-1;for(n=o.length,s=a.length,e=0,t=n<s?n:s;e<t;++e)if(o[e]!==a[e])return o[e]>a[e]^l<0?1:-1;return n===s?0:n>s^l<0?1:-1};_.cosine=_.cos=function(){var r,e,t=this,n=t.constructor;return t.d?t.d[0]?(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+S,n.rounding=1,t=Rc(n,va(n,t)),n.precision=r,n.rounding=e,x(tt==2||tt==3?t.neg():t,r,e,!0)):new n(1):new n(NaN)};_.cubeRoot=_.cbrt=function(){var r,e,t,n,s,i,o,a,l,u,c=this,d=c.constructor;if(!c.isFinite()||c.isZero())return new d(c);for(O=!1,i=c.s*ie(c.s*c,1/3),!i||Math.abs(i)==1/0?(t=ue(c.d),r=c.e,(i=(r-t.length+1)%3)&&(t+=i==1||i==-2?"0":"00"),i=ie(t,1/3),r=pe((r+1)/3)-(r%3==(r<0?-1:2)),i==1/0?t="5e"+r:(t=i.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),n=new d(t),n.s=c.s):n=new d(i.toString()),o=(r=d.precision)+3;;)if(a=n,l=a.times(a).times(a),u=l.plus(c),n=X(u.plus(c).times(a),u.plus(l),o+2,1),ue(a.d).slice(0,o)===(t=ue(n.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!s&&t=="4999"){if(!s&&(x(a,r+1,0),a.times(a).times(a).eq(c))){n=a;break}o+=4,s=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(x(n,r+1,1),e=!n.times(n).times(n).eq(c));break}return O=!0,x(n,r,d.rounding,e)};_.decimalPlaces=_.dp=function(){var r,e=this.d,t=NaN;if(e){if(r=e.length-1,t=(r-pe(this.e/S))*S,r=e[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t};_.dividedBy=_.div=function(r){return X(this,new this.constructor(r))};_.dividedToIntegerBy=_.divToInt=function(r){var e=this,t=e.constructor;return x(X(e,new t(r),0,1,1),t.precision,t.rounding)};_.equals=_.eq=function(r){return this.cmp(r)===0};_.floor=function(){return x(new this.constructor(this),this.e+1,3)};_.greaterThan=_.gt=function(r){return this.cmp(r)>0};_.greaterThanOrEqualTo=_.gte=function(r){var e=this.cmp(r);return e==1||e===0};_.hyperbolicCosine=_.cosh=function(){var r,e,t,n,s,i=this,o=i.constructor,a=new o(1);if(!i.isFinite())return new o(i.s?1/0:NaN);if(i.isZero())return a;t=o.precision,n=o.rounding,o.precision=t+Math.max(i.e,i.sd())+4,o.rounding=1,s=i.d.length,s<32?(r=Math.ceil(s/3),e=(1/hs(4,r)).toString()):(r=16,e="2.3283064365386962890625e-10"),i=ur(o,1,i.times(e),new o(1),!0);for(var l,u=r,c=new o(8);u--;)l=i.times(i),i=a.minus(l.times(c.minus(l.times(c))));return x(i,o.precision=t,o.rounding=n,!0)};_.hyperbolicSine=_.sinh=function(){var r,e,t,n,s=this,i=s.constructor;if(!s.isFinite()||s.isZero())return new i(s);if(e=i.precision,t=i.rounding,i.precision=e+Math.max(s.e,s.sd())+4,i.rounding=1,n=s.d.length,n<3)s=ur(i,2,s,s,!0);else{r=1.4*Math.sqrt(n),r=r>16?16:r|0,s=s.times(1/hs(5,r)),s=ur(i,2,s,s,!0);for(var o,a=new i(5),l=new i(16),u=new i(20);r--;)o=s.times(s),s=s.times(a.plus(o.times(l.times(o).plus(u))))}return i.precision=e,i.rounding=t,x(s,e,t,!0)};_.hyperbolicTangent=_.tanh=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+7,n.rounding=1,X(t.sinh(),t.cosh(),n.precision=r,n.rounding=e)):new n(t.s)};_.inverseCosine=_.acos=function(){var r=this,e=r.constructor,t=r.abs().cmp(1),n=e.precision,s=e.rounding;return t!==-1?t===0?r.isNeg()?ze(e,n,s):new e(0):new e(NaN):r.isZero()?ze(e,n+4,s).times(.5):(e.precision=n+6,e.rounding=1,r=new e(1).minus(r).div(r.plus(1)).sqrt().atan(),e.precision=n,e.rounding=s,r.times(2))};_.inverseHyperbolicCosine=_.acosh=function(){var r,e,t=this,n=t.constructor;return t.lte(1)?new n(t.eq(1)?0:NaN):t.isFinite()?(r=n.precision,e=n.rounding,n.precision=r+Math.max(Math.abs(t.e),t.sd())+4,n.rounding=1,O=!1,t=t.times(t).minus(1).sqrt().plus(t),O=!0,n.precision=r,n.rounding=e,t.ln()):new n(t)};_.inverseHyperbolicSine=_.asinh=function(){var r,e,t=this,n=t.constructor;return!t.isFinite()||t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+2*Math.max(Math.abs(t.e),t.sd())+6,n.rounding=1,O=!1,t=t.times(t).plus(1).sqrt().plus(t),O=!0,n.precision=r,n.rounding=e,t.ln())};_.inverseHyperbolicTangent=_.atanh=function(){var r,e,t,n,s=this,i=s.constructor;return s.isFinite()?s.e>=0?new i(s.abs().eq(1)?s.s/0:s.isZero()?s:NaN):(r=i.precision,e=i.rounding,n=s.sd(),Math.max(n,r)<2*-s.e-1?x(new i(s),r,e,!0):(i.precision=t=n-s.e,s=X(s.plus(1),new i(1).minus(s),t+r,1),i.precision=r+4,i.rounding=1,s=s.ln(),i.precision=r,i.rounding=e,s.times(.5))):new i(NaN)};_.inverseSine=_.asin=function(){var r,e,t,n,s=this,i=s.constructor;return s.isZero()?new i(s):(e=s.abs().cmp(1),t=i.precision,n=i.rounding,e!==-1?e===0?(r=ze(i,t+4,n).times(.5),r.s=s.s,r):new i(NaN):(i.precision=t+6,i.rounding=1,s=s.div(new i(1).minus(s.times(s)).sqrt().plus(1)).atan(),i.precision=t,i.rounding=n,s.times(2)))};_.inverseTangent=_.atan=function(){var r,e,t,n,s,i,o,a,l,u=this,c=u.constructor,d=c.precision,f=c.rounding;if(u.isFinite()){if(u.isZero())return new c(u);if(u.abs().eq(1)&&d+4<=Ri)return o=ze(c,d+4,f).times(.25),o.s=u.s,o}else{if(!u.s)return new c(NaN);if(d+4<=Ri)return o=ze(c,d+4,f).times(.5),o.s=u.s,o}for(c.precision=a=d+10,c.rounding=1,t=Math.min(28,a/S+2|0),r=t;r;--r)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(O=!1,e=Math.ceil(a/S),n=1,l=u.times(u),o=new c(u),s=u;r!==-1;)if(s=s.times(l),i=o.minus(s.div(n+=2)),s=s.times(l),o=i.plus(s.div(n+=2)),o.d[e]!==void 0)for(r=e;o.d[r]===i.d[r]&&r--;);return t&&(o=o.times(2<<t-1)),O=!0,x(o,c.precision=d,c.rounding=f,!0)};_.isFinite=function(){return!!this.d};_.isInteger=_.isInt=function(){return!!this.d&&pe(this.e/S)>this.d.length-2};_.isNaN=function(){return!this.s};_.isNegative=_.isNeg=function(){return this.s<0};_.isPositive=_.isPos=function(){return this.s>0};_.isZero=function(){return!!this.d&&this.d[0]===0};_.lessThan=_.lt=function(r){return this.cmp(r)<0};_.lessThanOrEqualTo=_.lte=function(r){return this.cmp(r)<1};_.logarithm=_.log=function(r){var e,t,n,s,i,o,a,l,u=this,c=u.constructor,d=c.precision,f=c.rounding,h=5;if(r==null)r=new c(10),e=!0;else{if(r=new c(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new c(NaN);e=r.eq(10)}if(t=u.d,u.s<0||!t||!t[0]||u.eq(1))return new c(t&&!t[0]?-1/0:u.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)i=!0;else{for(s=t[0];s%10===0;)s/=10;i=s!==1}if(O=!1,a=d+h,o=dt(u,a),n=e?cs(c,a+10):dt(r,a),l=X(o,n,a,1),Wr(l.d,s=d,f))do if(a+=10,o=dt(u,a),n=e?cs(c,a+10):dt(r,a),l=X(o,n,a,1),!i){+ue(l.d).slice(s+1,s+15)+1==1e14&&(l=x(l,d+1,0));break}while(Wr(l.d,s+=10,f));return O=!0,x(l,d,f)};_.minus=_.sub=function(r){var e,t,n,s,i,o,a,l,u,c,d,f,h=this,p=h.constructor;if(r=new p(r),!h.d||!r.d)return!h.s||!r.s?r=new p(NaN):h.d?r.s=-r.s:r=new p(r.d||h.s!==r.s?h:NaN),r;if(h.s!=r.s)return r.s=-r.s,h.plus(r);if(u=h.d,f=r.d,a=p.precision,l=p.rounding,!u[0]||!f[0]){if(f[0])r.s=-r.s;else if(u[0])r=new p(h);else return new p(l===3?-0:0);return O?x(r,a,l):r}if(t=pe(r.e/S),c=pe(h.e/S),u=u.slice(),i=c-t,i){for(d=i<0,d?(e=u,i=-i,o=f.length):(e=f,t=c,o=u.length),n=Math.max(Math.ceil(a/S),o)+2,i>n&&(i=n,e.length=1),e.reverse(),n=i;n--;)e.push(0);e.reverse()}else{for(n=u.length,o=f.length,d=n<o,d&&(o=n),n=0;n<o;n++)if(u[n]!=f[n]){d=u[n]<f[n];break}i=0}for(d&&(e=u,u=f,f=e,r.s=-r.s),o=u.length,n=f.length-o;n>0;--n)u[o++]=0;for(n=f.length;n>i;){if(u[--n]<f[n]){for(s=n;s&&u[--s]===0;)u[s]=$e-1;--u[s],u[n]+=$e}u[n]-=f[n]}for(;u[--o]===0;)u.pop();for(;u[0]===0;u.shift())--t;return u[0]?(r.d=u,r.e=fs(u,t),O?x(r,a,l):r):new p(l===3?-0:0)};_.modulo=_.mod=function(r){var e,t=this,n=t.constructor;return r=new n(r),!t.d||!r.s||r.d&&!r.d[0]?new n(NaN):!r.d||t.d&&!t.d[0]?x(new n(t),n.precision,n.rounding):(O=!1,n.modulo==9?(e=X(t,r.abs(),0,3,1),e.s*=r.s):e=X(t,r,0,n.modulo,1),e=e.times(r),O=!0,t.minus(e))};_.naturalExponential=_.exp=function(){return Mi(this)};_.naturalLogarithm=_.ln=function(){return dt(this)};_.negated=_.neg=function(){var r=new this.constructor(this);return r.s=-r.s,x(r)};_.plus=_.add=function(r){var e,t,n,s,i,o,a,l,u,c,d=this,f=d.constructor;if(r=new f(r),!d.d||!r.d)return!d.s||!r.s?r=new f(NaN):d.d||(r=new f(r.d||d.s===r.s?d:NaN)),r;if(d.s!=r.s)return r.s=-r.s,d.minus(r);if(u=d.d,c=r.d,a=f.precision,l=f.rounding,!u[0]||!c[0])return c[0]||(r=new f(d)),O?x(r,a,l):r;if(i=pe(d.e/S),n=pe(r.e/S),u=u.slice(),s=i-n,s){for(s<0?(t=u,s=-s,o=c.length):(t=c,n=i,o=u.length),i=Math.ceil(a/S),o=i>o?i+1:o+1,s>o&&(s=o,t.length=1),t.reverse();s--;)t.push(0);t.reverse()}for(o=u.length,s=c.length,o-s<0&&(s=o,t=c,c=u,u=t),e=0;s;)e=(u[--s]=u[s]+c[s]+e)/$e|0,u[s]%=$e;for(e&&(u.unshift(e),++n),o=u.length;u[--o]==0;)u.pop();return r.d=u,r.e=fs(u,n),O?x(r,a,l):r};_.precision=_.sd=function(r){var e,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(ft+r);return t.d?(e=ba(t.d),r&&t.e+1>e&&(e=t.e+1)):e=NaN,e};_.round=function(){var r=this,e=r.constructor;return x(new e(r),r.e+1,e.rounding)};_.sine=_.sin=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+Math.max(t.e,t.sd())+S,n.rounding=1,t=$c(n,va(n,t)),n.precision=r,n.rounding=e,x(tt>2?t.neg():t,r,e,!0)):new n(NaN)};_.squareRoot=_.sqrt=function(){var r,e,t,n,s,i,o=this,a=o.d,l=o.e,u=o.s,c=o.constructor;if(u!==1||!a||!a[0])return new c(!u||u<0&&(!a||a[0])?NaN:a?o:1/0);for(O=!1,u=Math.sqrt(+o),u==0||u==1/0?(e=ue(a),(e.length+l)%2==0&&(e+="0"),u=Math.sqrt(e),l=pe((l+1)/2)-(l<0||l%2),u==1/0?e="5e"+l:(e=u.toExponential(),e=e.slice(0,e.indexOf("e")+1)+l),n=new c(e)):n=new c(u.toString()),t=(l=c.precision)+3;;)if(i=n,n=i.plus(X(o,i,t+2,1)).times(.5),ue(i.d).slice(0,t)===(e=ue(n.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!s&&e=="4999"){if(!s&&(x(i,l+1,0),i.times(i).eq(o))){n=i;break}t+=4,s=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(x(n,l+1,1),r=!n.times(n).eq(o));break}return O=!0,x(n,l,c.rounding,r)};_.tangent=_.tan=function(){var r,e,t=this,n=t.constructor;return t.isFinite()?t.isZero()?new n(t):(r=n.precision,e=n.rounding,n.precision=r+10,n.rounding=1,t=t.sin(),t.s=1,t=X(t,new n(1).minus(t.times(t)).sqrt(),r+10,0),n.precision=r,n.rounding=e,x(tt==2||tt==4?t.neg():t,r,e,!0)):new n(NaN)};_.times=_.mul=function(r){var e,t,n,s,i,o,a,l,u,c=this,d=c.constructor,f=c.d,h=(r=new d(r)).d;if(r.s*=c.s,!f||!f[0]||!h||!h[0])return new d(!r.s||f&&!f[0]&&!h||h&&!h[0]&&!f?NaN:!f||!h?r.s/0:r.s*0);for(t=pe(c.e/S)+pe(r.e/S),l=f.length,u=h.length,l<u&&(i=f,f=h,h=i,o=l,l=u,u=o),i=[],o=l+u,n=o;n--;)i.push(0);for(n=u;--n>=0;){for(e=0,s=l+n;s>n;)a=i[s]+h[n]*f[s-n-1]+e,i[s--]=a%$e|0,e=a/$e|0;i[s]=(i[s]+e)%$e|0}for(;!i[--o];)i.pop();return e?++t:i.shift(),r.d=i,r.e=fs(i,t),O?x(r,d.precision,d.rounding):r};_.toBinary=function(r,e){return $i(this,2,r,e)};_.toDecimalPlaces=_.toDP=function(r,e){var t=this,n=t.constructor;return t=new n(t),r===void 0?t:(Ee(r,0,ht),e===void 0?e=n.rounding:Ee(e,0,8),x(t,r+t.e+1,e))};_.toExponential=function(r,e){var t,n=this,s=n.constructor;return r===void 0?t=We(n,!0):(Ee(r,0,ht),e===void 0?e=s.rounding:Ee(e,0,8),n=x(new s(n),r+1,e),t=We(n,!0,r+1)),n.isNeg()&&!n.isZero()?"-"+t:t};_.toFixed=function(r,e){var t,n,s=this,i=s.constructor;return r===void 0?t=We(s):(Ee(r,0,ht),e===void 0?e=i.rounding:Ee(e,0,8),n=x(new i(s),r+s.e+1,e),t=We(n,!1,r+n.e+1)),s.isNeg()&&!s.isZero()?"-"+t:t};_.toFraction=function(r){var e,t,n,s,i,o,a,l,u,c,d,f,h=this,p=h.d,m=h.constructor;if(!p)return new m(h);if(u=t=new m(1),n=l=new m(0),e=new m(n),i=e.e=ba(p)-h.e-1,o=i%S,e.d[0]=ie(10,o<0?S+o:o),r==null)r=i>0?e:u;else{if(a=new m(r),!a.isInt()||a.lt(u))throw Error(ft+a);r=a.gt(e)?i>0?e:u:a}for(O=!1,a=new m(ue(p)),c=m.precision,m.precision=i=p.length*S*2;d=X(a,e,0,1,1),s=t.plus(d.times(n)),s.cmp(r)!=1;)t=n,n=s,s=u,u=l.plus(d.times(s)),l=s,s=e,e=a.minus(d.times(s)),a=s;return s=X(r.minus(t),n,0,1,1),l=l.plus(s.times(u)),t=t.plus(s.times(n)),l.s=u.s=h.s,f=X(u,n,i,1).minus(h).abs().cmp(X(l,t,i,1).minus(h).abs())<1?[u,n]:[l,t],m.precision=c,O=!0,f};_.toHexadecimal=_.toHex=function(r,e){return $i(this,16,r,e)};_.toNearest=function(r,e){var t=this,n=t.constructor;if(t=new n(t),r==null){if(!t.d)return t;r=new n(1),e=n.rounding}else{if(r=new n(r),e===void 0?e=n.rounding:Ee(e,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(O=!1,t=X(t,r,0,e,1).times(r),O=!0,x(t)):(r.s=t.s,t=r),t};_.toNumber=function(){return+this};_.toOctal=function(r,e){return $i(this,8,r,e)};_.toPower=_.pow=function(r){var e,t,n,s,i,o,a=this,l=a.constructor,u=+(r=new l(r));if(!a.d||!r.d||!a.d[0]||!r.d[0])return new l(ie(+a,u));if(a=new l(a),a.eq(1))return a;if(n=l.precision,i=l.rounding,r.eq(1))return x(a,n,i);if(e=pe(r.e/S),e>=r.d.length-1&&(t=u<0?-u:u)<=Oc)return s=_a(l,a,t,n),r.s<0?new l(1).div(s):x(s,n,i);if(o=a.s,o<0){if(e<r.d.length-1)return new l(NaN);if((r.d[e]&1)==0&&(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return t=ie(+a,u),e=t==0||!isFinite(t)?pe(u*(Math.log("0."+ue(a.d))/Math.LN10+a.e+1)):new l(t+"").e,e>l.maxE+1||e<l.minE-1?new l(e>0?o/0:0):(O=!1,l.rounding=a.s=1,t=Math.min(12,(e+"").length),s=Mi(r.times(dt(a,n+t)),n),s.d&&(s=x(s,n+5,1),Wr(s.d,n,i)&&(e=n+10,s=x(Mi(r.times(dt(a,e+t)),e),e+5,1),+ue(s.d).slice(n+1,n+15)+1==1e14&&(s=x(s,n+1,0)))),s.s=o,O=!0,l.rounding=i,x(s,n,i))};_.toPrecision=function(r,e){var t,n=this,s=n.constructor;return r===void 0?t=We(n,n.e<=s.toExpNeg||n.e>=s.toExpPos):(Ee(r,1,ht),e===void 0?e=s.rounding:Ee(e,0,8),n=x(new s(n),r,e),t=We(n,r<=n.e||n.e<=s.toExpNeg,r)),n.isNeg()&&!n.isZero()?"-"+t:t};_.toSignificantDigits=_.toSD=function(r,e){var t=this,n=t.constructor;return r===void 0?(r=n.precision,e=n.rounding):(Ee(r,1,ht),e===void 0?e=n.rounding:Ee(e,0,8)),x(new n(t),r,e)};_.toString=function(){var r=this,e=r.constructor,t=We(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t};_.truncated=_.trunc=function(){return x(new this.constructor(this),this.e+1,1)};_.valueOf=_.toJSON=function(){var r=this,e=r.constructor,t=We(r,r.e<=e.toExpNeg||r.e>=e.toExpPos);return r.isNeg()?"-"+t:t};function ue(r){var e,t,n,s=r.length-1,i="",o=r[0];if(s>0){for(i+=o,e=1;e<s;e++)n=r[e]+"",t=S-n.length,t&&(i+=ct(t)),i+=n;o=r[e],n=o+"",t=S-n.length,t&&(i+=ct(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return i+o}function Ee(r,e,t){if(r!==~~r||r<e||r>t)throw Error(ft+r)}function Wr(r,e,t,n){var s,i,o,a;for(i=r[0];i>=10;i/=10)--e;return--e<0?(e+=S,s=0):(s=Math.ceil((e+1)/S),e%=S),i=ie(10,S-e),a=r[s]%i|0,n==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),o=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):o=(t<4&&a+1==i||t>3&&a+1==i/2)&&(r[s+1]/i/100|0)==ie(10,e-2)-1||(a==i/2||a==0)&&(r[s+1]/i/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),o=(n||t<4)&&a==9999||!n&&t>3&&a==4999):o=((n||t<4)&&a+1==i||!n&&t>3&&a+1==i/2)&&(r[s+1]/i/1e3|0)==ie(10,e-3)-1,o}function os(r,e,t){for(var n,s=[0],i,o=0,a=r.length;o<a;){for(i=s.length;i--;)s[i]*=e;for(s[0]+=Oi.indexOf(r.charAt(o++)),n=0;n<s.length;n++)s[n]>t-1&&(s[n+1]===void 0&&(s[n+1]=0),s[n+1]+=s[n]/t|0,s[n]%=t)}return s.reverse()}function Rc(r,e){var t,n,s;if(e.isZero())return e;n=e.d.length,n<32?(t=Math.ceil(n/3),s=(1/hs(4,t)).toString()):(t=16,s="2.3283064365386962890625e-10"),r.precision+=t,e=ur(r,1,e.times(s),new r(1));for(var i=t;i--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return r.precision-=t,e}var X=(function(){function r(n,s,i){var o,a=0,l=n.length;for(n=n.slice();l--;)o=n[l]*s+a,n[l]=o%i|0,a=o/i|0;return a&&n.unshift(a),n}function e(n,s,i,o){var a,l;if(i!=o)l=i>o?1:-1;else for(a=l=0;a<i;a++)if(n[a]!=s[a]){l=n[a]>s[a]?1:-1;break}return l}function t(n,s,i,o){for(var a=0;i--;)n[i]-=a,a=n[i]<s[i]?1:0,n[i]=a*o+n[i]-s[i];for(;!n[0]&&n.length>1;)n.shift()}return function(n,s,i,o,a,l){var u,c,d,f,h,p,m,g,b,y,w,k,A,v,N,L,U,ve,Y,ne,Ne=n.constructor,G=n.s==s.s?1:-1,se=n.d,M=s.d;if(!se||!se[0]||!M||!M[0])return new Ne(!n.s||!s.s||(se?M&&se[0]==M[0]:!M)?NaN:se&&se[0]==0||!M?G*0:G/0);for(l?(h=1,c=n.e-s.e):(l=$e,h=S,c=pe(n.e/h)-pe(s.e/h)),Y=M.length,U=se.length,b=new Ne(G),y=b.d=[],d=0;M[d]==(se[d]||0);d++);if(M[d]>(se[d]||0)&&c--,i==null?(v=i=Ne.precision,o=Ne.rounding):a?v=i+(n.e-s.e)+1:v=i,v<0)y.push(1),p=!0;else{if(v=v/h+2|0,d=0,Y==1){for(f=0,M=M[0],v++;(d<U||f)&&v--;d++)N=f*l+(se[d]||0),y[d]=N/M|0,f=N%M|0;p=f||d<U}else{for(f=l/(M[0]+1)|0,f>1&&(M=r(M,f,l),se=r(se,f,l),Y=M.length,U=se.length),L=Y,w=se.slice(0,Y),k=w.length;k<Y;)w[k++]=0;ne=M.slice(),ne.unshift(0),ve=M[0],M[1]>=l/2&&++ve;do f=0,u=e(M,w,Y,k),u<0?(A=w[0],Y!=k&&(A=A*l+(w[1]||0)),f=A/ve|0,f>1?(f>=l&&(f=l-1),m=r(M,f,l),g=m.length,k=w.length,u=e(m,w,g,k),u==1&&(f--,t(m,Y<g?ne:M,g,l))):(f==0&&(u=f=1),m=M.slice()),g=m.length,g<k&&m.unshift(0),t(w,m,k,l),u==-1&&(k=w.length,u=e(M,w,Y,k),u<1&&(f++,t(w,Y<k?ne:M,k,l))),k=w.length):u===0&&(f++,w=[0]),y[d++]=f,u&&w[0]?w[k++]=se[L]||0:(w=[se[L]],k=1);while((L++<U||w[0]!==void 0)&&v--);p=w[0]!==void 0}y[0]||y.shift()}if(h==1)b.e=c,fa=p;else{for(d=1,f=y[0];f>=10;f/=10)d++;b.e=d+c*h-1,x(b,a?i+b.e+1:i,o,p)}return b}})();function x(r,e,t,n){var s,i,o,a,l,u,c,d,f,h=r.constructor;e:if(e!=null){if(d=r.d,!d)return r;for(s=1,a=d[0];a>=10;a/=10)s++;if(i=e-s,i<0)i+=S,o=e,c=d[f=0],l=c/ie(10,s-o-1)%10|0;else if(f=Math.ceil((i+1)/S),a=d.length,f>=a)if(n){for(;a++<=f;)d.push(0);c=l=0,s=1,i%=S,o=i-S+1}else break e;else{for(c=a=d[f],s=1;a>=10;a/=10)s++;i%=S,o=i-S+s,l=o<0?0:c/ie(10,s-o-1)%10|0}if(n=n||e<0||d[f+1]!==void 0||(o<0?c:c%ie(10,s-o-1)),u=t<4?(l||n)&&(t==0||t==(r.s<0?3:2)):l>5||l==5&&(t==4||n||t==6&&(i>0?o>0?c/ie(10,s-o):0:d[f-1])%10&1||t==(r.s<0?8:7)),e<1||!d[0])return d.length=0,u?(e-=r.e+1,d[0]=ie(10,(S-e%S)%S),r.e=-e||0):d[0]=r.e=0,r;if(i==0?(d.length=f,a=1,f--):(d.length=f+1,a=ie(10,S-i),d[f]=o>0?(c/ie(10,s-o)%ie(10,o)|0)*a:0),u)for(;;)if(f==0){for(i=1,o=d[0];o>=10;o/=10)i++;for(o=d[0]+=a,a=1;o>=10;o/=10)a++;i!=a&&(r.e++,d[0]==$e&&(d[0]=1));break}else{if(d[f]+=a,d[f]!=$e)break;d[f--]=0,a=1}for(i=d.length;d[--i]===0;)d.pop()}return O&&(r.e>h.maxE?(r.d=null,r.e=NaN):r.e<h.minE&&(r.e=0,r.d=[0])),r}function We(r,e,t){if(!r.isFinite())return ya(r);var n,s=r.e,i=ue(r.d),o=i.length;return e?(t&&(n=t-o)>0?i=i.charAt(0)+"."+i.slice(1)+ct(n):o>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(r.e<0?"e":"e+")+r.e):s<0?(i="0."+ct(-s-1)+i,t&&(n=t-o)>0&&(i+=ct(n))):s>=o?(i+=ct(s+1-o),t&&(n=t-s-1)>0&&(i=i+"."+ct(n))):((n=s+1)<o&&(i=i.slice(0,n)+"."+i.slice(n)),t&&(n=t-o)>0&&(s+1===o&&(i+="."),i+=ct(n))),i}function fs(r,e){var t=r[0];for(e*=S;t>=10;t/=10)e++;return e}function cs(r,e,t){if(e>Bc)throw O=!0,t&&(r.precision=t),Error(ha);return x(new r(ls),e,1,!0)}function ze(r,e,t){if(e>Ri)throw Error(ha);return x(new r(us),e,t,!0)}function ba(r){var e=r.length-1,t=e*S+1;if(e=r[e],e){for(;e%10==0;e/=10)t--;for(e=r[0];e>=10;e/=10)t++}return t}function ct(r){for(var e="";r--;)e+="0";return e}function _a(r,e,t,n){var s,i=new r(1),o=Math.ceil(n/S+4);for(O=!1;;){if(t%2&&(i=i.times(e),ca(i.d,o)&&(s=!0)),t=pe(t/2),t===0){t=i.d.length-1,s&&i.d[t]===0&&++i.d[t];break}e=e.times(e),ca(e.d,o)}return O=!0,i}function ua(r){return r.d[r.d.length-1]&1}function wa(r,e,t){for(var n,s,i=new r(e[0]),o=0;++o<e.length;){if(s=new r(e[o]),!s.s){i=s;break}n=i.cmp(s),(n===t||n===0&&i.s===t)&&(i=s)}return i}function Mi(r,e){var t,n,s,i,o,a,l,u=0,c=0,d=0,f=r.constructor,h=f.rounding,p=f.precision;if(!r.d||!r.d[0]||r.e>17)return new f(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:NaN);for(e==null?(O=!1,l=p):l=e,a=new f(.03125);r.e>-2;)r=r.times(a),d+=5;for(n=Math.log(ie(2,d))/Math.LN10*2+5|0,l+=n,t=i=o=new f(1),f.precision=l;;){if(i=x(i.times(r),l,1),t=t.times(++c),a=o.plus(X(i,t,l,1)),ue(a.d).slice(0,l)===ue(o.d).slice(0,l)){for(s=d;s--;)o=x(o.times(o),l,1);if(e==null)if(u<3&&Wr(o.d,l-n,h,u))f.precision=l+=10,t=i=a=new f(1),c=0,u++;else return x(o,f.precision=p,h,O=!0);else return f.precision=p,o}o=a}}function dt(r,e){var t,n,s,i,o,a,l,u,c,d,f,h=1,p=10,m=r,g=m.d,b=m.constructor,y=b.rounding,w=b.precision;if(m.s<0||!g||!g[0]||!m.e&&g[0]==1&&g.length==1)return new b(g&&!g[0]?-1/0:m.s!=1?NaN:g?0:m);if(e==null?(O=!1,c=w):c=e,b.precision=c+=p,t=ue(g),n=t.charAt(0),Math.abs(i=m.e)<15e14){for(;n<7&&n!=1||n==1&&t.charAt(1)>3;)m=m.times(r),t=ue(m.d),n=t.charAt(0),h++;i=m.e,n>1?(m=new b("0."+t),i++):m=new b(n+"."+t.slice(1))}else return u=cs(b,c+2,w).times(i+""),m=dt(new b(n+"."+t.slice(1)),c-p).plus(u),b.precision=w,e==null?x(m,w,y,O=!0):m;for(d=m,l=o=m=X(m.minus(1),m.plus(1),c,1),f=x(m.times(m),c,1),s=3;;){if(o=x(o.times(f),c,1),u=l.plus(X(o,new b(s),c,1)),ue(u.d).slice(0,c)===ue(l.d).slice(0,c))if(l=l.times(2),i!==0&&(l=l.plus(cs(b,c+2,w).times(i+""))),l=X(l,new b(h),c,1),e==null)if(Wr(l.d,c-p,y,a))b.precision=c+=p,u=o=m=X(d.minus(1),d.plus(1),c,1),f=x(m.times(m),c,1),s=a=1;else return x(l,b.precision=w,y,O=!0);else return b.precision=w,l;l=u,s+=2}}function ya(r){return String(r.s*r.s/0)}function as(r,e){var t,n,s;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),n=0;e.charCodeAt(n)===48;n++);for(s=e.length;e.charCodeAt(s-1)===48;--s);if(e=e.slice(n,s),e){if(s-=n,r.e=t=t-n-1,r.d=[],n=(t+1)%S,t<0&&(n+=S),n<s){for(n&&r.d.push(+e.slice(0,n)),s-=S;n<s;)r.d.push(+e.slice(n,n+=S));e=e.slice(n),n=S-e.length}else n-=s;for(;n--;)e+="0";r.d.push(+e),O&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function Mc(r,e){var t,n,s,i,o,a,l,u,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),ga.test(e))return as(r,e)}else if(e==="Infinity"||e==="NaN")return+e||(r.s=NaN),r.e=NaN,r.d=null,r;if(Nc.test(e))t=16,e=e.toLowerCase();else if(Cc.test(e))t=2;else if(Ic.test(e))t=8;else throw Error(ft+e);for(i=e.search(/p/i),i>0?(l=+e.slice(i+1),e=e.substring(2,i)):e=e.slice(2),i=e.indexOf("."),o=i>=0,n=r.constructor,o&&(e=e.replace(".",""),a=e.length,i=a-i,s=_a(n,new n(t),i,i*2)),u=os(e,t,$e),c=u.length-1,i=c;u[i]===0;--i)u.pop();return i<0?new n(r.s*0):(r.e=fs(u,c),r.d=u,O=!1,o&&(r=X(r,s,a*4)),l&&(r=r.times(Math.abs(l)<54?ie(2,l):Gr.pow(2,l))),O=!0,r)}function $c(r,e){var t,n=e.d.length;if(n<3)return e.isZero()?e:ur(r,2,e,e);t=1.4*Math.sqrt(n),t=t>16?16:t|0,e=e.times(1/hs(5,t)),e=ur(r,2,e,e);for(var s,i=new r(5),o=new r(16),a=new r(20);t--;)s=e.times(e),e=e.times(i.plus(s.times(o.times(s).minus(a))));return e}function ur(r,e,t,n,s){var i,o,a,l,u=1,c=r.precision,d=Math.ceil(c/S);for(O=!1,l=t.times(t),a=new r(n);;){if(o=X(a.times(l),new r(e++*e++),c,1),a=s?n.plus(o):n.minus(o),n=X(o.times(l),new r(e++*e++),c,1),o=a.plus(n),o.d[d]!==void 0){for(i=d;o.d[i]===a.d[i]&&i--;);if(i==-1)break}i=a,a=n,n=o,o=i,u++}return O=!0,o.d.length=d+1,o}function hs(r,e){for(var t=r;--e;)t*=r;return t}function va(r,e){var t,n=e.s<0,s=ze(r,r.precision,1),i=s.times(.5);if(e=e.abs(),e.lte(i))return tt=n?4:1,e;if(t=e.divToInt(s),t.isZero())tt=n?3:2;else{if(e=e.minus(t.times(s)),e.lte(i))return tt=ua(t)?n?2:3:n?4:1,e;tt=ua(t)?n?1:4:n?3:2}return e.minus(s).abs()}function $i(r,e,t,n){var s,i,o,a,l,u,c,d,f,h=r.constructor,p=t!==void 0;if(p?(Ee(t,1,ht),n===void 0?n=h.rounding:Ee(n,0,8)):(t=h.precision,n=h.rounding),!r.isFinite())c=ya(r);else{for(c=We(r),o=c.indexOf("."),p?(s=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):s=e,o>=0&&(c=c.replace(".",""),f=new h(1),f.e=c.length-o,f.d=os(We(f),10,s),f.e=f.d.length),d=os(c,10,s),i=l=d.length;d[--l]==0;)d.pop();if(!d[0])c=p?"0p+0":"0";else{if(o<0?i--:(r=new h(r),r.d=d,r.e=i,r=X(r,f,t,n,0,s),d=r.d,i=r.e,u=fa),o=d[t],a=s/2,u=u||d[t+1]!==void 0,u=n<4?(o!==void 0||u)&&(n===0||n===(r.s<0?3:2)):o>a||o===a&&(n===4||u||n===6&&d[t-1]&1||n===(r.s<0?8:7)),d.length=t,u)for(;++d[--t]>s-1;)d[t]=0,t||(++i,d.unshift(1));for(l=d.length;!d[l-1];--l);for(o=0,c="";o<l;o++)c+=Oi.charAt(d[o]);if(p){if(l>1)if(e==16||e==8){for(o=e==16?4:3,--l;l%o;l++)c+="0";for(d=os(c,s,e),l=d.length;!d[l-1];--l);for(o=1,c="1.";o<l;o++)c+=Oi.charAt(d[o])}else c=c.charAt(0)+"."+c.slice(1);c=c+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)c="0"+c;c="0."+c}else if(++i>l)for(i-=l;i--;)c+="0";else i<l&&(c=c.slice(0,i)+"."+c.slice(i))}c=(e==16?"0x":e==2?"0b":e==8?"0o":"")+c}return r.s<0?"-"+c:c}function ca(r,e){if(r.length>e)return r.length=e,!0}function Lc(r){return new this(r).abs()}function Pc(r){return new this(r).acos()}function Fc(r){return new this(r).acosh()}function jc(r,e){return new this(r).plus(e)}function Uc(r){return new this(r).asin()}function qc(r){return new this(r).asinh()}function Vc(r){return new this(r).atan()}function Hc(r){return new this(r).atanh()}function zc(r,e){r=new this(r),e=new this(e);var t,n=this.precision,s=this.rounding,i=n+4;return!r.s||!e.s?t=new this(NaN):!r.d&&!e.d?(t=ze(this,i,1).times(e.s>0?.25:.75),t.s=r.s):!e.d||r.isZero()?(t=e.s<0?ze(this,n,s):new this(0),t.s=r.s):!r.d||e.isZero()?(t=ze(this,i,1).times(.5),t.s=r.s):e.s<0?(this.precision=i,this.rounding=1,t=this.atan(X(r,e,i,1)),e=ze(this,i,1),this.precision=n,this.rounding=s,t=r.s<0?t.minus(e):t.plus(e)):t=this.atan(X(r,e,i,1)),t}function Wc(r){return new this(r).cbrt()}function Gc(r){return x(r=new this(r),r.e+1,2)}function Xc(r,e,t){return new this(r).clamp(e,t)}function Yc(r){if(!r||typeof r!="object")throw Error(ds+"Object expected");var e,t,n,s=r.defaults===!0,i=["precision",1,ht,"rounding",0,8,"toExpNeg",-lr,0,"toExpPos",0,lr,"maxE",0,lr,"minE",-lr,0,"modulo",0,9];for(e=0;e<i.length;e+=3)if(t=i[e],s&&(this[t]=Bi[t]),(n=r[t])!==void 0)if(pe(n)===n&&n>=i[e+1]&&n<=i[e+2])this[t]=n;else throw Error(ft+t+": "+n);if(t="crypto",s&&(this[t]=Bi[t]),(n=r[t])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(pa);else this[t]=!1;else throw Error(ft+t+": "+n);return this}function Zc(r){return new this(r).cos()}function Jc(r){return new this(r).cosh()}function Ea(r){var e,t,n;function s(i){var o,a,l,u=this;if(!(u instanceof s))return new s(i);if(u.constructor=s,da(i)){u.s=i.s,O?!i.d||i.e>s.maxE?(u.e=NaN,u.d=null):i.e<s.minE?(u.e=0,u.d=[0]):(u.e=i.e,u.d=i.d.slice()):(u.e=i.e,u.d=i.d?i.d.slice():i.d);return}if(l=typeof i,l==="number"){if(i===0){u.s=1/i<0?-1:1,u.e=0,u.d=[0];return}if(i<0?(i=-i,u.s=-1):u.s=1,i===~~i&&i<1e7){for(o=0,a=i;a>=10;a/=10)o++;O?o>s.maxE?(u.e=NaN,u.d=null):o<s.minE?(u.e=0,u.d=[0]):(u.e=o,u.d=[i]):(u.e=o,u.d=[i]);return}if(i*0!==0){i||(u.s=NaN),u.e=NaN,u.d=null;return}return as(u,i.toString())}if(l==="string")return(a=i.charCodeAt(0))===45?(i=i.slice(1),u.s=-1):(a===43&&(i=i.slice(1)),u.s=1),ga.test(i)?as(u,i):Mc(u,i);if(l==="bigint")return i<0?(i=-i,u.s=-1):u.s=1,as(u,i.toString());throw Error(ft+i)}if(s.prototype=_,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=Yc,s.clone=Ea,s.isDecimal=da,s.abs=Lc,s.acos=Pc,s.acosh=Fc,s.add=jc,s.asin=Uc,s.asinh=qc,s.atan=Vc,s.atanh=Hc,s.atan2=zc,s.cbrt=Wc,s.ceil=Gc,s.clamp=Xc,s.cos=Zc,s.cosh=Jc,s.div=Kc,s.exp=Qc,s.floor=ed,s.hypot=td,s.ln=rd,s.log=nd,s.log10=id,s.log2=sd,s.max=od,s.min=ad,s.mod=ld,s.mul=ud,s.pow=cd,s.random=dd,s.round=fd,s.sign=hd,s.sin=pd,s.sinh=md,s.sqrt=gd,s.sub=bd,s.sum=_d,s.tan=wd,s.tanh=yd,s.trunc=vd,r===void 0&&(r={}),r&&r.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<n.length;)r.hasOwnProperty(t=n[e++])||(r[t]=this[t]);return s.config(r),s}function Kc(r,e){return new this(r).div(e)}function Qc(r){return new this(r).exp()}function ed(r){return x(r=new this(r),r.e+1,3)}function td(){var r,e,t=new this(0);for(O=!1,r=0;r<arguments.length;)if(e=new this(arguments[r++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return O=!0,new this(1/0);t=e}return O=!0,t.sqrt()}function da(r){return r instanceof Gr||r&&r.toStringTag===ma||!1}function rd(r){return new this(r).ln()}function nd(r,e){return new this(r).log(e)}function sd(r){return new this(r).log(2)}function id(r){return new this(r).log(10)}function od(){return wa(this,arguments,-1)}function ad(){return wa(this,arguments,1)}function ld(r,e){return new this(r).mod(e)}function ud(r,e){return new this(r).mul(e)}function cd(r,e){return new this(r).pow(e)}function dd(r){var e,t,n,s,i=0,o=new this(1),a=[];if(r===void 0?r=this.precision:Ee(r,1,ht),n=Math.ceil(r/S),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));i<n;)s=e[i],s>=429e7?e[i]=crypto.getRandomValues(new Uint32Array(1))[0]:a[i++]=s%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(n*=4);i<n;)s=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+((e[i+3]&127)<<24),s>=214e7?crypto.randomBytes(4).copy(e,i):(a.push(s%1e7),i+=4);i=n/4}else throw Error(pa);else for(;i<n;)a[i++]=Math.random()*1e7|0;for(n=a[--i],r%=S,n&&r&&(s=ie(10,S-r),a[i]=(n/s|0)*s);a[i]===0;i--)a.pop();if(i<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=S)a.shift();for(n=1,s=a[0];s>=10;s/=10)n++;n<S&&(t-=S-n)}return o.e=t,o.d=a,o}function fd(r){return x(r=new this(r),r.e+1,this.rounding)}function hd(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function pd(r){return new this(r).sin()}function md(r){return new this(r).sinh()}function gd(r){return new this(r).sqrt()}function bd(r,e){return new this(r).sub(e)}function _d(){var r=0,e=arguments,t=new this(e[r]);for(O=!1;t.s&&++r<e.length;)t=t.plus(e[r]);return O=!0,x(t,this.precision,this.rounding)}function wd(r){return new this(r).tan()}function yd(r){return new this(r).tanh()}function vd(r){return x(r=new this(r),r.e+1,1)}_[Symbol.for("nodejs.util.inspect.custom")]=_.toString;_[Symbol.toStringTag]="Decimal";var Gr=_.constructor=Ea(Bi);ls=new Gr(ls);us=new Gr(us);var ka=Gr;var Ed=20,kd=1,It=1e6,Aa=1e6,Ad=-7,Td=21,xd=!1,Xr="[big.js] ",Ot=Xr+"Invalid ",ps=Ot+"decimal places",Dd=Ot+"rounding mode",Ta=Xr+"Division by zero",H={},Ge=void 0,Sd=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function xa(){function r(e){var t=this;if(!(t instanceof r))return e===Ge?xa():new r(e);if(e instanceof r)t.s=e.s,t.e=e.e,t.c=e.c.slice();else{if(typeof e!="string"){if(r.strict===!0&&typeof e!="bigint")throw TypeError(Ot+"value");e=e===0&&1/e<0?"-0":String(e)}Cd(t,e)}t.constructor=r}return r.prototype=H,r.DP=Ed,r.RM=kd,r.NE=Ad,r.PE=Td,r.strict=xd,r.roundDown=0,r.roundHalfUp=1,r.roundHalfEven=2,r.roundUp=3,r}function Cd(r,e){var t,n,s;if(!Sd.test(e))throw Error(Ot+"number");for(r.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(t=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(t<0&&(t=n),t+=+e.slice(n+1),e=e.substring(0,n)):t<0&&(t=e.length),s=e.length,n=0;n<s&&e.charAt(n)=="0";)++n;if(n==s)r.c=[r.e=0];else{for(;s>0&&e.charAt(--s)=="0";);for(r.e=t-n-1,r.c=[],t=0;n<=s;)r.c[t++]=+e.charAt(n++)}return r}function Bt(r,e,t,n){var s=r.c;if(t===Ge&&(t=r.constructor.RM),t!==0&&t!==1&&t!==2&&t!==3)throw Error(Dd);if(e<1)n=t===3&&(n||!!s[0])||e===0&&(t===1&&s[0]>=5||t===2&&(s[0]>5||s[0]===5&&(n||s[1]!==Ge))),s.length=1,n?(r.e=r.e-e+1,s[0]=1):s[0]=r.e=0;else if(e<s.length){if(n=t===1&&s[e]>=5||t===2&&(s[e]>5||s[e]===5&&(n||s[e+1]!==Ge||s[e-1]&1))||t===3&&(n||!!s[0]),s.length=e,n){for(;++s[--e]>9;)if(s[e]=0,e===0){++r.e,s.unshift(1);break}}for(e=s.length;!s[--e];)s.pop()}return r}function Rt(r,e,t){var n=r.e,s=r.c.join(""),i=s.length;if(e)s=s.charAt(0)+(i>1?"."+s.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)s="0"+s;s="0."+s}else if(n>0)if(++n>i)for(n-=i;n--;)s+="0";else n<i&&(s=s.slice(0,n)+"."+s.slice(n));else i>1&&(s=s.charAt(0)+"."+s.slice(1));return r.s<0&&t?"-"+s:s}H.abs=function(){var r=new this.constructor(this);return r.s=1,r};H.cmp=function(r){var e,t=this,n=t.c,s=(r=new t.constructor(r)).c,i=t.s,o=r.s,a=t.e,l=r.e;if(!n[0]||!s[0])return n[0]?i:s[0]?-o:0;if(i!=o)return i;if(e=i<0,a!=l)return a>l^e?1:-1;for(o=(a=n.length)<(l=s.length)?a:l,i=-1;++i<o;)if(n[i]!=s[i])return n[i]>s[i]^e?1:-1;return a==l?0:a>l^e?1:-1};H.div=function(r){var e=this,t=e.constructor,n=e.c,s=(r=new t(r)).c,i=e.s==r.s?1:-1,o=t.DP;if(o!==~~o||o<0||o>It)throw Error(ps);if(!s[0])throw Error(Ta);if(!n[0])return r.s=i,r.c=[r.e=0],r;var a,l,u,c,d,f=s.slice(),h=a=s.length,p=n.length,m=n.slice(0,a),g=m.length,b=r,y=b.c=[],w=0,k=o+(b.e=e.e-r.e)+1;for(b.s=i,i=k<0?0:k,f.unshift(0);g++<a;)m.push(0);do{for(u=0;u<10;u++){if(a!=(g=m.length))c=a>g?1:-1;else for(d=-1,c=0;++d<a;)if(s[d]!=m[d]){c=s[d]>m[d]?1:-1;break}if(c<0){for(l=g==a?s:f;g;){if(m[--g]<l[g]){for(d=g;d&&!m[--d];)m[d]=9;--m[d],m[g]+=10}m[g]-=l[g]}for(;!m[0];)m.shift()}else break}y[w++]=c?u:++u,m[0]&&c?m[g]=n[h]||0:m=[n[h]]}while((h++<p||m[0]!==Ge)&&i--);return!y[0]&&w!=1&&(y.shift(),b.e--,k--),w>k&&Bt(b,k,t.RM,m[0]!==Ge),b};H.eq=function(r){return this.cmp(r)===0};H.gt=function(r){return this.cmp(r)>0};H.gte=function(r){return this.cmp(r)>-1};H.lt=function(r){return this.cmp(r)<0};H.lte=function(r){return this.cmp(r)<1};H.minus=H.sub=function(r){var e,t,n,s,i=this,o=i.constructor,a=i.s,l=(r=new o(r)).s;if(a!=l)return r.s=-l,i.plus(r);var u=i.c.slice(),c=i.e,d=r.c,f=r.e;if(!u[0]||!d[0])return d[0]?r.s=-l:u[0]?r=new o(i):r.s=1,r;if(a=c-f){for((s=a<0)?(a=-a,n=u):(f=c,n=d),n.reverse(),l=a;l--;)n.push(0);n.reverse()}else for(t=((s=u.length<d.length)?u:d).length,a=l=0;l<t;l++)if(u[l]!=d[l]){s=u[l]<d[l];break}if(s&&(n=u,u=d,d=n,r.s=-r.s),(l=(t=d.length)-(e=u.length))>0)for(;l--;)u[e++]=0;for(l=e;t>a;){if(u[--t]<d[t]){for(e=t;e&&!u[--e];)u[e]=9;--u[e],u[t]+=10}u[t]-=d[t]}for(;u[--l]===0;)u.pop();for(;u[0]===0;)u.shift(),--f;return u[0]||(r.s=1,u=[f=0]),r.c=u,r.e=f,r};H.mod=function(r){var e,t=this,n=t.constructor,s=t.s,i=(r=new n(r)).s;if(!r.c[0])throw Error(Ta);return t.s=r.s=1,e=r.cmp(t)==1,t.s=s,r.s=i,e?new n(t):(s=n.DP,i=n.RM,n.DP=n.RM=0,t=t.div(r),n.DP=s,n.RM=i,this.minus(t.times(r)))};H.neg=function(){var r=new this.constructor(this);return r.s=-r.s,r};H.plus=H.add=function(r){var e,t,n,s=this,i=s.constructor;if(r=new i(r),s.s!=r.s)return r.s=-r.s,s.minus(r);var o=s.e,a=s.c,l=r.e,u=r.c;if(!a[0]||!u[0])return u[0]||(a[0]?r=new i(s):r.s=s.s),r;if(a=a.slice(),e=o-l){for(e>0?(l=o,n=u):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-u.length<0&&(n=u,u=a,a=n),e=u.length,t=0;e;a[e]%=10)t=(a[--e]=a[e]+u[e]+t)/10|0;for(t&&(a.unshift(t),++l),e=a.length;a[--e]===0;)a.pop();return r.c=a,r.e=l,r};H.pow=function(r){var e=this,t=new e.constructor("1"),n=t,s=r<0;if(r!==~~r||r<-Aa||r>Aa)throw Error(Ot+"exponent");for(s&&(r=-r);r&1&&(n=n.times(e)),r>>=1,!!r;)e=e.times(e);return s?t.div(n):n};H.prec=function(r,e){if(r!==~~r||r<1||r>It)throw Error(Ot+"precision");return Bt(new this.constructor(this),r,e)};H.round=function(r,e){if(r===Ge)r=0;else if(r!==~~r||r<-It||r>It)throw Error(ps);return Bt(new this.constructor(this),r+this.e+1,e)};H.sqrt=function(){var r,e,t,n=this,s=n.constructor,i=n.s,o=n.e,a=new s("0.5");if(!n.c[0])return new s(n);if(i<0)throw Error(Xr+"No square root");i=Math.sqrt(+Rt(n,!0,!0)),i===0||i===1/0?(e=n.c.join(""),e.length+o&1||(e+="0"),i=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),r=new s((i==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+o)):r=new s(i+""),o=r.e+(s.DP+=4);do t=r,r=a.times(t.plus(n.div(t)));while(t.c.slice(0,o).join("")!==r.c.slice(0,o).join(""));return Bt(r,(s.DP-=4)+r.e+1,s.RM)};H.times=H.mul=function(r){var e,t=this,n=t.constructor,s=t.c,i=(r=new n(r)).c,o=s.length,a=i.length,l=t.e,u=r.e;if(r.s=t.s==r.s?1:-1,!s[0]||!i[0])return r.c=[r.e=0],r;for(r.e=l+u,o<a&&(e=s,s=i,i=e,u=o,o=a,a=u),e=new Array(u=o+a);u--;)e[u]=0;for(l=a;l--;){for(a=0,u=o+l;u>l;)a=e[u]+i[l]*s[u-l-1]+a,e[u--]=a%10,a=a/10|0;e[u]=a}for(a?++r.e:e.shift(),l=e.length;!e[--l];)e.pop();return r.c=e,r};H.toExponential=function(r,e){var t=this,n=t.c[0];if(r!==Ge){if(r!==~~r||r<0||r>It)throw Error(ps);for(t=Bt(new t.constructor(t),++r,e);t.c.length<r;)t.c.push(0)}return Rt(t,!0,!!n)};H.toFixed=function(r,e){var t=this,n=t.c[0];if(r!==Ge){if(r!==~~r||r<0||r>It)throw Error(ps);for(t=Bt(new t.constructor(t),r+t.e+1,e),r=r+t.e+1;t.c.length<r;)t.c.push(0)}return Rt(t,!1,!!n)};H[Symbol.for("nodejs.util.inspect.custom")]=H.toJSON=H.toString=function(){var r=this,e=r.constructor;return Rt(r,r.e<=e.NE||r.e>=e.PE,!!r.c[0])};H.toNumber=function(){var r=+Rt(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(r.toString()))throw Error(Xr+"Imprecise conversion");return r};H.toPrecision=function(r,e){var t=this,n=t.constructor,s=t.c[0];if(r!==Ge){if(r!==~~r||r<1||r>It)throw Error(Ot+"precision");for(t=Bt(new n(t),r,e);t.c.length<r;)t.c.push(0)}return Rt(t,r<=t.e||t.e<=n.NE||t.e>=n.PE,!!s)};H.valueOf=function(){var r=this,e=r.constructor;if(e.strict===!0)throw Error(Xr+"valueOf disallowed");return Rt(r,r.e<=e.NE||r.e>=e.PE,!0)};var Nd=xa(),Da=Nd;var Gi={};Dc(Gi,{DecodeError:()=>me,Decoder:()=>Pe,EXT_TIMESTAMP:()=>Pi,Encoder:()=>cr,ExtData:()=>Le,ExtensionCodec:()=>pt,decode:()=>$a,decodeArrayStream:()=>Fa,decodeAsync:()=>Pa,decodeMulti:()=>La,decodeMultiStream:()=>ja,decodeTimestampExtension:()=>Vi,decodeTimestampToTimeSpec:()=>qi,encode:()=>bs,encodeDateToTimeSpec:()=>ji,encodeTimeSpecToTimestamp:()=>Fi,encodeTimestampExtension:()=>Ui});function Sa(r){let e=r.length,t=0,n=0;for(;n<e;){let s=r.charCodeAt(n++);if((s&4294967168)===0){t++;continue}else if((s&4294965248)===0)t+=2;else{if(s>=55296&&s<=56319&&n<e){let i=r.charCodeAt(n);(i&64512)===56320&&(++n,s=((s&1023)<<10)+(i&1023)+65536)}(s&4294901760)===0?t+=3:t+=4}}return t}function Id(r,e,t){let n=r.length,s=t,i=0;for(;i<n;){let o=r.charCodeAt(i++);if((o&4294967168)===0){e[s++]=o;continue}else if((o&4294965248)===0)e[s++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&i<n){let a=r.charCodeAt(i);(a&64512)===56320&&(++i,o=((o&1023)<<10)+(a&1023)+65536)}(o&4294901760)===0?(e[s++]=o>>12&15|224,e[s++]=o>>6&63|128):(e[s++]=o>>18&7|240,e[s++]=o>>12&63|128,e[s++]=o>>6&63|128)}e[s++]=o&63|128}}var Od=new TextEncoder,Bd=50;function Rd(r,e,t){Od.encodeInto(r,e.subarray(t))}function Ca(r,e,t){r.length>Bd?Rd(r,e,t):Id(r,e,t)}var Md=4096;function Li(r,e,t){let n=e,s=n+t,i=[],o="";for(;n<s;){let a=r[n++];if((a&128)===0)i.push(a);else if((a&224)===192){let l=r[n++]&63;i.push((a&31)<<6|l)}else if((a&240)===224){let l=r[n++]&63,u=r[n++]&63;i.push((a&31)<<12|l<<6|u)}else if((a&248)===240){let l=r[n++]&63,u=r[n++]&63,c=r[n++]&63,d=(a&7)<<18|l<<12|u<<6|c;d>65535&&(d-=65536,i.push(d>>>10&1023|55296),d=56320|d&1023),i.push(d)}else i.push(a);i.length>=Md&&(o+=String.fromCharCode(...i),i.length=0)}return i.length>0&&(o+=String.fromCharCode(...i)),o}var $d=new TextDecoder,Ld=200;function Pd(r,e,t){let n=r.subarray(e,e+t);return $d.decode(n)}function Na(r,e,t){return t>Ld?Pd(r,e,t):Li(r,e,t)}var Le=class{type;data;constructor(e,t){this.type=e,this.data=t}};var me=class r extends Error{constructor(e){super(e);let t=Object.create(r.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:r.name})}};function Ia(r,e,t){let n=t/4294967296,s=t;r.setUint32(e,n),r.setUint32(e+4,s)}function ms(r,e,t){let n=Math.floor(t/4294967296),s=t;r.setUint32(e,n),r.setUint32(e+4,s)}function gs(r,e){let t=r.getInt32(e),n=r.getUint32(e+4);return t*4294967296+n}function Oa(r,e){let t=r.getUint32(e),n=r.getUint32(e+4);return t*4294967296+n}var Pi=-1,Fd=4294967296-1,jd=17179869184-1;function Fi({sec:r,nsec:e}){if(r>=0&&e>=0&&r<=jd)if(e===0&&r<=Fd){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,r),t}else{let t=r/4294967296,n=r&4294967295,s=new Uint8Array(8),i=new DataView(s.buffer);return i.setUint32(0,e<<2|t&3),i.setUint32(4,n),s}else{let t=new Uint8Array(12),n=new DataView(t.buffer);return n.setUint32(0,e),ms(n,4,r),t}}function ji(r){let e=r.getTime(),t=Math.floor(e/1e3),n=(e-t*1e3)*1e6,s=Math.floor(n/1e9);return{sec:t+s,nsec:n-s*1e9}}function Ui(r){if(r instanceof Date){let e=ji(r);return Fi(e)}else return null}function qi(r){let e=new DataView(r.buffer,r.byteOffset,r.byteLength);switch(r.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),n=e.getUint32(4),s=(t&3)*4294967296+n,i=t>>>2;return{sec:s,nsec:i}}case 12:{let t=gs(e,4),n=e.getUint32(0);return{sec:t,nsec:n}}default:throw new me(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${r.length}`)}}function Vi(r){let e=qi(r);return new Date(e.sec*1e3+e.nsec/1e6)}var Ba={type:Pi,encode:Ui,decode:Vi};var pt=class r{static defaultCodec=new r;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(Ba)}register({type:e,encode:t,decode:n}){if(e>=0)this.encoders[e]=t,this.decoders[e]=n;else{let s=-1-e;this.builtInEncoders[s]=t,this.builtInDecoders[s]=n}}tryToEncode(e,t){for(let n=0;n<this.builtInEncoders.length;n++){let s=this.builtInEncoders[n];if(s!=null){let i=s(e,t);if(i!=null){let o=-1-n;return new Le(o,i)}}}for(let n=0;n<this.encoders.length;n++){let s=this.encoders[n];if(s!=null){let i=s(e,t);if(i!=null){let o=n;return new Le(o,i)}}}return e instanceof Le?e:null}decode(e,t,n){let s=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return s?s(e,t,n):new Le(t,e)}};function Ud(r){return r instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&r instanceof SharedArrayBuffer}function Yr(r){return r instanceof Uint8Array?r:ArrayBuffer.isView(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):Ud(r)?new Uint8Array(r):Uint8Array.from(r)}var qd=100,Vd=2048,cr=class r{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??pt.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??qd,this.initialBufferSize=e?.initialBufferSize??Vd,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new r({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),n=new Uint8Array(t),s=new DataView(t);n.set(this.bytes),this.view=s,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let n=Sa(e);this.ensureBufferSizeToWrite(5+n),this.writeStringHeader(n),Ca(e,this.bytes,this.pos),this.pos+=n}encodeObject(e,t){let n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);let n=Yr(e);this.writeU8a(n)}encodeArray(e,t){let n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(let s of e)this.doEncode(s,t+1)}countWithoutUndefined(e,t){let n=0;for(let s of t)e[s]!==void 0&&n++;return n}encodeMap(e,t){let n=Object.keys(e);this.sortKeys&&n.sort();let s=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(s<16)this.writeU8(128+s);else if(s<65536)this.writeU8(222),this.writeU16(s);else if(s<4294967296)this.writeU8(223),this.writeU32(s);else throw new Error(`Too large map object: ${s}`);for(let i of n){let o=e[i];this.ignoreUndefined&&o===void 0||(this.encodeString(i),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let n=e.data(this.pos+6),s=n.length;if(s>=4294967296)throw new Error(`Too large extension object: ${s}`);this.writeU8(201),this.writeU32(s),this.writeI8(e.type),this.writeU8a(n);return}let t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),Ia(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),ms(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function bs(r,e){return new cr(e).encodeSharedRef(r)}function _s(r){return`${r<0?"-":""}0x${Math.abs(r).toString(16).padStart(2,"0")}`}var Hd=16,zd=16,ws=class{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor(e=Hd,t=zd){this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){let s=this.caches[n-1];e:for(let i of s){let o=i.bytes;for(let a=0;a<n;a++)if(o[a]!==e[t+a])continue e;return i.str}return null}store(e,t){let n=this.caches[e.length-1],s={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=s:n.push(s)}decode(e,t,n){let s=this.find(e,t,n);if(s!=null)return this.hit++,s;this.miss++;let i=Li(e,t,n),o=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(o,i),i}};var Hi="array",Kr="map_key",Ma="map_value",Wd=r=>{if(typeof r=="string"||typeof r=="number")return r;throw new me("The type of key must be string or number but "+typeof r)},zi=class{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=Hi,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=Kr,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===Hi){let n=e;n.size=0,n.array=void 0,n.position=0,n.type=void 0}if(e.type===Kr||e.type===Ma){let n=e;n.size=0,n.map=void 0,n.readCount=0,n.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},Jr=-1,Wi=new DataView(new ArrayBuffer(0)),Gd=new Uint8Array(Wi.buffer);try{Wi.getInt8(0)}catch(r){if(!(r instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var Ra=new RangeError("Insufficient data"),Xd=new ws,Pe=class r{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=Wi;bytes=Gd;headByte=Jr;stack=new zi;entered=!1;constructor(e){this.extensionCodec=e?.extensionCodec??pt.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??4294967295,this.maxBinLength=e?.maxBinLength??4294967295,this.maxArrayLength=e?.maxArrayLength??4294967295,this.maxMapLength=e?.maxMapLength??4294967295,this.maxExtLength=e?.maxExtLength??4294967295,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:Xd,this.mapKeyConverter=e?.mapKeyConverter??Wd}clone(){return new r({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Jr,this.stack.reset()}setBuffer(e){let t=Yr(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Jr&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=Yr(e),s=new Uint8Array(t.length+n.length);s.set(t),s.set(n,t.length),this.setBuffer(s)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:n}=this;return new RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(let a of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{n=this.doDecodeSync(),t=!0}catch(l){if(!(l instanceof RangeError))throw l}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:s,pos:i,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${_s(s)} at ${o} (${i} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,s=-1;for await(let i of e){if(t&&s===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(i),n&&(s=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--s!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let s=e-128;if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(e<160){let s=e-144;if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else{let s=e-160;t=this.decodeString(s,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){let s=this.lookU8();t=this.decodeString(s,1)}else if(e===218){let s=this.lookU16();t=this.decodeString(s,2)}else if(e===219){let s=this.lookU32();t=this.decodeString(s,4)}else if(e===220){let s=this.readU16();if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else if(e===221){let s=this.readU32();if(s!==0){this.pushArrayState(s),this.complete();continue e}else t=[]}else if(e===222){let s=this.readU16();if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(e===223){let s=this.readU32();if(s!==0){this.pushMapState(s),this.complete();continue e}else t={}}else if(e===196){let s=this.lookU8();t=this.decodeBinary(s,1)}else if(e===197){let s=this.lookU16();t=this.decodeBinary(s,2)}else if(e===198){let s=this.lookU32();t=this.decodeBinary(s,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let s=this.lookU8();t=this.decodeExtension(s,1)}else if(e===200){let s=this.lookU16();t=this.decodeExtension(s,2)}else if(e===201){let s=this.lookU32();t=this.decodeExtension(s,4)}else throw new me(`Unrecognized type byte: ${_s(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let s=n.top();if(s.type===Hi)if(s.array[s.position]=t,s.position++,s.position===s.size)t=s.array,n.release(s);else continue e;else if(s.type===Kr){if(t==="__proto__")throw new me("The key __proto__ is not allowed");s.key=this.mapKeyConverter(t),s.type=Ma;continue e}else if(s.map[s.key]=t,s.readCount++,s.readCount===s.size)t=s.map,n.release(s);else{s.key=null,s.type=Kr;continue e}}return t}}readHeadByte(){return this.headByte===Jr&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Jr}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new me(`Unrecognized array type byte: ${_s(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new me(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new me(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new me(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw Ra;let n=this.pos+t,s;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?s=this.keyDecoder.decode(this.bytes,n,e):s=Na(this.bytes,n,e),this.pos+=t+e,s}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===Kr:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new me(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw Ra;let n=this.pos+t,s=this.bytes.subarray(n,n+e);return this.pos+=t+e,s}decodeExtension(e,t){if(e>this.maxExtLength)throw new me(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),s=this.decodeBinary(e,t+1);return this.extensionCodec.decode(s,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=Oa(this.view,this.pos);return this.pos+=8,e}readI64(){let e=gs(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function $a(r,e){return new Pe(e).decode(r)}function La(r,e){return new Pe(e).decodeMulti(r)}function Yd(r){return r[Symbol.asyncIterator]!=null}async function*Zd(r){let e=r.getReader();try{for(;;){let{done:t,value:n}=await e.read();if(t)return;yield n}}finally{e.releaseLock()}}function ys(r){return Yd(r)?r:Zd(r)}async function Pa(r,e){let t=ys(r);return new Pe(e).decodeAsync(t)}function Fa(r,e){let t=ys(r);return new Pe(e).decodeArrayStream(t)}function ja(r,e){let t=ys(r);return new Pe(e).decodeStream(t)}var Fs=oa(go(),1),bo=ka,_o=Da,Je=Gi,zl=Fs.DOMParser,Wl=Fs.XMLSerializer;var Gl=Je!==null;function Xl(){if(!Gl)throw new Error("@msgpack/msgpack is required for MessagePack support. Install with: npm install @msgpack/msgpack")}var Yl=Zh();function Zh(){if(!Gl)return null;let r=new TextEncoder,e=new TextDecoder,t=new Je.ExtensionCodec;return t.register({type:-1,encode:n=>{if(n instanceof Date){let s=vt(n);if(s==="D"||s==="H")return null}return Je.encodeTimestampExtension(n)},decode:n=>Je.decodeTimestampExtension(n)}),t.register({type:1,encode:n=>fe(n)?r.encode(n.toString()):null,decode:n=>Et(e.decode(n))}),t.register({type:2,encode:n=>{if(n instanceof Date&&vt(n)==="D"){let s=n.getUTCFullYear(),i=String(n.getUTCMonth()+1).padStart(2,"0"),o=String(n.getUTCDate()).padStart(2,"0");return r.encode(`${s}-${i}-${o}`)}return null},decode:n=>new Date(e.decode(n)+"T00:00:00.000Z")}),t.register({type:3,encode:n=>{if(n instanceof Date&&vt(n)==="H"){let s=String(n.getUTCHours()).padStart(2,"0"),i=String(n.getUTCMinutes()).padStart(2,"0"),o=String(n.getUTCSeconds()).padStart(2,"0"),a=String(n.getUTCMilliseconds()).padStart(3,"0");return r.encode(`${s}:${i}:${o}.${a}`)}return null},decode:n=>{let s=e.decode(n),i=s.indexOf("."),o=i>=0?s.substring(0,i):s,a=i>=0?s.substring(i+1):"0",[l,u,c]=o.split(":"),d=Math.round(+a.substring(0,3));return new Date(Date.UTC(1970,0,1,+l,+u,+c,d))}}),t.register({type:4,encode:n=>{let s=wo(n);if(s!==null){let[i,o]=s;return r.encode(`${i}:${o(n)}`)}return null},decode:n=>{let s=e.decode(n),i=s.indexOf(":"),o=s.slice(0,i),a=s.slice(i+1),l=kt[o];if(l!==void 0){let[,u]=l;return u(a)}return`${a}::${o}`}}),t}function Zl(r){return Xl(),Je.encode(r,{extensionCodec:Yl})}function Jl(r){return Xl(),Je.decode(r,{extensionCodec:Yl})}function Us(r,e=!1){let t=qs(r);if(t===null)return[!1,String(r)];let[n,s,i]=t;return i&&!e?[!1,String(r)]:[!0,`${s(r)}::${n}`]}function yo(r){if(!r.includes("::"))return[!1,r];let e=r.lastIndexOf("::"),t=r.slice(0,e),n=r.slice(e+2),s=kt[n];if(s===void 0)return[!1,r];let[,i]=s;return[!0,i(t)]}function js(r,e,t){if(r!==null&&typeof r=="object"&&!Array.isArray(r)){let n={};for(let[s,i]of Object.entries(r))n[s]=js(i,e,t);return n}return Array.isArray(r)?r.map(n=>js(n,e,t)):t(r)?e(r):r}function vo(r){let e=qs(r);if(e!==null){let[t,n,s]=e;return s?[r,!1]:[`${n(r)}::${t}`,!0]}if(Array.isArray(r)){let t=!1;return[r.map(s=>{let[i,o]=vo(s);return o&&(t=!0),i}),t]}if(r!==null&&typeof r=="object"){let t=!1,n={};for(let[s,i]of Object.entries(r)){let[o,a]=vo(i);a&&(t=!0),n[s]=o}return[n,t]}return[r,!1]}function Jh(r,e=!1){let[t,n]=Us(r,e);if(t)return n;let[s,i]=vo(r),o=JSON.stringify(s);return i?`${o}::JS`:o}function Kh(r){return JSON.stringify(r)}function Qh(r){if(!Je)throw new Error("@msgpack/msgpack is required for MessagePack support");return Je.encode(r)}function W(r,e=null,{raw:t=!1,qs:n=!1,_forceSuffix:s=!1}={}){if(n)return`${Ql(r)}::QS`;if(t){if(e===null||e==="json")return Kh(r);if(e==="msgpack")return Qh(r);throw e==="xml"?new Error("raw=true is not supported for XML transport"):new Error(`Unknown transport: ${e}`)}if(e===null||e==="json"){let i=Jh(r,s);return e==="json"?`"${i}"`:i}else{if(e==="xml")return`<?xml version="1.0" ?><tytx_root>${Kl(r)}</tytx_root>`;if(e==="msgpack")return Zl(r);throw new Error(`Unknown transport: ${e}`)}}var Cr,Eo;typeof window<"u"&&window.DOMParser?(Cr=window.DOMParser,Eo=window.XMLSerializer):(Cr=zl,Eo=Wl);function eu(r){if(r===null||typeof r!="object"||Array.isArray(r))return!1;let e=Object.keys(r);if(e.length!==1)return!1;let t=r[e[0]];return t!==null&&typeof t=="object"&&"value"in t}function tu(r,e,t){let n=r.createElement(e),s=t.attrs||{},i=t.value;for(let[o,a]of Object.entries(s))n.setAttribute(o,W(a,null,{_forceSuffix:!0}));if(Array.isArray(i))for(let o of i)if(eu(o)){let[a]=Object.keys(o),l=o[a],u=tu(r,a,l);n.appendChild(u)}else{n.textContent=W(i);break}else n.textContent=W(i);return n}function Kl(r){if(!Cr)throw new Error("XML support requires @xmldom/xmldom package in Node.js");if(eu(r)){let[e]=Object.keys(r),t=r[e],n=new Cr().parseFromString("<root/>","text/xml"),s=tu(n,e,t);return new Eo().serializeToString(s)}else return W(r)}function ko(r){let e={};for(let n=0;n<r.attributes.length;n++){let s=r.attributes[n];e[s.name]=P(s.value)}let t=[];for(let n=0;n<r.childNodes.length;n++){let s=r.childNodes[n];s.nodeType===1&&t.push(s)}if(t.length>0)if(t.length===1){let n=t[0],s=ko(n);return{attrs:e,value:{[n.tagName]:s}}}else{let n=[];for(let s of t){let i=ko(s);n.push({[s.tagName]:i})}return{attrs:e,value:n}}return{attrs:e,value:P(r.textContent)}}function ru(r){if(!Cr)throw new Error("XML support requires @xmldom/xmldom package in Node.js");let n=new Cr().parseFromString(r,"text/xml").documentElement;if(n.tagName==="tytx_root"){let i=null;for(let o=0;o<n.childNodes.length;o++)if(n.childNodes[o].nodeType===1){i=n.childNodes[o];break}if(!i)return P(n.textContent);n=i}let s=ko(n);return{[n.tagName]:s}}function ep(r){return typeof r=="string"}function tp(r){let[e,t]=yo(r);if(e)return t;let n=r;n.endsWith("::JS")&&(n=n.slice(0,-4));let s;try{s=JSON.parse(n)}catch{return r}return js(s,rp,ep)}function rp(r){return r.includes("::")?yo(r)[1]:r}function np(r){let e=ru(r);return typeof e=="string"?P(e):e}function sp(r){return Jl(r)}function P(r,e=null){if(r===null)return null;if(e===null||e==="json"){let t=r;return e==="json"&&r.startsWith('"')&&r.endsWith('"')&&(t=r.slice(1,-1)),tp(t)}else{if(e==="xml")return np(r);if(e==="msgpack")return sp(r);throw new Error(`Unknown transport: ${e}`)}}function Ql(r){if(Array.isArray(r))return r.map(e=>String(e)).join("&");if(r!==null&&typeof r=="object"){let e=[];for(let[t,n]of Object.entries(r)){let[s,i]=Us(n,!0);s?e.push(`${t}=${i}`):e.push(`${t}=${n}`)}return e.join("&")}throw new TypeError(`toQs expects object or array, got ${typeof r}`)}function nu(r){if(!r)return[];let e=r.split("&"),t=e.map(o=>o.includes("=")),n=t.every(Boolean),s=!t.some(Boolean);if(!n&&!s)throw new Error("QS format error: mixed items with and without '='");if(s)return e.map(o=>P(o));let i={};for(let o of e){let a=o.indexOf("="),l=o.slice(0,a),u=o.slice(a+1);i[l]=P(u)}return i}var iu=bo||_o||Number,ou=bo?"decimal.js":_o?"big.js":"number";function To(){return ou}function Et(r){return new iu(r)}function fe(r){return ou==="number"?!1:r instanceof iu}function vt(r){let e=r.getUTCFullYear()===1970&&r.getUTCMonth()===0&&r.getUTCDate()===1,t=r.getUTCHours()===0&&r.getUTCMinutes()===0&&r.getUTCSeconds()===0&&r.getUTCMilliseconds()===0;return e&&!t?"H":t&&!e?"D":"DHZ"}function ip(r){return r.toString()}function op(r){let e=r.getUTCFullYear(),t=String(r.getUTCMonth()+1).padStart(2,"0"),n=String(r.getUTCDate()).padStart(2,"0");return`${e}-${t}-${n}`}function ap(r){return r.toISOString()}function lp(r){let e=String(r.getUTCHours()).padStart(2,"0"),t=String(r.getUTCMinutes()).padStart(2,"0"),n=String(r.getUTCSeconds()).padStart(2,"0"),s=String(r.getUTCMilliseconds()).padStart(3,"0");return`${e}:${t}:${n}.${s}`}function up(r){return r?"true":"false"}function cp(r){return r.toString()}function dp(r){return r.toString()}function fp(r){let e="";for(let t=0;t<r.length;t+=32768)e+=String.fromCharCode.apply(null,r.subarray(t,t+32768));return btoa(e)}var Vs=[],Ao=new Map;function wo(r){if(r===null||typeof r!="object")return null;for(let e=Object.getPrototypeOf(r);e!==null;e=Object.getPrototypeOf(e))for(let[t,n,s,i]of Vs)if(t.prototype===e)return[n,s,i];return null}function qs(r){if(r===null)return["NN",()=>"",!0];if(fe(r))return["N",ip,!1];if(r instanceof Uint8Array)return["RAW",fp,!1];if(r instanceof Date){let e=vt(r);return e==="D"?["D",op,!1]:e==="H"?["H",lp,!1]:["DHZ",ap,!1]}return typeof r=="boolean"?["B",up,!0]:typeof r=="number"?Number.isInteger(r)?["L",cp,!0]:["R",dp,!0]:wo(r)}function hp(r){return Et(r)}function pp(r){let[e,t,n]=r.split("-").map(Number);return new Date(Date.UTC(e,t-1,n,0,0,0,0))}function su(r){return new Date(r)}function mp(r){let[e,t,n]=r.split(":"),[s,i]=n.split(".");return new Date(Date.UTC(1970,0,1,Number(e),Number(t),Number(s),Number(i||0)))}function gp(r){return r.toLowerCase()==="true"}function bp(r){return parseInt(r,10)}function _p(r){return parseFloat(r)}function wp(r){return r}function yp(r){return null}var vp=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function Ep(r){if(!vp.test(r))throw new Error(`RAW payload is not standard padded base64: '${r}'`);let e=atob(r),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function kp(r){return nu(r)}var Ap=/^[A-Z]+$/,kt={N:[Object,hp],D:[Date,pp],DH:[Date,su],DHZ:[Date,su],H:[Date,mp],L:[Number,bp],R:[Number,_p],T:[String,wp],B:[Boolean,gp],QS:[Object,kp],NN:[null,yp],RAW:[Uint8Array,Ep]};function wn(r){return Object.hasOwn(kt,r)?kt[r][0]:null}function xo(r,e,t,n,s=!1){if(typeof e!="string"||!Ap.test(e))throw new Error(`TYTX suffix '${e}' is invalid: expected uppercase ASCII letters only`);let i=kt[e];if(i!==void 0&&i[0]!==r){let o=i[0]===null?"null":i[0].name;throw new Error(`TYTX suffix '${e}' is already registered for ${o}`)}Vs=Vs.filter(([o])=>o!==r),Vs.push([r,e,t,s]),kt[e]=[r,n]}function Ft(r,e){Ao.set(r,e)}function Re(r){return Ao.has(r)?Ao.get(r):{}}var au={network:{maxAttempts:3,delay:1,backoff:2,jitter:!0,on:["TypeError","NetworkError","AbortError"]},aggressive:{maxAttempts:5,delay:.5,backoff:2,jitter:!0,on:["Error"]},gentle:{maxAttempts:2,delay:2,backoff:1.5,jitter:!1,on:["TypeError","NetworkError"]}};function xp(r){let e=r._retryPolicy;return e==null?null:typeof e=="string"?au[e]||null:e}function Dp(r,e){return e.some(t=>t==="Error"?!0:r.name===t||r.constructor.name===t)}function Sp(r){return new Promise(e=>setTimeout(e,r))}async function Cp(r,e){if(!e)return r();let t=e.maxAttempts||3,n=e.delay||1,s=e.backoff||2,i=e.jitter!==!1,o=e.on||["Error"],a=null,l=n*1e3;for(let u=0;u<t;u++)try{let c=r();return c instanceof Promise?await c:c}catch(c){if(a=c,u<t-1&&Dp(c,o)){let d=l;i&&(d*=1+Math.random()*.1),await Sp(d),l*=s}else throw c}throw a}var Z=class r{static classKwargs={cacheTime:0,readOnly:!1,asBag:null,retryPolicy:null};static classArgs=[];static internalParams=new Set(["cacheTime","readOnly","asBag","retryPolicy"]);constructor(e={}){let n={...this.constructor.classKwargs,...e};for(let i of["interval","reactive"])if(Object.hasOwn(n,i))throw new TypeError(`Removed resolver option: ${i}. Schedule updates in the application; use reset() and read explicitly.`);this.cacheTime=n.cacheTime,this._readOnly=n.readOnly,this._asBag=n.asBag,this._retryPolicy=n.retryPolicy,this._kw={};let s=this.constructor.internalParams;for(let[i,o]of Object.entries(n))s.has(i)||(this._kw[i]=o);this._lastUpdate=null,this._node=null,this._lastEffectiveFingerprint=null,this._cachedValue=null,this.init()}init(){}setNode(e){e!==this._node&&!this.readOnly&&this._lastUpdate!==null&&this.reset(),this._node=e,this.onSetResolver(e)}onSetResolver(e){}get node(){return this._node}get cacheTime(){return this._cacheTime}set cacheTime(e){if(typeof e=="boolean")throw new TypeError("cacheTime must be numeric; use a negative value for infinite caching");this._cacheTime=e}get readOnly(){return this._readOnly}get expired(){return this._cacheTime<0?this._lastUpdate===null:this._cacheTime===0||this._lastUpdate===null?!0:(Date.now()-this._lastUpdate)/1e3>this._cacheTime}reset(...e){if(e.length)throw new TypeError("reset() takes no arguments. It invalidates the cache for the next explicit read.");this._lastUpdate=null,this._lastEffectiveFingerprint=null}get cachedValue(){return!this.readOnly&&this._node?this._node._value:this._cachedValue}set cachedValue(e){!this.readOnly&&this._node?this._node.setValue(e,!1):this._cachedValue=e}_computeEffectiveFingerprint(e){return JSON.stringify(Object.entries(e).sort())}resolve(e={}){let{static:t=!1,...n}=e;if(t)return this._node?this._node._value:this.cachedValue;let s={...this._kw};if(this._node&&this._node.attr){let u=this.constructor.internalParams;for(let[c,d]of Object.entries(this._node.attr))u.has(c)||(s[c]=d)}Object.assign(s,n);let i=this._computeEffectiveFingerprint(s);if(i===this._lastEffectiveFingerprint&&!this.expired)return this.cachedValue;this._lastEffectiveFingerprint=i;let o=xp(this),a=()=>this.load(s);if(o)return Cp(a,o).then(u=>this._finalize(u));let l=a();return l&&typeof l.then=="function"?l.then(u=>this._finalize(u)):this._finalize(l)}_finalize(e){let t;return this._asBag===!0?t=!0:this._asBag===!1?t=!1:t=!this._readOnly,t&&e!==null&&e!==void 0&&(e=this._convertToBag(e)),this._lastUpdate=Date.now(),(!this.readOnly||this.cacheTime!==0)&&(this.cachedValue=e),e}_convertToBag(e){let t=r._BagClass;if(!t||e&&typeof e._htraverse=="function")return e;if(typeof e=="string"){if(e=e.trim(),e.startsWith("<")&&t.fromXml)return t.fromXml(e);if((e.startsWith("{")||e.startsWith("["))&&t.fromTytx)return t.fromTytx(e)}return e}static registerBagClass(e){r._BagClass=e}load(e){return null}};Z._BagClass=null;var jt=class extends Z{static classKwargs={cacheTime:0,readOnly:!1,asBag:!1,retryPolicy:null,callback:null};static classArgs=["callback"];static internalParams=new Set(["cacheTime","readOnly","asBag","retryPolicy","callback"]);constructor(e={}){typeof e=="function"&&(e={callback:e}),super(e),this._callback=e.callback||null}load(e){return this._callback?this._callback.call(this,e):null}};var Fe=class r{constructor(e,t,n=null,s=null,i=null,o=null,a=null,l=!0){this.label=t,this._value=null,this._attr={},this._parentBag=null,this._resolver=null,this._nodeSubscribers={},this._onChangedValue=null,this.nodeTag=o,this.xmlTag=a,this._compiled=null,this.parentBag=e,s&&this.setAttr(s,!1,!0,l),n!==null&&this.setValue(n,!1),i&&(this.resolver=i)}get parentBag(){return this._parentBag}set parentBag(e){e===null&&this._value?.parentNode===this&&this._value.setBackref(),this._parentBag=e,e?.backref&&this._value&&typeof this._value._htraverse=="function"&&this._value.setBackref(this,e)}get value(){return this.getValue()}set value(e){this.setValue(e)}getValue(e=!1,t=null,n={}){if(t!==null){let s=P(`${t}::QS`);if(Array.isArray(s)){let i=s.length?s:Object.keys(this._attr),o=i.map(l=>{let u=this.getAttr(l);return!e&&u instanceof Z?u.resolve():u}),a=l=>s.length===0?Object.fromEntries(i.map((u,c)=>[u,l[c]])):l.length===1?l[0]:l;return o.some(l=>l&&typeof l.then=="function")?Promise.all(o).then(a):a(o)}else{if(!this._resolver)throw new Error("Cannot use kwargs syntax without resolver");n={...n,...s}}}return this._resolver!==null?this._resolver.resolve({static:e,...n}):this._value}setValue(e,t=!0,n=null,s=null,i=!0,o=null,a=!1){e instanceof Z?(this.resolver=e,e=null):e instanceof r&&(n=n||{},Object.assign(n,e._attr),e.resolver&&(this.resolver=e.resolver),e=e._value);let l=this._value;l!==e&&l?.parentNode===this&&l.setBackref(),this._value=e;let u=l!==this._value,c=t??!0,d=null;if(n!==null){let h={...this._attr};this.setAttr(n,!1,s,i);let p=this._buildAttrDiff(h,this._attr);d=Object.keys(p).length>0?p:null}t=c&&(u||d!==null);let f=d?u?"upd_value_attr":"upd_attrs":"upd_value";if(this._onChangedValue&&this._onChangedValue(this,e,l,c),t){let h=d!==null?{oldvalue:l,attrs_diff:d}:{oldvalue:l};for(let p of Object.values(this._nodeSubscribers))p({node:this,info:h,evt:f})}this._parentBag!==null&&this._parentBag.backref&&(e&&typeof e._htraverse=="function"&&e.setBackref(this,this._parentBag),t&&this._parentBag._onNodeChanged(this,[this.label],f,l,d,o,a))}replace(e){if(!(e instanceof r))throw new TypeError("BagNode.replace expects a BagNode");if(e===this)return this;let t=e.staticValue;t&&typeof t._htraverse=="function"&&(t=t.createChildBag().replace(t));let n=null;e.resolver&&(n=Object.create(Object.getPrototypeOf(e.resolver),Object.getOwnPropertyDescriptors(e.resolver)),n._node=null,n._kw={...e.resolver._kw});let s=this._value,i={...this._attr},o=this.resolver;o&&o._node===this&&(o._node=null),this.resolver=n,this.setValue(t,!1,{...e.attr},!1,!1,null);let a=this._buildAttrDiff(i,this._attr),l=Object.keys(a).length?a:null,u=s!==t||o!==n;if(u||l){let c=l?u?"upd_value_attr":"upd_attrs":"upd_value",d=l?{oldvalue:s,attrs_diff:l}:{oldvalue:s};for(let f of Object.values(this._nodeSubscribers))f({node:this,info:d,evt:c});this._parentBag!==null&&this._parentBag.backref&&this._parentBag._onNodeChanged(this,[this.label],c,s,l)}return this}get staticValue(){return this._value}set staticValue(e){this._value=e}get resolver(){return this._resolver}set resolver(e){this._resolver=e,e&&e.setNode&&e.setNode(this)}resetResolver(){if(!this._resolver)throw new Error("Cannot reset resolver: node has no resolver");this._resolver.reset(),this.setValue(null)}get attr(){return this._attr}getAttr(e=null,t=null){return e?e in this._attr?this._attr[e]:t:this._attr}_buildAttrDiff(e,t){let n={},s=new Set([...Object.keys(e),...Object.keys(t)]);for(let i of s){let o=i in e?e[i]:null,a=i in t?t[i]:null;o!==a&&(n[i]={old:o,new:a})}return n}setAttr(e=null,t=!0,n=!0,s=!0){let i=e||{},o=Object.keys(this._nodeSubscribers).length>0,l=t&&(o||this._parentBag!==null&&this._parentBag.backref)?{...this._attr}:null;if(n?Object.assign(this._attr,i):this._attr={...i},s)for(let u of Object.keys(this._attr))this._attr[u]===null&&delete this._attr[u];if(t&&l!==null){let u=this._buildAttrDiff(l,this._attr);if(Object.keys(u).length>0&&o)for(let c of Object.values(this._nodeSubscribers))c({node:this,info:{attrs_diff:u},evt:"upd_attrs"});if(Object.keys(u).length>0&&this._parentBag!==null&&this._parentBag.backref){let c=t===!0?"true":String(t);this._parentBag._onNodeChanged(this,[this.label],"upd_attrs",null,u,c)}}}delAttr(...e){for(let t of e)if(typeof t=="string"&&t.includes(","))for(let n of t.split(","))delete this._attr[n.trim()];else delete this._attr[t]}hasAttr(e,t=null){return e in this._attr?t!==null?this._attr[e]===t:!0:!1}getInheritedAttributes(){let e={};return this._parentBag&&this._parentBag.parentNode&&(e=this._parentBag.parentNode.getInheritedAttributes()),{...e,...this._attr}}subscribe(e,t){this._nodeSubscribers[e]=t}unsubscribe(e){delete this._nodeSubscribers[e]}get compiled(){return this._compiled||(this._compiled={}),this._compiled}get isBranch(){return this._value!=null&&typeof this._value._htraverse=="function"}get position(){return this._parentBag===null?null:this._parentBag._nodes.index(this.label)}get fullpath(){if(this._parentBag!==null){let e=this._parentBag.fullpath;return e?`${e}.${this.label}`:this.label}return null}get parentNode(){return this._parentBag?this._parentBag.parentNode:null}attributeOwnerNode(e,t=null){let n=this;if(t===null)for(;n&&!(e in n._attr);)n=n.parentNode;else for(;n&&n._attr[e]!==t;)n=n.parentNode;return n}asTuple(){return[this.label,this.value,this._attr,this._resolver||null]}isEqual(e){if(!(e instanceof r)||this.label!==e.label)return!1;let t=Object.keys(this._attr),n=Object.keys(e._attr);if(t.length!==n.length)return!1;for(let s of t)if(this._attr[s]!==e._attr[s])return!1;return this._resolver!==null?this._resolver===e._resolver:this._value&&typeof this._value.equalTo=="function"?this._value.equalTo(e._value):this._value&&typeof this._value.isEqual=="function"?this._value.isEqual(e._value):this._value===e._value}diff(e){if(this.label!==e.label)return`Other label: ${e.label}`;let t=Object.keys(this._attr),n=Object.keys(e._attr);return t.length!==n.length||t.some(s=>this._attr[s]!==e._attr[s])?`attributes self:${JSON.stringify(this._attr)} --- other:${JSON.stringify(e._attr)}`:this._value!==e._value?`value self:${this._value} --- other:${e._value}`:null}toJson(e=!0){let t=this.value;return t&&typeof t.toJson=="function"&&(t=t.toJson(e,!0)),{label:this.label,value:t,attr:this._attr}}toString(){return`BagNode : ${this.label}`}};var yn=class r{constructor(){this._dict=Object.create(null),this._list=[],this._parentBag=null}index(e){if(e in this._dict)return this._list.findIndex(n=>n.label===e);let t=e.match(/^#(\d+)$/);if(t){let n=parseInt(t[1],10);return n<this._list.length?n:-1}if(t=e.match(/^#(\w*)=(.*)$/),t){let[,n,s]=t,i=s.includes("::")?P(s):s;return n?this._list.findIndex(o=>o.getAttr(n)===i):this._list.findIndex(o=>o._value===i)}return-1}_parsePosition(e){let t=this._list.length;if(e==null||e===">")return t;if(typeof e=="number")return e<0&&(e=t+e),Math.max(0,Math.min(e,t));if(e==="<")return 0;if(e.startsWith("#")){let n=this._parseSharpIndex(e.slice(1),e);return Math.min(n,t)}if(e.startsWith("<")){let n=e.slice(1);if(n.startsWith("#")){let i=this._parseSharpIndex(n.slice(1),e);return Math.min(i,t)}let s=this.index(n);if(s<0)throw new Error(`Invalid node_position '${e}': label '${n}' not found`);return s}if(e.startsWith(">")){let n=e.slice(1);if(n.startsWith("#")){let i=this._parseSharpIndex(n.slice(1),e);return Math.min(i+1,t)}let s=this.index(n);if(s<0)throw new Error(`Invalid node_position '${e}': label '${n}' not found`);return s+1}throw new Error(`Invalid node_position '${e}': unrecognized syntax`)}_parseSharpIndex(e,t){if(!/^-?\d+$/.test(e))throw new Error(`Invalid node_position '${t}': '${e}' is not an integer`);let n=parseInt(e,10);if(n<0)throw new Error(`Invalid node_position '${t}': negative index not allowed in '#n' syntax`);return n}get(e){if(typeof e=="number")return e>=0&&e<this._list.length?this._list[e]:null;if(e.startsWith("#")){let t=this.index(e);return t>=0?this._list[t]:null}return this._dict[e]||null}set(e,t,n=">",s=null,i=null,o=null,a=!1,l=!0,u=null,c=!0,d=!1,f=null){let h=null;if(e.includes("?")&&([e,h]=e.split("?",2)),e==null||e.startsWith("#"))throw new Error("Cannot create new node with #n syntax");if(h){let m=h.split("&");if(m.length===1)s={[m[0]]:t};else{if(!Array.isArray(t)||t.length!==m.length)throw new Error("Wrong attributes assignment");s={};for(let g=0;g<m.length;g++)s[m[g]]=t[g]}t=null}let p=this._dict[e];if(p)f&&(p.nodeTag=f),o!==null&&(o===!1?p.resolver=null:p.resolver=o),h?p.setAttr(s,c,!0,l):p.setValue(t,c,s,a,l,u,d);else{let m=i&&i.nodeClass?i.nodeClass:Fe;p=new m(i,e,h?null:t,s,o,f,null,l);let g=this._parsePosition(n);this._dict[e]=p,this._list.splice(g,0,p),c&&i&&i.backref&&i._onNodeInserted(p,g,null,u,d)}return d&&p.setValue(null,!1),p}pop(e){let t=this.get(e);if(t){delete this._dict[t.label];let n=this._list.indexOf(t);return n>=0&&this._list.splice(n,1),t}return null}has(e){return e in this._dict}get length(){return this._list.length}clear(){this._dict=Object.create(null),this._list=[]}keys(){return this._list.map(e=>e.label)}values(){return this._list.map(e=>e.getValue())}items(){return this._list.map(e=>[e.label,e.getValue()])}[Symbol.iterator](){return this._list[Symbol.iterator]()}move(e,t,n=!0){if(t<0)return;let s=Array.isArray(e)?e:[e];if(s.length===0||t>=this._list.length)return;let i=this._list[t].label;if(s.length>1){let o=[...s].sort((c,d)=>c-d),a=o[0]<t?1:0,l=[];for(let c=o.length-1;c>=0;c--){let d=o[c];if(d>=0&&d<this._list.length){let f=this._list[d];this._list.splice(d,1),l.push(f),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(f,d)}}let u=this.index(i);u<0&&(u=this._list.length),u+=a;for(let c of l)this._list.splice(u,0,c),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(c,u)}else{let o=s[0];if(o===t||o<0||o>=this._list.length)return;let a=this._list[o];this._list.splice(o,1),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeDeleted(a,o),this._list.splice(t,0,a),n&&this._parentBag&&this._parentBag.backref&&this._parentBag._onNodeInserted(a,t)}}isEqual(e){if(!(e instanceof r)||this._list.length!==e._list.length)return!1;for(let t=0;t<this._list.length;t++){let n=this._list[t],s=e._list[t];if(!n.isEqual(s))return!1}return!0}};var du=oa(go(),1);var Do="::RSLV:",Np=new Map,Ip=new Map,Hs=new WeakMap,re=class extends Error{constructor(e){super(e),this.name="BagSerializationError"}},vn=class extends Z{constructor(e){super({asBag:!1}),Hs.set(this,e)}get payload(){return Hs.get(this)}load(){throw new re("This resolver is opaque; local execution is unavailable")}};function lu(r){if(!r||typeof r!="object"||Array.isArray(r)||typeof r.resolver_module!="string"||typeof r.resolver_class!="string"||!Array.isArray(r.args??[])||!r.kwargs||typeof r.kwargs!="object"||Array.isArray(r.kwargs))throw new re("Invalid resolver description")}function uu(r,e=new Set){if(!(r===null||typeof r=="string"||typeof r=="boolean")&&!(typeof r=="number"&&Number.isFinite(r))){if(typeof r!="object"||e.has(r)||!Array.isArray(r)&&Object.getPrototypeOf(r)!==Object.prototype&&Object.getPrototypeOf(r)!==null)throw new re("Resolver parameters must be JSON data; callbacks cannot travel");e.add(r);for(let t of Object.values(r))uu(t,e);e.delete(r)}}function En(r){if(Hs.has(r))return Hs.get(r);let e=Ip.get(r.constructor);if(!e)throw new re(`Unregistered resolver: ${r.constructor.name}`);let t=e.encode(r),n={resolver_module:e.module,resolver_class:e.name,args:t.args??[],kwargs:t.kwargs??{}};return lu(n),uu(n),Do+JSON.stringify(n)}function zs(r){if(typeof r!="string"||!r.startsWith(Do))return null;let e=r.slice(Do.length);if(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+$/.test(e))return new vn(r);let t;try{t=JSON.parse(e)}catch{throw new re("Invalid resolver JSON or signed token")}lu(t);let n=Np.get(JSON.stringify([t.resolver_module,t.resolver_class]));if(!n)return new vn(r);let s=n.decode({args:t.args??[],kwargs:t.kwargs});if(!(s instanceof n.cls))throw new re("Resolver decoder returned an incompatible instance");return s}function Ws(r){return Object.fromEntries(Object.entries(r||{}).map(([e,t])=>[e,t instanceof Z?En(t):t]))}function So(r){return Object.fromEntries(Object.entries(r||{}).map(([e,t])=>[e,zs(t)??t]))}var je="__cls";function Nr(r,e){return r!==null&&r.tytxSuffix===e?r:wn(e)}function Op(r){let e=r.tytxSuffix,t=Object.entries(Re(e)).filter(([,n])=>n===r).map(([n])=>n);if(t.length===0)throw new re(`${r.name} is not in the TYTX subtype dictionary of '${e}'`);if(t.length>1)throw new re(`${r.name} is in the TYTX subtype dictionary of '${e}' under several names: ${t.sort().join(", ")}`);return t[0]}function Co(r,e){let t=Re(r);if(!Object.hasOwn(t,e))throw new re(`Unknown Bag class '${e}' for TYTX type '${r}'`);return t[e]}function No(r,e){return r===e?null:Op(r)}function*fu(r,e=[]){for(let t of r){let n=[...e,t.label];yield[n,t];let s=t.getValue(!0);!t.resolver&&s instanceof C&&(yield*fu(s,n))}}function Bp(r){let e=r.toISOString(),t=r.getUTCFullYear()===1970&&r.getUTCMonth()===0&&r.getUTCDate()===1,n=r.getUTCHours()===0&&r.getUTCMinutes()===0&&r.getUTCSeconds()===0&&r.getUTCMilliseconds()===0;if(n&&!t)return e.slice(0,e.indexOf("T"));let s=e.replace(/\.000Z$/,"Z");return t&&!n?s.slice(s.indexOf("T")+1):s}function Ir(r){if(r===null||typeof r!="object")return!1;let e=Object.getPrototypeOf(r);return e===Object.prototype||e===null}function At(r){return typeof r=="string"?r.includes("::")?`${r}::T`:r:Array.isArray(r)?r.map(At):Ir(r)?Object.fromEntries(Object.entries(r).map(([e,t])=>[e,At(t)])):r}function Io(r){if(!Ir(r))throw new TypeError("Bag options must be an object");let{recursive:e=!0}=r;if(typeof e!="boolean")throw new TypeError("recursive must be a boolean");return e}var cu=!1,C=class r{static tytxSuffix="X";constructor(e=null,t={}){this._nodes=new yn,this._backref=!1,this._parent=null,this._parentNode=null,this._rootAttributes=null,this._updSubscribers={},this._insSubscribers={},this._delSubscribers={},Io(t),e!=null&&this.fillFrom(e,t)}get parent(){return this._parent}set parent(e){this._parent=e}get parentNode(){return this._parentNode}set parentNode(e){this._parentNode=e}get backref(){return!!this._backref}get nodeClass(){return Fe}createChildBag(){return new this.constructor}get fullpath(){if(this._parent!==null&&this._parentNode!==null){let e=this._parent.fullpath;return e?`${e}.${this._parentNode.label}`:this._parentNode.label}return null}relativePath(e){let t=[],n=e;for(;n!==null;){if(n.parentBag===this)return t.push(n.label),t.reverse(),t.join(".");t.push(n.label),n=n.parentNode}return null}get length(){return this._nodes.length}get root(){let e=this;for(;e.parent!==null;)e=e.parent;return e}get attributes(){return this._parentNode!==null?this._parentNode.getAttr():{}}get rootAttributes(){return this._rootAttributes}set rootAttributes(e){this._rootAttributes=e!==null?{...e}:null}_htraverseBefore(e){let t=this,n;for(typeof e=="string"?(e=e.replace(/\.\.\//g,"#parent."),n=e.split(".").filter(s=>s)):n=[...e];n.length&&n[0]==="#parent"&&t!==null;)n.shift(),t=t.parent;return[t,n]}_htraverse(e,t=!1,n=!0){let[s,i]=this._htraverseBefore(e);if(s===null)return[null,null];if(i.length===0)return[s,""];for(;i.length>1&&s instanceof r;){let o=i[0];if(o==="#parent"){if(s.parent===null||s.parent===void 0)break;i.shift(),s=s.parent;continue}let a=s._nodes.get(o);if(!a)break;let l=a.getValue(n);if(l instanceof r)i.shift(),s=l;else if(t){let u=s.createChildBag();a.setValue(u,!0,null,!0,!0,"autocreate"),i.shift(),s=u}else break}if(!t)return i.length>1?[null,null]:[s,i[0]];for(;i.length>1;){let o=i.shift();if(o.startsWith("#"))throw new kn("Not existing index in #n syntax");let a=s.createChildBag();s._nodes.set(o,a,">",null,s,null,!1,!0,"autocreate"),s=a}return[s,i[0]]}get(e,t=null,n=!0,s={}){if(!e)return this;if(e==="#parent")return this.parent;let i=null;e.includes("?")&&([e,i]=e.split("?",2));let o=this._nodes.get(e);return o?o.getValue(n,i,s):t}getItem(e,t=null,n=!1,s={}){if(!e)return this;let[i,o]=this._htraverse(e,!1,n);return i instanceof r?i.get(o,t,n,s):t}setItem(e,t,n=null,s=">",i=!1,o=!0,a=null,l=!1,u=!0,c=null,d=null){if(e==="")throw new RangeError("setItem requires a non-empty path");let[f,h]=this._htraverse(e,!0);return f._nodes.set(h,t,s,n,f,c,i,o,a,u,l,d)}_pop(e,t=null){let n=this._nodes.index(e);if(n>=0){let s=this._nodes.pop(n);return this.backref&&this._onNodeDeleted(s,n,t),s}return null}pop(e,t=null,n=null){let s=this.popNode(e,n);return s?s.value:t}delItem(e,t=null,n=null){return this.pop(e,t,n)}popNode(e,t=null){let[n,s]=this._htraverse(e,!1,!0);if(!n||!s)return null;let i=n._nodes.get(s);if(!i)return null;try{return n._pop(s,t)}finally{i.parentBag===n&&n._nodes._dict[i.label]!==i&&(i.parentBag=null)}}clear(){let e=[...this._nodes];this._nodes.clear(),this.backref&&this._onNodeDeleted(e,-1);for(let t of e)t.parentBag=null}getNode(e,t=!0,n=!1,s=null){if(e==null||e==="")return this.parentNode;if(typeof e=="number")return this._nodes.get(e);typeof e=="string"&&(e=e.split("?",1)[0]);let[i,o]=this._htraverse(e,n,t);if(i instanceof r&&o){let a=i._nodes.get(o);if(a)return a;if(n)return i._nodes.set(o,s,">",null,i,null,!1,!0,"autocreate"),i._nodes.get(o)}return null}setBackref(e=null,t=null){let n=this._backref;if(this._backref=!0,this._parent=t,this._parentNode=e,!n){this._nodes._parentBag=this;for(let s of this)s.parentBag=this}}delParentRef(){this._parent=null,this._parentNode=null,this._backref=!1}clearBackref(){if(this._backref){this._backref=!1,this._parent=null,this._parentNode=null,this._nodes._parentBag=null;for(let e of this){e.parentBag=null;let t=e.getValue(!0);t instanceof r&&t.clearBackref()}}}_onNodeChanged(e,t,n,s=null,i=null,o=null,a=!1){for(let l of Object.values(this._updSubscribers))l({node:e,pathlist:t,oldvalue:s,attrs_diff:i,evt:n,reason:o,fired:a});this._parent&&this._parentNode&&this._parent._onNodeChanged(e,[this._parentNode.label,...t],n,s,i,o,a)}_onNodeInserted(e,t,n=null,s=null,i=!1){let o=e.parentBag,a=e.getValue(!0);o!==null&&o.backref&&a instanceof r&&a.setBackref(e,o),n===null&&(n=[]);for(let l of Object.values(this._insSubscribers))l({node:e,pathlist:n,ind:t,evt:"ins",reason:s,fired:i});this._parent&&this._parentNode&&this._parent._onNodeInserted(e,t,[this._parentNode.label,...n],s,i)}_onNodeDeleted(e,t,n=null,s=null){for(let i of Object.values(this._delSubscribers))i({node:e,pathlist:n,ind:t,evt:"del",reason:s});this._parent&&this._parentNode&&(n===null&&(n=[]),this._parent._onNodeDeleted(e,t,[this._parentNode.label,...n],s))}_subscribe(e,t,n){n!=null&&(t[e]=n)}subscribe(e,t={}){if(Object.hasOwn(t,"timer")||Object.hasOwn(t,"interval"))throw new TypeError("Timer subscriptions were removed. Schedule polling in the application.");let{update:n=null,insert:s=null,delete:i=null,any:o=null}=t;this.backref||this.setBackref(),this._subscribe(e,this._updSubscribers,n||o),this._subscribe(e,this._insSubscribers,s||o),this._subscribe(e,this._delSubscribers,i||o)}unsubscribe(e,t={}){if(Object.hasOwn(t,"timer")||Object.hasOwn(t,"interval"))throw new TypeError("Timer subscriptions were removed. Schedule polling in the application.");let{update:n=!1,insert:s=!1,delete:i=!1,any:o=!1}=t;(n||o)&&delete this._updSubscribers[e],(s||o)&&delete this._insSubscribers[e],(i||o)&&delete this._delSubscribers[e]}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}keys(){return this._nodes.keys()}values(){return this._nodes.values()}items(){return[...this._nodes].map(e=>({key:e.label,value:e.getValue()}))}get nodes(){return this.getNodes()}node(e){return this._nodes.get(e)}setAttr(e=null,t=null,n=!0){let s=r.prototype.getNode.call(this,e,!0,!0);s&&s.setAttr(t,!0,!0,n)}getAttr(e=null,t=null,n=null){let s=this.getNode(e);return s?s.getAttr(t,n):n}delAttr(e=null,...t){let n=this.getNode(e);n&&n.delAttr(...t)}getInheritedAttributes(){return this._parentNode?this._parentNode.getInheritedAttributes():{}}getNodes(e=null){return e?[...this._nodes].filter(t=>e(t)):[...this._nodes]}getNodeByValue(e,t){for(let n of this._nodes){let s=n.value;if(s instanceof r){if(s.getItem(e)===t)return n}else if(s&&s.get&&s.get(e)===t)return n}return null}getNodeByAttr(e,t,n=!1,s=!1){let i=t===void 0,o=n&&typeof t=="string"?t.toLowerCase():t,a=l=>{let u=[];for(let c of l._nodes){if(e in c.attr){let d=n&&typeof c.attr[e]=="string"?c.attr[e].toLowerCase():c.attr[e];if(i||d==o)return c}if(c._value instanceof r)if(s){let d=a(c._value);if(d)return d}else u.push(c._value)}for(let c of u){let d=a(c);if(d)return d}return null};return a(this)}isEmpty(e=!1,t=!1){if(this._nodes.length===0)return!0;for(let n of this._nodes){if(n._resolver!==null)return!1;let s=n.getValue(!0);if(s!=null&&!(e&&s===0)&&!(t&&s===""))return!1}return!0}query(e=null,t=null,n=!1,s=!1,i=!0,o=!0,a=null,l=!0){e||(e="#k,#v,#a");let u=this,c;if(typeof e=="string"){if(e.includes(":")){let[h,p]=e.split(":");u=this.getItem(h),e=p}c=e.split(",").map(h=>h.trim())}else c=e;let d=(h,p,m,g,b)=>{if(p==="#k")return h.label;if(p==="#p")return m;if(p==="#n")return h;if(typeof p=="function")return p(h);if(p==="#v"){let y=b();return g&&y instanceof r?null:y}else if(p.startsWith("#v.")){let y=p.split(".").slice(1).join("."),w=b();return w&&w.getItem?w.getItem(y):null}else{if(p==="#__v")return h.getValue(!0);if(p.startsWith("#a")){let y=p.includes(".")?p.split(".").slice(1).join("."):null;return h.getAttr(y)}else{let y=b();return y&&y.getItem?y.getItem(p):null}}};function*f(){let h=0;function*p(m,g){for(let b of m._nodes){let y=g?`${g}.${b.label}`:b.label,w=!1,k,A=()=>(w||(k=b.getValue(l),w=!0),k);if((i&&o||(A()instanceof r?o:i))&&(t===null||t(b))&&(yield c.length===1?d(b,c[0],y,s,A):c.map(N=>d(b,N,y,s,A)),h++,a!==null&&h>=a))return;if(s){let N=A();if(N instanceof r&&(yield*p(N,y),a!==null&&h>=a))return}}}yield*p(u,"")}return n?f():[...f()]}getLeaves(){let e=[],t=(n,s)=>{for(let i of n._nodes){let o=s?`${s}.${i.label}`:i.label,a=i.getValue(!1);a instanceof r?t(a,o):e.push([o,a])}};return t(this,""),e}digest(e=null,t=null,n=!1){typeof t=="boolean"&&(console.warn("Bag.digest(what, asColumns) is deprecated; use digest(what, null, asColumns)."),n=t,t=null);let s=this.query(e,t,!1,!1,!0,!0,null,!1);if(n){if(!s||s.length===0)return(typeof e=="string"?e:"#k,#v,#a").split(",").map(l=>l.trim()).map(()=>[]);let i=[...s];if(i.length&&Array.isArray(i[0])){let o=i[0].length,a=[];for(let l=0;l<o;l++)a.push(i.map(u=>u[l]));return a}return[i]}return[...s]}columns(e,t=!1){typeof e=="string"&&(e=e.split(","));let n=t?"#a.":"",s=e.map(i=>`${n}${i}`).join(",");return this.digest(s,null,!0)}sum(e="#v",t=!1,n=null){if(t!=null&&typeof t!="boolean")throw new TypeError("sum strict must be a boolean; pass condition as the third argument");if(n!=null&&typeof n!="function")throw new TypeError("sum condition must be callable; deep is no longer supported");let s=i=>{let o=0,a=!1;for(let l of this.query(i,n)){if(l==null||l===""){a=!0;continue}if(typeof l!="number"&&typeof l!="boolean"){if(t)throw new TypeError(`sum encountered non-numeric value: ${typeof l}`);continue}o+=l}return t&&a?null:o};return e.includes(",")?e.split(",").map(i=>s(i.trim())):s(e)}sort(e="#k:a"){let t=(s,i)=>s==null?[-1,""]:i&&typeof s=="string"?[0,s.toLowerCase()]:[0,s],n=(s,i)=>s[0]!==i[0]?s[0]-i[0]:s[1]<i[1]?-1:s[1]>i[1]?1:0;if(typeof e=="function")this._nodes._list.sort((s,i)=>{let o=e(s),a=e(i);return o<a?-1:o>a?1:0});else{let s=e.split(",");s.reverse();for(let i of s){let o,a;i.includes(":")?[o,a]=i.split(":",2):(o=i,a="a"),o=o.trim(),a=a.trim();let l=a==="d"||a==="D",u=a==="a"||a==="d",c;if(o.toLowerCase()==="#k")c=d=>t(d.label,u);else if(o.toLowerCase()==="#v")c=d=>t(d.value,u);else if(o.toLowerCase().startsWith("#a.")){let d=o.slice(3);c=f=>t(f.getAttr(d),u)}else c=d=>{let f=d.value,h=f instanceof r?f.getItem(o):f?f[o]:null;return t(h,u)};this._nodes._list.sort((d,f)=>{let h=n(c(d),c(f));return l?-h:h})}}return this}equalTo(e){return e instanceof r?this._nodes.isEqual(e._nodes):!1}has(e){if(typeof e=="string"){let t=null;e.includes("?")&&([e,t]=e.split("?",2));let n=this.getNode(e);return n===null?!1:t===null?!0:t.split("&").every(s=>s in n.attr)}else if(e&&e.label!==void 0)return[...this._nodes].includes(e);return!1}getResolver(e){let t=this.getNode(e);return t?t.resolver:null}setResolver(e,t){let n=this.getNode(e);n||(this.setItem(e,null),n=this.getNode(e)),n.resolver=t}setCallbackItem(e,t,n={}){let s=new jt({callback:t,...n});this.setResolver(e,s)}move(e,t,n=!0){this._nodes.move(e,t,n)}asDict(e=!1,t=!1,n=!1,s=!1){let i={};for(let o of this._nodes){let a=o.value;if(s&&a==null)continue;let l=o.label;e&&(l=String(l)),t&&(l=l.toLowerCase()),n&&a instanceof r&&(a=r.prototype.asDict.call(a,e,t,n,s)),Object.defineProperty(i,l,{value:a,enumerable:!0,writable:!0,configurable:!0})}return i}setdefault(e,t=null){let n=this.getNode(e);return n?n.value:(this.setItem(e,t),t)}deepcopy(e=!1){let t=this.createChildBag();for(let n of this._nodes){let s=n.getValue(!e);s instanceof r&&(s=s.deepcopy(e));let i=new t.nodeClass(t,n.label,s);i.setAttr({...n.attr},!1,!1,!1),i.nodeTag=n.nodeTag,i.xmlTag=n.xmlTag,t._nodes._list.push(i),t._nodes._dict[i.label]=i}return t}update(e,t=null,n=null,s=!1){if(!(e instanceof r)){for(let i in e){let o=e[i];(!s||o!==null||!this._nodes.has(i))&&this.setItem(i,o,null,">",!1,!1,n,!1,n!==!1)}return}for(let i of[...e]){let o=i.label,a=t==="static"?i.resolver:null,l=a?null:i.getValue(),u=i.attr.__replace;delete i.attr.__replace;let c=this._nodes.get(o);if(c)if(c.setAttr(i.attr,n===null?!0:n,!0,!1),i.nodeTag!=null&&(c.nodeTag=i.nodeTag),i.xmlTag!=null&&(c.xmlTag=i.xmlTag),a)c.resolver=a,c.setValue(null,n===null?!0:n,null,null,!1,n);else{i.resolver&&(c.resolver=null);let d=c.getValue();l instanceof r&&d instanceof r&&!u?d.update(l,t,n,s):(!s||l!==null)&&c.setValue(l,n===null?!0:n,null,null,!1,n)}else{let d=this.setItem(o,a||l,i.attr,">",!1,!1,n,!1,n!==!1);d.nodeTag=i.nodeTag,d.xmlTag=i.xmlTag}}}_fillFromBag(e){this.clear();for(let t of e){let n=new this.nodeClass(this,t.label);n.replace(t),n.nodeTag=t.nodeTag,n.xmlTag=t.xmlTag,this._nodes._list.push(n),this._nodes._dict[n.label]=n}}_appendLiteral(e,t,n=null,s=null,i=null){if(typeof e!="string")throw new TypeError("Bag labels must be strings");let o=new this.nodeClass(this,e,null,n,s,i,null,!1);return t instanceof Z?o.resolver=t:o._value=t,this._nodes._dict[e]=o,this._nodes._list.push(o),o}fillFrom(e=null,t={}){let n=Io(t);if(e!=null&&!Ir(e)&&!Array.isArray(e))throw new TypeError("Bag source must be a dictionary, array or null");let s=this.createChildBag(),i=new Set,o=(a,l,u)=>{if(i.has(l))throw new TypeError(`Cyclic Bag source at ${u}`);i.add(l);try{let c=Array.isArray(l)?String(l.length).length+1:0,d=Array.isArray(l)?Array.from(l,(f,h)=>[`r_${String(h).padStart(c,"0")}`,f]):Object.entries(l);if(!Array.isArray(l)&&Object.getOwnPropertySymbols(l).some(f=>Object.prototype.propertyIsEnumerable.call(l,f)))throw new TypeError(`Bag labels must be strings at ${u}`);for(let[f,h]of d){let p=h;n&&(Ir(p)||Array.isArray(p))&&(p=this.createChildBag(),o(p,h,`${u}[${JSON.stringify(f)}]`)),a._appendLiteral(f,p)}}finally{i.delete(l)}};return e!=null&&o(s,e,"$"),this._replacePrepared(s)}_loadSource(e,t={}){return this.fillFrom(e,t)}replace(e){if(!(e instanceof r))throw new TypeError("Bag.replace expects a Bag");if(e===this)return this;let t=this.createChildBag();return t._fillFromBag(e),this._replacePrepared(t)}_replacePrepared(e){for(let n of this._nodes){n.parentBag=null;let s=n.getValue(!0);s instanceof r&&s.clearBackref()}let t=this._nodes;this._nodes=e._nodes,e._nodes=t,this._nodes._parentBag=this.backref?this:null,e._nodes._parentBag=null;for(let n of this._nodes)n.parentBag=this;for(let n of e._nodes)n._parentBag=e;return this.backref&&this.parent&&this.parentNode&&this.parent._onNodeChanged(this.parentNode,[this.parentNode.label],"upd_value",e),this}forEach(e,{static:t=!0,deep:n=!1,kwargs:s={}}={}){if(typeof e!="function")throw new TypeError("forEach requires a callback");let i=(o,a)=>{for(let l=0;l<o._nodes.length;l++){let u=o._nodes._list[l],c={...a};"_pathlist"in a&&(c._pathlist=[...a._pathlist,u.label]),"_indexlist"in a&&(c._indexlist=[...a._indexlist,l]);let d=e(u,c,l);if(d)return d;if(d==null&&n){let f=u.getValue(t);if(f instanceof r){let h=i(f,c);if(h)return h}}}return null};return i(this,s)}*traverse(){for(let e of this._nodes){yield e;let t=e.getValue(!0);t instanceof r&&(yield*t.traverse())}}*_iterNodesWithPaths(e=!0,t=""){for(let n of this._nodes){let s=t?`${t}.${n.label}`:n.label;yield[s,n];let i=n.getValue(e);i instanceof r&&(yield*i._iterNodesWithPaths(e,s))}}*_nodeFlattener(e=null){let t=e!==null,n=t?Object.create(null):null,s=0,i=new Map([["[]",this.constructor]]);for(let[o,a]of fu(this)){let l=o.slice(0,-1),u=JSON.stringify(o),c=JSON.stringify(l),d=a.getValue(!0),f,h=null;if(a.resolver)f=En(a.resolver);else if(d instanceof r){let g=d.constructor,b=g.tytxSuffix;i.set(u,g),h=No(g,Nr(i.get(c),b)),f=`::${b}`}else d===null?f="::NN":f=At(d);if(a.attr&&Object.hasOwn(a.attr,je))throw new re(`node '${o}': the attribute '${je}' is reserved for the Bag class name`);let p=Ws(At(a.attr));h!==null&&(p[je]=h);let m=a.nodeTag;t?(yield[l.length?n[c]:null,a.label,m,f,p],d instanceof r&&(n[u]=s,e[s]=o,s++)):yield[l,a.label,m,f,p]}}toTytx(e="json",t=!1){let n=this._toTytxPayload(t),s=this.constructor.tytxSuffix;if(e==="json")return`${n}::${s}`;if(e==="msgpack")return bs(new Le(4,new TextEncoder().encode(`${s}:${n}`)));throw new TypeError(`Unsupported transport: ${e}`)}_toTytxPayload(e=!1){let t;if(e){let i={};t={rows:[...this._nodeFlattener(i)],paths:i}}else t={rows:[...this._nodeFlattener(null)]};let n=this.constructor,s=No(n,Nr(null,n.tytxSuffix));return s!==null&&(t[je]=s),t.rows=t.rows.map(([i,o,a,l,u])=>[At(i),At(o),At(a),l,u]),t.paths&&(t.paths=At(t.paths)),W(t)}static fromTytx(e,t="json",n={}){if(Ir(t)&&(n=t,t="json"),Io(n),typeof e!="string"&&!(e instanceof Uint8Array))throw new TypeError("fromTytx requires serialized text or bytes");if(t!=="json"&&t!=="msgpack")throw new TypeError(`Unsupported transport: ${t}`);t==="json"&&e instanceof Uint8Array&&(e=new TextDecoder().decode(e));let s=P(e,t==="json"?null:t);if(s instanceof r)return s;if(!Ir(s)&&!Array.isArray(s))throw new TypeError("fromTytx requires a dictionary, array or typed Bag root");return new this(s,n)}static _fromTytxPayload(e){let t=this.tytxSuffix;if(e==="")return new(Nr(null,t));let n=P(e);if(!n||!Array.isArray(n.rows))throw new re("Invalid TYTX Bag: expected rows");let s=n.paths,i=s!=null,o=Object.hasOwn(n,je)?Co(t,n[je]):Nr(null,t),a=new o,l=new Map([["[]",a]]);for(let u of n.rows){if(!Array.isArray(u)||u.length!==5)throw new re("Invalid TYTX Bag row");let[c,d,f,h,p]=u,m=c??"";if(i){if(c!==null&&!Object.hasOwn(s,c))throw new re(`Unknown TYTX parent reference: ${c}`);m=c===null?"":s[c]}if(typeof m=="string"&&(m=m?m.split("."):[]),!Array.isArray(m))throw new re("Invalid TYTX parent path");let g=JSON.stringify(m);if(!l.has(g))throw new re(`Missing or undecodable TYTX parent branch: ${m}`);let b=l.get(g),y=JSON.stringify([...m,d]),w=h,k=zs(w),A=So(p),v=Object.hasOwn(A,je)?A[je]:null;if(delete A[je],w instanceof r){let L=w.constructor.tytxSuffix,U=v!==null?Co(L,v):Nr(b.constructor,L);w=new U,l.set(y,w)}else if(v!==null)throw new re(`node '${y}': the attribute '${je}' is reserved for the Bag class name of a branch`);let N=b._appendLiteral(d,k?null:w,A,k);N.nodeTag=f??null}return a}toXml(e={}){let{pretty:t=!1,encoding:n="UTF-8",docHeader:s=null,selfClosedTags:i=null}=e,o=this._bagToXml(i,t);return s===!0?o=`<?xml version='1.0' encoding='${n}'?>
16
+ ${o}`:typeof s=="string"&&(o=`${s}
17
+ ${o}`),o}_bagToXml(e=null,t=!1,n=0){let s=[];for(let i of this._nodes)s.push((t?" ".repeat(n):"")+this._nodeToXml(i,e,t,n));return s.join(t?`
18
+ `:"")}_nodeToXml(e,t=null,n=!1,s=0){let i=e.xmlTag||e.nodeTag||e.label,o=this._sanitizeTag(i),a=[];if(o!==i&&a.push(`_tag="${this._escapeAttr(i)}"`),e.resolver&&a.push(`_resolver="${this._escapeAttr(En(e.resolver))}"`),e.attr)for(let[f,h]of Object.entries(Ws(e.attr)))h!==null&&h!==!1&&h!==void 0&&a.push(`${f}="${this._escapeAttr(String(h))}"`);let l=a.length?" "+a.join(" "):"",u=e.resolver?null:e.getValue(!0);if(u&&typeof u._bagToXml=="function"){n=n&&e.attr?.["xml:space"]!=="preserve";let f=u._bagToXml(t,n,s+1);return f?n?`<${o}${l}>
19
19
  ${f}
20
- ${" ".repeat(s)}</${a}>`:`<${a}${l}>${f}</${a}>`:t===null||t.includes(a)?`<${a}${l}/>`:`<${a}${l}></${a}>`}if(u==null||u==="")return t===null||t.includes(a)?`<${a}${l}/>`:`<${a}${l}></${a}>`;let c=u instanceof Date&&!Number.isNaN(u.getTime())?Ep(u):String(u),d=this._escapeXml(c);return`<${a}${l}>${d}</${a}>`}_sanitizeTag(e){return e?e.replace(/[^a-zA-Z0-9_\-.:]/g,"_"):"_none_"}_escapeXml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}_escapeAttr(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}static fromXml(e,t={}){let{tagAttribute:n=null}=t,s;if(typeof DOMParser<"u"){s=new DOMParser().parseFromString(e,"application/xml");let a=s.querySelector("parsererror");if(a)throw new Error(`XML parse error: ${a.textContent}`)}else s=new tu.DOMParser().parseFromString(e,"application/xml");return this._xmlElementToBag(s.documentElement,n)}static _xmlElementToBag(e,t=null){let n=new this,s=Array.from(e.childNodes).filter(i=>i.nodeType===1);for(let i of s){let a=i.tagName,o={};for(let m=0;m<i.attributes.length;m++){let g=i.attributes[m];o[g.name]=g.value}let l=Fs(o._resolver);l&&delete o._resolver;let u=String(o._T||"").toUpperCase()==="BAG";Object.assign(o,_a(o));let c=a;"_tag"in o&&(c=o._tag,delete o._tag),t&&t in o&&(c=o[t],delete o[t]);let d=c,f=1;for(;n.getNode(c);)c=`${d}_${f++}`;let h=Array.from(i.childNodes).filter(m=>m.nodeType===1),p;if(h.length>0||u){let m=this._xmlElementToBag(i,t);p=n.setItem(c,m,Object.keys(o).length>0?o:null)}else{let m=i.textContent||"";p=n.setItem(c,m,Object.keys(o).length>0?o:null)}l&&(p.resolver=l),p.xmlTag=a}return n}static async fromUrl(e,t={}){let{timeout:n=30}=t,s={};n&&(s.signal=AbortSignal.timeout(n*1e3));let i=await fetch(e,s),a=i.headers.get("content-type")||"",o=await i.text();if(a.includes("json"))return r.fromTytx(o);if(a.includes("xml"))return r.fromXml(o);let l=o.trim();if(l.startsWith("<"))return r.fromXml(o);if(l.startsWith("{")||l.startsWith("["))return r.fromTytx(o);throw new yn(`Unsupported content-type: ${a}`)}toJson(e=!0){let t=[];for(let n of this._nodes)t.push(this._nodeToJsonDict(n,e));return e?W(t):JSON.stringify(t)}_nodeToJsonDict(e,t){let n=e.resolver?null:e.getValue(!0);if(n&&typeof n._nodeToJsonDict=="function"){let i=[];for(let a of n._nodes)i.push(n._nodeToJsonDict(a,t));n=i}let s={label:e.label,value:n,attr:js(e.attr)};return e.nodeTag!==null&&(s.tag=e.nodeTag),e.resolver&&(s.resolver=wn(e.resolver)),s}static fromJson(e,t={}){return eu||(console.warn("Bag.fromJson is deprecated; use Bag.fromTytx"),eu=!0),this.fromTytx(e,"json",t)}toStringTree(e=!0,t=null,n="",s=!0){t===null&&(t=new Map);let i=[],a=[...this._nodes];for(let o=0;o<a.length;o++){let l=a[o],u=o===a.length-1,c=l.getValue(e),d=l.getAttr(),f="",h=Object.keys(d);h.length>0&&(f=" ["+h.map(_=>`${_}=${JSON.stringify(d[_])}`).join(", ")+"]");let p=u?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",m=n+(u?" ":"\u2502 ");if(c instanceof r){let g=l,_=c.backref?"(*)":"";if(t.has(g))i.push(`${n}${p}${l.label}${_}${f} \u2192 (circular ref)`);else{t.set(g,l.label),i.push(`${n}${p}${l.label}${_}${f}`);let w=c.toStringTree(e,t,m,u);w&&i.push(w)}}else{let g;if(c===null)g="null";else if(c===void 0)g="undefined";else if(c instanceof ArrayBuffer||c instanceof Uint8Array){let _=new TextDecoder("utf-8",{fatal:!1}),w=c instanceof ArrayBuffer?new Uint8Array(c):c;g=_.decode(w)}else typeof c=="string"?c.length>50?g=JSON.stringify(c.slice(0,47)+"..."):g=JSON.stringify(c):g=String(c);i.push(`${n}${p}${l.label}: ${g}${f}`)}}return i.join(`
21
- `)}toString(e=!0,t=null,n=""){t||(t=new Set);let s=[],i=[...this._nodes];for(let a=0;a<i.length;a++){let o=i[a],l=a===i.length-1,u=o.getValue(e),c="",d=o.attr;d&&Object.keys(d).length>0&&(c=` [${Object.entries(d).map(([m,g])=>`${m}=${JSON.stringify(g)}`).join(", ")}]`);let f=l?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",h=n+(l?" ":"\u2502 ");if(u&&typeof u._htraverse=="function"){let p=o;if(t.has(p))s.push(`${n}${f}${o.label}${c} \u2192 (circular ref)`);else{t.add(p),s.push(`${n}${f}${o.label}${c}`);let m=u.toString(e,t,h);m&&s.push(m)}}else{let p;u==null?p="null":typeof u=="string"&&u.length>50?p=JSON.stringify(u.slice(0,47)+"..."):typeof u=="string"?p=JSON.stringify(u):p=String(u),s.push(`${n}${f}${o.label}: ${p}${c}`)}}return s.join(`
22
- `)}},yn=class extends Error{constructor(e){super(e),this.name="BagException"}};Z.registerBagClass(R);ma(R,"X",r=>r._toTytxPayload(),r=>R._fromTytxPayload(r));Pt(R.tytxSuffix,{...Re(R.tytxSuffix),Bag:R});var nu=new Set(["False","None","True","and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"]);function su(r){return r.endsWith("_")&&nu.has(r.slice(0,-1))?r.slice(0,-1):r}function iu(r){let e=su(r);return e!==r?e:r.startsWith("_")&&nu.has(r.slice(1))?r.slice(1):r}function vn(r,{renderTag:e=null,ns:t=null,dialectName:n=null}={}){let s=e||r;if(!s)return s;if(s=su(s),t&&!e){let i=`${n}_`;s.startsWith(i)&&(s=s.slice(i.length)),s=`${t}:${s}`}return s}var Cr=Symbol("value"),jt=new Set(["_meta","datapath","nodeId","ns","form","formId","_anchor","updateOn"]);function ge(r){return Object.entries(r||{}).filter(([e])=>!jt.has(e)).map(([e,t])=>[iu(e),t])}var we=class extends Pe{constructor(e,t,n=null,s=null,i=null,a=null,o=null){super(e,t,n,s,i,a,o),this._builder=e?._insertingBuilder??e?._builder??null,this._targetId=null}get builder(){if(this._builder)return this._builder;let e=this.parentBag;return e?e._builder:null}get data(){return this.builder.data}get rootBuilder(){return this.parentBag.root._builder}_getMeta(e){let t=this.getAttr("_meta")||{},n=e.split(",").map(s=>s.trim());return n.length===1?t[n[0]]!==void 0?t[n[0]]:null:n.map(s=>t[s]!==void 0?t[s]:null)}pointerType(e){return typeof e=="string"&&(e[0]==="^"||e[0]==="=")&&!e.startsWith("==")?e[0]:null}pointers(){this.builder.validateCustomTypes(this);let e=[];for(let[t,n]of Object.entries(this.getAttr()||{}))this.pointerType(n)==="^"&&e.push([t,n.split(":",1)[0]]);return this.pointerType(this.value)==="^"&&e.push(["",this.value.split(":",1)[0]]),e}fixedAttrItems(){return ge(this.getAttr())}runtimeToEvaluate(){let e=new Map(this.fixedAttrItems());return e.set(Cr,this.value),e}absDatapath(e){let t=e;this.pointerType(e)&&(e=(V(e)?.pointer??e).slice(1));let n=null;return e.includes("?")&&([e,n]=e.split("?",2)),e.startsWith("#")?this._finalizeAbsPath(this._resolveSymbolicDatapath(e,t),n):(e.startsWith(".")&&(e=this._composeRelativeDatapath(e,t)),this._finalizeAbsPath(e,n))}_finalizeAbsPath(e,t){return e=this._collapseParentDatapath(e,e),t?`${e}?${t}`:e}_composeRelativeDatapath(e,t){let n=this;for(;n!==null&&e.startsWith(".");){let s=n.getAttr("datapath");s!=null&&(e=e==="."?s:s+e),n=n.parentNode}if(e.startsWith("."))throw new Error(`unresolved relative datapath: ${t}`);return e}_collapseParentDatapath(e,t){let n=[];for(let s of e.split("."))if(s==="#parent"){if(n.length===0)throw new Error(`#parent has no segment to cancel: ${t}`);n.pop()}else n.push(s);return n.join(".")}_resolveSymbolicDatapath(e,t){let n=e.slice(1),s=n.indexOf("."),i=s===-1?n:n.slice(0,s),a=s===-1?"":n.slice(s+1),o;if(i==="FORM")o=this._findMarkedDatapathAncestor(!0,!1,t);else if(i==="ANCHOR")o=this._findMarkedDatapathAncestor(!1,!0,t);else{let l=this.rootBuilder;if(!l)throw new Error(`#<id>: cannot resolve ${t} on a node without builder`);if(o=l.source.getNodeByAttr("nodeId",i),o==null)throw new Error(`#<id>: cannot resolve ${t}`)}return o.absDatapath(a?`.${a}`:".")}_findMarkedDatapathAncestor(e,t,n){let s=this;for(;s!=null;){let a=s.getAttr()||{};if(e&&(a.formId!=null||a.form===!0)||t&&"_anchor"in a)return s;s=s.parentNode}let i=e?"FORM":"ANCHOR";throw new Error(`#${i}: no marked ancestor found for ${n}`)}getRelativeData(e,t=null,{autocreate:n=!1}={}){let s=this.data,i=this.absDatapath(e);return n&&s.getItem(i)==null&&s.setItem(i,t),s.getItem(i,t)}setRelativeData(e,t,{attributes:n=null,fired:s=!1,reason:i=null}={}){let a=this.data,o=this.absDatapath(e);a.setItem(o,t,n,">",!1,!0,i===null?!0:i,s)}fireEvent(e,t=!0,{attributes:n=null,reason:s=null}={}){this.setRelativeData(e,t,{attributes:n,fired:!0,reason:s})}SET(e,t){this.setRelativeData(e,t)}GET(e){return this.getRelativeData(e)}PUT(e,t){this.setRelativeData(e,t,{reason:!1})}FIRE(e,t=!0){this.setRelativeData(e,t,{fired:!0})}},x=class r extends R{constructor(e=null,t=null){super(e),this._builder=t,this._insertingBuilder=null}get nodeClass(){return we}_setBuilderItem(e,t,n,...s){let i=t?.map(([o])=>[o,o._builder])||null;if(t)for(let[o,l]of t)o._builder=l;let a=this._insertingBuilder;this._insertingBuilder=e;try{return this.setItem(n,...s)}catch(o){if(this.node(n)==null&&i)for(let[l,u]of i)l._builder=u;throw o}finally{this._insertingBuilder=a}}bindBuilder(e){if(!e)throw new Error("SourceBag.bindBuilder requires a builder");let t=this._builderBindingPlan(e);for(let[n,s]of t)n._builder=s;return this.setBackref(),this}_builderBindingPlan(e){let t=[],n=new WeakSet,s=(i,a)=>{if(n.has(i))throw new Error("source contains a cyclic or shared SourceBag branch");n.add(i),t.push([i,a]);for(let o of i.getNodes()){let l=a,u=o._getMeta("subbuilder");u!=null&&(l=a._resolveSubbuilderReference(u,o.getAttr()||{},o.nodeTag)),t.push([o,l]);let c=o.getValue(!0);c instanceof r&&s(c,l)}};return s(this,e),t}};if((Re(x.tytxSuffix).SourceBag??x)!==x)throw new Error("TYTX subtype name 'SourceBag' is already registered for another class");Pt(x.tytxSuffix,{...Re(x.tytxSuffix),SourceBag:x});function Dp(r){if(r.length===0)return{value:null,attrs:{}};let e=r[0];if(e!==null&&typeof e=="object"){let t=Object.getPrototypeOf(e);if(t===Object.prototype||t===null)return{value:null,attrs:e}}return{value:e,attrs:r[1]||{}}}var xp=new Set(["then","toJSON"]),ou=new WeakMap;function se(r){return ou.get(r)||r}function En(r){if(r==null)return r;r=se(r);let e=r._builder||r.parentBag&&r.parentBag._builder;return e?e.wrapSource(r):r}function lu(r,e){let t=e instanceof R,n=new Proxy(e,{get(s,i){if(typeof i=="symbol"||i.startsWith("_")||xp.has(i))return Reflect.get(s,i,s);let a=r.schemaTag(i);if(t&&a)return au(r,s,a,t);if(i in s){let l=Reflect.get(s,i,s);return typeof l=="function"?l.bind(s):l}if(a)return au(r,s,a,t);let o=r.containerMethod(i);if(o)return(...l)=>r[o](r.wrapSource(s),...l)}});return ou.set(n,e),n}function au(r,e,t,n){return(...s)=>{let{value:i,attrs:a}=Dp(s),o=n?r.bagCall(e,t,i,a):r.commandOnNode(e,t,i,a);return o.builder.wrapSource(o)}}function va(r,e,{transport:t="json"}={}){let n=P(r,t==="json"?null:t);if(!(n instanceof x))throw new TypeError("TYTX payload did not decode to SourceBag");return n.bindBuilder(e)}var cu=/^[A-Za-z_][A-Za-z0-9_]*$/,Sp=new Set(["positional_only","positional_or_keyword","keyword_only","var_positional","var_keyword"]),Cp=new Set(["framework","value","attribute"]),Np=new Map([["builtins.str",r=>typeof r=="string"],["builtins.int",r=>Number.isInteger(r)],["builtins.float",r=>typeof r=="number"&&Number.isFinite(r)],["builtins.bool",r=>typeof r=="boolean"],["builtins.list",r=>Array.isArray(r)],["builtins.dict",r=>r!==null&&typeof r=="object"&&!Array.isArray(r)],["builtins.tuple",r=>Array.isArray(r)],["builtins.set",r=>Array.isArray(r)||r instanceof Set],["builtins.NoneType",r=>r===null],["builtins.object",r=>!0]]);function qt(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function A(r,e){throw new TypeError(`${r}: ${e}`)}function Je(r,e,t,n){qt(r)||A(n,"must be an object");for(let s of Object.keys(r))e.includes(s)||A(n,`unknown field '${s}'`);for(let s of t)Object.hasOwn(r,s)||A(n,`missing field '${s}'`)}function Vt(r,e){if(!(r===null||typeof r=="string"||typeof r=="boolean")&&!(typeof r=="number"&&Number.isFinite(r))){if(Array.isArray(r))return r.forEach((t,n)=>Vt(t,`${e}[${n}]`));if(qt(r))return Object.entries(r).forEach(([t,n])=>Vt(n,`${e}.${t}`));A(e,"must be lossless JSON data")}}function Op(r,e){let t="",n=!1;for(let s=0;s<r.length;s++){let i=r[s];if(i==="\\"){t+=i+(r[++s]??"");continue}i==="["&&(n=!0),!n&&i==="."&&!(e&16)?t+="[^\\n]":!n&&i==="^"&&e&8?t+="(?:^|(?<=\\n))":!n&&i==="$"?t+=e&8?"(?=\\n|(?![\\s\\S]))":"(?=\\n?(?![\\s\\S]))":t+=i,i==="]"&&(n=!1)}return t}function Ut(r,e,t=!1,n=null){if(r===null)return null;switch(Je(r,["kind","dtype","module","name","origin","arguments","items","values","base","metadata","pattern","flags","ge","le","gt","lt","value"],["kind"],e),r.kind){case"custom":return Je(r,["kind","name"],["kind","name"],e),n||A(e,"custom references require a catalog; nested catalog references are unsupported"),n.resolve(r.name,e);case"dtype":{Je(r,["kind","dtype"],["kind","dtype"],e);let s=r.dtype;typeof s!="string"&&A(e,"dtype must be a string");let i=gn(s);return!i&&s!=="NN"&&A(e,`unknown dtype '${s}'`),{...r,test:o=>s==="NN"?o===null:s==="N"?fe(o)&&!["NaN","Infinity","-Infinity"].includes(o.toString()):i===Number?typeof o=="number"&&Number.isFinite(o)&&(s!=="L"||Number.isInteger(o)):i===String?typeof o=="string":i===Boolean?typeof o=="boolean":i===Date?o instanceof Date&&Number.isFinite(o.getTime()):i===Object?qt(o)&&[Object.prototype,null].includes(Object.getPrototypeOf(o)):o instanceof i}}case"any":return{...r,test:s=>!0};case"type":{(typeof r.module!="string"||typeof r.name!="string")&&A(e,"type requires string module/name");let s=`${r.module}.${r.name}`;if(s==="collections.abc.Callable")return{...r,test:a=>typeof a=="function",portable:!1};let i=Np.get(s);return i||A(e,`unsupported type '${s}'`),{...r,test:i}}case"union":{(!Array.isArray(r.items)||!r.items.length)&&A(e,"union items must be non-empty");let s=r.items.map((i,a)=>Ut(i,`${e}.items[${a}]`,!0,n));return{...r,items:s,inputConstraint:s.some(i=>i.inputConstraint),test:i=>s.some(a=>a.test&&a.test(i))}}case"literal":return Array.isArray(r.values)||A(e,"literal values must be an array"),r.values.forEach((s,i)=>Vt(s,`${e}.values[${i}]`)),{...r,test:s=>r.values.some(i=>Object.is(i,s))};case"annotated":{Array.isArray(r.metadata)||A(e,"annotated metadata must be an array"),r.metadata.some(a=>!["regex","range","value"].includes(a?.kind))&&A(e,"unsupported annotation metadata kind");let s=Ut(r.base,`${e}.base`,!0,n),i=r.metadata.map((a,o)=>Ut(a,`${e}.metadata[${o}]`,!0,n));return{...r,base:s,metadata:i,inputConstraint:s.inputConstraint,test:a=>s.test(a)&&i.every(o=>!o.test||o.test(a))}}case"range":{for(let s of["ge","le","gt","lt"])Object.hasOwn(r,s)||A(e,`range missing '${s}'`);for(let s of["ge","le","gt","lt"])r[s]!==null&&(typeof r[s]!="number"||!Number.isFinite(r[s]))&&A(e,`${s} must be finite number or null`);return{...r,test:s=>typeof s=="number"&&(r.ge===null||s>=r.ge)&&(r.le===null||s<=r.le)&&(r.gt===null||s>r.gt)&&(r.lt===null||s<r.lt)}}case"regex":{(typeof r.pattern!="string"||!Number.isInteger(r.flags)||r.flags<0)&&A(e,"regex requires pattern and non-negative integer flags");let s=r.flags&-59;s&&A(e,`unsupported Python regex flags ${s}`),r.flags&2&&A(e,"IGNORECASE is not portable across Python and JavaScript Unicode rules"),/\\[AZzUwWdDsSabBN0-9]|\(\?P[<=!]|\(\?\(|\(\?>|\(\?#|\(\?[aiLmsux-]|[+*?}]\+|\{,/.test(r.pattern.replaceAll(String.raw`[\s\S]`,"."))&&A(e,"regex uses a non-portable construct or character class");let i="uy";r.flags&16&&(i+="s");let a;try{a=new RegExp(`(?:${Op(r.pattern,r.flags)})(?![\\s\\S])`,i)}catch(o){A(e,`invalid portable regex: ${o.message}`)}return{...r,test:o=>typeof o!="string"?!1:(a.lastIndex=0,a.test(o))}}case"value":return Vt(r.value,`${e}.value`),{...r};case"generic":{let s=Ut(r.origin,`${e}.origin`,!0,n);(r.origin?.kind!=="type"||r.origin.module!=="builtins"||!["list","dict","tuple","set"].includes(r.origin.name))&&A(e,"only list, dict, tuple and set generic origins are supported"),Array.isArray(r.arguments)||A(e,"generic arguments must be an array");let i=r.arguments.map((a,o)=>Ut(a,`${e}.arguments[${o}]`,!0,n));return{...r,origin:s,arguments:i,inputConstraint:i.some(a=>a.inputConstraint),test:a=>s.test(a)&&Ip(r.origin,i,a)}}case"arguments":A(e,"Callable argument-list descriptors are not supported by Python validation");case"ellipsis":return t||A(e,"ellipsis is only valid as a nested descriptor"),{...r};default:A(e,`unknown annotation kind '${r.kind}'`)}}function Ip(r,e,t){let n=`${r.module}.${r.name}`;return n==="builtins.tuple"&&e.length&&e[1]?.kind!=="ellipsis"?t.length===e.length&&t.every((s,i)=>e[i].test(s)):n==="builtins.list"||n==="builtins.set"||n==="builtins.tuple"?[...t].every(s=>!e[0]?.test||e[0].test(s)):n==="builtins.dict"?Object.entries(t).every(([s,i])=>(!e[0]?.test||e[0].test(s))&&(!e[1]?.test||e[1].test(i))):!1}function du(r,e){if(r===null)return null;if(typeof r!="string"&&A(e,"must be string or null"),r==="")return new Map;let t=new Map;for(let n of r.split(",")){let s=n.trim();/^[A-Za-z_][A-Za-z0-9_]*\[\]$/.test(s)&&A(e,`invalid cardinality item '${n}'`);let i=s.match(/^([A-Za-z_][A-Za-z0-9_]*|\*)(?:\[(?:(\d+)|(?:(\d*):(\d*)))\])?$/);i||A(e,`invalid cardinality item '${n}'`);let[,a,o,l,u]=i;t.has(a)&&A(e,`duplicate tag '${a}'`);let c=0,d=1/0;s.includes("[")&&(s.includes(":")?(c=l?Number(l):0,d=u?Number(u):1/0):c=d=Number(o)),d<c&&A(e,`maximum ${d} is below minimum ${c}`),t.set(a,{min:c,max:d})}return t.has("*")&&t.size>1&&A(e,"wildcard '*' cannot be combined with named tags"),t}function fu(r,e){if(r===null)return null;typeof r!="string"&&A(e,"must be string or null");let t=new Set;for(let n of r.split(",")){let s=n.trim();s&&((!cu.test(s)||t.has(s))&&A(e,`invalid or duplicate parent '${n}'`),t.add(s))}return t}function Bp(r,e,t){if(r===null)return null;Je(r,["parameters","accepts_var_keyword","accepts_var_positional"],[],e);let n=r.parameters??[];Array.isArray(n)||A(e,"parameters must be an array"),r={parameters:n,accepts_var_keyword:n.some(l=>l.kind==="var_keyword"),accepts_var_positional:n.some(l=>l.kind==="var_positional"),...r},(!Array.isArray(r.parameters)||typeof r.accepts_var_keyword!="boolean"||typeof r.accepts_var_positional!="boolean")&&A(e,"invalid signature descriptor");let s=new Set,i=!1,a=!1,o=r.parameters.map((l,u)=>{let c=`${e}.parameters[${u}]`;return Je(l,["name","kind","role","annotation","has_default","default"],["name","kind","role","annotation","has_default"],c),(typeof l.name!="string"||!cu.test(l.name)||s.has(l.name))&&A(c,"invalid or duplicate parameter name"),s.add(l.name),(!Sp.has(l.kind)||!Cp.has(l.role)||typeof l.has_default!="boolean")&&A(c,"invalid kind, role, or has_default"),l.has_default!==Object.hasOwn(l,"default")&&A(c,"default presence must equal has_default"),l.has_default&&Vt(l.default,`${c}.default`),i||=l.kind==="var_keyword",a||=l.kind==="var_positional",{...l,annotation:Ut(l.annotation,`${c}.annotation`,!1,t)}});return(i!==r.accepts_var_keyword||a!==r.accepts_var_positional)&&A(e,"variadic summary flags do not match parameters"),{...r,parameters:o}}function uu(r,e,t,n){let s=["doc","sub_tags","parent_tags","inherits_from","ns","attributes",...t?["node_label","collection_key"]:[],"_meta"];Je(r,s,[],e),r={...Object.fromEntries(s.map(i=>[i,null])),...r};for(let i of["doc","inherits_from","ns",...t?["node_label","collection_key"]:[]])r[i]!==null&&typeof r[i]!="string"&&A(e,`${i} must be string or null`);return r._meta!==null&&(qt(r._meta)||A(e,"_meta must be object or null"),Vt(r._meta,`${e}._meta`)),du(r.sub_tags,`${e}.sub_tags`),fu(r.parent_tags,`${e}.parent_tags`),{...r,attributes:Bp(r.attributes,`${e}.attributes`,n)}}function hu(r){return r?r.split(",").map(e=>e.trim()).filter(Boolean):[]}function pu(r,e){let t={...e};for(let[n,s]of Object.entries(r))n==="inherits_from"||n.startsWith("_")||t[n]||(t[n]=s);return t._meta={...r._meta||{},...e._meta||{}},t}function mu(r){let e={...r};return e._subSpec=Object.hasOwn(e,"sub_tags")?du(e.sub_tags,"resolved.sub_tags"):null,e._parentSpec=Object.hasOwn(e,"parent_tags")?fu(e.parent_tags,"resolved.parent_tags"):null,e}function gu(r,e,t,n){if(t.get(r)===1&&A(n,`inheritance cycle at '${r}'`),t.get(r)===2)return e[r];let s=e[r];s||A(n,`unknown abstract '${r}'`),t.set(r,1);let i={...s};for(let a of hu(s.inherits_from))i=pu(gu(a,e,t,n),i);return i=mu(i),t.set(r,2),e[r]=i,i}function Ea({abstracts:r={},elements:e={}}){let t={...r},n=new Map;for(let i of Object.keys(t))gu(i,t,n,`abstracts.${i}.inherits_from`);let s={};for(let[i,a]of Object.entries(e)){let o={...a};for(let l of hu(a.inherits_from)){let u=t[l];u||A(`elements.${i}.inherits_from`,`unknown abstract '${l}'`),o=pu(u,o)}s[i]=mu(o)}return{abstracts:t,elements:s}}function ka(r){Je(r,["document_format","grammar","abstracts","elements","custom_types"],["document_format","grammar","abstracts","elements"],"grammar document"),Je(r.document_format,["name","version"],["name","version"],"document_format"),(r.document_format.name!=="builder_grammar"||!["1.1","1.2"].includes(r.document_format.version))&&A("document_format","expected builder_grammar version 1.1 or 1.2"),Je(r.grammar,["name","version","title","description"],["name","version","title","description"],"grammar"),(typeof r.grammar.name!="string"||!r.grammar.name)&&A("grammar.name","must be non-empty string");for(let s of["version","title","description"])r.grammar[s]!==null&&typeof r.grammar[s]!="string"&&A(`grammar.${s}`,"must be string or null");(!qt(r.abstracts)||!qt(r.elements))&&A("grammar document","abstracts/elements must be objects"),Object.hasOwn(r,"custom_types")&&r.document_format.version!=="1.2"&&A("custom_types","requires version 1.2");let e=Nr.fromJSON(r.custom_types??{}),t={};for(let[s,i]of Object.entries(r.abstracts))(!s||s.startsWith("_"))&&A("abstracts",`invalid public name '${s}'`),t[s]=uu(i,`abstracts.${s}`,!1,e);let n={};for(let[s,i]of Object.entries(r.elements))(!s||s.startsWith("_"))&&A("elements",`invalid public name '${s}'`),n[s]=uu(i,`elements.${s}`,!0,e);return{grammar:structuredClone(r.grammar),abstracts:t,elements:n}}function _u(r,e,t,n){let s=e.attributes;if(!s)return;let i={...n};t!=null&&(i.node_value=t);let a=new Set(s.parameters.filter(u=>u.role==="attribute").map(u=>u.name)),o=new Set(["node_label","node_position","nodeId","target_id","datapath","iterate","store","_tag","_meta","ns"]);if(!s.accepts_var_keyword)for(let u of Object.keys(n))!a.has(u)&&!o.has(u)&&A(r,`unknown attribute '${u}'`);let l=e._meta?.component?s.parameters.find(u=>u.role!=="framework"&&["positional_only","positional_or_keyword"].includes(u.kind))?.name:null;for(let u of s.parameters){if(u.name===l||u.role==="framework"||u.kind.startsWith("var_"))continue;let c=Object.hasOwn(i,u.name);!c&&!u.has_default&&A(r,`missing required ${u.role} '${u.name}'`),c&&u.annotation!==null&&(!u.annotation.test||!u.annotation.test(i[u.name]))&&A(r,`invalid value for ${u.role} '${u.name}'`)}}var Nr=class r{#e=new Map;#t=new Map;register(e,t,n){let s=new Map([[String,"str"],[Number,"float"],["string","str"],["integer","int"],["number","float"]]),i=s.has(t)?{kind:"type",module:"builtins",name:s.get(t)}:t;return this.#r(e,{kind:"annotated",base:i,metadata:[n]})}#r(e,t){(typeof e!="string"||!/^[A-Za-z][A-Za-z0-9_]*$/.test(e)||e in this||["to_dict","from_dict"].includes(e)||Rp.has(e))&&A("custom_types",`invalid, reserved or duplicate name '${e}'`),Je(t,["kind","base","metadata"],["kind","base","metadata"],`custom_types.${e}`),(t.kind!=="annotated"||!Array.isArray(t.metadata)||t.metadata.length!==1||!["regex","range"].includes(t.metadata[0]?.kind))&&A(`custom_types.${e}`,"requires an annotated base with one Regex or Range validator");let n=t.metadata[0].kind==="regex"?["str"]:["int","float"];(t.base?.kind!=="type"||t.base.module!=="builtins"||!n.includes(t.base.name))&&A(`custom_types.${e}`,"portable Regex requires str; portable Range requires int or float"),Vt(t,`custom_types.${e}`);let s=structuredClone(t),i=Ut(s,`custom_types.${e}`),a=Object.freeze({kind:"custom",name:e});return Object.defineProperty(this,e,{value:a,enumerable:!0}),this.#e.set(e,s),this.#t.set(e,{...a,inputConstraint:!0,test:i.test}),a}resolve(e,t="custom_types"){return this.#t.has(e)||A(t,`unknown custom type '${e}'`),{...this.#t.get(e)}}validate(e,t){return this.resolve(e).test(t)||A(`custom_types.${e}`,"invalid input value"),!0}toJSON(){return structuredClone(Object.fromEntries(this.#e))}static fromJSON(e){qt(e)||A("custom_types","must be an object");let t=new r;for(let[n,s]of Object.entries(e))t.#r(n,s);return t}},Rp=new Set("False None True and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield".split(" "));function bu(r,e,t,n){let s=e?.attributes;if(s)for(let i of s.parameters){if(!i.annotation?.inputConstraint||i.role==="framework"||["var_keyword","var_positional"].includes(i.kind))continue;let a=i.role==="value"?t:n[i.name];a!==void 0&&(i.annotation.test(a)||A(r,`invalid input for '${i.name}' (custom type)`))}}function wu(r,e,t=[]){if(e===null)return structuredClone(r);if(t.length===2&&t[0]==="custom_types"&&r!==void 0){if(!Aa(r,e))throw new TypeError(`conflicting custom type '${t[1]}'`);return structuredClone(r)}if(t.length===2&&["abstracts","elements"].includes(t[0]))return structuredClone(e);if(nt(r)&&nt(e)){let n=structuredClone(r);for(let[s,i]of Object.entries(e))i!==null&&Object.defineProperty(n,s,{value:wu(n[s],i,[...t,s]),enumerable:!0,writable:!0,configurable:!0});return n}return structuredClone(e)}function Aa(r,e){return Object.is(r,e)?!0:Array.isArray(r)&&Array.isArray(e)?r.length===e.length&&r.every((t,n)=>Aa(t,e[n])):nt(r)&&nt(e)?Object.keys(r).length===Object.keys(e).length&&Object.keys(r).every(t=>Object.hasOwn(e,t)&&Aa(r[t],e[t])):!1}function nt(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)&&Object.getPrototypeOf(r)===Object.prototype}function Ta(r){if(!(r===null||typeof r=="string"||typeof r=="boolean")&&!(typeof r=="number"&&Number.isFinite(r))){if(Array.isArray(r)){r.forEach(Ta);return}if(nt(r)){Object.values(r).forEach(Ta);return}throw new TypeError("collection must contain only finite JSON values")}}var st=class r{#e;constructor(e){Ta(e);let t=["document_format","grammar","abstracts","elements"];if(!nt(e)||Object.keys(e).some(s=>![...t,"custom_types"].includes(s))||t.some(s=>!Object.hasOwn(e,s)))throw new TypeError("collection requires document_format, grammar, abstracts and elements");let n=e.document_format;if(!nt(n)||Object.keys(n).length!==2||n.name!=="builder_grammar"||!["1.1","1.2"].includes(n.version))throw new TypeError("expected builder_grammar version 1.1 or 1.2");for(let s of["grammar","abstracts","elements"])if(!nt(e[s]))throw new TypeError(`${s} must be an object`);if(Object.hasOwn(e,"custom_types")&&(n.version!=="1.2"||!nt(e.custom_types)))throw new TypeError("custom_types requires an object catalog and version 1.2");this.#e=structuredClone(e)}update(e){let t=new r(e),n=wu(this.#e,t.#e);return(this.#e.document_format.version==="1.2"||t.#e.document_format.version==="1.2")&&(n.document_format.version="1.2"),this.#e=n,this}toDocument(){return structuredClone(this.#e)}};var zt=class{static renderType="string";static mode=null;constructor(e){this._builder=e,this.renders=new Map([[e,this]])}get builder(){return this._builder}get renderType(){return this.constructor.renderType}get mode(){return this.constructor.mode}addRender(e,t){this.renders.set(e,t)}getRender(e){let t=this.renders.get(e);if(t!==void 0)return t;let n=e.getRenderer();return this.renders.set(e,n),n}render(e,t={}){let n=e.builder,[s,i]=n.runtimeValues(e);if(e._getMeta("data_element"))return null;if(e._getMeta("component"))return this._renderComponent(e,i,t);let a=this.getRender(n),o;return[o,i]=a._handleMeta(e,i),e._getMeta("subbuilder")||(i=a.adaptAttrs(i)),e.value instanceof x&&(s=this.renderChildren(e.value,t)),a.renderedItem(e,s,i,{tag:o,...t})}renderChildren(e,t={}){let n=[];for(let s of e.getNodes()){let i=this.render(s,t);i!==null&&(Array.isArray(i)?n.push(...i):n.push(i))}return n}_renderComponent(e,t,n){let[s,i,a,o]=this._expansionInputs(e,t);if(!Object.hasOwn(e.getAttr(),"iterate"))return this._expandBlock(e,s,a,o,n);if(i==null)return[];if(!(i instanceof R))throw new TypeError(`component '${e.nodeTag}': iterate must resolve to a Bag, got ${i?.constructor?.name||typeof i}`);return i.getNodes().map(l=>this._expandBlock(e,s,a,{node_label:l.label},n))}_expansionInputs(e,t){let n=e.builder,s=n.componentMethod(e.nodeTag),i=s&&n[s];if(typeof i!="function")throw new Error(`component '${e.nodeTag}' has no implementation`);let a=t.iterate;delete t.iterate,delete t.store;let o=e.getAttr("iterate")||e.getAttr("store");o!=null?(e.pointerType(o)&&(o=o.slice(1)),o.startsWith(".")&&(o=e._composeRelativeDatapath(o,o))):o=null;for(let l of Object.keys(t)){let u=e.getAttr(l);e.pointerType(u)==="^"&&(t[l]=`^${e.absDatapath(u)}`)}return[i,a,o,t]}_expandBlock(e,t,n,s,i){let a=e.builder._expansionRoot(n);t.call(e.builder,En(a),s);let o=a.getNodes();if(o.length!==1)throw new Error(`component '${e.nodeTag}' must build a tree, not a forest: ${o.length} root nodes`);let l={...i,depthOffset:this._nodeDepth(e,i.depthOffset||0)};return this.render(o[0],l)}preprocess(e){return e}renderedItem(e,t,n,s){throw new Error(`${this.constructor.name} does not implement renderedItem`)}_handleMeta(e,t){let[n,s]=e._getMeta("render_tag,render_attributes"),i=vn(e.nodeTag,{renderTag:n,ns:e.getAttr("ns"),dialectName:e.builder?.constructor._name});if(!i)throw new Error(`node ${e.label} has no tag to render (no render_tag, no node_tag)`);return s&&(t={...t,...s}),[i,t]}adaptAttrs(e){return e}adapt(e){let t=`${this.builder.constructor._name}_`;return e.startsWith(t)?e.slice(t.length):e}finalize(e,t=null,n={}){let s=this._composeStringFragments(e);if(t==null)return s;if(typeof t=="string")throw new TypeError("string render targets require filesystem support, which is unavailable in the portable renderer; pass a callable or writable target instead");if(typeof t.full=="function"&&typeof t.write!="function")return t.full(s),null;if(typeof t.write=="function")return t.write(s),null;if(typeof t=="function")return t(s),null;throw new TypeError("render target must be writable (.write), callable, or expose .full")}_composeStringFragments(e){if(!Array.isArray(e))return e;if(e.some(t=>typeof t!="string"))throw new TypeError("String composition requires string fragments; object renderers must define their own composition");return e.join("")}_escapeText(e){return String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}_escapeAttr(e){return this._escapeText(e).replaceAll('"',"&quot;")}_nodeDepth(e,t=0){let s=((e.fullpath||"").match(/\./g)||[]).length;return Math.max(s-1,0)+t}};var Ht=class extends zt{static mode="xml";renderedItem(e,t,n,{tag:s,pretty:i=!1,depthOffset:a=0}={}){let o=this._formatAttrs(n),l=i?" ".repeat(this._nodeDepth(e,a)):"",u=i?`
23
- `:"";if(Array.isArray(t)){let c=this._composeStringFragments(t);return`${l}<${s}${o}>${u}${c}${l}</${s}>${u}`}return t==null?`${l}<${s}${o}></${s}>${u}`:`${l}<${s}${o}>${this._escapeText(t)}</${s}>${u}`}finalize(e,t=null,{docHeader:n=null}={}){let s=this._composeStringFragments(e);return n===!0?s=`<?xml version='1.0' encoding='UTF-8'?>${s}`:typeof n=="string"&&(s=n+s),super.finalize(s,t)}_formatAttrs(e){return Object.entries(e||{}).map(([t,n])=>` ${t.startsWith("xmlns_")?`xmlns:${t.slice(6)}`:t}="${this._escapeAttr(n)}"`).join("")}};var yu={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"base",version:null,title:null,description:null},abstracts:{},elements:{dataSetter:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"value",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataFormula:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataController:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}}}};function vu(r){let e=[];for(;r&&r!==Function.prototype;)e.push(r),r=Object.getPrototypeOf(r);return e.reverse()}function $p(r){let e=Object.create(null),t=(n,s)=>{let i=n.toLowerCase(),a=e[i];if(a!==void 0&&a!==s)throw new Error(`container '${n}' is already tied to implementation method '${a}' (cannot rebind to '${s}')`);e[i]=s};for(let n of vu(r))if(Object.hasOwn(n,"containers"))for(let s of n.containers||[])t(s,s);return e}function kn(r){let e=Object.create(null);for(let t of Object.keys(r)){let n=t.toLowerCase();if(Object.hasOwn(e,n))throw new Error(`element declaration '${t}' has a case-insensitive collision with '${e[n]}'`);e[n]=t}return e}var An="_root_",Tn="_root_",Eu=new Set(["destination","func","value","_on_start"]),ye=class r{static _sourceClass=x;static registerBuilder(e){if(typeof e!="function"||!(e.prototype instanceof r))throw new TypeError("registerBuilder requires a BuilderBase subclass");let t=e._name;if(typeof t!="string"||!t)throw new TypeError("registered builders require a non-empty static _name");let n=r._registry.get(t);if(n&&n!==e)throw new Error(`Builder name '${t}' is already registered to ${n.name}; cannot register ${e.name}`);return r._registry.set(t,e),e}static getBuilderClass(e){let t=r._registry.get(e);if(!t)throw new Error(`No builder registered with name '${e}'`);return t}constructor(e=null){this.name=e||this.constructor._name,this._dataroot=new R,this._dataroot.setBackref(),this._dataroot.setItem(Tn,new R),this.data=this._dataroot.getItem(Tn),this._defaultTargets=new Map,this.materialized=Object.create(null),this._collection=null,this._schemaOverride=null,this._tagNamesOverride=null,this._componentMap=null,this._targetSerial=0,this._subbuilders=new Map,this._sourceHandles=new WeakMap;let t=this.constructor._sourceClass;this._sourceroot=new t(null,this),this._sourceroot.setBackref(),this._sourceroot.setItem(An,new t(null,this)),this.source=this._sourceroot.getItem(An)}wrapSource(e){if(e=se(e),!(e instanceof x)&&!(e instanceof we))throw new TypeError("wrapSource requires a SourceBag or SourceBagNode");let t=this._sourceHandles.get(e);return t||(t=lu(this,e),this._sourceHandles.set(e,t)),t}get root(){return this.wrapSource(this.source)}getSubbuilder(e){if(typeof e!="string"||!e||e.includes(":"))throw new Error(`unsupported subbuilder reference '${e}'`);let t=this._subbuilders.get(e);if(!t){let n=r.getBuilderClass(e);t=new n,this._subbuilders.set(e,t)}return t._dataroot=this._dataroot,t.data=this.data,t}_resolveSubbuilderReference(e,t,n){if(typeof e!="string"||!e)throw new Error(`'${n}': subbuilder declaration must be a non-empty string`);if(e.includes(":"))throw new Error(`'${n}': runtime subbuilder reference '${e}' is unsupported`);return this.getSubbuilder(e)}static defineGrammar(e){let t=this._classCollection,n=t?new st(t.toDocument()).update(e):new st(e),s=ka(n.toDocument()),i=Ea(s),a=kn(i.elements);this._classCollection=n,this._classSchema=i.elements,this._abstracts=i.abstracts,this._tagNames=a}static{this.defineGrammar(yu)}get _containers(){return $p(this.constructor)}containerMethod(e){return this._containers[e.toLowerCase()]||null}componentMethod(e){return this._componentMap?.[e.toLowerCase()]||null}get schema(){return this._schemaOverride||this.constructor._classSchema||{}}get schemaTagNames(){return this._schemaOverride?this._tagNamesOverride??=kn(this.schema):this.constructor._tagNames??=kn(this.schema)}schemaTag(e){let t=e.toLowerCase(),n=this.schemaTagNames[t];if(n)return n;let s=`${this.constructor._name}_`;return t.startsWith(s)&&this.schemaTagNames[t.slice(s.length)]||null}loadGrammar(e,{replace:t=!1}={}){let n=this._collection||this.constructor._classCollection,s=t?new st(e):new st(n.toDocument()).update(e),i=ka(s.toDocument()),a=Ea(i),o=kn(a.elements);return this._collection=s,this._schemaOverride=a.elements,this._tagNamesOverride=o,this}validateCustomTypes(e){let t=e.parentBag?.parentNode?.builder||e.parentBag?._builder,n=t&&t!==this&&t.schema[e.nodeTag]?._meta?.subbuilder?t:this;bu(e.nodeTag,n.schema[e.nodeTag],e.value,e.getAttr()||{})}validateNodeValues(e,t,n={}){let s=this.schemaTag(e);if(!s)throw new Error(`unknown element '${e}'`);return _u(s,this.schema[s],t,n),!0}validateNode(e,{value:t,attrs:n,childTags:s}={}){if(!e||typeof e.nodeTag!="string")throw new TypeError("validateNode requires a source node");let i=t!==void 0?t:e.value instanceof x?null:e.value;this.validateNodeValues(e.nodeTag,i,n||e.getAttr?.()||{});let a=this.schema[this.schemaTag(e.nodeTag)],o=s||(e.value instanceof x?e.value.getNodes().map(l=>l.nodeTag):null);return o&&this._validateChildren(e.nodeTag,a,o,!1),!0}validateChildren(e,t,{includeMinimum:n=!1}={}){let s=this.schemaTag(e);if(!s)throw new Error(`unknown element '${e}'`);if(!Array.isArray(t)||t.some(i=>typeof i!="string"))throw new TypeError("childTags must be an array of strings");return this._validateChildren(s,this.schema[s],t,n)}validateParent(e,t=null){let n=this.schemaTag(e);if(!n)throw new Error(`unknown element '${e}'`);let s=this.schema[n];if(!this._countsForGrammar(s))return!0;let i=s._parentSpec;if(i==null||i.has("*"))return!0;if(t===null)throw new Error(`'${n}' requires a declared parent`);let a=this.schemaTag(t);if(!a)throw new Error(`unknown parent element '${t}'`);return this._validateParent(n,s,a),!0}bagCall(e,t,n,s){return this.setChild(e,t,n,s)}commandOnNode(e,t,n,s){if(e=se(e),e.value instanceof x)return this.setChild(e.value,t,n,s);let i=e.value,a=new e.parentBag.constructor(null,e.builder||this),o=this.setChild(a,t,n,s,e);return this.promoteNodeValue(e,i,a),o}promoteNodeValue(e,t,n){e.setValue(n)}setChild(e,t,n,s,i=null){let a={...s},o=this.schema[t];if(!o)throw new Error(`unknown element '${t}'`);this.validateNodeValues(t,n,a);let l=o._meta?.subbuilder,c=(l==null?null:this._resolveSubbuilderReference(l,a,t))||this,d=n instanceof x?n._builderBindingPlan(c):null,f=i?.rootBuilder||e.root._builder||this;if(a.nodeId!=null&&f.source.getNodeByAttr("nodeId",a.nodeId))throw new Error(`Duplicate nodeId '${a.nodeId}'`);n instanceof x&&this._validateChildren(t,o,n.getNodes().map(y=>y.nodeTag),!1);let h=i||e.parentNode,p=h?.nodeTag?this.schema[h.nodeTag]:null;if(p&&!h._getMeta("subbuilder")&&this._countsForGrammar(o))this._validateParent(t,o,h.nodeTag),this._validateChildren(h.nodeTag,p,[...e.getNodes().map(y=>y.nodeTag),t],!1);else if(!p&&!h?._getMeta("subbuilder")&&o._parentSpec!=null&&this._countsForGrammar(o))throw new Error(`'${t}' requires a declared parent`);o._meta&&!("_meta"in a)&&(a._meta=o._meta),o.ns&&!("ns"in a)&&(a.ns=o.ns);let m=a.node_position;delete a.node_position;let g=a.node_label;delete a.node_label;let _;if(p?.collection_key){if(g!=null)throw new Error(`'${t}': node_label is not allowed in a collection`);_=this._collectionLabel(p.collection_key,t,a)}else{let y=p?._subSpec?.get(t);if(y&&y.max===1){if(g!=null)throw new Error(`'${t}': node_label is not allowed on a singleton`);_=t}else _=g||o.node_label||this._autoLabel(e,t)}if(e.node(_)!=null)throw new Error(`duplicate node label '${_}'`);return e._setBuilderItem(c,d,_,n,a,m||">",!1,!0,null,!1,!0,null,t)}_countsForGrammar(e){let t=e?._meta||{};return!(t.data_element||t.subbuilder||t.component)}_validateParent(e,t,n){let s=t._parentSpec;if(!(s==null||s.has("*")||!this._countsForGrammar(t))&&!s.has(n))throw new Error(`'${e}' not allowed as child of '${n}'`)}_validateChildren(e,t,n,s){let i=t._subSpec;if(i==null||i.has("*")||t._meta?.subbuilder)return[];let a=new Map;for(let o of n){let l=this.schema[o];if(l&&!this._countsForGrammar(l))continue;let u=i.get(o);if(!u)throw new Error(`'${o}' not allowed as child of '${e}'`);let c=(a.get(o)||0)+1;if(a.set(o,c),c>u.max)throw new Error(`too many '${o}' in '${e}'`)}return s?[...i].filter(([o,l])=>(a.get(o)||0)<l.min).map(([o])=>o):[]}_collectionLabel(e,t,n){let s=i=>{if(n[i]===null||n[i]===void 0)throw new Error(`'${t}': collection key needs attribute '${i}'`);return String(n[i])};return e.includes("${")?e.replace(/\$\{([^}]+)\}/g,(i,a)=>s(a)):s(e)}validateSource(){let e=[],t=(n,s="")=>{for(let i of n.getNodes()){let a=s?`${s}.${i.label}`:i.label,o=i.builder;o.validateCustomTypes(i);let l=o.schema[i.nodeTag];if(l&&!i._getMeta("data_element,subbuilder,component").some(Boolean)){let u=i.value instanceof x?i.value.getNodes().map(d=>d.nodeTag):[],c=o._validateChildren(i.nodeTag,l,u,!0);c.length&&e.push([a,c])}i.value instanceof x&&t(i.value,a)}};return t(this.source),e}_autoLabel(e,t){let n=0;for(;e.node(`${t}_${n}`)!==null&&e.node(`${t}_${n}`)!==void 0;)n+=1;return`${t}_${n}`}nodeById(e){let t=this.source.getNodeByAttr("nodeId",e);if(t==null)throw new Error(`nodeId not found: ${e}`);return t.builder.wrapSource(t)}runtimeValues(e){e.builder.validateCustomTypes(e);let t=new Map,n={},s=e.runtimeToEvaluate(),i=new Set(s.keys()),a=new Map([...Object.entries(e.getAttr()),...e.fixedAttrItems()]);for(let[c,d]of[...s])if(!(typeof c!="string"||!V(d)))for(let f of Ve(e,d))s.has(f)||s.set(f,a.get(f));let o=e._getMeta("data_element");for(let[c,d]of s){if(d instanceof Z){t.set(c,d.resolve());continue}let f=typeof c=="string"?V(d)?.pointer??d:d;if(!e.pointerType(f)){t.set(c,typeof c=="string"&&typeof d=="string"&&d.startsWith("==")?null:d);continue}let h=e.absDatapath(f);if(t.set(c,this.data.getItem(h)),!o&&!h.includes("?")&&c===Cr){let p=this.data.getNode(h);p&&Object.assign(n,p.getAttr("_wdg"))}}let l=Ja(s,t,(c,d,f,h)=>this.evaluatePointerExpression(e,c,d,f,h)),u=l.get(Cr);l.delete(Cr);for(let c of l.keys())i.has(c)||l.delete(c);return[u,{...Object.fromEntries(l),...n}]}evaluatePointerExpression(e,t,n,s,i){return null}targetId(e){if(e._targetId)return e._targetId;let t=e.rootBuilder;return e.parentBag.root!==t.source.root?null:(t._targetSerial+=1,e._targetId=`n${t._targetSerial}`,e._targetId)}get dataLogic(){if(!this._dataLogic){let e=this._buildDataLogic();this._dataLogic=Array.isArray(e)?e:[e]}return this._dataLogic}_buildDataLogic(){return this}_resolveLogicFunc(e){if(typeof e=="function")return e;if(typeof e!="string")throw new Error("data-element func must be a name or a function");for(let t of this.dataLogic){let s=(typeof t=="function"?t:t.constructor)[e];if(typeof s=="function")return s}throw new Error(`data-element func '${e}' not found on any data_logic source`)}_bindings(e){let[,t]=this.runtimeValues(e),n={};for(let[s,i]of Object.entries(t))Eu.has(s)||(n[s]=i);return n}computeLogic(e){for(let t of e)this._computeNode(t)}_computeNode(e){let t=e.getAttr()||{};if(e.nodeTag==="dataSetter"){let n={};for(let[s,i]of Object.entries(t))s!=="destination"&&s!=="value"&&!s.startsWith("_")&&(n[s]=i);e.setRelativeData(t.destination,t.value,{attributes:Object.keys(n).length?n:null})}else if(e.nodeTag==="dataFormula"){let n=this._resolveLogicFunc(t.func);e.setRelativeData(t.destination,n(this._bindings(e)))}else e.nodeTag==="dataController"&&this._resolveLogicFunc(t.func)(e,this._bindings(e))}_dataElementNodes(){let e=[],t=n=>{for(let s of n.getNodes())s._getMeta("data_element")&&e.push(s),s.value instanceof x&&t(s.value)};return t(this.source),e}setup(e){}main(e){throw new Error(`${this.constructor.name}.main() not implemented: a bare builder is grammar, not a renderable page`)}_resolveComponents(){let e={};for(let o of vu(this.constructor))if(Object.hasOwn(o,"components"))for(let l of o.components||[])e[l]=l;if(!Object.keys(e).length)return;let t={...this.schema},n={};for(let[o,l]of Object.entries(e))t[o]={sub_tags:"",_meta:{component:!0}},n[o.toLowerCase()]=l;let s=kn(t),i=this._collection||this.constructor._classCollection,a=i.toDocument();a.abstracts={},a.elements=Object.fromEntries(Object.keys(e).map(o=>[o,t[o]])),this._collection=new st(i.toDocument()).update(a),this._schemaOverride=t,this._componentMap=n,this._tagNamesOverride=s}_expansionRoot(e=null){let t=this.constructor._sourceClass,n=new t(null,this);return n.setBackref(),n.setItem(An,new t(null,this),e?{datapath:e}:null),n.getItem(An)}create(){this.setup(this.data),this._resolveComponents(),this.main(this.root),this.computeLogic(this._dataElementNodes())}get renderer_xml(){return new Ht(this)}getRenderer(e=null){e??=this.constructor._defaultRenderMode;let t=this[`renderer_${e}`];if(!t)throw new Error(`${this.constructor.name} does not expose renderer_${e}`);return t}materialize(e=null,t={}){e??=this.constructor._defaultRenderMode;let n=this.getRenderer(e),s=n.renderChildren(n.preprocess(this.source),t);return this.materialized[e]=s,s}setRenderTarget(e,t=null){t??=this.constructor._defaultRenderMode,this._defaultTargets.set(t,e)}render({mode:e=null,target:t=null,...n}={}){e??=this.constructor._defaultRenderMode;let s=this.getRenderer(e);if(t===!1&&s.renderType!=="string")throw new TypeError("target=false is not valid for an object renderer");let i=t===!1?null:t||this._defaultTargets.get(s.mode)||null,a={...i?.renderOpts,...n};return s.finalize(this.materialize(e,a),i,a)}};ye._registry=new Map;var Lp=new Set(["short","medium","long","full"]),Pp=/('(?:[^']|'')*'|[a-zA-Z]+|[^a-zA-Z']+)/g;function Fp(r,e){if(!(r instanceof Date))throw new TypeError("Temporal formats require a typed Date value");if(!Number.isFinite(r.getTime()))throw new RangeError("Invalid date");let t=e||W(r).split("::").at(-1);if(!["D","H","DH","DHZ"].includes(t))throw new RangeError(`Unsupported temporal dtype: ${t}`);return t}function jp(r,e,t,n){let s=e.match(Pp)||[];if(s.join("")!==e)throw new RangeError("Unclosed format literal");let i=(c,d=2)=>String(c).padStart(d,"0"),a=c=>new Intl.DateTimeFormat(t,{timeZone:"UTC",...c}).format(r),u={...n==="H"?{}:{y:()=>String(r.getUTCFullYear()),yy:()=>i(r.getUTCFullYear()%100),yyyy:()=>i(r.getUTCFullYear(),4),M:()=>String(r.getUTCMonth()+1),MM:()=>i(r.getUTCMonth()+1),MMM:()=>a({month:"short"}),MMMM:()=>a({month:"long"}),d:()=>String(r.getUTCDate()),dd:()=>i(r.getUTCDate()),EEE:()=>a({weekday:"short"}),EEEE:()=>a({weekday:"long"})},...n==="D"?{}:{H:()=>String(r.getUTCHours()),HH:()=>i(r.getUTCHours()),h:()=>String(r.getUTCHours()%12||12),hh:()=>i(r.getUTCHours()%12||12),m:()=>String(r.getUTCMinutes()),mm:()=>i(r.getUTCMinutes()),s:()=>String(r.getUTCSeconds()),ss:()=>i(r.getUTCSeconds()),a:()=>new Intl.DateTimeFormat(t,{hour:"numeric",hour12:!0,timeZone:"UTC"}).formatToParts(r).find(c=>c.type==="dayPeriod").value}};return s.map(c=>{if(c.startsWith("'"))return c==="''"?"'":c.slice(1,-1).replaceAll("''","'");if(!/^[a-zA-Z]/.test(c))return c;if(!u[c])throw new RangeError(`Unsupported date format token: ${c}`);return u[c]()}).join("")}function ku(r,{format:e,mask:t,locale:n,dtype:s,places:i}={}){let a=r==null?"":String(r);if(r!=null&&r!==""&&(e!=null&&e!==""||i!=null))if(typeof r=="number"||fe(r))a=qp(r,{format:e,locale:n,places:i});else{let o=Fp(r,s);if(Lp.has(e)){let l={timeZone:"UTC"};o!=="H"&&(l.dateStyle=e),o!=="D"&&(l.timeStyle=e),a=new Intl.DateTimeFormat(n||void 0,l).format(r)}else a=jp(r,String(e),n||void 0,o)}return t==null?a:String(t).replaceAll("%s",()=>a)}function Up({format:r="decimal",places:e}={}){let t={maximumFractionDigits:20};if(!r||r==="decimal")t.style="decimal";else if(r==="percent")t.style="percent";else if(r==="scientific")t.notation="scientific";else{let n=/^(0|#,##0)(?:\.(0*)(#*))?$/.exec(r);if(!n||r.includes(".")&&!n[2]&&!n[3])throw new RangeError(`Unsupported number format: ${r}`);t.useGrouping=n[1].includes(","),t.minimumFractionDigits=(n[2]||"").length,t.maximumFractionDigits=(n[2]||"").length+(n[3]||"").length}if(e!=null&&e!==""){let n=Number(e);if(!Number.isInteger(n)||n<0||n>20)throw new RangeError("places must be an integer from 0 to 20");t.minimumFractionDigits=n,t.maximumFractionDigits=n}return t}function qp(r,e={}){if(typeof r!="number"&&!fe(r))throw new TypeError("Number formatting requires a Number or Decimal");if(!Number.isFinite(Number(r)))throw new RangeError("Number must be finite");let t=new Intl.NumberFormat(e.locale||void 0,Up(e));if(fe(r)&&new Intl.NumberFormat("en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal values without precision loss");return t.format(fe(r)?r.toString():r)}var Vp=new Set(["style","script"]),zp=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),Au=new Set(["width","height","top","left","right","bottom","padding","margin","border","position","display","overflow","float","clear","resize","z_index","min_width","min_height","max_width","max_height","color","background","font","text","line_height","white_space","vertical_align","flex","gap","row_gap","column_gap","grid","align_content","justify_content","align_items","justify_items","visibility","opacity","cursor"]),Dn=new Set(["rounded","gradient","shadow","transform","transition","zoom","filter"]),Tu=r=>r===!0?"true":r===!1?"false":String(r),Us=r=>typeof r=="number"&&Number.isFinite(r)?`${r}px`:String(r);function Hp(r){if(Au.has(r))return!0;for(let e of Au)if(r.startsWith(`${e}_`))return!0;return!1}function Wp(r){let e=new Map;if(!r)return e;let t=[],n=0,s=null,i=!1,a=!1,o=0,l=String(r);for(let u=0;u<l.length;u+=1){let c=l[u],d=l[u+1];if(a){c==="*"&&d==="/"&&(a=!1,u+=1);continue}if(i){i=!1;continue}if(c==="\\"){i=!0;continue}if(s){c===s&&(s=null);continue}c==='"'||c==="'"?s=c:c==="/"&&d==="*"?(a=!0,u+=1):"([{".includes(c)?o+=1:")]}".includes(c)&&o>0?o-=1:c===";"&&o===0&&(t.push(l.slice(n,u)),n=u+1)}t.push(l.slice(n));for(let u of t){let c=u.trim();if(!c)continue;let d=c.indexOf(":");if(d<0)throw new TypeError(`malformed style declaration '${c}'`);e.set(c.slice(0,d).trim(),c.slice(d+1).trim())}return e}var Wt=class extends zt{static mode="html";renderedItem(e,t,n,{tag:s,xml:i=!0,pretty:a=!1,depthOffset:o=0,includeDatapath:l=!1}={}){e.parentNode?._getMeta("subbuilder")==="html"&&(n={xmlns:"http://www.w3.org/1999/xhtml",...n});let{format:c,mask:d,locale:f,places:h,dtype:p,...m}=n;!Array.isArray(t)&&(c!=null||d!=null||h!=null)&&(t=ku(t,{format:c,mask:d,places:h,dtype:p,locale:this._displayLocale(e,f)}));let g=this._formatAttrs(m);if(l){if(!Object.hasOwn(n,"id")){let k=this.builder.targetId(e);k!==null&&(g+=` id="${this._htmlAttrValue(k)}"`)}for(let[k,T]of Object.entries(e.getAttr()))e.pointerType(T)&&(g+=` data-${this.adapt(k)}-pointer="${this._htmlAttrValue(e.absDatapath(T))}"`)}let _=a?" ".repeat(this._nodeDepth(e,o)):"",w=a?`
24
- `:"";if(e._getMeta("void"))return`${_}<${s}${g}${i?"/":""}>${w}`;if(Array.isArray(t)){let k=this._composeStringFragments(t);return`${_}<${s}${g}>${w}${k}${_}</${s}>${w}`}if(t==null)return`${_}<${s}${g}></${s}>${w}`;let y=typeof t=="string"&&t.endsWith("::HTML")?t.slice(0,-6):Vp.has(s)?String(t):this._escapeText(t);return`${_}<${s}${g}>${y}</${s}>${w}`}_displayLocale(e,t){if(t)return t;for(let n=e.parentNode;n;n=n.parentNode){let s=n.getAttr("locale");if(s==null)continue;let i=n.pointerType(s)?n.data.getItem(n.absDatapath(s)):s;if(i)return i}}adaptAttrs(e){let t={},n={};for(let[i,a]of Object.entries(e||{}))if(i.startsWith(`${this.builder.constructor._name}_`))t[this.adapt(i)]=a;else if(i==="dtype")t.dtype=a;else{if(this.builder.constructor.retainedAttrPrefixes.some(o=>i.startsWith(o)))continue;this._isStyleContribution(i)?n[i]=a:t[i]=a}let s=this._adaptStyle(n);return s&&(t.style=s),t}_isStyleContribution(e){if(e==="style"||e.startsWith("style_")||Dn.has(e))return!0;let t=e.includes("_")?e.slice(0,e.indexOf("_")):null;return t!==null&&Dn.has(t)||Hp(e)}_adaptStyle(e){let t=Wp(e.style),n=new Map,s=new Map;for(let[i,a]of Object.entries(e))if(i!=="style")if(i.startsWith("style_"))t.set(i.slice(6).replaceAll("_","-"),Tu(a));else if(Dn.has(i))n.set(i,a);else{let o=i.indexOf("_"),l=o<0?i:i.slice(0,o);o>=0&&Dn.has(l)?(s.has(l)||s.set(l,{}),s.get(l)[i.slice(o+1)]=a):t.set(i.replaceAll("_","-"),Tu(a))}for(let i of Dn)(n.has(i)||s.has(i))&&this[`_macro_${i}`](n.get(i),s.get(i)||{},t);return[...t].map(([i,a])=>`${i}: ${a}`).join("; ")}_formatAttrs(e){let t=[];for(let[n,s]of Object.entries(e||{}))zp.has(n)?s&&t.push(` ${n}`):t.push(` ${n}="${this._htmlAttrValue(s)}"`);return t.join("")}_htmlAttrValue(e){return(e===!0?"true":e===!1?"false":String(e)).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}_macro_rounded(e,t,n){let s=e===void 0?{}:{top_left:e,top_right:e,bottom_left:e,bottom_right:e};for(let[i,a]of Object.entries(t))if(i==="top"||i==="bottom")s[`${i}_left`]=a,s[`${i}_right`]=a;else if(i==="left"||i==="right")s[`top_${i}`]=a,s[`bottom_${i}`]=a;else if(["top_left","top_right","bottom_left","bottom_right"].includes(i))s[i]=a;else throw new TypeError(`rounded: unknown sub-kwarg '${i}'`);for(let[i,a]of Object.entries(s))n.set(`border-${i.replaceAll("_","-")}-radius`,Us(a))}_macro_transform(e,t,n){let s=e===void 0?[]:[String(e)];for(let[i,a]of Object.entries(t))i==="rotate"?s.push(`rotate(${a}deg)`):i==="scale"||i==="translate"?s.push(`${i}(${a})`):i==="translate_x"?s.push(`translateX(${Us(a)})`):i==="translate_y"?s.push(`translateY(${Us(a)})`):i==="skew_x"?s.push(`skewX(${a}deg)`):i==="skew_y"?s.push(`skewY(${a}deg)`):s.push(`${i.replaceAll("_","-")}(${a})`);s.length&&n.set("transform",s.join(" "))}_macro_filter(e,t,n){let s=e===void 0?[]:[String(e)];for(let[i,a]of Object.entries(t))i==="rotate"?s.push(`hue-rotate(${a}deg)`):i==="blur"?s.push(`blur(${Us(a)})`):i==="drop_shadow"?s.push(`drop-shadow(${a})`):s.push(`${i.replaceAll("_","-")}(${a})`);s.length&&n.set("filter",s.join(" "))}_macro_transition(e,t,n){e!==void 0&&n.set("transition",String(e));for(let[s,i]of Object.entries(t))n.set(`transition-${s.replaceAll("_","-")}`,String(i))}_macro_zoom(e,t,n){e!==void 0&&n.set("zoom",String(e))}_macro_shadow(e,t,n){e!==void 0&&n.set("box-shadow",String(e));for(let[s,i]of Object.entries(t))n.set(`box-shadow-${s.replaceAll("_","-")}`,String(i))}_macro_gradient(e,t,n){e!==void 0&&n.set("background-image",String(e))}};var Gp=new Set(["alignment_baseline","baseline_shift","clip_path","clip_rule","color_interpolation","color_interpolation_filters","dominant_baseline","fill_opacity","fill_rule","flood_color","flood_opacity","font_family","font_size","font_size_adjust","font_stretch","font_style","font_variant","font_weight","glyph_orientation_horizontal","glyph_orientation_vertical","image_rendering","letter_spacing","lighting_color","marker_end","marker_mid","marker_start","overline_position","overline_thickness","paint_order","pointer_events","shape_rendering","stop_color","stop_opacity","strikethrough_position","strikethrough_thickness","stroke_dasharray","stroke_dashoffset","stroke_linecap","stroke_linejoin","stroke_miterlimit","stroke_opacity","stroke_width","text_anchor","text_decoration","text_rendering","underline_position","underline_thickness","unicode_bidi","word_spacing","writing_mode"]);function qs(r){return Object.fromEntries(Object.entries(r||{}).map(([e,t])=>[Gp.has(e)?e.replaceAll("_","-"):e,t]))}var Gt=class extends Ht{static mode="svg";adaptAttrs(e){return qs(e)}};var Du={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"html",version:null,title:null,description:null},abstracts:{},elements:{svg:{doc:"Switch to the SVG dialect from this node down (BLD.2).\n\n A sub-builder element: ``_meta['subbuilder']`` switches the active\n dialect to SVG from this node down. No ``render_tag``: ``<svg>`` is\n emitted verbatim (HTML5 has a native ``<svg>`` tag).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{subbuilder:"svg"}},a:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},abbr:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},address:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},area:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},article:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},aside:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},audio:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},b:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},base:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},bdi:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},bdo:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},blockquote:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},body:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},br:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},button:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},canvas:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},caption:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},cite:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},code:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},col:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},colgroup:{doc:null,sub_tags:"col,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},data:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},datalist:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,option,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dd:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},del_:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},details:{doc:null,sub_tags:"summary[0:1],a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dfn:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dialog:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},div:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dl:{doc:null,sub_tags:"dd,div,dt,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dt:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},em:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},embed:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},fieldset:{doc:null,sub_tags:"legend[0:1],a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},figcaption:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},figure:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figcaption[0:1],figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},footer:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},form:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h1:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h2:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h3:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h4:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h5:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h6:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},head:{doc:null,sub_tags:"base[0:1],link,meta,noscript,script,style,template,title[0:1]",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},header:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},hgroup:{doc:null,sub_tags:"h1,h2,h3,h4,h5,h6,p,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},hr:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},html:{doc:null,sub_tags:"head[0:1],body[0:1]",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},i:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},iframe:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},img:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},input:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},ins:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},kbd:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},label:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},legend:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,h1,h2,h3,h4,h5,h6,hgroup,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},li:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},link:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},main:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},map:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},mark:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},menu:{doc:null,sub_tags:"li,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},meta:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},meter:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},nav:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},noscript:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},object:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},ol:{doc:null,sub_tags:"li,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},optgroup:{doc:null,sub_tags:"div,legend,noscript,option,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},option:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,div,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},output:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},p:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},picture:{doc:null,sub_tags:"img[0:1],script,source,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},pre:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},progress:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},q:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},rp:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},rt:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},ruby:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},s:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},samp:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},script:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},search:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},section:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},select:{doc:null,sub_tags:"button,div,hr,noscript,optgroup,option,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},slot:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},small:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},source:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},span:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},strong:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},style:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},sub:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},summary:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,h1,h2,h3,h4,h5,h6,hgroup,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},sup:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},table:{doc:null,sub_tags:"caption[0:1],colgroup,script,tbody,template,tfoot[0:1],thead[0:1],tr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},tbody:{doc:null,sub_tags:"script,template,tr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},td:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},template:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,caption,cite,code,col,colgroup,data,datalist,del_,details,dfn,dialog,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,legend,li,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,optgroup,option,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,source,span,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,tr,track,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},textarea:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},tfoot:{doc:null,sub_tags:"script,template,tr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},th:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},thead:{doc:null,sub_tags:"script,template,tr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},time:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},title:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},tr:{doc:null,sub_tags:"script,td,template,th",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},track:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},u:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},ul:{doc:null,sub_tags:"li,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},var:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},video:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},wbr:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},selectedcontent:{doc:"Mirror of the selected option for Customizable Select (HTML 2024).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dataSetter:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"value",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataFormula:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataController:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}}}};var kt=class extends ye{static _name="html";static _defaultRenderMode="html";static retainedAttrPrefixes=["validate_","dtype"];static{this.defineGrammar(Du)}get renderer_html(){return new Wt(this)}};ye.registerBuilder(kt);var xu={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"svg",version:null,title:null,description:null},abstracts:{graphics:{doc:"SVG graphics content: any graphical element.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},_meta:null},containerElement:{doc:"SVG container content: elements that can hold children.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},_meta:null}},elements:{html:{doc:"Switch to the HTML dialect from this node down (BLD.2).\n\n A sub-builder element: ``_meta['subbuilder']`` switches the active\n dialect to HTML from this node down. The source tag ``html`` is\n rendered as ``_meta['render_tag']`` (``<foreignObject>``) carrying\n ``_meta['render_attributes']`` (the SVG namespace). The immediate\n HTML child declares XHTML so both sides of the XML boundary retain\n their native namespace.\n ",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{subbuilder:"html",render_tag:"foreignObject",render_attributes:{xmlns:"http://www.w3.org/2000/svg"}}},svg:{doc:"Root SVG container or nested SVG viewport.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},g:{doc:"Group container for applying transforms and styles.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},defs:{doc:"Container for referenced elements (gradients, patterns, etc.).",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},symbol:{doc:"Reusable graphical template, rendered only when referenced by <use>.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},use:{doc:"Reference and render a <symbol> or other element.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},rect:{doc:"Rectangle.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},circle:{doc:"Circle.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},ellipse:{doc:"Ellipse.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},line:{doc:"Line segment between two points.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},polyline:{doc:"Open shape of connected line segments.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},polygon:{doc:"Closed shape of connected line segments.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},path:{doc:"Arbitrary shape defined by path commands (d attribute).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},image:{doc:"Embedded raster image.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},text:{doc:"Text block. Contains text content and optional <tspan>/<textPath>.",sub_tags:"tspan,textPath",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},tspan:{doc:"Inline text span within <text>.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},textPath:{doc:"Text rendered along a path shape.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},linearGradient:{doc:"Linear gradient definition. Place inside <defs>.",sub_tags:"stop",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},radialGradient:{doc:"Radial gradient definition. Place inside <defs>.",sub_tags:"stop",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},stop:{doc:"Gradient stop (color and offset).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},pattern:{doc:"Tile pattern definition. Place inside <defs>.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},clipPath:{doc:"Clipping path definition.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},mask:{doc:"Alpha mask definition.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},marker:{doc:"Marker symbol for line endpoints or vertices.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},filter:{doc:"Filter effect container. Place inside <defs>.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feGaussianBlur:{doc:"Gaussian blur filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feOffset:{doc:"Offset filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feBlend:{doc:"Blend filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feColorMatrix:{doc:"Color matrix filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feComposite:{doc:"Composite filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feFlood:{doc:"Flood fill filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feMerge:{doc:"Merge filter primitive (container for feMergeNode).",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feMergeNode:{doc:"Single input for feMerge.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feDropShadow:{doc:"Drop shadow filter primitive (SVG 2).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feDiffuseLighting:{doc:"Diffuse lighting filter primitive.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feSpecularLighting:{doc:"Specular lighting filter primitive.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},fePointLight:{doc:"Point light source for lighting filters.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feDistantLight:{doc:"Distant light source for lighting filters.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feSpotLight:{doc:"Spot light source for lighting filters.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feMorphology:{doc:"Morphology filter primitive (erode/dilate).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feTurbulence:{doc:"Turbulence noise filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feDisplacementMap:{doc:"Displacement map filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feConvolveMatrix:{doc:"Convolution matrix filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feImage:{doc:"Image filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feTile:{doc:"Tile filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},animate:{doc:"Animate an attribute over time.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},animateTransform:{doc:"Animate a transform attribute.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},animateMotion:{doc:"Animate motion along a path.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},set:{doc:"Set an attribute to a value for a duration.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},title:{doc:"Accessible title (tooltip in browsers).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},desc:{doc:"Accessible description.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},metadata:{doc:"Metadata container (RDF, Dublin Core, etc.).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},a:{doc:"Hyperlink wrapper.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},foreignObject:{doc:"Container for non-SVG content (HTML, MathML).",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},switch:{doc:"Conditional processing (renders first matching child).",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dataSetter:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"value",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataFormula:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataController:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}}}};var At=class extends ye{static _name="svg";static _defaultRenderMode="svg";static{this.defineGrammar(xu)}get renderer_svg(){return new Gt(this)}};ye.registerBuilder(At);var Xt=class r{#e;constructor(e,t=0){this.pattern=e,this.flags=t,this.#e=Nr.fromJSON({nameSyntax:{kind:"annotated",base:{kind:"type",module:"builtins",name:"str"},metadata:[this.toJSON()]}}).resolve("nameSyntax").test,Object.freeze(this)}static fromJSON(e){if((e!==null&&typeof e=="object"?Object.keys(e).sort():[]).join()!=="flags,kind,pattern"||e.kind!=="regex")throw new TypeError(`A name syntax is {kind: 'regex', pattern, flags}, not ${JSON.stringify(e)}`);return new r(e.pattern,e.flags)}toJSON(){return{kind:"regex",pattern:this.pattern,flags:this.flags}}matches(e){return this.#e(e)}},xn=new Xt(String.raw`[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*`);var Se=class{constructor(e){this.gramlot=e}};var Zp=/^[a-z][.0-9_a-z\-\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]*$/u,Jp=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]);function it(r){let e=r.code;if(typeof e!="string"||Zp.exec(e)?.[0]!==e||!e.includes("-")||Jp.has(e))throw new TypeError("webcomponent: code must be a literal custom-element name");return e}function Da(r){for(let e of Object.values(r))e&&typeof e=="object"&&Da(e);return Object.freeze(r)}function Su(r){if(typeof r.dtype!="string"&&!Array.isArray(r.dtype))throw new TypeError("Component parameter requires dtype");let e=(Array.isArray(r.dtype)?r.dtype:[r.dtype]).map(t=>({kind:"dtype",dtype:t}));return r.nullable&&e.push({kind:"dtype",dtype:"NN"}),r.binding&&r.dtype!=="T"&&e.push({kind:"annotated",base:{kind:"dtype",dtype:"T"},metadata:[{kind:"regex",pattern:"^[\\^=].+",flags:0}]}),e.length===1?e[0]:{kind:"union",items:e}}function Or({name:r,tag:e,base:t,mixins:n=[],parameters:s={},subTags:i="",presentationDefaults:a=[],dataScope:o=!1,command:l=!1,childParameters:u={},sourceContext:c=!1,bagStore:d=!1,dragSource:f=!1,implementation:h}){if(it({code:e}),!/^[a-zA-Z][a-zA-Z0-9]*$/.test(r))throw new TypeError("Invalid component authoring name");let p={...t.parameters};for(let m of n)for(let[g,_]of Object.entries(m.parameters)){if(Object.hasOwn(p,g))throw new Error(`Duplicate mixin parameter: ${g}`);p[g]=_}Object.assign(p,s);for(let m of Object.values(p))Su(m);return Object.freeze({name:r,tag:e,base:t,subTags:i,presentationDefaults:Object.freeze([...a]),dataScope:o,command:l,bagStore:d,mixins:Object.freeze([...n]),parameters:Da(structuredClone(p)),childParameters:Da(structuredClone(u)),sourceContext:c,dragSource:f,implementation:h})}var Yt=class{#e=new WeakMap;constructor({name:e,components:t}){this.name=e,this.components=Object.freeze([...t]);let n=new Set,s=new Set;for(let i of t){if(n.has(i.name.toLowerCase())||s.has(i.tag))throw new Error(`Duplicate component: ${i.name}`);n.add(i.name.toLowerCase()),s.add(i.tag)}}toDocument(){return{document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:this.name,version:null,title:this.name,description:null},abstracts:{},elements:Object.fromEntries(this.components.map(e=>[e.name,{doc:null,sub_tags:e.subTags,parent_tags:null,inherits_from:null,ns:null,node_label:null,collection_key:null,attributes:{parameters:[...Object.entries(e.parameters).map(([t,n])=>({name:t,kind:"keyword_only",role:"attribute",annotation:Su(n),has_default:!0,default:n.default??null})),{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},_meta:{render_tag:e.tag,gramlot_component:{parameters:structuredClone(e.parameters),presentationDefaults:[...e.presentationDefaults],dataScope:e.dataScope,command:e.command,...Object.keys(e.childParameters).length?{childParameters:structuredClone(e.childParameters)}:{},...e.sourceContext?{sourceContext:!0}:{},...e.dragSource?{dragSource:!0}:{},...e.bagStore?{bagStore:!0}:{}}}}]))}}register(e){if(this.#e.has(e))return;let t=[];for(let n of this.components){if(e.customElements.get(n.tag))throw new Error(`Custom element already registered: ${n.tag}`);let s=n.base(e.HTMLElement);for(let a of n.mixins)s=a(s);let i=n.implementation(s);Object.defineProperty(i,"gramlotComponent",{value:n}),t.push([n.tag,i])}for(let[n,s]of t)e.customElements.define(n,s);this.#e.set(e,t)}};function Cu(r){return new Yt(r)}function Vs(r,e){return r.parameters=Object.fromEntries(Object.entries(r.constructor.gramlotComponent.parameters).map(([t,n])=>[t,Object.hasOwn(e,t)?e[t]:n.default])),Object.fromEntries(Object.entries(e).filter(([t])=>!Object.hasOwn(r.parameters,t)))}function Nu(r){if(r==="")return[];let e=new Set;return r.split(",").map(t=>{let n=t.indexOf(":"),s=n<0?t:t.slice(0,n),i=n<0?t:t.slice(n+1);if(!s||e.has(s))throw new Error("Invalid or duplicate choice code");return e.add(s),{id:s,caption:i}})}function zs(r){return class extends r{constructor(){super();let e=this.attachShadow({mode:"open"}),t=this.ownerDocument.createElement("style");t.textContent=`:host{display:inline-block;font:inherit} *,*::before,*::after{box-sizing:border-box}
20
+ ${" ".repeat(s)}</${o}>`:`<${o}${l}>${f}</${o}>`:t===null||t.includes(o)?`<${o}${l}/>`:`<${o}${l}></${o}>`}if(u==null||u==="")return t===null||t.includes(o)?`<${o}${l}/>`:`<${o}${l}></${o}>`;let c=u instanceof Date&&!Number.isNaN(u.getTime())?Bp(u):String(u),d=this._escapeXml(c);return`<${o}${l}>${d}</${o}>`}_sanitizeTag(e){return e?e.replace(/[^a-zA-Z0-9_\-.:]/g,"_"):"_none_"}_escapeXml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}_escapeAttr(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}static fromXml(e,t={}){let{tagAttribute:n=null}=t,s;if(typeof DOMParser<"u"){s=new DOMParser().parseFromString(e,"application/xml");let o=s.querySelector("parsererror");if(o)throw new Error(`XML parse error: ${o.textContent}`)}else s=new du.DOMParser().parseFromString(e,"application/xml");return this._xmlElementToBag(s.documentElement,n)}static _xmlElementToBag(e,t=null){let n=new this,s=Array.from(e.childNodes).filter(i=>i.nodeType===1);for(let i of s){let o=i.tagName,a={};for(let m=0;m<i.attributes.length;m++){let g=i.attributes[m];a[g.name]=g.value}let l=zs(a._resolver);l&&delete a._resolver;let u=String(a._T||"").toUpperCase()==="BAG";Object.assign(a,So(a));let c=o;"_tag"in a&&(c=a._tag,delete a._tag),t&&t in a&&(c=a[t],delete a[t]);let d=c,f=1;for(;n.getNode(c);)c=`${d}_${f++}`;let h=Array.from(i.childNodes).filter(m=>m.nodeType===1),p;if(h.length>0||u){let m=this._xmlElementToBag(i,t);p=n.setItem(c,m,Object.keys(a).length>0?a:null)}else{let m=i.textContent||"";p=n.setItem(c,m,Object.keys(a).length>0?a:null)}l&&(p.resolver=l),p.xmlTag=o}return n}static async fromUrl(e,t={}){let{timeout:n=30}=t,s={};n&&(s.signal=AbortSignal.timeout(n*1e3));let i=await fetch(e,s),o=i.headers.get("content-type")||"",a=await i.text();if(o.includes("json"))return r.fromTytx(a);if(o.includes("xml"))return r.fromXml(a);let l=a.trim();if(l.startsWith("<"))return r.fromXml(a);if(l.startsWith("{")||l.startsWith("["))return r.fromTytx(a);throw new kn(`Unsupported content-type: ${o}`)}toJson(e=!0){let t=[];for(let n of this._nodes)t.push(this._nodeToJsonDict(n,e));return e?W(t):JSON.stringify(t)}_nodeToJsonDict(e,t){let n=e.resolver?null:e.getValue(!0);if(n&&typeof n._nodeToJsonDict=="function"){let i=[];for(let o of n._nodes)i.push(n._nodeToJsonDict(o,t));n=i}let s={label:e.label,value:n,attr:Ws(e.attr)};return e.nodeTag!==null&&(s.tag=e.nodeTag),e.resolver&&(s.resolver=En(e.resolver)),s}static fromJson(e,t={}){return cu||(console.warn("Bag.fromJson is deprecated; use Bag.fromTytx"),cu=!0),this.fromTytx(e,"json",t)}toStringTree(e=!0,t=null,n="",s=!0){t===null&&(t=new Map);let i=[],o=[...this._nodes];for(let a=0;a<o.length;a++){let l=o[a],u=a===o.length-1,c=l.getValue(e),d=l.getAttr(),f="",h=Object.keys(d);h.length>0&&(f=" ["+h.map(b=>`${b}=${JSON.stringify(d[b])}`).join(", ")+"]");let p=u?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",m=n+(u?" ":"\u2502 ");if(c instanceof r){let g=l,b=c.backref?"(*)":"";if(t.has(g))i.push(`${n}${p}${l.label}${b}${f} \u2192 (circular ref)`);else{t.set(g,l.label),i.push(`${n}${p}${l.label}${b}${f}`);let y=c.toStringTree(e,t,m,u);y&&i.push(y)}}else{let g;if(c===null)g="null";else if(c===void 0)g="undefined";else if(c instanceof ArrayBuffer||c instanceof Uint8Array){let b=new TextDecoder("utf-8",{fatal:!1}),y=c instanceof ArrayBuffer?new Uint8Array(c):c;g=b.decode(y)}else typeof c=="string"?c.length>50?g=JSON.stringify(c.slice(0,47)+"..."):g=JSON.stringify(c):g=String(c);i.push(`${n}${p}${l.label}: ${g}${f}`)}}return i.join(`
21
+ `)}toString(e=!0,t=null,n=""){t||(t=new Set);let s=[],i=[...this._nodes];for(let o=0;o<i.length;o++){let a=i[o],l=o===i.length-1,u=a.getValue(e),c="",d=a.attr;d&&Object.keys(d).length>0&&(c=` [${Object.entries(d).map(([m,g])=>`${m}=${JSON.stringify(g)}`).join(", ")}]`);let f=l?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",h=n+(l?" ":"\u2502 ");if(u&&typeof u._htraverse=="function"){let p=a;if(t.has(p))s.push(`${n}${f}${a.label}${c} \u2192 (circular ref)`);else{t.add(p),s.push(`${n}${f}${a.label}${c}`);let m=u.toString(e,t,h);m&&s.push(m)}}else{let p;u==null?p="null":typeof u=="string"&&u.length>50?p=JSON.stringify(u.slice(0,47)+"..."):typeof u=="string"?p=JSON.stringify(u):p=String(u),s.push(`${n}${f}${a.label}: ${p}${c}`)}}return s.join(`
22
+ `)}},kn=class extends Error{constructor(e){super(e),this.name="BagException"}};Z.registerBagClass(C);xo(C,"X",r=>r._toTytxPayload(),r=>C._fromTytxPayload(r));Ft(C.tytxSuffix,{...Re(C.tytxSuffix),Bag:C});var hu=new Set(["False","None","True","and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"]);function pu(r){return r.endsWith("_")&&hu.has(r.slice(0,-1))?r.slice(0,-1):r}function mu(r){let e=pu(r);return e!==r?e:r.startsWith("_")&&hu.has(r.slice(1))?r.slice(1):r}function An(r,{renderTag:e=null,ns:t=null,dialectName:n=null}={}){let s=e||r;if(!s)return s;if(s=pu(s),t&&!e){let i=`${n}_`;s.startsWith(i)&&(s=s.slice(i.length)),s=`${t}:${s}`}return s}var Or=Symbol("value"),Ut=new Set(["_meta","datapath","nodeId","ns","form","formId","_anchor","updateOn"]);function he(r){return Object.entries(r||{}).filter(([e])=>!Ut.has(e)).map(([e,t])=>[mu(e),t])}var we=class extends Fe{constructor(e,t,n=null,s=null,i=null,o=null,a=null){super(e,t,n,s,i,o,a),this._builder=e?._insertingBuilder??e?._builder??null,this._targetId=null}get builder(){if(this._builder)return this._builder;let e=this.parentBag;return e?e._builder:null}get data(){return this.builder.data}get rootBuilder(){return this.parentBag.root._builder}_getMeta(e){let t=this.getAttr("_meta")||{},n=e.split(",").map(s=>s.trim());return n.length===1?t[n[0]]!==void 0?t[n[0]]:null:n.map(s=>t[s]!==void 0?t[s]:null)}pointerType(e){return typeof e=="string"&&(e[0]==="^"||e[0]==="=")&&!e.startsWith("==")?e[0]:null}pointers(){this.builder.validateCustomTypes(this);let e=[];for(let[t,n]of Object.entries(this.getAttr()||{}))this.pointerType(n)==="^"&&e.push([t,n.split(":",1)[0]]);return this.pointerType(this.value)==="^"&&e.push(["",this.value.split(":",1)[0]]),e}fixedAttrItems(){return he(this.getAttr())}runtimeToEvaluate(){let e=new Map(this.fixedAttrItems());return e.set(Or,this.value),e}absDatapath(e){let t=e;this.pointerType(e)&&(e=(V(e)?.pointer??e).slice(1));let n=null;return e.includes("?")&&([e,n]=e.split("?",2)),e.startsWith("#")?this._finalizeAbsPath(this._resolveSymbolicDatapath(e,t),n):(e.startsWith(".")&&(e=this._composeRelativeDatapath(e,t)),this._finalizeAbsPath(e,n))}_finalizeAbsPath(e,t){return e=this._collapseParentDatapath(e,e),t?`${e}?${t}`:e}_composeRelativeDatapath(e,t){let n=this;for(;n!==null&&e.startsWith(".");){let s=n.getAttr("datapath");s!=null&&(e=e==="."?s:s+e),n=n.parentNode}if(e.startsWith("."))throw new Error(`unresolved relative datapath: ${t}`);return e}_collapseParentDatapath(e,t){let n=[];for(let s of e.split("."))if(s==="#parent"){if(n.length===0)throw new Error(`#parent has no segment to cancel: ${t}`);n.pop()}else n.push(s);return n.join(".")}_resolveSymbolicDatapath(e,t){let n=e.slice(1),s=n.indexOf("."),i=s===-1?n:n.slice(0,s),o=s===-1?"":n.slice(s+1),a;if(i==="FORM")a=this._findMarkedDatapathAncestor(!0,!1,t);else if(i==="ANCHOR")a=this._findMarkedDatapathAncestor(!1,!0,t);else{let l=this.rootBuilder;if(!l)throw new Error(`#<id>: cannot resolve ${t} on a node without builder`);if(a=l.source.getNodeByAttr("nodeId",i),a==null)throw new Error(`#<id>: cannot resolve ${t}`)}return a.absDatapath(o?`.${o}`:".")}_findMarkedDatapathAncestor(e,t,n){let s=this;for(;s!=null;){let o=s.getAttr()||{};if(e&&(o.formId!=null||o.form===!0)||t&&"_anchor"in o)return s;s=s.parentNode}let i=e?"FORM":"ANCHOR";throw new Error(`#${i}: no marked ancestor found for ${n}`)}getRelativeData(e,t=null,{autocreate:n=!1}={}){let s=this.data,i=this.absDatapath(e);return n&&s.getItem(i)==null&&s.setItem(i,t),s.getItem(i,t)}setRelativeData(e,t,{attributes:n=null,fired:s=!1,reason:i=null}={}){let o=this.data,a=this.absDatapath(e);o.setItem(a,t,n,">",!1,!0,i===null?!0:i,s)}fireEvent(e,t=!0,{attributes:n=null,reason:s=null}={}){this.setRelativeData(e,t,{attributes:n,fired:!0,reason:s})}SET(e,t){this.setRelativeData(e,t)}GET(e){return this.getRelativeData(e)}PUT(e,t){this.setRelativeData(e,t,{reason:!1})}FIRE(e,t=!0){this.setRelativeData(e,t,{fired:!0})}},D=class r extends C{constructor(e=null,t=null){super(e),this._builder=t,this._insertingBuilder=null}get nodeClass(){return we}_setBuilderItem(e,t,n,...s){let i=t?.map(([a])=>[a,a._builder])||null;if(t)for(let[a,l]of t)a._builder=l;let o=this._insertingBuilder;this._insertingBuilder=e;try{return this.setItem(n,...s)}catch(a){if(this.node(n)==null&&i)for(let[l,u]of i)l._builder=u;throw a}finally{this._insertingBuilder=o}}bindBuilder(e){if(!e)throw new Error("SourceBag.bindBuilder requires a builder");let t=this._builderBindingPlan(e);for(let[n,s]of t)n._builder=s;return this.setBackref(),this}_builderBindingPlan(e){let t=[],n=new WeakSet,s=(i,o)=>{if(n.has(i))throw new Error("source contains a cyclic or shared SourceBag branch");n.add(i),t.push([i,o]);for(let a of i.getNodes()){let l=o,u=a._getMeta("subbuilder");u!=null&&(l=o._resolveSubbuilderReference(u,a.getAttr()||{},a.nodeTag)),t.push([a,l]);let c=a.getValue(!0);c instanceof r&&s(c,l)}};return s(this,e),t}};if((Re(D.tytxSuffix).SourceBag??D)!==D)throw new Error("TYTX subtype name 'SourceBag' is already registered for another class");Ft(D.tytxSuffix,{...Re(D.tytxSuffix),SourceBag:D});function Lp(r){if(r.length===0)return{value:null,attrs:{}};let e=r[0];if(e!==null&&typeof e=="object"){let t=Object.getPrototypeOf(e);if(t===Object.prototype||t===null)return{value:null,attrs:e}}return{value:e,attrs:r[1]||{}}}var Pp=new Set(["then","toJSON"]),bu=new WeakMap;function te(r){return bu.get(r)||r}function Tn(r){if(r==null)return r;r=te(r);let e=r._builder||r.parentBag&&r.parentBag._builder;return e?e.wrapSource(r):r}function _u(r,e){let t=e instanceof C,n=new Proxy(e,{get(s,i){if(typeof i=="symbol"||i.startsWith("_")||Pp.has(i))return Reflect.get(s,i,s);let o=r.schemaTag(i);if(t&&o)return gu(r,s,o,t);if(i in s){let l=Reflect.get(s,i,s);return typeof l=="function"?l.bind(s):l}if(o)return gu(r,s,o,t);let a=r.containerMethod(i);if(a)return(...l)=>r[a](r.wrapSource(s),...l)}});return bu.set(n,e),n}function gu(r,e,t,n){return(...s)=>{let{value:i,attrs:o}=Lp(s),a=n?r.bagCall(e,t,i,o):r.commandOnNode(e,t,i,o);return a.builder.wrapSource(a)}}function Oo(r,e,{transport:t="json"}={}){let n=P(r,t==="json"?null:t);if(!(n instanceof D))throw new TypeError("TYTX payload did not decode to SourceBag");return n.bindBuilder(e)}var yu=/^[A-Za-z_][A-Za-z0-9_]*$/,Fp=new Set(["positional_only","positional_or_keyword","keyword_only","var_positional","var_keyword"]),jp=new Set(["framework","value","attribute"]),Up=new Map([["builtins.str",r=>typeof r=="string"],["builtins.int",r=>Number.isInteger(r)],["builtins.float",r=>typeof r=="number"&&Number.isFinite(r)],["builtins.bool",r=>typeof r=="boolean"],["builtins.list",r=>Array.isArray(r)],["builtins.dict",r=>r!==null&&typeof r=="object"&&!Array.isArray(r)],["builtins.tuple",r=>Array.isArray(r)],["builtins.set",r=>Array.isArray(r)||r instanceof Set],["builtins.NoneType",r=>r===null],["builtins.object",r=>!0]]);function Vt(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function T(r,e){throw new TypeError(`${r}: ${e}`)}function Ke(r,e,t,n){Vt(r)||T(n,"must be an object");for(let s of Object.keys(r))e.includes(s)||T(n,`unknown field '${s}'`);for(let s of t)Object.hasOwn(r,s)||T(n,`missing field '${s}'`)}function Ht(r,e){if(!(r===null||typeof r=="string"||typeof r=="boolean")&&!(typeof r=="number"&&Number.isFinite(r))){if(Array.isArray(r))return r.forEach((t,n)=>Ht(t,`${e}[${n}]`));if(Vt(r))return Object.entries(r).forEach(([t,n])=>Ht(n,`${e}.${t}`));T(e,"must be lossless JSON data")}}function qp(r,e){let t="",n=!1;for(let s=0;s<r.length;s++){let i=r[s];if(i==="\\"){t+=i+(r[++s]??"");continue}i==="["&&(n=!0),!n&&i==="."&&!(e&16)?t+="[^\\n]":!n&&i==="^"&&e&8?t+="(?:^|(?<=\\n))":!n&&i==="$"?t+=e&8?"(?=\\n|(?![\\s\\S]))":"(?=\\n?(?![\\s\\S]))":t+=i,i==="]"&&(n=!1)}return t}function qt(r,e,t=!1,n=null){if(r===null)return null;switch(Ke(r,["kind","dtype","module","name","origin","arguments","items","values","base","metadata","pattern","flags","ge","le","gt","lt","value"],["kind"],e),r.kind){case"custom":return Ke(r,["kind","name"],["kind","name"],e),n||T(e,"custom references require a catalog; nested catalog references are unsupported"),n.resolve(r.name,e);case"dtype":{Ke(r,["kind","dtype"],["kind","dtype"],e);let s=r.dtype;typeof s!="string"&&T(e,"dtype must be a string");let i=wn(s);return!i&&s!=="NN"&&T(e,`unknown dtype '${s}'`),{...r,test:a=>s==="NN"?a===null:s==="N"?fe(a)&&!["NaN","Infinity","-Infinity"].includes(a.toString()):i===Number?typeof a=="number"&&Number.isFinite(a)&&(s!=="L"||Number.isInteger(a)):i===String?typeof a=="string":i===Boolean?typeof a=="boolean":i===Date?a instanceof Date&&Number.isFinite(a.getTime()):i===Object?Vt(a)&&[Object.prototype,null].includes(Object.getPrototypeOf(a)):a instanceof i}}case"any":return{...r,test:s=>!0};case"type":{(typeof r.module!="string"||typeof r.name!="string")&&T(e,"type requires string module/name");let s=`${r.module}.${r.name}`;if(s==="collections.abc.Callable")return{...r,test:o=>typeof o=="function",portable:!1};let i=Up.get(s);return i||T(e,`unsupported type '${s}'`),{...r,test:i}}case"union":{(!Array.isArray(r.items)||!r.items.length)&&T(e,"union items must be non-empty");let s=r.items.map((i,o)=>qt(i,`${e}.items[${o}]`,!0,n));return{...r,items:s,inputConstraint:s.some(i=>i.inputConstraint),test:i=>s.some(o=>o.test&&o.test(i))}}case"literal":return Array.isArray(r.values)||T(e,"literal values must be an array"),r.values.forEach((s,i)=>Ht(s,`${e}.values[${i}]`)),{...r,test:s=>r.values.some(i=>Object.is(i,s))};case"annotated":{Array.isArray(r.metadata)||T(e,"annotated metadata must be an array"),r.metadata.some(o=>!["regex","range","value"].includes(o?.kind))&&T(e,"unsupported annotation metadata kind");let s=qt(r.base,`${e}.base`,!0,n),i=r.metadata.map((o,a)=>qt(o,`${e}.metadata[${a}]`,!0,n));return{...r,base:s,metadata:i,inputConstraint:s.inputConstraint,test:o=>s.test(o)&&i.every(a=>!a.test||a.test(o))}}case"range":{for(let s of["ge","le","gt","lt"])Object.hasOwn(r,s)||T(e,`range missing '${s}'`);for(let s of["ge","le","gt","lt"])r[s]!==null&&(typeof r[s]!="number"||!Number.isFinite(r[s]))&&T(e,`${s} must be finite number or null`);return{...r,test:s=>typeof s=="number"&&(r.ge===null||s>=r.ge)&&(r.le===null||s<=r.le)&&(r.gt===null||s>r.gt)&&(r.lt===null||s<r.lt)}}case"regex":{(typeof r.pattern!="string"||!Number.isInteger(r.flags)||r.flags<0)&&T(e,"regex requires pattern and non-negative integer flags");let s=r.flags&-59;s&&T(e,`unsupported Python regex flags ${s}`),r.flags&2&&T(e,"IGNORECASE is not portable across Python and JavaScript Unicode rules"),/\\[AZzUwWdDsSabBN0-9]|\(\?P[<=!]|\(\?\(|\(\?>|\(\?#|\(\?[aiLmsux-]|[+*?}]\+|\{,/.test(r.pattern.replaceAll(String.raw`[\s\S]`,"."))&&T(e,"regex uses a non-portable construct or character class");let i="uy";r.flags&16&&(i+="s");let o;try{o=new RegExp(`(?:${qp(r.pattern,r.flags)})(?![\\s\\S])`,i)}catch(a){T(e,`invalid portable regex: ${a.message}`)}return{...r,test:a=>typeof a!="string"?!1:(o.lastIndex=0,o.test(a))}}case"value":return Ht(r.value,`${e}.value`),{...r};case"generic":{let s=qt(r.origin,`${e}.origin`,!0,n);(r.origin?.kind!=="type"||r.origin.module!=="builtins"||!["list","dict","tuple","set"].includes(r.origin.name))&&T(e,"only list, dict, tuple and set generic origins are supported"),Array.isArray(r.arguments)||T(e,"generic arguments must be an array");let i=r.arguments.map((o,a)=>qt(o,`${e}.arguments[${a}]`,!0,n));return{...r,origin:s,arguments:i,inputConstraint:i.some(o=>o.inputConstraint),test:o=>s.test(o)&&Vp(r.origin,i,o)}}case"arguments":T(e,"Callable argument-list descriptors are not supported by Python validation");case"ellipsis":return t||T(e,"ellipsis is only valid as a nested descriptor"),{...r};default:T(e,`unknown annotation kind '${r.kind}'`)}}function Vp(r,e,t){let n=`${r.module}.${r.name}`;return n==="builtins.tuple"&&e.length&&e[1]?.kind!=="ellipsis"?t.length===e.length&&t.every((s,i)=>e[i].test(s)):n==="builtins.list"||n==="builtins.set"||n==="builtins.tuple"?[...t].every(s=>!e[0]?.test||e[0].test(s)):n==="builtins.dict"?Object.entries(t).every(([s,i])=>(!e[0]?.test||e[0].test(s))&&(!e[1]?.test||e[1].test(i))):!1}function vu(r,e){if(r===null)return null;if(typeof r!="string"&&T(e,"must be string or null"),r==="")return new Map;let t=new Map;for(let n of r.split(",")){let s=n.trim();/^[A-Za-z_][A-Za-z0-9_]*\[\]$/.test(s)&&T(e,`invalid cardinality item '${n}'`);let i=s.match(/^([A-Za-z_][A-Za-z0-9_]*|\*)(?:\[(?:(\d+)|(?:(\d*):(\d*)))\])?$/);i||T(e,`invalid cardinality item '${n}'`);let[,o,a,l,u]=i;t.has(o)&&T(e,`duplicate tag '${o}'`);let c=0,d=1/0;s.includes("[")&&(s.includes(":")?(c=l?Number(l):0,d=u?Number(u):1/0):c=d=Number(a)),d<c&&T(e,`maximum ${d} is below minimum ${c}`),t.set(o,{min:c,max:d})}return t.has("*")&&t.size>1&&T(e,"wildcard '*' cannot be combined with named tags"),t}function Eu(r,e){if(r===null)return null;typeof r!="string"&&T(e,"must be string or null");let t=new Set;for(let n of r.split(",")){let s=n.trim();s&&((!yu.test(s)||t.has(s))&&T(e,`invalid or duplicate parent '${n}'`),t.add(s))}return t}function Hp(r,e,t){if(r===null)return null;Ke(r,["parameters","accepts_var_keyword","accepts_var_positional"],[],e);let n=r.parameters??[];Array.isArray(n)||T(e,"parameters must be an array"),r={parameters:n,accepts_var_keyword:n.some(l=>l.kind==="var_keyword"),accepts_var_positional:n.some(l=>l.kind==="var_positional"),...r},(!Array.isArray(r.parameters)||typeof r.accepts_var_keyword!="boolean"||typeof r.accepts_var_positional!="boolean")&&T(e,"invalid signature descriptor");let s=new Set,i=!1,o=!1,a=r.parameters.map((l,u)=>{let c=`${e}.parameters[${u}]`;return Ke(l,["name","kind","role","annotation","has_default","default"],["name","kind","role","annotation","has_default"],c),(typeof l.name!="string"||!yu.test(l.name)||s.has(l.name))&&T(c,"invalid or duplicate parameter name"),s.add(l.name),(!Fp.has(l.kind)||!jp.has(l.role)||typeof l.has_default!="boolean")&&T(c,"invalid kind, role, or has_default"),l.has_default!==Object.hasOwn(l,"default")&&T(c,"default presence must equal has_default"),l.has_default&&Ht(l.default,`${c}.default`),i||=l.kind==="var_keyword",o||=l.kind==="var_positional",{...l,annotation:qt(l.annotation,`${c}.annotation`,!1,t)}});return(i!==r.accepts_var_keyword||o!==r.accepts_var_positional)&&T(e,"variadic summary flags do not match parameters"),{...r,parameters:a}}function wu(r,e,t,n){let s=["doc","sub_tags","parent_tags","inherits_from","ns","attributes",...t?["node_label","collection_key"]:[],"_meta"];Ke(r,s,[],e),r={...Object.fromEntries(s.map(i=>[i,null])),...r};for(let i of["doc","inherits_from","ns",...t?["node_label","collection_key"]:[]])r[i]!==null&&typeof r[i]!="string"&&T(e,`${i} must be string or null`);return r._meta!==null&&(Vt(r._meta)||T(e,"_meta must be object or null"),Ht(r._meta,`${e}._meta`)),vu(r.sub_tags,`${e}.sub_tags`),Eu(r.parent_tags,`${e}.parent_tags`),{...r,attributes:Hp(r.attributes,`${e}.attributes`,n)}}function ku(r){return r?r.split(",").map(e=>e.trim()).filter(Boolean):[]}function Au(r,e){let t={...e};for(let[n,s]of Object.entries(r))n==="inherits_from"||n.startsWith("_")||t[n]||(t[n]=s);return t._meta={...r._meta||{},...e._meta||{}},t}function Tu(r){let e={...r};return e._subSpec=Object.hasOwn(e,"sub_tags")?vu(e.sub_tags,"resolved.sub_tags"):null,e._parentSpec=Object.hasOwn(e,"parent_tags")?Eu(e.parent_tags,"resolved.parent_tags"):null,e}function xu(r,e,t,n){if(t.get(r)===1&&T(n,`inheritance cycle at '${r}'`),t.get(r)===2)return e[r];let s=e[r];s||T(n,`unknown abstract '${r}'`),t.set(r,1);let i={...s};for(let o of ku(s.inherits_from))i=Au(xu(o,e,t,n),i);return i=Tu(i),t.set(r,2),e[r]=i,i}function Bo({abstracts:r={},elements:e={}}){let t={...r},n=new Map;for(let i of Object.keys(t))xu(i,t,n,`abstracts.${i}.inherits_from`);let s={};for(let[i,o]of Object.entries(e)){let a={...o};for(let l of ku(o.inherits_from)){let u=t[l];u||T(`elements.${i}.inherits_from`,`unknown abstract '${l}'`),a=Au(u,a)}s[i]=Tu(a)}return{abstracts:t,elements:s}}function Ro(r){Ke(r,["document_format","grammar","abstracts","elements","custom_types"],["document_format","grammar","abstracts","elements"],"grammar document"),Ke(r.document_format,["name","version"],["name","version"],"document_format"),(r.document_format.name!=="builder_grammar"||!["1.1","1.2"].includes(r.document_format.version))&&T("document_format","expected builder_grammar version 1.1 or 1.2"),Ke(r.grammar,["name","version","title","description"],["name","version","title","description"],"grammar"),(typeof r.grammar.name!="string"||!r.grammar.name)&&T("grammar.name","must be non-empty string");for(let s of["version","title","description"])r.grammar[s]!==null&&typeof r.grammar[s]!="string"&&T(`grammar.${s}`,"must be string or null");(!Vt(r.abstracts)||!Vt(r.elements))&&T("grammar document","abstracts/elements must be objects"),Object.hasOwn(r,"custom_types")&&r.document_format.version!=="1.2"&&T("custom_types","requires version 1.2");let e=Br.fromJSON(r.custom_types??{}),t={};for(let[s,i]of Object.entries(r.abstracts))(!s||s.startsWith("_"))&&T("abstracts",`invalid public name '${s}'`),t[s]=wu(i,`abstracts.${s}`,!1,e);let n={};for(let[s,i]of Object.entries(r.elements))(!s||s.startsWith("_"))&&T("elements",`invalid public name '${s}'`),n[s]=wu(i,`elements.${s}`,!0,e);return{grammar:structuredClone(r.grammar),abstracts:t,elements:n}}function Du(r,e,t,n){let s=e.attributes;if(!s)return;let i={...n};t!=null&&(i.node_value=t);let o=new Set(s.parameters.filter(u=>u.role==="attribute").map(u=>u.name)),a=new Set(["node_label","node_position","nodeId","target_id","datapath","iterate","store","_tag","_meta","ns"]);if(!s.accepts_var_keyword)for(let u of Object.keys(n))!o.has(u)&&!a.has(u)&&T(r,`unknown attribute '${u}'`);let l=e._meta?.component?s.parameters.find(u=>u.role!=="framework"&&["positional_only","positional_or_keyword"].includes(u.kind))?.name:null;for(let u of s.parameters){if(u.name===l||u.role==="framework"||u.kind.startsWith("var_"))continue;let c=Object.hasOwn(i,u.name);!c&&!u.has_default&&T(r,`missing required ${u.role} '${u.name}'`),c&&u.annotation!==null&&(!u.annotation.test||!u.annotation.test(i[u.name]))&&T(r,`invalid value for ${u.role} '${u.name}'`)}}var Br=class r{#e=new Map;#t=new Map;register(e,t,n){let s=new Map([[String,"str"],[Number,"float"],["string","str"],["integer","int"],["number","float"]]),i=s.has(t)?{kind:"type",module:"builtins",name:s.get(t)}:t;return this.#r(e,{kind:"annotated",base:i,metadata:[n]})}#r(e,t){(typeof e!="string"||!/^[A-Za-z][A-Za-z0-9_]*$/.test(e)||e in this||["to_dict","from_dict"].includes(e)||zp.has(e))&&T("custom_types",`invalid, reserved or duplicate name '${e}'`),Ke(t,["kind","base","metadata"],["kind","base","metadata"],`custom_types.${e}`),(t.kind!=="annotated"||!Array.isArray(t.metadata)||t.metadata.length!==1||!["regex","range"].includes(t.metadata[0]?.kind))&&T(`custom_types.${e}`,"requires an annotated base with one Regex or Range validator");let n=t.metadata[0].kind==="regex"?["str"]:["int","float"];(t.base?.kind!=="type"||t.base.module!=="builtins"||!n.includes(t.base.name))&&T(`custom_types.${e}`,"portable Regex requires str; portable Range requires int or float"),Ht(t,`custom_types.${e}`);let s=structuredClone(t),i=qt(s,`custom_types.${e}`),o=Object.freeze({kind:"custom",name:e});return Object.defineProperty(this,e,{value:o,enumerable:!0}),this.#e.set(e,s),this.#t.set(e,{...o,inputConstraint:!0,test:i.test}),o}resolve(e,t="custom_types"){return this.#t.has(e)||T(t,`unknown custom type '${e}'`),{...this.#t.get(e)}}validate(e,t){return this.resolve(e).test(t)||T(`custom_types.${e}`,"invalid input value"),!0}toJSON(){return structuredClone(Object.fromEntries(this.#e))}static fromJSON(e){Vt(e)||T("custom_types","must be an object");let t=new r;for(let[n,s]of Object.entries(e))t.#r(n,s);return t}},zp=new Set("False None True and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield".split(" "));function Su(r,e,t,n){let s=e?.attributes;if(s)for(let i of s.parameters){if(!i.annotation?.inputConstraint||i.role==="framework"||["var_keyword","var_positional"].includes(i.kind))continue;let o=i.role==="value"?t:n[i.name];o!==void 0&&(i.annotation.test(o)||T(r,`invalid input for '${i.name}' (custom type)`))}}function Cu(r,e,t=[]){if(e===null)return structuredClone(r);if(t.length===2&&t[0]==="custom_types"&&r!==void 0){if(!Mo(r,e))throw new TypeError(`conflicting custom type '${t[1]}'`);return structuredClone(r)}if(t.length===2&&["abstracts","elements"].includes(t[0]))return structuredClone(e);if(it(r)&&it(e)){let n=structuredClone(r);for(let[s,i]of Object.entries(e))i!==null&&Object.defineProperty(n,s,{value:Cu(n[s],i,[...t,s]),enumerable:!0,writable:!0,configurable:!0});return n}return structuredClone(e)}function Mo(r,e){return Object.is(r,e)?!0:Array.isArray(r)&&Array.isArray(e)?r.length===e.length&&r.every((t,n)=>Mo(t,e[n])):it(r)&&it(e)?Object.keys(r).length===Object.keys(e).length&&Object.keys(r).every(t=>Object.hasOwn(e,t)&&Mo(r[t],e[t])):!1}function it(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)&&Object.getPrototypeOf(r)===Object.prototype}function $o(r){if(!(r===null||typeof r=="string"||typeof r=="boolean")&&!(typeof r=="number"&&Number.isFinite(r))){if(Array.isArray(r)){r.forEach($o);return}if(it(r)){Object.values(r).forEach($o);return}throw new TypeError("collection must contain only finite JSON values")}}var ot=class r{#e;constructor(e){$o(e);let t=["document_format","grammar","abstracts","elements"];if(!it(e)||Object.keys(e).some(s=>![...t,"custom_types"].includes(s))||t.some(s=>!Object.hasOwn(e,s)))throw new TypeError("collection requires document_format, grammar, abstracts and elements");let n=e.document_format;if(!it(n)||Object.keys(n).length!==2||n.name!=="builder_grammar"||!["1.1","1.2"].includes(n.version))throw new TypeError("expected builder_grammar version 1.1 or 1.2");for(let s of["grammar","abstracts","elements"])if(!it(e[s]))throw new TypeError(`${s} must be an object`);if(Object.hasOwn(e,"custom_types")&&(n.version!=="1.2"||!it(e.custom_types)))throw new TypeError("custom_types requires an object catalog and version 1.2");this.#e=structuredClone(e)}update(e){let t=new r(e),n=Cu(this.#e,t.#e);return(this.#e.document_format.version==="1.2"||t.#e.document_format.version==="1.2")&&(n.document_format.version="1.2"),this.#e=n,this}toDocument(){return structuredClone(this.#e)}};var zt=class{static renderType="string";static mode=null;constructor(e){this._builder=e,this.renders=new Map([[e,this]])}get builder(){return this._builder}get renderType(){return this.constructor.renderType}get mode(){return this.constructor.mode}addRender(e,t){this.renders.set(e,t)}getRender(e){let t=this.renders.get(e);if(t!==void 0)return t;let n=e.getRenderer();return this.renders.set(e,n),n}render(e,t={}){let n=e.builder,[s,i]=n.runtimeValues(e);if(e._getMeta("data_element"))return null;if(e._getMeta("component"))return this._renderComponent(e,i,t);let o=this.getRender(n),a;return[a,i]=o._handleMeta(e,i),e._getMeta("subbuilder")||(i=o.adaptAttrs(i)),e.value instanceof D&&(s=this.renderChildren(e.value,t)),o.renderedItem(e,s,i,{tag:a,...t})}renderChildren(e,t={}){let n=[];for(let s of e.getNodes()){let i=this.render(s,t);i!==null&&(Array.isArray(i)?n.push(...i):n.push(i))}return n}_renderComponent(e,t,n){let[s,i,o,a]=this._expansionInputs(e,t);if(!Object.hasOwn(e.getAttr(),"iterate"))return this._expandBlock(e,s,o,a,n);if(i==null)return[];if(!(i instanceof C))throw new TypeError(`component '${e.nodeTag}': iterate must resolve to a Bag, got ${i?.constructor?.name||typeof i}`);return i.getNodes().map(l=>this._expandBlock(e,s,o,{node_label:l.label},n))}_expansionInputs(e,t){let n=e.builder,s=n.componentMethod(e.nodeTag),i=s&&n[s];if(typeof i!="function")throw new Error(`component '${e.nodeTag}' has no implementation`);let o=t.iterate;delete t.iterate,delete t.store;let a=e.getAttr("iterate")||e.getAttr("store");a!=null?(e.pointerType(a)&&(a=a.slice(1)),a.startsWith(".")&&(a=e._composeRelativeDatapath(a,a))):a=null;for(let l of Object.keys(t)){let u=e.getAttr(l);e.pointerType(u)==="^"&&(t[l]=`^${e.absDatapath(u)}`)}return[i,o,a,t]}_expandBlock(e,t,n,s,i){let o=e.builder._expansionRoot(n);t.call(e.builder,Tn(o),s);let a=o.getNodes();if(a.length!==1)throw new Error(`component '${e.nodeTag}' must build a tree, not a forest: ${a.length} root nodes`);let l={...i,depthOffset:this._nodeDepth(e,i.depthOffset||0)};return this.render(a[0],l)}preprocess(e){return e}renderedItem(e,t,n,s){throw new Error(`${this.constructor.name} does not implement renderedItem`)}_handleMeta(e,t){let[n,s]=e._getMeta("render_tag,render_attributes"),i=An(e.nodeTag,{renderTag:n,ns:e.getAttr("ns"),dialectName:e.builder?.constructor._name});if(!i)throw new Error(`node ${e.label} has no tag to render (no render_tag, no node_tag)`);return s&&(t={...t,...s}),[i,t]}adaptAttrs(e){return e}adapt(e){let t=`${this.builder.constructor._name}_`;return e.startsWith(t)?e.slice(t.length):e}finalize(e,t=null,n={}){let s=this._composeStringFragments(e);if(t==null)return s;if(typeof t=="string")throw new TypeError("string render targets require filesystem support, which is unavailable in the portable renderer; pass a callable or writable target instead");if(typeof t.full=="function"&&typeof t.write!="function")return t.full(s),null;if(typeof t.write=="function")return t.write(s),null;if(typeof t=="function")return t(s),null;throw new TypeError("render target must be writable (.write), callable, or expose .full")}_composeStringFragments(e){if(!Array.isArray(e))return e;if(e.some(t=>typeof t!="string"))throw new TypeError("String composition requires string fragments; object renderers must define their own composition");return e.join("")}_escapeText(e){return String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;")}_escapeAttr(e){return this._escapeText(e).replaceAll('"',"&quot;")}_nodeDepth(e,t=0){let s=((e.fullpath||"").match(/\./g)||[]).length;return Math.max(s-1,0)+t}};var Wt=class extends zt{static mode="xml";renderedItem(e,t,n,{tag:s,pretty:i=!1,depthOffset:o=0}={}){let a=this._formatAttrs(n),l=i?" ".repeat(this._nodeDepth(e,o)):"",u=i?`
23
+ `:"";if(Array.isArray(t)){let c=this._composeStringFragments(t);return`${l}<${s}${a}>${u}${c}${l}</${s}>${u}`}return t==null?`${l}<${s}${a}></${s}>${u}`:`${l}<${s}${a}>${this._escapeText(t)}</${s}>${u}`}finalize(e,t=null,{docHeader:n=null}={}){let s=this._composeStringFragments(e);return n===!0?s=`<?xml version='1.0' encoding='UTF-8'?>${s}`:typeof n=="string"&&(s=n+s),super.finalize(s,t)}_formatAttrs(e){return Object.entries(e||{}).map(([t,n])=>` ${t.startsWith("xmlns_")?`xmlns:${t.slice(6)}`:t}="${this._escapeAttr(n)}"`).join("")}};var Nu={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"base",version:null,title:null,description:null},abstracts:{},elements:{dataSetter:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"value",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataFormula:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataController:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}}}};function Iu(r){let e=[];for(;r&&r!==Function.prototype;)e.push(r),r=Object.getPrototypeOf(r);return e.reverse()}function Gp(r){let e=Object.create(null),t=(n,s)=>{let i=n.toLowerCase(),o=e[i];if(o!==void 0&&o!==s)throw new Error(`container '${n}' is already tied to implementation method '${o}' (cannot rebind to '${s}')`);e[i]=s};for(let n of Iu(r))if(Object.hasOwn(n,"containers"))for(let s of n.containers||[])t(s,s);return e}function xn(r){let e=Object.create(null);for(let t of Object.keys(r)){let n=t.toLowerCase();if(Object.hasOwn(e,n))throw new Error(`element declaration '${t}' has a case-insensitive collision with '${e[n]}'`);e[n]=t}return e}var Dn="_root_",Sn="_root_",Ou=new Set(["destination","func","value","_on_start"]),ye=class r{static _sourceClass=D;static registerBuilder(e){if(typeof e!="function"||!(e.prototype instanceof r))throw new TypeError("registerBuilder requires a BuilderBase subclass");let t=e._name;if(typeof t!="string"||!t)throw new TypeError("registered builders require a non-empty static _name");let n=r._registry.get(t);if(n&&n!==e)throw new Error(`Builder name '${t}' is already registered to ${n.name}; cannot register ${e.name}`);return r._registry.set(t,e),e}static getBuilderClass(e){let t=r._registry.get(e);if(!t)throw new Error(`No builder registered with name '${e}'`);return t}constructor(e=null){this.name=e||this.constructor._name,this._dataroot=new C,this._dataroot.setBackref(),this._dataroot.setItem(Sn,new C),this.data=this._dataroot.getItem(Sn),this._defaultTargets=new Map,this.materialized=Object.create(null),this._collection=null,this._schemaOverride=null,this._tagNamesOverride=null,this._componentMap=null,this._targetSerial=0,this._subbuilders=new Map,this._sourceHandles=new WeakMap;let t=this.constructor._sourceClass;this._sourceroot=new t(null,this),this._sourceroot.setBackref(),this._sourceroot.setItem(Dn,new t(null,this)),this.source=this._sourceroot.getItem(Dn)}wrapSource(e){if(e=te(e),!(e instanceof D)&&!(e instanceof we))throw new TypeError("wrapSource requires a SourceBag or SourceBagNode");let t=this._sourceHandles.get(e);return t||(t=_u(this,e),this._sourceHandles.set(e,t)),t}get root(){return this.wrapSource(this.source)}getSubbuilder(e){if(typeof e!="string"||!e||e.includes(":"))throw new Error(`unsupported subbuilder reference '${e}'`);let t=this._subbuilders.get(e);if(!t){let n=r.getBuilderClass(e);t=new n,this._subbuilders.set(e,t)}return t._dataroot=this._dataroot,t.data=this.data,t}_resolveSubbuilderReference(e,t,n){if(typeof e!="string"||!e)throw new Error(`'${n}': subbuilder declaration must be a non-empty string`);if(e.includes(":"))throw new Error(`'${n}': runtime subbuilder reference '${e}' is unsupported`);return this.getSubbuilder(e)}static defineGrammar(e){let t=this._classCollection,n=t?new ot(t.toDocument()).update(e):new ot(e),s=Ro(n.toDocument()),i=Bo(s),o=xn(i.elements);this._classCollection=n,this._classSchema=i.elements,this._abstracts=i.abstracts,this._tagNames=o}static{this.defineGrammar(Nu)}get _containers(){return Gp(this.constructor)}containerMethod(e){return this._containers[e.toLowerCase()]||null}componentMethod(e){return this._componentMap?.[e.toLowerCase()]||null}get schema(){return this._schemaOverride||this.constructor._classSchema||{}}get schemaTagNames(){return this._schemaOverride?this._tagNamesOverride??=xn(this.schema):this.constructor._tagNames??=xn(this.schema)}schemaTag(e){let t=e.toLowerCase(),n=this.schemaTagNames[t];if(n)return n;let s=`${this.constructor._name}_`;return t.startsWith(s)&&this.schemaTagNames[t.slice(s.length)]||null}loadGrammar(e,{replace:t=!1}={}){let n=this._collection||this.constructor._classCollection,s=t?new ot(e):new ot(n.toDocument()).update(e),i=Ro(s.toDocument()),o=Bo(i),a=xn(o.elements);return this._collection=s,this._schemaOverride=o.elements,this._tagNamesOverride=a,this}validateCustomTypes(e){let t=e.parentBag?.parentNode?.builder||e.parentBag?._builder,n=t&&t!==this&&t.schema[e.nodeTag]?._meta?.subbuilder?t:this;Su(e.nodeTag,n.schema[e.nodeTag],e.value,e.getAttr()||{})}validateNodeValues(e,t,n={}){let s=this.schemaTag(e);if(!s)throw new Error(`unknown element '${e}'`);return Du(s,this.schema[s],t,n),!0}validateNode(e,{value:t,attrs:n,childTags:s}={}){if(!e||typeof e.nodeTag!="string")throw new TypeError("validateNode requires a source node");let i=t!==void 0?t:e.value instanceof D?null:e.value;this.validateNodeValues(e.nodeTag,i,n||e.getAttr?.()||{});let o=this.schema[this.schemaTag(e.nodeTag)],a=s||(e.value instanceof D?e.value.getNodes().map(l=>l.nodeTag):null);return a&&this._validateChildren(e.nodeTag,o,a,!1),!0}validateChildren(e,t,{includeMinimum:n=!1}={}){let s=this.schemaTag(e);if(!s)throw new Error(`unknown element '${e}'`);if(!Array.isArray(t)||t.some(i=>typeof i!="string"))throw new TypeError("childTags must be an array of strings");return this._validateChildren(s,this.schema[s],t,n)}validateParent(e,t=null){let n=this.schemaTag(e);if(!n)throw new Error(`unknown element '${e}'`);let s=this.schema[n];if(!this._countsForGrammar(s))return!0;let i=s._parentSpec;if(i==null||i.has("*"))return!0;if(t===null)throw new Error(`'${n}' requires a declared parent`);let o=this.schemaTag(t);if(!o)throw new Error(`unknown parent element '${t}'`);return this._validateParent(n,s,o),!0}bagCall(e,t,n,s){return this.setChild(e,t,n,s)}commandOnNode(e,t,n,s){if(e=te(e),e.value instanceof D)return this.setChild(e.value,t,n,s);let i=e.value,o=new e.parentBag.constructor(null,e.builder||this),a=this.setChild(o,t,n,s,e);return this.promoteNodeValue(e,i,o),a}promoteNodeValue(e,t,n){e.setValue(n)}setChild(e,t,n,s,i=null){let o={...s},a=this.schema[t];if(!a)throw new Error(`unknown element '${t}'`);this.validateNodeValues(t,n,o);let l=a._meta?.subbuilder,c=(l==null?null:this._resolveSubbuilderReference(l,o,t))||this,d=n instanceof D?n._builderBindingPlan(c):null,f=i?.rootBuilder||e.root._builder||this;if(o.nodeId!=null&&f.source.getNodeByAttr("nodeId",o.nodeId))throw new Error(`Duplicate nodeId '${o.nodeId}'`);n instanceof D&&this._validateChildren(t,a,n.getNodes().map(w=>w.nodeTag),!1);let h=i||e.parentNode,p=h?.nodeTag?this.schema[h.nodeTag]:null;if(p&&!h._getMeta("subbuilder")&&this._countsForGrammar(a))this._validateParent(t,a,h.nodeTag),this._validateChildren(h.nodeTag,p,[...e.getNodes().map(w=>w.nodeTag),t],!1);else if(!p&&!h?._getMeta("subbuilder")&&a._parentSpec!=null&&this._countsForGrammar(a))throw new Error(`'${t}' requires a declared parent`);a._meta&&!("_meta"in o)&&(o._meta=a._meta),a.ns&&!("ns"in o)&&(o.ns=a.ns);let m=o.node_position;delete o.node_position;let g=o.node_label;delete o.node_label;let b;if(p?.collection_key){if(g!=null)throw new Error(`'${t}': node_label is not allowed in a collection`);b=this._collectionLabel(p.collection_key,t,o)}else{let w=p?._subSpec?.get(t);if(w&&w.max===1){if(g!=null)throw new Error(`'${t}': node_label is not allowed on a singleton`);b=t}else b=g||a.node_label||this._autoLabel(e,t)}if(e.node(b)!=null)throw new Error(`duplicate node label '${b}'`);return e._setBuilderItem(c,d,b,n,o,m||">",!1,!0,null,!1,!0,null,t)}_countsForGrammar(e){let t=e?._meta||{};return!(t.data_element||t.subbuilder||t.component)}_validateParent(e,t,n){let s=t._parentSpec;if(!(s==null||s.has("*")||!this._countsForGrammar(t))&&!s.has(n))throw new Error(`'${e}' not allowed as child of '${n}'`)}_validateChildren(e,t,n,s){let i=t._subSpec;if(i==null||i.has("*")||t._meta?.subbuilder)return[];let o=new Map;for(let a of n){let l=this.schema[a];if(l&&!this._countsForGrammar(l))continue;let u=i.get(a);if(!u)throw new Error(`'${a}' not allowed as child of '${e}'`);let c=(o.get(a)||0)+1;if(o.set(a,c),c>u.max)throw new Error(`too many '${a}' in '${e}'`)}return s?[...i].filter(([a,l])=>(o.get(a)||0)<l.min).map(([a])=>a):[]}_collectionLabel(e,t,n){let s=i=>{if(n[i]===null||n[i]===void 0)throw new Error(`'${t}': collection key needs attribute '${i}'`);return String(n[i])};return e.includes("${")?e.replace(/\$\{([^}]+)\}/g,(i,o)=>s(o)):s(e)}validateSource(){let e=[],t=(n,s="")=>{for(let i of n.getNodes()){let o=s?`${s}.${i.label}`:i.label,a=i.builder;a.validateCustomTypes(i);let l=a.schema[i.nodeTag];if(l&&!i._getMeta("data_element,subbuilder,component").some(Boolean)){let u=i.value instanceof D?i.value.getNodes().map(d=>d.nodeTag):[],c=a._validateChildren(i.nodeTag,l,u,!0);c.length&&e.push([o,c])}i.value instanceof D&&t(i.value,o)}};return t(this.source),e}_autoLabel(e,t){let n=0;for(;e.node(`${t}_${n}`)!==null&&e.node(`${t}_${n}`)!==void 0;)n+=1;return`${t}_${n}`}nodeById(e){let t=this.source.getNodeByAttr("nodeId",e);if(t==null)throw new Error(`nodeId not found: ${e}`);return t.builder.wrapSource(t)}runtimeValues(e){e.builder.validateCustomTypes(e);let t=new Map,n={},s=e.runtimeToEvaluate(),i=new Set(s.keys()),o=new Map([...Object.entries(e.getAttr()),...e.fixedAttrItems()]);for(let[c,d]of[...s])if(!(typeof c!="string"||!V(d)))for(let f of He(e,d))s.has(f)||s.set(f,o.get(f));let a=e._getMeta("data_element");for(let[c,d]of s){if(d instanceof Z){t.set(c,d.resolve());continue}let f=typeof c=="string"?V(d)?.pointer??d:d;if(!e.pointerType(f)){t.set(c,typeof c=="string"&&typeof d=="string"&&d.startsWith("==")?null:d);continue}let h=e.absDatapath(f);if(t.set(c,this.data.getItem(h)),!a&&!h.includes("?")&&c===Or){let p=this.data.getNode(h);p&&Object.assign(n,p.getAttr("_wdg"))}}let l=la(s,t,(c,d,f,h)=>this.evaluatePointerExpression(e,c,d,f,h)),u=l.get(Or);l.delete(Or);for(let c of l.keys())i.has(c)||l.delete(c);return[u,{...Object.fromEntries(l),...n}]}evaluatePointerExpression(e,t,n,s,i){return null}targetId(e){if(e._targetId)return e._targetId;let t=e.rootBuilder;return e.parentBag.root!==t.source.root?null:(t._targetSerial+=1,e._targetId=`n${t._targetSerial}`,e._targetId)}get dataLogic(){if(!this._dataLogic){let e=this._buildDataLogic();this._dataLogic=Array.isArray(e)?e:[e]}return this._dataLogic}_buildDataLogic(){return this}_resolveLogicFunc(e){if(typeof e=="function")return e;if(typeof e!="string")throw new Error("data-element func must be a name or a function");for(let t of this.dataLogic){let s=(typeof t=="function"?t:t.constructor)[e];if(typeof s=="function")return s}throw new Error(`data-element func '${e}' not found on any data_logic source`)}_bindings(e){let[,t]=this.runtimeValues(e),n={};for(let[s,i]of Object.entries(t))Ou.has(s)||(n[s]=i);return n}computeLogic(e){for(let t of e)this._computeNode(t)}_computeNode(e){let t=e.getAttr()||{};if(e.nodeTag==="dataSetter"){let n={};for(let[s,i]of Object.entries(t))s!=="destination"&&s!=="value"&&!s.startsWith("_")&&(n[s]=i);e.setRelativeData(t.destination,t.value,{attributes:Object.keys(n).length?n:null})}else if(e.nodeTag==="dataFormula"){let n=this._resolveLogicFunc(t.func);e.setRelativeData(t.destination,n(this._bindings(e)))}else e.nodeTag==="dataController"&&this._resolveLogicFunc(t.func)(e,this._bindings(e))}_dataElementNodes(){let e=[],t=n=>{for(let s of n.getNodes())s._getMeta("data_element")&&e.push(s),s.value instanceof D&&t(s.value)};return t(this.source),e}setup(e){}main(e){throw new Error(`${this.constructor.name}.main() not implemented: a bare builder is grammar, not a renderable page`)}_resolveComponents(){let e={};for(let a of Iu(this.constructor))if(Object.hasOwn(a,"components"))for(let l of a.components||[])e[l]=l;if(!Object.keys(e).length)return;let t={...this.schema},n={};for(let[a,l]of Object.entries(e))t[a]={sub_tags:"",_meta:{component:!0}},n[a.toLowerCase()]=l;let s=xn(t),i=this._collection||this.constructor._classCollection,o=i.toDocument();o.abstracts={},o.elements=Object.fromEntries(Object.keys(e).map(a=>[a,t[a]])),this._collection=new ot(i.toDocument()).update(o),this._schemaOverride=t,this._componentMap=n,this._tagNamesOverride=s}_expansionRoot(e=null){let t=this.constructor._sourceClass,n=new t(null,this);return n.setBackref(),n.setItem(Dn,new t(null,this),e?{datapath:e}:null),n.getItem(Dn)}create(){this.setup(this.data),this._resolveComponents(),this.main(this.root),this.computeLogic(this._dataElementNodes())}get renderer_xml(){return new Wt(this)}getRenderer(e=null){e??=this.constructor._defaultRenderMode;let t=this[`renderer_${e}`];if(!t)throw new Error(`${this.constructor.name} does not expose renderer_${e}`);return t}materialize(e=null,t={}){e??=this.constructor._defaultRenderMode;let n=this.getRenderer(e),s=n.renderChildren(n.preprocess(this.source),t);return this.materialized[e]=s,s}setRenderTarget(e,t=null){t??=this.constructor._defaultRenderMode,this._defaultTargets.set(t,e)}render({mode:e=null,target:t=null,...n}={}){e??=this.constructor._defaultRenderMode;let s=this.getRenderer(e);if(t===!1&&s.renderType!=="string")throw new TypeError("target=false is not valid for an object renderer");let i=t===!1?null:t||this._defaultTargets.get(s.mode)||null,o={...i?.renderOpts,...n};return s.finalize(this.materialize(e,o),i,o)}};ye._registry=new Map;var Xp=new Set(["short","medium","long","full"]),Yp=/('(?:[^']|'')*'|[a-zA-Z]+|[^a-zA-Z']+)/g;function Zp(r,e){if(!(r instanceof Date))throw new TypeError("Temporal formats require a typed Date value");if(!Number.isFinite(r.getTime()))throw new RangeError("Invalid date");let t=e||W(r).split("::").at(-1);if(!["D","H","DH","DHZ"].includes(t))throw new RangeError(`Unsupported temporal dtype: ${t}`);return t}function Jp(r,e,t,n){let s=e.match(Yp)||[];if(s.join("")!==e)throw new RangeError("Unclosed format literal");let i=(c,d=2)=>String(c).padStart(d,"0"),o=c=>new Intl.DateTimeFormat(t,{timeZone:"UTC",...c}).format(r),u={...n==="H"?{}:{y:()=>String(r.getUTCFullYear()),yy:()=>i(r.getUTCFullYear()%100),yyyy:()=>i(r.getUTCFullYear(),4),M:()=>String(r.getUTCMonth()+1),MM:()=>i(r.getUTCMonth()+1),MMM:()=>o({month:"short"}),MMMM:()=>o({month:"long"}),d:()=>String(r.getUTCDate()),dd:()=>i(r.getUTCDate()),EEE:()=>o({weekday:"short"}),EEEE:()=>o({weekday:"long"})},...n==="D"?{}:{H:()=>String(r.getUTCHours()),HH:()=>i(r.getUTCHours()),h:()=>String(r.getUTCHours()%12||12),hh:()=>i(r.getUTCHours()%12||12),m:()=>String(r.getUTCMinutes()),mm:()=>i(r.getUTCMinutes()),s:()=>String(r.getUTCSeconds()),ss:()=>i(r.getUTCSeconds()),a:()=>new Intl.DateTimeFormat(t,{hour:"numeric",hour12:!0,timeZone:"UTC"}).formatToParts(r).find(c=>c.type==="dayPeriod").value}};return s.map(c=>{if(c.startsWith("'"))return c==="''"?"'":c.slice(1,-1).replaceAll("''","'");if(!/^[a-zA-Z]/.test(c))return c;if(!u[c])throw new RangeError(`Unsupported date format token: ${c}`);return u[c]()}).join("")}function Bu(r,{format:e,mask:t,locale:n,dtype:s,places:i}={}){let o=r==null?"":String(r);if(r!=null&&r!==""&&(e!=null&&e!==""||i!=null))if(typeof r=="number"||fe(r))o=Qp(r,{format:e,locale:n,places:i});else{let a=Zp(r,s);if(Xp.has(e)){let l={timeZone:"UTC"};a!=="H"&&(l.dateStyle=e),a!=="D"&&(l.timeStyle=e),o=new Intl.DateTimeFormat(n||void 0,l).format(r)}else o=Jp(r,String(e),n||void 0,a)}return t==null?o:String(t).replaceAll("%s",()=>o)}function Kp({format:r="decimal",places:e}={}){let t={maximumFractionDigits:20};if(!r||r==="decimal")t.style="decimal";else if(r==="percent")t.style="percent";else if(r==="scientific")t.notation="scientific";else{let n=/^(0|#,##0)(?:\.(0*)(#*))?$/.exec(r);if(!n||r.includes(".")&&!n[2]&&!n[3])throw new RangeError(`Unsupported number format: ${r}`);t.useGrouping=n[1].includes(","),t.minimumFractionDigits=(n[2]||"").length,t.maximumFractionDigits=(n[2]||"").length+(n[3]||"").length}if(e!=null&&e!==""){let n=Number(e);if(!Number.isInteger(n)||n<0||n>20)throw new RangeError("places must be an integer from 0 to 20");t.minimumFractionDigits=n,t.maximumFractionDigits=n}return t}function Qp(r,e={}){if(typeof r!="number"&&!fe(r))throw new TypeError("Number formatting requires a Number or Decimal");if(!Number.isFinite(Number(r)))throw new RangeError("Number must be finite");let t=new Intl.NumberFormat(e.locale||void 0,Kp(e));if(fe(r)&&new Intl.NumberFormat("en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal values without precision loss");return t.format(fe(r)?r.toString():r)}var em=new Set(["style","script"]),tm=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),Ru=new Set(["width","height","top","left","right","bottom","padding","margin","border","position","display","overflow","float","clear","resize","z_index","min_width","min_height","max_width","max_height","color","background","font","text","line_height","white_space","vertical_align","flex","gap","row_gap","column_gap","grid","align_content","justify_content","align_items","justify_items","visibility","opacity","cursor"]),Cn=new Set(["rounded","gradient","shadow","transform","transition","zoom","filter"]),Mu=r=>r===!0?"true":r===!1?"false":String(r),Gs=r=>typeof r=="number"&&Number.isFinite(r)?`${r}px`:String(r);function rm(r){if(Ru.has(r))return!0;for(let e of Ru)if(r.startsWith(`${e}_`))return!0;return!1}function nm(r){let e=new Map;if(!r)return e;let t=[],n=0,s=null,i=!1,o=!1,a=0,l=String(r);for(let u=0;u<l.length;u+=1){let c=l[u],d=l[u+1];if(o){c==="*"&&d==="/"&&(o=!1,u+=1);continue}if(i){i=!1;continue}if(c==="\\"){i=!0;continue}if(s){c===s&&(s=null);continue}c==='"'||c==="'"?s=c:c==="/"&&d==="*"?(o=!0,u+=1):"([{".includes(c)?a+=1:")]}".includes(c)&&a>0?a-=1:c===";"&&a===0&&(t.push(l.slice(n,u)),n=u+1)}t.push(l.slice(n));for(let u of t){let c=u.trim();if(!c)continue;let d=c.indexOf(":");if(d<0)throw new TypeError(`malformed style declaration '${c}'`);e.set(c.slice(0,d).trim(),c.slice(d+1).trim())}return e}var Gt=class extends zt{static mode="html";renderedItem(e,t,n,{tag:s,xml:i=!0,pretty:o=!1,depthOffset:a=0,includeDatapath:l=!1}={}){e.parentNode?._getMeta("subbuilder")==="html"&&(n={xmlns:"http://www.w3.org/1999/xhtml",...n});let{format:c,mask:d,locale:f,places:h,dtype:p,...m}=n;!Array.isArray(t)&&(c!=null||d!=null||h!=null)&&(t=Bu(t,{format:c,mask:d,places:h,dtype:p,locale:this._displayLocale(e,f)}));let g=this._formatAttrs(m);if(l){if(!Object.hasOwn(n,"id")){let k=this.builder.targetId(e);k!==null&&(g+=` id="${this._htmlAttrValue(k)}"`)}for(let[k,A]of Object.entries(e.getAttr()))e.pointerType(A)&&(g+=` data-${this.adapt(k)}-pointer="${this._htmlAttrValue(e.absDatapath(A))}"`)}let b=o?" ".repeat(this._nodeDepth(e,a)):"",y=o?`
24
+ `:"";if(e._getMeta("void"))return`${b}<${s}${g}${i?"/":""}>${y}`;if(Array.isArray(t)){let k=this._composeStringFragments(t);return`${b}<${s}${g}>${y}${k}${b}</${s}>${y}`}if(t==null)return`${b}<${s}${g}></${s}>${y}`;let w=typeof t=="string"&&t.endsWith("::HTML")?t.slice(0,-6):em.has(s)?String(t):this._escapeText(t);return`${b}<${s}${g}>${w}</${s}>${y}`}_displayLocale(e,t){if(t)return t;for(let n=e.parentNode;n;n=n.parentNode){let s=n.getAttr("locale");if(s==null)continue;let i=n.pointerType(s)?n.data.getItem(n.absDatapath(s)):s;if(i)return i}}adaptAttrs(e){let t={},n={};for(let[i,o]of Object.entries(e||{}))if(i.startsWith(`${this.builder.constructor._name}_`))t[this.adapt(i)]=o;else if(i==="dtype")t.dtype=o;else{if(this.builder.constructor.retainedAttrPrefixes.some(a=>i.startsWith(a)))continue;this._isStyleContribution(i)?n[i]=o:t[i]=o}let s=this._adaptStyle(n);return s&&(t.style=s),t}_isStyleContribution(e){if(e==="style"||e.startsWith("style_")||Cn.has(e))return!0;let t=e.includes("_")?e.slice(0,e.indexOf("_")):null;return t!==null&&Cn.has(t)||rm(e)}_adaptStyle(e){let t=nm(e.style),n=new Map,s=new Map;for(let[i,o]of Object.entries(e))if(i!=="style")if(i.startsWith("style_"))t.set(i.slice(6).replaceAll("_","-"),Mu(o));else if(Cn.has(i))n.set(i,o);else{let a=i.indexOf("_"),l=a<0?i:i.slice(0,a);a>=0&&Cn.has(l)?(s.has(l)||s.set(l,{}),s.get(l)[i.slice(a+1)]=o):t.set(i.replaceAll("_","-"),Mu(o))}for(let i of Cn)(n.has(i)||s.has(i))&&this[`_macro_${i}`](n.get(i),s.get(i)||{},t);return[...t].map(([i,o])=>`${i}: ${o}`).join("; ")}_formatAttrs(e){let t=[];for(let[n,s]of Object.entries(e||{}))tm.has(n)?s&&t.push(` ${n}`):t.push(` ${n}="${this._htmlAttrValue(s)}"`);return t.join("")}_htmlAttrValue(e){return(e===!0?"true":e===!1?"false":String(e)).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;")}_macro_rounded(e,t,n){let s=e===void 0?{}:{top_left:e,top_right:e,bottom_left:e,bottom_right:e};for(let[i,o]of Object.entries(t))if(i==="top"||i==="bottom")s[`${i}_left`]=o,s[`${i}_right`]=o;else if(i==="left"||i==="right")s[`top_${i}`]=o,s[`bottom_${i}`]=o;else if(["top_left","top_right","bottom_left","bottom_right"].includes(i))s[i]=o;else throw new TypeError(`rounded: unknown sub-kwarg '${i}'`);for(let[i,o]of Object.entries(s))n.set(`border-${i.replaceAll("_","-")}-radius`,Gs(o))}_macro_transform(e,t,n){let s=e===void 0?[]:[String(e)];for(let[i,o]of Object.entries(t))i==="rotate"?s.push(`rotate(${o}deg)`):i==="scale"||i==="translate"?s.push(`${i}(${o})`):i==="translate_x"?s.push(`translateX(${Gs(o)})`):i==="translate_y"?s.push(`translateY(${Gs(o)})`):i==="skew_x"?s.push(`skewX(${o}deg)`):i==="skew_y"?s.push(`skewY(${o}deg)`):s.push(`${i.replaceAll("_","-")}(${o})`);s.length&&n.set("transform",s.join(" "))}_macro_filter(e,t,n){let s=e===void 0?[]:[String(e)];for(let[i,o]of Object.entries(t))i==="rotate"?s.push(`hue-rotate(${o}deg)`):i==="blur"?s.push(`blur(${Gs(o)})`):i==="drop_shadow"?s.push(`drop-shadow(${o})`):s.push(`${i.replaceAll("_","-")}(${o})`);s.length&&n.set("filter",s.join(" "))}_macro_transition(e,t,n){e!==void 0&&n.set("transition",String(e));for(let[s,i]of Object.entries(t))n.set(`transition-${s.replaceAll("_","-")}`,String(i))}_macro_zoom(e,t,n){e!==void 0&&n.set("zoom",String(e))}_macro_shadow(e,t,n){e!==void 0&&n.set("box-shadow",String(e));for(let[s,i]of Object.entries(t))n.set(`box-shadow-${s.replaceAll("_","-")}`,String(i))}_macro_gradient(e,t,n){e!==void 0&&n.set("background-image",String(e))}};var sm=new Set(["alignment_baseline","baseline_shift","clip_path","clip_rule","color_interpolation","color_interpolation_filters","dominant_baseline","fill_opacity","fill_rule","flood_color","flood_opacity","font_family","font_size","font_size_adjust","font_stretch","font_style","font_variant","font_weight","glyph_orientation_horizontal","glyph_orientation_vertical","image_rendering","letter_spacing","lighting_color","marker_end","marker_mid","marker_start","overline_position","overline_thickness","paint_order","pointer_events","shape_rendering","stop_color","stop_opacity","strikethrough_position","strikethrough_thickness","stroke_dasharray","stroke_dashoffset","stroke_linecap","stroke_linejoin","stroke_miterlimit","stroke_opacity","stroke_width","text_anchor","text_decoration","text_rendering","underline_position","underline_thickness","unicode_bidi","word_spacing","writing_mode"]);function Xs(r){return Object.fromEntries(Object.entries(r||{}).map(([e,t])=>[sm.has(e)?e.replaceAll("_","-"):e,t]))}var Xt=class extends Wt{static mode="svg";adaptAttrs(e){return Xs(e)}};var $u={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"html",version:null,title:null,description:null},abstracts:{},elements:{svg:{doc:"Switch to the SVG dialect from this node down (BLD.2).\n\n A sub-builder element: ``_meta['subbuilder']`` switches the active\n dialect to SVG from this node down. No ``render_tag``: ``<svg>`` is\n emitted verbatim (HTML5 has a native ``<svg>`` tag).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{subbuilder:"svg"}},a:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},abbr:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},address:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},area:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},article:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},aside:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},audio:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},b:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},base:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},bdi:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},bdo:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},blockquote:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},body:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},br:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},button:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},canvas:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},caption:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},cite:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},code:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},col:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},colgroup:{doc:null,sub_tags:"col,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},data:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},datalist:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,option,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dd:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},del_:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},details:{doc:null,sub_tags:"summary[0:1],a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dfn:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dialog:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},div:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dl:{doc:null,sub_tags:"dd,div,dt,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dt:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},em:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},embed:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},fieldset:{doc:null,sub_tags:"legend[0:1],a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},figcaption:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},figure:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figcaption[0:1],figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},footer:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},form:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h1:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h2:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h3:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h4:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h5:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},h6:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},head:{doc:null,sub_tags:"base[0:1],link,meta,noscript,script,style,template,title[0:1]",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},header:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},hgroup:{doc:null,sub_tags:"h1,h2,h3,h4,h5,h6,p,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},hr:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},html:{doc:null,sub_tags:"head[0:1],body[0:1]",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},i:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},iframe:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},img:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},input:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},ins:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},kbd:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},label:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},legend:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,h1,h2,h3,h4,h5,h6,hgroup,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},li:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},link:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},main:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},map:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},mark:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},menu:{doc:null,sub_tags:"li,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},meta:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},meter:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},nav:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},noscript:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},object:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},ol:{doc:null,sub_tags:"li,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},optgroup:{doc:null,sub_tags:"div,legend,noscript,option,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},option:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,div,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},output:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},p:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},picture:{doc:null,sub_tags:"img[0:1],script,source,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},pre:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},progress:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},q:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},rp:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},rt:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},ruby:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},s:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},samp:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},script:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},search:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},section:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},select:{doc:null,sub_tags:"button,div,hr,noscript,optgroup,option,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},slot:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},small:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},source:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},span:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},strong:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},style:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},sub:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},summary:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,h1,h2,h3,h4,h5,h6,hgroup,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},sup:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},table:{doc:null,sub_tags:"caption[0:1],colgroup,script,tbody,template,tfoot[0:1],thead[0:1],tr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},tbody:{doc:null,sub_tags:"script,template,tr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},td:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},template:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,caption,cite,code,col,colgroup,data,datalist,del_,details,dfn,dialog,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,legend,li,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,optgroup,option,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,source,span,strong,style,sub,summary,sup,table,tbody,td,template,textarea,tfoot,th,thead,time,tr,track,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},textarea:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},tfoot:{doc:null,sub_tags:"script,template,tr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},th:{doc:null,sub_tags:"a,abbr,address,area,article,aside,audio,b,bdi,bdo,blockquote,br,button,canvas,cite,code,data,datalist,del_,details,dfn,dialog,div,dl,em,embed,fieldset,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,iframe,img,input,ins,kbd,label,link,main,map,mark,menu,meta,meter,nav,noscript,object,ol,output,p,picture,pre,progress,q,ruby,s,samp,script,search,section,select,selectedcontent,slot,small,span,strong,style,sub,sup,table,template,textarea,time,u,ul,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},thead:{doc:null,sub_tags:"script,template,tr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},time:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},title:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},tr:{doc:null,sub_tags:"script,td,template,th",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},track:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},u:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},ul:{doc:null,sub_tags:"li,script,template",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},var:{doc:null,sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},video:{doc:null,sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},wbr:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{void:!0}},selectedcontent:{doc:"Mirror of the selected option for Customizable Select (HTML 2024).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dataSetter:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"value",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataFormula:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataController:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}}}};var Tt=class extends ye{static _name="html";static _defaultRenderMode="html";static retainedAttrPrefixes=["validate_","dtype"];static{this.defineGrammar($u)}get renderer_html(){return new Gt(this)}};ye.registerBuilder(Tt);var Lu={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"svg",version:null,title:null,description:null},abstracts:{graphics:{doc:"SVG graphics content: any graphical element.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},_meta:null},containerElement:{doc:"SVG container content: elements that can hold children.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},_meta:null}},elements:{html:{doc:"Switch to the HTML dialect from this node down (BLD.2).\n\n A sub-builder element: ``_meta['subbuilder']`` switches the active\n dialect to HTML from this node down. The source tag ``html`` is\n rendered as ``_meta['render_tag']`` (``<foreignObject>``) carrying\n ``_meta['render_attributes']`` (the SVG namespace). The immediate\n HTML child declares XHTML so both sides of the XML boundary retain\n their native namespace.\n ",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{subbuilder:"html",render_tag:"foreignObject",render_attributes:{xmlns:"http://www.w3.org/2000/svg"}}},svg:{doc:"Root SVG container or nested SVG viewport.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},g:{doc:"Group container for applying transforms and styles.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},defs:{doc:"Container for referenced elements (gradients, patterns, etc.).",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},symbol:{doc:"Reusable graphical template, rendered only when referenced by <use>.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},use:{doc:"Reference and render a <symbol> or other element.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},rect:{doc:"Rectangle.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},circle:{doc:"Circle.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},ellipse:{doc:"Ellipse.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},line:{doc:"Line segment between two points.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},polyline:{doc:"Open shape of connected line segments.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},polygon:{doc:"Closed shape of connected line segments.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},path:{doc:"Arbitrary shape defined by path commands (d attribute).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},image:{doc:"Embedded raster image.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},text:{doc:"Text block. Contains text content and optional <tspan>/<textPath>.",sub_tags:"tspan,textPath",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},tspan:{doc:"Inline text span within <text>.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},textPath:{doc:"Text rendered along a path shape.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},linearGradient:{doc:"Linear gradient definition. Place inside <defs>.",sub_tags:"stop",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},radialGradient:{doc:"Radial gradient definition. Place inside <defs>.",sub_tags:"stop",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},stop:{doc:"Gradient stop (color and offset).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},pattern:{doc:"Tile pattern definition. Place inside <defs>.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},clipPath:{doc:"Clipping path definition.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},mask:{doc:"Alpha mask definition.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},marker:{doc:"Marker symbol for line endpoints or vertices.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},filter:{doc:"Filter effect container. Place inside <defs>.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feGaussianBlur:{doc:"Gaussian blur filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feOffset:{doc:"Offset filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feBlend:{doc:"Blend filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feColorMatrix:{doc:"Color matrix filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feComposite:{doc:"Composite filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feFlood:{doc:"Flood fill filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feMerge:{doc:"Merge filter primitive (container for feMergeNode).",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feMergeNode:{doc:"Single input for feMerge.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feDropShadow:{doc:"Drop shadow filter primitive (SVG 2).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feDiffuseLighting:{doc:"Diffuse lighting filter primitive.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feSpecularLighting:{doc:"Specular lighting filter primitive.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},fePointLight:{doc:"Point light source for lighting filters.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feDistantLight:{doc:"Distant light source for lighting filters.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feSpotLight:{doc:"Spot light source for lighting filters.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feMorphology:{doc:"Morphology filter primitive (erode/dilate).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feTurbulence:{doc:"Turbulence noise filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feDisplacementMap:{doc:"Displacement map filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feConvolveMatrix:{doc:"Convolution matrix filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feImage:{doc:"Image filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},feTile:{doc:"Tile filter primitive.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},animate:{doc:"Animate an attribute over time.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},animateTransform:{doc:"Animate a transform attribute.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},animateMotion:{doc:"Animate motion along a path.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},set:{doc:"Set an attribute to a value for a duration.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},title:{doc:"Accessible title (tooltip in browsers).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},desc:{doc:"Accessible description.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},metadata:{doc:"Metadata container (RDF, Dublin Core, etc.).",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},a:{doc:"Hyperlink wrapper.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},foreignObject:{doc:"Container for non-SVG content (HTML, MathML).",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},switch:{doc:"Conditional processing (renders first matching child).",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null},dataSetter:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"value",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataFormula:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataController:{doc:null,sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"collections.abc",name:"Callable"}]},has_default:!1},{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}}}};var xt=class extends ye{static _name="svg";static _defaultRenderMode="svg";static{this.defineGrammar(Lu)}get renderer_svg(){return new Xt(this)}};ye.registerBuilder(xt);var Yt=class r{#e;constructor(e,t=0){this.pattern=e,this.flags=t,this.#e=Br.fromJSON({nameSyntax:{kind:"annotated",base:{kind:"type",module:"builtins",name:"str"},metadata:[this.toJSON()]}}).resolve("nameSyntax").test,Object.freeze(this)}static fromJSON(e){if((e!==null&&typeof e=="object"?Object.keys(e).sort():[]).join()!=="flags,kind,pattern"||e.kind!=="regex")throw new TypeError(`A name syntax is {kind: 'regex', pattern, flags}, not ${JSON.stringify(e)}`);return new r(e.pattern,e.flags)}toJSON(){return{kind:"regex",pattern:this.pattern,flags:this.flags}}matches(e){return this.#e(e)}},Nn=new Yt(String.raw`[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*`);var Se=class{constructor(e){this.gramlot=e}};var am=/^[a-z][.0-9_a-z\-\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]*$/u,lm=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]);function at(r){let e=r.code;if(typeof e!="string"||am.exec(e)?.[0]!==e||!e.includes("-")||lm.has(e))throw new TypeError("webcomponent: code must be a literal custom-element name");return e}function Lo(r){for(let e of Object.values(r))e&&typeof e=="object"&&Lo(e);return Object.freeze(r)}function Pu(r){if(typeof r.dtype!="string"&&!Array.isArray(r.dtype))throw new TypeError("Component parameter requires dtype");let e=(Array.isArray(r.dtype)?r.dtype:[r.dtype]).map(t=>({kind:"dtype",dtype:t}));return r.nullable&&e.push({kind:"dtype",dtype:"NN"}),r.binding&&r.dtype!=="T"&&e.push({kind:"annotated",base:{kind:"dtype",dtype:"T"},metadata:[{kind:"regex",pattern:"^[\\^=].+",flags:0}]}),e.length===1?e[0]:{kind:"union",items:e}}function Rr({name:r,tag:e,base:t,mixins:n=[],parameters:s={},subTags:i="",presentationDefaults:o=[],dataScope:a=!1,command:l=!1,childParameters:u={},sourceContext:c=!1,bagStore:d=!1,dragSource:f=!1,implementation:h}){if(at({code:e}),!/^[a-zA-Z][a-zA-Z0-9]*$/.test(r))throw new TypeError("Invalid component authoring name");let p={...t.parameters};for(let m of n)for(let[g,b]of Object.entries(m.parameters)){if(Object.hasOwn(p,g))throw new Error(`Duplicate mixin parameter: ${g}`);p[g]=b}Object.assign(p,s);for(let m of Object.values(p))Pu(m);return Object.freeze({name:r,tag:e,base:t,subTags:i,presentationDefaults:Object.freeze([...o]),dataScope:a,command:l,bagStore:d,mixins:Object.freeze([...n]),parameters:Lo(structuredClone(p)),childParameters:Lo(structuredClone(u)),sourceContext:c,dragSource:f,implementation:h})}var Zt=class{#e=new WeakMap;constructor({name:e,components:t}){this.name=e,this.components=Object.freeze([...t]);let n=new Set,s=new Set;for(let i of t){if(n.has(i.name.toLowerCase())||s.has(i.tag))throw new Error(`Duplicate component: ${i.name}`);n.add(i.name.toLowerCase()),s.add(i.tag)}}toDocument(){return{document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:this.name,version:null,title:this.name,description:null},abstracts:{},elements:Object.fromEntries(this.components.map(e=>[e.name,{doc:null,sub_tags:e.subTags,parent_tags:null,inherits_from:null,ns:null,node_label:null,collection_key:null,attributes:{parameters:[...Object.entries(e.parameters).map(([t,n])=>({name:t,kind:"keyword_only",role:"attribute",annotation:Pu(n),has_default:!0,default:n.default??null})),{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},_meta:{render_tag:e.tag,gramlot_component:{parameters:structuredClone(e.parameters),presentationDefaults:[...e.presentationDefaults],dataScope:e.dataScope,command:e.command,...Object.keys(e.childParameters).length?{childParameters:structuredClone(e.childParameters)}:{},...e.sourceContext?{sourceContext:!0}:{},...e.dragSource?{dragSource:!0}:{},...e.bagStore?{bagStore:!0}:{}}}}]))}}register(e){if(this.#e.has(e))return;let t=[];for(let n of this.components){if(e.customElements.get(n.tag))throw new Error(`Custom element already registered: ${n.tag}`);let s=n.base(e.HTMLElement);for(let o of n.mixins)s=o(s);let i=n.implementation(s);Object.defineProperty(i,"gramlotComponent",{value:n}),t.push([n.tag,i])}for(let[n,s]of t)e.customElements.define(n,s);this.#e.set(e,t)}};function Fu(r){return new Zt(r)}function Ys(r,e){return r.parameters=Object.fromEntries(Object.entries(r.constructor.gramlotComponent.parameters).map(([t,n])=>[t,Object.hasOwn(e,t)?e[t]:n.default])),Object.fromEntries(Object.entries(e).filter(([t])=>!Object.hasOwn(r.parameters,t)))}function ju(r,e=","){if(typeof e!="string"||!e)throw new TypeError("separator must be a nonempty string");if(r==="")return[];let t=new Set;return r.split(e).map(n=>{let s=n.indexOf(":"),i=s<0?n:n.slice(0,s),o=s<0?n:n.slice(s+1);if(!i||t.has(i))throw new Error("Invalid or duplicate choice code");return t.add(i),{id:i,caption:o}})}function Zs(r){return class extends r{constructor(){super();let e=this.attachShadow({mode:"open"}),t=this.ownerDocument.createElement("style");t.textContent=`:host{display:inline-block;font:inherit} *,*::before,*::after{box-sizing:border-box}
25
25
  input,textarea{font:inherit;max-width:100%} .control-box{min-width:0;color:var(--gramlot-ink,CanvasText)}
26
26
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),textarea{
27
27
  appearance:none;box-sizing:border-box;border:1px solid var(--gramlot-border-control,#7a8798);
@@ -36,13 +36,16 @@ ${" ".repeat(s)}</${a}>`:`<${a}${l}>${f}</${a}>`:t===null||t.includes(a)?`<${a}
36
36
  input[type=range],input[type=color],button{min-width:var(--gramlot-touch-target,0px);min-height:var(--gramlot-touch-target,0px)}
37
37
  input[type=checkbox],input[type=radio]{min-width:calc(var(--gramlot-touch-target,0px) / 2);min-height:calc(var(--gramlot-touch-target,0px) / 2)}
38
38
  .options{display:grid;gap:.3em .8em} .option{display:flex;align-items:center;gap:.35em;min-width:var(--gramlot-touch-target,0px);min-height:var(--gramlot-touch-target,0px)}
39
- .caption:empty{display:none}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",e.append(t,this.controlBox)}projectAttributes(e){return Vs(this,e)}setPageContext(e){this.pageContext=e}releaseControl(){}validateCandidate(e,t){return t(e),{ok:!0,value:e,isCurrent:()=>this.pageContext.isActive()}}finishValidation(){}validateSelection(){throw new TypeError("validate_select requires a constrained choice editor.")}shouldProjectControlValue(){return!0}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,t=>{if(t==null&&!this.constructor.gramlotComponent.parameters.value.nullable)throw new TypeError("This component requires a non-null value.");if(t!=null&&e!=null&&typeof t!=typeof e)throw new TypeError("Validation must preserve the component value type.");this.sameControlValue(e,t)||this.writeControlValue(t)})}sameControlValue(e,t){return Object.is(e,t)}focus(e){this.control.focus(e)}}}function Kp(r){return class extends zs(r){constructor(){super(),this.control=this.createControl(),(this.control.localName==="textarea"||this.control.localName==="input"&&["text","password"].includes(this.control.type))&&(this.control.setAttribute("autocomplete","off"),this.control.setAttribute("autocorrect","off"),this.control.setAttribute("autocapitalize","off"),this.control.setAttribute("spellcheck","false")),this.control.id="control";let e=this.ownerDocument.createElement("label");e.className="option",this.optionCaption=this.ownerDocument.createElement("span"),this.optionCaption.className="caption",e.append(this.control,this.optionCaption),this.controlBox.append(e)}projectAttributes(e,t){let n=super.projectAttributes(e,t),{disabled:s,readonly:i}=this.parameters;this.control.disabled=!!s,this.control.readOnly=!!i;for(let[a,o]of Object.entries(this.constructor.gramlotComponent.parameters)){if(o.target==="control"){let l=this.parameters[a]??"";String(this.control[a])!==String(l)&&(this.control[a]=l)}o.target==="optionCaption"&&(this.optionCaption.textContent=this.parameters[a]??"")}return n}}}Kp.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!1,binding:"read"}};function Qp(r){return class extends zs(r){#e=new Map;#t;#r=null;constructor(){super(),this.control=this.ownerDocument.createElement("div"),this.control.className="options",this.control.id="control",this.control.setAttribute("role",this.multiple?"group":"radiogroup"),this.controlBox.append(this.control),this.control.addEventListener("keydown",e=>{if(!this.multiple||!["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Home","End"].includes(e.key))return;let t=[...this.control.querySelectorAll("input:not(:disabled)")],n=t.indexOf(e.target);if(n<0)return;e.preventDefault();let s=e.key==="Home"?0:e.key==="End"?t.length-1:Math.max(0,Math.min(t.length-1,n+(["ArrowDown","ArrowRight"].includes(e.key)?1:-1)));t[s].focus()})}projectAttributes(e,t){let n=super.projectAttributes(e,t),s=this.parameters.values??"";if(s!==this.#t){let a=Nu(s),o=new Set,l=null;for(let{id:u,caption:c}of a){let d=this.#e.get(u);if(!d){let h=this.ownerDocument.createElement("label");h.className="option";let p=this.ownerDocument.createElement("input");p.type=this.choiceType,p.name="choice",p.value=u;let m=this.ownerDocument.createElement("span");h.append(p,m),d={label:h,input:p,text:m},this.#e.set(u,d)}d.text.textContent=c;let f=l?l.nextSibling:this.control.firstChild;f!==d.label&&this.control.insertBefore(d.label,f),l=d.label,o.add(u)}for(let[u,c]of this.#e)o.has(u)||(c.label.remove(),this.#e.delete(u));this.#t=s}let i=this.parameters.cols;if(!Number.isInteger(i)||i<1)throw new TypeError("cols must be a positive integer");this.control.style.gridTemplateColumns=`repeat(${i}, minmax(0, 1fr))`,this.control.disabled=!!this.parameters.disabled,this.control.readOnly=!!this.parameters.readonly;for(let{input:a}of this.#e.values())a.disabled=this.control.disabled||this.control.readOnly;return n}readControlValue(){if(this.multiple){let t=(this.#r?this.#r.split(","):[]).filter(n=>!this.#e.has(n)||this.#e.get(n).input.checked);for(let[n,{input:s}]of this.#e)s.checked&&!t.includes(n)&&t.push(n);return t.join(",")||null}for(let[e,{input:t}]of this.#e)if(t.checked)return e;return null}writeControlValue(e){this.#r=e;let t=this.multiple?new Set(e?e.split(","):[]):null;for(let[n,{input:s}]of this.#e)s.checked=this.multiple?t.has(n):n===e}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,t=>this.writeControlValue(t))}focus(e){let t=[...this.#e.values()];(t.find(({input:n})=>n.checked&&!n.disabled)??t.find(({input:n})=>!n.disabled))?.input.focus(e)}}}Qp.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"}};function Ou(r,e,{align:t="start",matchWidth:n=!1,inset:s=0}={}){let i=e.ownerDocument.defaultView,a=e.getBoundingClientRect(),o=Math.max(0,i.innerWidth-16);r.style.setProperty("--gramlot-popup-available-width",`${o}px`),n&&(r.style.width=`${Math.min(Math.max(0,a.width-2*s),o)}px`),r.style.removeProperty("--gramlot-popup-available-height");let l=r.getBoundingClientRect(),u=Math.max(0,i.innerHeight-8-a.bottom-3),c=Math.max(0,a.top-8-3),d=l.height>u&&c>u;r.style.setProperty("--gramlot-popup-available-height",`${d?c:u}px`);let f=r.getBoundingClientRect(),h=t==="end"?a.right-f.width-s:a.left+s,p=d?a.top-f.height-3:a.bottom+3;r.style.left=`${Math.max(8,Math.min(h,i.innerWidth-f.width-8))}px`,r.style.top=`${Math.max(8,Math.min(p,i.innerHeight-f.height-8))}px`}function Sn(r){return class extends zs(r){constructor(){super();let e=this.ownerDocument;this.control=e.createElement("button"),this.control.type="button",this.control.id="control",this.icon=e.createElement("span"),this.icon.className="icon",this.icon.setAttribute("aria-hidden","true"),this.caption=e.createElement("slot"),this.control.append(this.icon,this.caption),this.controlBox.append(this.control);let t=e.createElement("style");t.textContent=`:host{vertical-align:middle} .control-box{display:flex;align-items:stretch}
39
+ .caption:empty{display:none}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",e.append(t,this.controlBox)}projectAttributes(e){return Ys(this,e)}setPageContext(e){this.pageContext=e}releaseControl(){}get liveWrites(){return this.control.localName==="textarea"||["text","password","range","color"].includes(this.control.type)}validateCandidate(e,t){return t(e),{ok:!0,value:e,isCurrent:()=>this.pageContext.isActive()}}finishValidation(){}validateSelection(){throw new TypeError("validate_select requires a constrained choice editor.")}shouldProjectControlValue(){return!0}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,t=>{if(t==null&&!this.constructor.gramlotComponent.parameters.value.nullable)throw new TypeError("This component requires a non-null value.");if(t!=null&&e!=null&&typeof t!=typeof e)throw new TypeError("Validation must preserve the component value type.");this.sameControlValue(e,t)||this.writeControlValue(t)})}sameControlValue(e,t){return Object.is(e,t)}focus(e){this.control.focus(e)}}}function um(r){return class extends Zs(r){constructor(){super(),this.control=this.createControl(),(this.control.localName==="textarea"||this.control.localName==="input"&&["text","password"].includes(this.control.type))&&(this.control.setAttribute("autocomplete","off"),this.control.setAttribute("autocorrect","off"),this.control.setAttribute("autocapitalize","off"),this.control.setAttribute("spellcheck","false")),this.control.id="control";let e=this.ownerDocument.createElement("label");e.className="option",this.optionCaption=this.ownerDocument.createElement("span"),this.optionCaption.className="caption",e.append(this.control,this.optionCaption),this.controlBox.append(e)}projectAttributes(e,t){let n=super.projectAttributes(e,t),{disabled:s,readonly:i}=this.parameters;this.control.disabled=!!s,this.control.readOnly=!!i;for(let[o,a]of Object.entries(this.constructor.gramlotComponent.parameters)){if(a.target==="control"){let l=this.parameters[o]??"";String(this.control[o])!==String(l)&&(this.control[o]=l)}a.target==="optionCaption"&&(this.optionCaption.textContent=this.parameters[o]??"")}return n}}}um.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"},live:{dtype:"B",default:!1,binding:"read"}};function cm(r){return class extends Zs(r){#e=new Map;#t;#r=null;constructor(){super(),this.control=this.ownerDocument.createElement("div"),this.control.className="options",this.control.id="control",this.control.setAttribute("role",this.multiple?"group":"radiogroup"),this.controlBox.append(this.control),this.control.addEventListener("keydown",e=>{if(!this.multiple||!["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Home","End"].includes(e.key))return;let t=[...this.control.querySelectorAll("input:not(:disabled)")],n=t.indexOf(e.target);if(n<0)return;e.preventDefault();let s=e.key==="Home"?0:e.key==="End"?t.length-1:Math.max(0,Math.min(t.length-1,n+(["ArrowDown","ArrowRight"].includes(e.key)?1:-1)));t[s].focus()})}projectAttributes(e,t){let n=super.projectAttributes(e,t),s=this.parameters.values??"";if(s!==this.#t){let o=ju(s),a=new Set,l=null;for(let{id:u,caption:c}of o){let d=this.#e.get(u);if(!d){let h=this.ownerDocument.createElement("label");h.className="option";let p=this.ownerDocument.createElement("input");p.type=this.choiceType,p.name="choice",p.value=u;let m=this.ownerDocument.createElement("span");h.append(p,m),d={label:h,input:p,text:m},this.#e.set(u,d)}d.text.textContent=c;let f=l?l.nextSibling:this.control.firstChild;f!==d.label&&this.control.insertBefore(d.label,f),l=d.label,a.add(u)}for(let[u,c]of this.#e)a.has(u)||(c.label.remove(),this.#e.delete(u));this.#t=s}let i=this.parameters.cols;if(!Number.isInteger(i)||i<1)throw new TypeError("cols must be a positive integer");this.control.style.gridTemplateColumns=`repeat(${i}, minmax(0, 1fr))`,this.control.disabled=!!this.parameters.disabled,this.control.readOnly=!!this.parameters.readonly;for(let{input:o}of this.#e.values())o.disabled=this.control.disabled||this.control.readOnly;return n}readControlValue(){if(this.multiple){let t=(this.#r?this.#r.split(","):[]).filter(n=>!this.#e.has(n)||this.#e.get(n).input.checked);for(let[n,{input:s}]of this.#e)s.checked&&!t.includes(n)&&t.push(n);return t.join(",")||null}for(let[e,{input:t}]of this.#e)if(t.checked)return e;return null}writeControlValue(e){this.#r=e;let t=this.multiple?new Set(e?e.split(","):[]):null;for(let[n,{input:s}]of this.#e)s.checked=this.multiple?t.has(n):n===e}acceptControlValue(){let e=this.readControlValue();return this.validateCandidate(e,t=>this.writeControlValue(t))}focus(e){let t=[...this.#e.values()];(t.find(({input:n})=>n.checked&&!n.disabled)??t.find(({input:n})=>!n.disabled))?.input.focus(e)}}}cm.parameters={disabled:{dtype:"B",default:!1,binding:"read"},readonly:{dtype:"B",default:!1,binding:"read"}};function Uu(r,e,{align:t="start",matchWidth:n=!1,inset:s=0}={}){let i=e.ownerDocument.defaultView,o=e.getBoundingClientRect(),a=Math.max(0,i.innerWidth-16);r.style.setProperty("--gramlot-popup-available-width",`${a}px`),n&&(r.style.width=`${Math.min(Math.max(0,o.width-2*s),a)}px`),r.style.removeProperty("--gramlot-popup-available-height");let l=r.getBoundingClientRect(),u=Math.max(0,i.innerHeight-8-o.bottom-3),c=Math.max(0,o.top-8-3),d=l.height>u&&c>u;r.style.setProperty("--gramlot-popup-available-height",`${d?c:u}px`);let f=r.getBoundingClientRect(),h=t==="end"?o.right-f.width-s:o.left+s,p=d?o.top-f.height-3:o.bottom+3;r.style.left=`${Math.max(8,Math.min(h,i.innerWidth-f.width-8))}px`,r.style.top=`${Math.max(8,Math.min(p,i.innerHeight-f.height-8))}px`}function In(r){return class extends Zs(r){constructor(){super();let e=this.ownerDocument;this.control=e.createElement("button"),this.control.type="button",this.control.id="control",this.icon=e.createElement("span"),this.icon.className="icon",this.icon.setAttribute("aria-hidden","true"),this.caption=e.createElement("slot"),this.control.append(this.icon,this.caption),this.controlBox.append(this.control);let t=e.createElement("style");t.textContent=`:host{vertical-align:middle} .control-box{display:flex;align-items:stretch}
40
40
  button{display:inline-flex;align-items:center;justify-content:center;gap:var(--gramlot-button-gap,.35em);font:inherit;
41
41
  color:var(--gramlot-ink,CanvasText);background:var(--gramlot-button-background,var(--gramlot-field-background,Canvas));
42
42
  border:1px solid var(--gramlot-border-control,#888);border-radius:var(--gramlot-radius-sm,4px);
43
43
  min-height:max(var(--gramlot-field-height,28px),var(--gramlot-touch-target,0px));
44
44
  padding:var(--gramlot-button-padding,.25em .65em);cursor:pointer}
45
45
  button:hover:not(:disabled){background:var(--gramlot-button-hover,var(--gramlot-field-readonly-background,#eee))}
46
+ :host(.button--quiet) button{background:transparent;color:var(--gramlot-action,CanvasText);border-color:transparent}
47
+ :host(.button--quiet) button:hover:not(:disabled){background:var(--gramlot-selected,Highlight);color:var(--gramlot-action-hover,CanvasText);border-color:transparent}
48
+ button:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:2px}
46
49
  button:disabled{opacity:.55;cursor:not-allowed} .icon:empty{display:none}
47
50
  .led{display:inline-block;width:.6em;height:.6em;border-radius:50%;background:var(--gramlot-button-led-off,#888)}
48
51
  [aria-pressed=true] .led{background:var(--gramlot-button-led-on,#2b9a46)}
@@ -54,16 +57,16 @@ ${" ".repeat(s)}</${a}>`:`<${a}${l}>${f}</${a}>`:t===null||t.includes(a)?`<${a}
54
57
  color:var(--gramlot-ink,CanvasText);background:var(--gramlot-field-background,Canvas);box-shadow:0 3px 12px #0003}
55
58
  :host([role=menuitem]){display:block} :host([role=menuitem]) button{width:100%;justify-content:start;border:0;background:transparent}
56
59
  :host([role=separator]){display:block;border-top:1px solid var(--gramlot-border-control,#888);margin:.25em}
57
- :host([role=separator]) button{display:none}`,this.shadowRoot.append(t)}get disabled(){return this.control.disabled}set disabled(e){this.control.disabled=!!e}projectAttributes(e,t){let n=super.projectAttributes(e,t);return this.control.disabled=!!this.parameters.disabled,this.control.readOnly=!!this.parameters.readonly,this.icon.textContent=this.parameters.icon??"",e["aria-label"]!=null?this.control.setAttribute("aria-label",e["aria-label"]):this.control.removeAttribute("aria-label"),n}attachCommand(){}releaseCommand(){}commandTarget(){return this}prepareCommand(){return!this.disabled}}}Sn.parameters={disabled:{dtype:"B",default:!1,binding:"read"},icon:{dtype:"T",default:"",binding:"read"}};var em=Or({name:"button",tag:"gramlot-button",base:Sn,command:!0,subTags:"*",implementation:r=>class extends r{}}),tm=Or({name:"toggleButton",tag:"gramlot-toggle-button",base:Sn,command:!0,subTags:"*",parameters:{value:{dtype:"B",default:!1,binding:"twoWay"},readonly:{dtype:"B",default:!1,binding:"read"}},implementation:r=>class extends r{#e=!1;constructor(){super();let e=this.ownerDocument.createElement("span");e.className="led",e.setAttribute("aria-hidden","true"),this.control.prepend(e),this.writeControlValue(!1)}get commitOnChange(){return!0}readControlValue(){return this.#e}writeControlValue(e){this.#e=e,this.control.setAttribute("aria-pressed",String(e))}prepareCommand(e){return!super.prepareCommand(e)||this.control.readOnly?!1:(this.writeControlValue(!this.#e),this.control.dispatchEvent(new this.ownerDocument.defaultView.Event("change")),!0)}}});function rm(r){return class extends r{constructor(){super(),this.attachShadow({mode:"open"}).append(this.ownerDocument.createElement("slot"))}connectedCallback(){this.slot="menu",this.setAttribute("role","menu")}projectAttributes(e){return Vs(this,e)}}}var nm=Or({name:"menu",tag:"gramlot-menu",base:rm,subTags:"menuline",implementation:r=>class extends r{}}),sm=Or({name:"menuline",tag:"gramlot-menu-line",base:Sn,command:!0,subTags:"*",parameters:{code:{dtype:"T",nullable:!0}},implementation:r=>class extends r{attachCommand(){let e=this.textContent.trim()==="-";if(!e&&!this.parameters.code)throw new TypeError("menuline requires a stable code");this.setAttribute("role",e?"separator":"menuitem"),this.control.tabIndex=-1,this.disabled||=e}get disabled(){return super.disabled||!!this.closest("gramlot-drop-down-button")?.parameters.disabled}set disabled(e){super.disabled=e}prepareCommand(e){return super.prepareCommand(e)?(this.closest("gramlot-drop-down-button").selectCommand(this,e.shiftKey),!0):!1}}}),im=Or({name:"dropDownButton",tag:"gramlot-drop-down-button",base:Sn,command:!0,subTags:"*",parameters:{persist:{dtype:"B",default:!1}},implementation:r=>class extends r{#e=null;#t=null;#r=null;#s=null;#n;#i;#a;constructor(){super();let e=this.ownerDocument;this.control.classList.add("split"),this.#a=e.createElement("span"),this.#a.hidden=!0,this.control.append(this.#a),this.#i=e.createElement("button"),this.#i.type="button",this.#i.className="arrow",this.#i.textContent="\u25BE",this.#i.setAttribute("aria-label","Open menu"),this.#i.setAttribute("aria-haspopup","menu"),this.#i.setAttribute("aria-expanded","false"),this.controlBox.append(this.#i),this.#n=e.createElement("div"),this.#n.className="popup",this.#n.id="menu",this.#n.setAttribute("popover","auto"),this.#i.setAttribute("aria-controls","menu");let t=e.createElement("slot");t.name="menu",this.#n.append(t),this.shadowRoot.append(this.#n),this.#i.addEventListener("click",n=>{n.stopPropagation(),this.#n.matches(":popover-open")?this.closeMenu():this.openMenu()}),this.#i.addEventListener("keydown",n=>{(n.key==="ArrowDown"||n.key==="ArrowUp")&&(n.preventDefault(),this.openMenu(n.key==="ArrowUp"))}),this.addEventListener("keydown",n=>{if(!this.#n.matches(":popover-open"))return;let s=this.menuItems.filter(o=>!o.disabled),i=s.indexOf(n.composedPath().find(o=>s.includes(o))),a;n.key==="ArrowDown"&&(a=(i+1)%s.length),n.key==="ArrowUp"&&(a=(i-1+s.length)%s.length),n.key==="Home"&&(a=0),n.key==="End"&&(a=s.length-1),a!==void 0&&(n.preventDefault(),s[a]?.focus()),(n.key==="Escape"||n.key==="Tab")&&(n.key==="Escape"&&n.preventDefault(),this.closeMenu())}),this.#n.addEventListener("toggle",()=>{let n=this.#n.matches(":popover-open");this.#i.setAttribute("aria-expanded",String(n)),n||(this.#r?.abort(),this.#r=null)})}get menuItems(){return[...this.querySelectorAll(":scope > gramlot-menu > gramlot-menu-line")]}projectAttributes(e,t){let n=super.projectAttributes(e,t);return this.#i.disabled=this.disabled,this.disabled&&this.#n.matches(":popover-open")&&this.closeMenu(),this.#o(),n}attachCommand(){if(this.parameters.persist){if(!this.id)throw new TypeError("dropDownButton persist requires an explicit id");this.#s=`gramlot:command:${this.ownerDocument.location.pathname}${this.ownerDocument.location.search}:${this.id}`;try{this.#e=this.ownerDocument.defaultView.localStorage.getItem(this.#s)}catch{}}this.#o(),this.#t=new this.ownerDocument.defaultView.MutationObserver(()=>this.#o()),this.#t.observe(this,{childList:!0,subtree:!0,characterData:!0})}releaseCommand(){this.#t?.disconnect(),this.#t=null,this.#r?.abort(),this.#r=null,this.#n.matches(":popover-open")&&this.#n.hidePopover()}commandTarget(e){return e?.composedPath().includes(this.#n)?null:this.menuItems.find(t=>t.parameters.code===this.#e)??this}selectCommand(e,t){if(t){if(this.#e=e.parameters.code,this.#s)try{this.ownerDocument.defaultView.localStorage.setItem(this.#s,this.#e)}catch{}this.#o()}this.closeMenu()}#o(){let e=this.menuItems.filter(s=>s.parameters.code).map(s=>s.parameters.code);if(new Set(e).size!==e.length)throw new TypeError("Dropdown menu codes must be unique");let t=this.commandTarget(),n=t!==this;this.caption.hidden=n,this.#a.hidden=!n,this.#a.textContent=n?t.textContent:"",this.icon.textContent=n?t.parameters.icon:this.parameters.icon}openMenu(e=!1){if(this.disabled)return;let t=this.menuItems.filter(i=>!i.disabled);if(!t.length)return;this.#n.showPopover(),this.#i.setAttribute("aria-expanded","true");let n=()=>Ou(this.#n,this.controlBox);n(),this.#r?.abort(),this.#r=new this.ownerDocument.defaultView.AbortController;let s={signal:this.#r.signal,capture:!0};this.ownerDocument.defaultView.addEventListener("resize",n,s),this.ownerDocument.addEventListener("scroll",n,s),t[e?t.length-1:0].focus()}closeMenu(){this.#n.matches(":popover-open")&&(this.#n.hidePopover(),this.#i.setAttribute("aria-expanded","false"),this.#r?.abort(),this.#r=null,this.#i.focus())}}}),Hs=Cu({name:"buttons",components:[em,tm,im,nm,sm]});function Iu(r){if(r!=null&&(typeof r!="string"||/[{}]/.test(r.replaceAll("{}",""))))throw new RangeError("This formatter mask supports only {} placeholders")}function Gs(r,e){return Iu(e),e==null?r:e.replaceAll("{}",()=>r)}function am(r){if(r instanceof Date)return wt(r);if(fe(r))return"N";if(typeof r=="number")return Number.isInteger(r)?"L":"R";throw new TypeError("Formatting requires finite JavaScript numbers, TYTX Decimal values or valid Date objects")}function om(r,e,{pattern:t="short",locale:n,timeZone:s}){if(!["short","medium","long","full"].includes(t))throw new RangeError("Temporal formatting currently supports short, medium, long and full only");if(e==="DHZ"&&(typeof s!="string"||!s))throw new TypeError("DHZ formatting currently requires an explicit timeZone");let i={timeZone:e==="DHZ"?s:"UTC"};return e!=="H"&&(i.dateStyle=t),e!=="D"&&(i.timeStyle=t),new Intl.DateTimeFormat(n,i).format(r)}function Ws(r){let e=/^(-|\()?(#,##0|0+)(?:\.(0*#*))?(\))?$/.exec(r);if(!e||e[1]==="("!=(e[4]===")")||r.endsWith("."))throw new RangeError(`Unsupported numeric pattern section: ${r}`);let t=e[3]??"";return{prefix:e[1]??"",suffix:e[4]??"",intl:{useGrouping:e[2].startsWith("#,##")?"always":!1,minimumIntegerDigits:e[2].replace("#,##","").length,minimumFractionDigits:t.replaceAll("#","").length,maximumFractionDigits:t.length}}}function lm(r){let e=r.split(";");if(e.length>3)throw new RangeError("Numeric patterns support at most three sections");let t=Ws(e[0]);if(t.prefix||t.suffix)throw new RangeError("Positive-section affixes are not implemented");let n=e.length===3?e[1]:null;n!==null&&n!==""&&n!=="-"&&Ws(n);let s=e.length>1?Ws(e.at(-1)):null;return{positive:t,zero:n,negative:s}}function Bu(r,e={},t={}){if(r===null)return"";if(typeof e=="string"&&(e={pattern:e}),!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Format options must be a pattern string or an options object");for(let g of Object.keys(e))if(!["pattern","locale","mask","dtype","timeZone"].includes(g))throw new RangeError(`Unsupported format option: ${g}`);e={...e,locale:e.locale??t.locale,timeZone:e.timeZone??t.timeZone};let n=e.dtype===void 0?am(r):e.dtype,s=["D","H","DHZ"].includes(n);if(!s&&!["L","R","N"].includes(n))throw new RangeError(`Unsupported format dtype: ${n}`);if(s){if(!(r instanceof Date)||!Number.isFinite(r.getTime()))throw new TypeError(`${n} requires a valid Date object`)}else if(!(typeof r=="number"&&Number.isFinite(r))&&!(fe(r)&&!["NaN","Infinity","-Infinity"].includes(r.toString())))throw new TypeError(`${n} formatting requires finite JavaScript numbers or TYTX Decimal values`);if(n==="L"&&!Number.isInteger(r))throw new TypeError("L formatting requires an integer");let{pattern:i,locale:a,mask:o}=e;if(!s&&typeof i!="string")throw new TypeError("Numeric formatting currently requires an explicit pattern");if(typeof a!="string"||!a)throw new TypeError("Formatting currently requires an explicit locale");if(!(s?Intl.DateTimeFormat:Intl.NumberFormat).supportedLocalesOf([a]).length)throw new RangeError(`Unsupported format locale: ${a}`);if(Iu(o),s){let g=om(r,n,e);return Gs(g,o)}let{positive:u,zero:c,negative:d}=lm(i),f=fe(r),h=f?r.eq(0):r===0,p=f?r.lt(0):r<0;if(f&&new Intl.NumberFormat("en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal without precision loss");let m;if(h&&c!==null){if(c==="")return"";if(c==="-")m="-";else{let g=Ws(c);m=g.prefix+new Intl.NumberFormat(a,g.intl).format(0)+g.suffix}}else{let g=p&&d?d:u,_=f?(p&&d?r.abs():r).toString():p&&d?-r:r===0?0:r;m=g.prefix+new Intl.NumberFormat(a,u.intl).format(_)+g.suffix}return Gs(m,o)}var je="http://www.w3.org/1999/xhtml",Cn="http://www.w3.org/2000/svg",um=new Set(["default","default_value","live","group","visible","action","fire","ask","_ask","_ask_if","_ask_title","_ask_onCancel","if","else","_init","_onStart","_onBuilt","_delay","_timing","_userChanges","remote","_cachedRemote","_onRemote","_onCalling","onClose","onDrag","onDrop","dropTargetCb","onDragEnd","dropTarget","dropTypes","dragTags","dropTags","effectAllowed","dropEffect","dragClass"]),cm=["default_","attr_","fire_","connect_on","subscribe_","selfsubscribe_","formsubscribe_","remote_"],dm={table:["width","border"],editor:["height"],embed:["width","height"],img:["width","height"],canvas:["width","height"]},fm=["format","mask","locale","timeZone","places","dtype"],hm=new Set(["href","src","formaction","xlink:href","xlink_href"]);function Tt(r){return Object.fromEntries(Object.entries(r).filter(([e,t])=>!(t&&typeof t=="object"&&Object.hasOwn(t,"$gramlotRef"))&&!um.has(e)&&!cm.some(n=>e.startsWith(n))))}function Br(r,e,t=[]){for(let[n,s]of Object.entries(e)){let i=t.find(o=>n.startsWith(o))??"",a=n.slice(i.length);if(["style","class","_class"].includes(a)&&s!=null&&typeof s!="string")throw new TypeError(`${r.nodeTag} '${r.label}': '${n}' must be a string or null`)}}function Rr(r,e,t=[]){if(e.onClose!=null&&!r.parentNode?._getMeta("gramlot_component")?.childParameters?.onClose)throw new Error("onClose is only supported on a tab/stack panel");for(let[n,s]of Object.entries(Mr(Tt(e)))){let i=t.find(o=>n.startsWith(o)),a=i?n.slice(i.length):n;if(/^on./i.test(a))throw new Error(`${r.nodeTag} '${r.label}': '${n}' has the form of a native event handler, run by the browser outside Gramlot; write connect_${a} for an event, or rename the attribute`);if(hm.has(a.toLowerCase())&&pm(s))throw new Error(`${r.nodeTag} '${r.label}': '${n}' holds a javascript: URL, run by the browser as code; write connect_onclick or the action of a button instead`)}}function pm(r){return typeof r=="string"&&/^javascript:/i.test(r.replace(/[\t\n\r]/g,"").replace(/^[\u0000-\u0020]+/,""))}function Ru(r,e,t=[]){if(r.nodeTag!=="iframe")return e;let n=o=>{let l=t.find(u=>o.startsWith(u))??"";return[l,o.slice(l.length).toLowerCase()]},s=Object.fromEntries(ge(r.getAttr())),i=[...Object.keys(s),...Object.keys(e)].find(o=>n(o)[1]==="srcdoc");if(i===void 0||Object.keys(s).some(o=>n(o)[1]==="sandbox")||r.pointerType(r.value)===null&&!(Object.hasOwn(s,i)&&(r.pointerType(s[i])!==null||Ue(s[i]))))return e;let a=Object.fromEntries(Object.entries(e).filter(([o])=>n(o)[1]!=="sandbox"));return{[`${n(i)[0]}sandbox`]:"",...a}}function Mr(r){return Object.fromEntries(Object.entries(r).filter(([,e])=>e!=null))}function Nn(r){return Object.fromEntries(Object.entries(r).map(([e,t])=>e.startsWith("xmlns_")?[`xmlns:${e.slice(6)}`,t]:e.startsWith("data_")||e.startsWith("aria_")?[e.replaceAll("_","-"),t]:[e,t]))}function Xs(r){let{_meta:e,...t}=r;return Nn(Mr(Tt(t)))}function Mu(r,e){let t=dm[String(r).toLowerCase()]??[],n={},s={};for(let[i,a]of Object.entries(e))t.includes(i)?s[i]=a:n[i]=a;return[n,s]}function Ir(r){return String(r)}function On(r,e,t=null){let n={...e},{mask:s,format:i,locale:a,timeZone:o,dtype:l,places:u}=n;for(let d of fm)delete n[d];let c=d=>{if(t&&i!=null){if(u!=null)throw new RangeError("places is not implemented; specify precision in format");return t(d,{pattern:i,mask:s,...a==null?{}:{locale:a},...o==null?{}:{timeZone:o},...l==null?{}:{dtype:l}})}if(typeof d=="boolean"&&(d=Ir(d)),s==null)return d;let f=d==null?"":Ir(d);return f===""?f:Gs(f,s)};return Array.isArray(r)?(Object.hasOwn(n,"_text")&&(n._text=c(n._text)),[r,n]):[c(r),n]}function Ue(r){return typeof r=="string"&&r.startsWith("==")}function mm(r,e,t=r){let n=new Map,s=new Set,i=new Map;for(let[o,l]of e){if(typeof o!="string")continue;let u=V(l)?.pointer??l;i.set(o,u instanceof Z?u.resolve():r.pointerType(u)?t.getRelativeData(u):Ue(u)?null:u)}let a=o=>{if(n.has(o))return n.get(o);if(!e.has(o))throw new Error(`Source attribute '${o}' does not exist`);if(s.has(o))throw new Error(`cyclic attribute dependency: ${[...s,o].join(" -> ")}`);s.add(o);let l=e.get(o),u=V(l),c=u?i.get(o):null,d,f=h=>h?a(h):c;try{if(u)if(u.expression){let h=qr(u.body),p=h.slots.map(f);d=r.rootBuilder.evaluatePointerExpression(r,o,l,h,p)}else d=Ur(u.body,f),c==null&&(d=null);else d=i.get(o);return n.set(o,d),d}finally{s.delete(o)}};return{resolve:a}}function Dt(r,e,t=r){let n=new Map([...Object.entries(r.getAttr()),...ge(r.getAttr())]);return mm(r,n,t).resolve(e)}var gm={dataFormula:["formula","_if","_else","_ask_if","_ask_onCancel"],dataController:["script","_if","_else","_ask_if","_ask_onCancel"],dataRpc:["_ask_if","_ask_onCancel","_if","_else","_onCalling","_onResult","_onError"],dataRemote:["_if","_else","_onCalling"]},xa=["_cachedRemote","_if","_else","_onRemote","_onCalling","_delay","_timing","_userChanges"],_m=["_if","_else","_onRemote","_onCalling"],Sa=class{#e;#t=null;#r=null;#s=!1;constructor(e){this.#e=e}get inflight(){return this.#t?.view??null}get pending(){let e=this.#r;return e?Object.freeze({method:e.method,get params(){return P(e.text)}}):null}calling(e){if(!e)return!0;let t=!1,n=this.#s;this.#s=!0;try{t=e()!==!1}finally{this.#s=n,!t&&!this.#t&&this.#n()}return t}submit(e,t,n){try{let s=W(t);return this.#t?this.#r?Promise.resolve(void 0):new Promise((i,a)=>{this.#r={method:e,text:s,perform:n,resolve:i,reject:a}}):(this.#r?.resolve(void 0),this.#r=null,this.#i(e,t,s,n))}catch(s){return Promise.reject(s)}}submitSync(e,t){if(this.#t)throw new Error("A synchronous call cannot start while a request of the node is in flight");if(!this.#e.matches(e))throw new TypeError(`Method name must match ${this.#e.pattern}, not ${JSON.stringify(e)}`);return t()}#n(){let e=this.#r;if(!e)return;this.#r=null;let t;try{t=this.#i(e.method,P(e.text),e.text,e.perform)}catch(n){t=Promise.reject(n)}t.then(e.resolve,e.reject)}#i(e,t,n,s){if(!this.#e.matches(e))return Promise.reject(new TypeError(`Method name must match ${this.#e.pattern}, not ${JSON.stringify(e)}`));let i=new AbortController,a={method:e,params:t,text:n,controller:i,ignored:!1};a.view=Object.freeze({method:e,get params(){return P(n)},sentAt:Date.now(),cancel:()=>this.#o(a)}),this.#t=a,i.signal.addEventListener("abort",()=>this.#a(a),{once:!0});let o;try{o=Promise.resolve(s(a))}catch(l){o=Promise.reject(l)}return o.then(()=>this.#a(a),()=>this.#a(a)),o}#a(e){this.#t===e&&(this.#t=null,this.#n())}#o(e){this.#t===e&&(e.ignored=!0,this.#t=null,this.#s||this.#n())}};function $u(r){return typeof r=="string"&&r.startsWith("==")}var Zt=class extends we{#e=new Set;#t=null;#r=null;get requests(){return this.#r??=new Sa(this.rootBuilder.nameSyntax)}codeAttributes(){let e=[...gm[this.nodeTag]??[],...Object.entries(this.parentNode?._getMeta("gramlot_component")?.childParameters??{}).filter(([,n])=>n.inline).map(([n])=>n),...this._getMeta("gramlot_component")?.command?["action","_ask_if"]:[],...typeof this.getAttr("remote")=="string"?_m:[]],t=[];for(let[n,s]of Object.entries(this.getAttr()??{}))typeof s=="string"&&(e.includes(n)||n==="validate_call"||n==="validate__onResult"||n==="validate_onAccept"||n==="validate_onReject"||/^validate_\w+_if$/.test(n)||n.startsWith("connect_on")||n.startsWith("subscribe_")||n.startsWith("selfsubscribe_"))&&t.push([n,s]);for(let n of["ask","_ask"]){let s=this.getAttr(n);if(s&&typeof s=="object")for(let i of["_if","askIf"])typeof s[i]=="string"&&t.push([`${n}.${i}`,s[i]])}for(let[n,s]of ge(this.getAttr()))$u(s)&&t.push([n,s]);return $u(this.staticValue)&&t.push(["",this.staticValue]),t}activateCode(){let e=new Map;for(let[t,n]of this.codeAttributes()){if(this.pointerType(n))throw new Error(`${this.nodeTag} '${this.label}': '${t}' is inline code and cannot be the pointer '${n}'; inline code is never read from Data`);e.set(t,n)}for(let[t,n]of[...ge(this.getAttr()),["datapath",this.getAttr("datapath")]])V(n)?.expression&&e.set(t,n);this.#t=e}activatedCode(e){return this.#t?.get(e)??null}remote(e,t={}){let n=this.rootBuilder.nameSyntax;if(typeof e!="string"||!(this.pointerType(e)||n.matches(e)))throw new TypeError(`${this.nodeTag} '${this.label}': remote name must be a pointer or match ${n.pattern}, not ${JSON.stringify(e)}`);let s=Object.keys(t).find(a=>a.startsWith("_")&&!xa.includes(a));if(s)throw new TypeError(`${this.nodeTag} '${this.label}': remote parameter '${s}' is not accepted; the control attributes are ${xa.join(", ")}`);let i={remote:e};for(let[a,o]of Object.entries(t))i[xa.includes(a)?a:`remote_${a}`]=o;return this.setAttr(i),En(this)}publish(e,t={}){return this.builder.binding.subscriptions.publishNode(this,e,t)}pointers(){let e=this.getAttr("datapath"),t=V(e)?Ve(this,e):new Set,n=super.pointers().filter(([s,i])=>!t.has(s)&&!this.#i(s,i)).map(([s,i])=>[s,V(i)?.pointer??i]);for(let s of t){let i=this.getAttr(s);this.pointerType(i)==="^"&&n.push(["datapath",V(i)?.pointer??i])}return n}runtimeToEvaluate(){let e=super.runtimeToEvaluate();for(let[t,n]of e)if(this.pointerType(n)){if(V(n)){if(typeof t!="string")throw new Error(`${this.nodeTag} '${this.label}': pointer suffixes belong to attributes; use format/mask for node text`);this.absDatapath(n)===null&&e.set(t,new Ft(()=>Dt(this,t)));continue}this.#i(t,n)?e.set(t,n.slice(1)):this.absDatapath(n)===null&&e.set(t,null)}return e}pathAttribute(e){let t=this.getAttr(e);return V(t)?Dt(this,e):this.pointerType(t)&&this.#i(e,t)?t.slice(1):t}getRelativeData(e,t=null,n={}){return this.absDatapath(e)===null?null:super.getRelativeData(e,t,n)}setRelativeData(e,t,n={}){this.#a(e),super.setRelativeData(e,t,n)}PUT(e,t){this.#a(e),this.data.setItem(this.absDatapath(e),t,null,">",!1,!0,this,!1,!1)}FIRE(e,t=!0,n=null){t===null&&(t=!0),this.#a(e);let s=this.absDatapath(e);if(s.includes("?")){this.#s(s,t);return}this.data.getNode(s)?.setValue(null,!1);try{this.fireEvent(e,t,{attributes:n})}finally{this.data.getNode(s)?.setValue(null,!1)}}#s(e,t){let[n,s]=e.split("?",2),i=this.data;i.getNode(n)?.setAttr({[s]:null},!1);try{let a=i.getNode(n);a?a.setValue(a.staticValue,!0,{[s]:t},!0,!0,!0,!0):i.setItem(n,null,{[s]:t},">",!0,!0,!0,!0)}finally{i.getNode(n)?.setAttr({[s]:null},!1)}}FIRE_AFTER(e,t=!0,n=10){this.#a(e);let s=this.rootBuilder?.binding?.bindingFor(this)??null,i=null,a=setTimeout(()=>{i?.(),this.FIRE(e,t)},n);return i=s?.track(()=>clearTimeout(a))??null,()=>{clearTimeout(a),i?.()}}absDatapath(e){e=V(e)?.pointer??e;let t=this.pointerType(e)?e.slice(1):e;if(t.startsWith("#")&&t.includes("?")){let[n,s]=t.split("?",2),i=super.absDatapath(n);return i===null?null:`${i}?${s}`}return super.absDatapath(e)}_composeRelativeDatapath(e,t){let n=this;for(;n!==null&&e.startsWith(".");){let s=n.getAttr("datapath");if(this.pointerType(s)&&(s=this.#n(n,s),s===null))return null;if(s!=null&&(e=e==="."?s:s+e),e.startsWith("#"))return n.parentNode._resolveSymbolicDatapath(e,t);n=n.parentNode}if(e.startsWith("."))throw new Error(`unresolved relative datapath: ${t}`);return e}_finalizeAbsPath(e,t){return e===null?null:super._finalizeAbsPath(e,t)}_resolveSymbolicDatapath(e,t){let n=e.slice(1).split(".",1)[0];if(n==="FORM"||n==="ANCHOR")return super._resolveSymbolicDatapath(e,t);let s=this.rootBuilder?.binding;if(!s)return super._resolveSymbolicDatapath(e,t);let i=s.nodeIds.get(n);if(!i)throw new Error(`#<id>: cannot resolve ${t}`);let a=e.slice(n.length+2);return i.absDatapath(a?`.${a}`:".")}#n(e,t){if(V(t)){let i=Dt(e,"datapath",e.parentNode);return i==null||i===""?null:i}let n=e.parentNode.absDatapath(t);if(n===null)return null;let s=this.data.getItem(n);return s==null||s===""?null:s}#i(e,t){return V(t)||typeof e!="string"||!e.endsWith("_path")?!1:(this.#e.has(e)||(this.#e.add(e),console.warn(`${this.nodeTag} '${this.label}': '${e}' holds a bare Data path; the pointer symbol of '${t}' is removed`)),!0)}#a(e){if(this.absDatapath(e)===null)throw new Error(`${this.nodeTag} '${this.label}': write on a null path: '${e}'`)}},le=class r extends x{get nodeClass(){return Zt}authorizedCopy(e){let t=new this.constructor;for(let n of this.getNodes()){let s=n.getAttr("auth")??null;if(s!==null){if(typeof s!="string")throw new TypeError(`${n.nodeTag} '${n.label}': 'auth' must be a string rule, not ${typeof s}`);if(e(s)!==null)continue}let i=n.staticValue;i instanceof r&&(i=i.authorizedCopy(e));let{auth:a,...o}=n.getAttr(),l=t.setItem(n.label,i,o,">",!1,!1,null,!1,!0,null,n.nodeTag);l.xmlTag=n.xmlTag}return t}activateCode(){for(let e of this.getNodes())e.activateCode(),e.staticValue instanceof r&&e.staticValue.activateCode();return this}};if((Re(le.tytxSuffix).GramlotBuilderBag??le)!==le)throw new Error("TYTX subtype name 'GramlotBuilderBag' is already registered for another class");Pt(le.tytxSuffix,{...Re(le.tytxSuffix),GramlotBuilderBag:le});var bm=new Set(["animate","animateMotion","animateTransform","circle","ellipse","feBlend","feColorMatrix","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feGaussianBlur","feImage","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","image","line","metadata","path","polygon","polyline","rect","set","stop","use"]),In=class extends Gt{constructor(e,t){super(e),this._owner=t}get owner(){return this._owner}_handleMeta(e,t){let n=this.owner.evaluateExpressions(e,t);Rr(e,n);let[s,i]=super._handleMeta(e,n);return Br(e,i),e._getMeta("subbuilder")?[s,qs(Xs(i))]:[s,i]}adaptAttrs(e){let{_meta:t,...n}=e;return Nn(super.adaptAttrs(Mr(Tt(n))))}renderedItem(e,t,n,s={}){if(this.owner.renderType==="object")return this.owner.renderedItem(e,t,n,s);let{_text:i,...a}=n;return t=this.owner.expressionValue(e,t),Array.isArray(t)&&i!=null&&(t=[this._escapeText(Ir(i)),...t]),bm.has(s.tag)?`${s.pretty?" ".repeat(this._nodeDepth(e,s.depthOffset??0)):""}<${s.tag}${this._formatAttrs(a)} />${s.pretty?`
58
- `:""}`:super.renderedItem(e,t,a,s)}};var Jt=class extends Wt{#e=new WeakMap;#t=new WeakMap;get inlineCompiler(){return null}getRender(e){return this.renders.has(e)||(e instanceof kt?this.addRender(e,this):e instanceof At&&this.addRender(e,new In(e,this))),super.getRender(e)}render(e,t={}){if(e._getMeta("data_element"))return null;let[n,s]=e.rootBuilder.runtimeValues(e),i=this.getRender(e.builder),[a,o]=i._handleMeta(e,s);return e._getMeta("subbuilder")||(o=i.adaptAttrs(o)),i.renderedItem(e,e.value instanceof x?this.renderChildren(e.value,t):n,o,{tag:a,...t})}_handleMeta(e,t){let n=this.builder.constructor.dialectPrefixes,s=this.evaluateExpressions(e,t);Rr(e,s,n);let[i,a]=super._handleMeta(e,Ru(e,s,n));if(Br(e,a,n),e.nodeTag==="webcomponent"){i=it(e.getAttr());let{code:u,...c}=a;a=c}if(e._getMeta("subbuilder")){let u=Xs(a);return e._getMeta("subbuilder")==="html"&&(u.xmlns=Cn),[i,u]}let[o,l]=Mu(i,a);return Object.keys(l).length&&this.#e.set(e,l),[i,o]}evaluateExpressions(e,t){let n=this.inlineCompiler,s=(a,o)=>n?n.compileExpression(e,a,o)(t):null,i={...t};for(let[a,o]of ge(e.getAttr()))Ue(o)&&Object.hasOwn(i,a)&&(i[a]=s(a,o));return Ue(e.value)&&this.#t.set(e,s("",e.value)),i}expressionValue(e,t){return Ue(e.value)?this.#t.get(e)??null:t}restoreNativeAttributes(e,t){let n=this.#e.get(e);return n?(this.#e.delete(e),{...t,...Mr(n)}):t}adaptAttrs(e){let{_meta:t,...n}=e,s=`${this.builder.constructor._name}_`,i=this.builder.constructor.dialectPrefixes,a={},o={};for(let[l,u]of Object.entries(Tt(n))){if(u==null)continue;if(l.startsWith(s))throw new Error(`${l}: the attribute prefix '${s}' is not accepted; use the prefix '${i[0]}'`);let c=i.find(d=>l.startsWith(d));c?a[l.slice(c.length)]=u:o[l]=u}return Nn({...super.adaptAttrs(o),...a})}renderedItem(e,t,n,s={}){let i;[t,i]=On(this.expressionValue(e,t),this.restoreNativeAttributes(e,n));let{_text:a,...o}=i;Array.isArray(t)&&a!=null&&(t=[this._escapeText(Ir(a)),...t]);let l=e.parentNode?._getMeta("subbuilder")==="html"?{xmlns:je,...o}:o;return super.renderedItem(e,t,l,s)}finalize(e,t=null,n={}){if(!n.doctype)return super.finalize(e,t,n);let s=this._composeStringFragments(e),i=this.builder.source.getNodes().filter(a=>!a._getMeta("data_element"));return i.length===1&&i[0].nodeTag==="html"||(s=`<html>${s}</html>`),super.finalize(`<!doctype html>${s}`,t,n)}};var Lu={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"binding",version:null,title:"Gramlot binding",description:"Gramlot Data declarations and the plain HTML button; loaded after the HTML grammar."},abstracts:{},elements:{dataSetter:{doc:"Initial Data value, written literally at destination_path.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination_path",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"value",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"any"},has_default:!0,default:null},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataFormula:{doc:"Computed Data value written at result_path; formula is inline, func is a name.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"result_path",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"formula",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"params",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataController:{doc:"Side effects on Data; script is inline, func is a name.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"script",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"params",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataRpc:{doc:"Server endpoint called through gramlot.rpc; the value is written at result_path when given.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"method",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"result_path",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"timeout",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"int"},{kind:"type",module:"builtins",name:"float"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"params",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataRemote:{doc:"Data node resolved by a server endpoint through gramlot.rpc, on first read and again when cacheTime expires; with sync (default) the read waits for the answer when the transport supports it.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination_path",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"method",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"cacheTime",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"int"},{kind:"type",module:"builtins",name:"float"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"sync",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"bool"},has_default:!0,default:!0},{name:"params",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},html_button:{doc:"Plain native HTML button without Gramlot click mechanisms.",sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{render_tag:"button"}}}};var Pu={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"webcomponent",version:null,title:"Gramlot webcomponent",description:"An explicitly loaded autonomous custom element."},abstracts:{},elements:{webcomponent:{doc:"Create the custom-element tag named by literal code.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"code",kind:"keyword_only",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null}}};function De(){return Array.from(globalThis.crypto.getRandomValues(new Uint8Array(16)),r=>r.toString(16).padStart(2,"0")).join("")}var vm="data is forbidden: write dataSetter for a Data value or html_data for the HTML5 <data> element",Em=new Set,km=new Set(["serverpath","dbenv","shared_id"]),Am=["formsubscribe_"],Tm={dataSetter:"destination_path",dataFormula:"result_path",dataRpc:"result_path",dataRemote:"destination_path"},Dm={dataFormula:"formula",dataController:"script"};function Fu(r,e){if(["input","textarea","select","webcomponent"].includes(r)&&V(e.value))return"'value' does not accept pointer suffixes; use an ordinary value pointer";if(r==="html_button"&&Object.keys(e).some(s=>["action","ask","_delay","fire"].includes(s)||s.startsWith("fire_")))return"plain HTML button: use button for action, ask, fire or _delay";if(Object.hasOwn(e,"ask")&&!["button","toggleButton","dropDownButton","menuline"].includes(r))return"'ask' is supported on buttons";if(Object.hasOwn(e,"_ask")&&!["dataController","dataFormula","dataRpc"].includes(r))return"'_ask' requires a controller, formula or RPC";if(["dataSetter","dataRemote"].includes(r)&&Object.keys(e).some(s=>s.startsWith("subscribe_")||s.startsWith("selfsubscribe_")))return"topic subscriptions are supported on controllers, formulas, RPCs and rendered elements";let t=Tm[r];if(t&&String(e[t]??"").includes("?"))return`'${t}' does not accept '?attr': '${e[t]}'`;let n=Dm[r];return n&&e[n]!=null&&e.func!=null?`'func' and '${n}' cannot be declared on the same node`:n&&e._if!=null&&e.func!=null?"'_if' is inline and cannot be declared with 'func': write the condition in the method":null}function ju(r){return Object.keys(r).find(e=>km.has(e)||Am.some(t=>e.startsWith(t)))}var qe=class r extends kt{static _name="gramlot";static _sourceClass=le;static{this.defineGrammar(Lu)}static{this.defineGrammar(Pu)}static{this.defineGrammar(Hs.toDocument())}static get dialectPrefixes(){let e=[];for(let t=Object.getPrototypeOf(r);t&&t!==Function.prototype;t=Object.getPrototypeOf(t))Object.hasOwn(t,"_name")&&t._name&&e.push(`${t._name}_`);return e}constructor(e=null,{collections:t=[],auth:n=null,nameSyntax:s=xn}={}){if(!(s instanceof Xt))throw new TypeError(`nameSyntax must be a NameSyntax, not ${s}`);super(e),this._binding=null,this._auth=n,this._nameSyntax=s;for(let i of t)this.loadCollection(i)}get auth(){return this._auth}get nameSyntax(){return this._nameSyntax}get binding(){return this._binding}set binding(e){this._binding=e}evaluatePointerExpression(e,t,n,s,i){return this.binding?this.binding.inlineCompiler.compilePointerExpression(e,t,n,s.text)(i):null}nodeById(e){if(!this.binding)return super.nodeById(e);let t=this.binding.nodeIds.get(e);if(!t)throw new Error(`nodeId not found: ${e}`);return t.builder.wrapSource(t)}loadCollection(e){return this.loadGrammar(e instanceof Yt?e.toDocument():e),this}schemaTag(e){let t=e.toLowerCase(),n=r.dialectPrefixes;if(t.startsWith(`${r._name}_`))throw new Error(`${e}: the tag prefix '${r._name}_' is not accepted; use the prefix '${n[0]}'`);if(Em.has(t))throw new Error(`${e}: excluded from Gramlot`);let s=this.schemaTagNames[t];if(s)return s;for(let i of n)if(t.startsWith(i)&&this.schemaTagNames[t.slice(i.length)])return t;return null}bagCall(e,t,n,s){return super.bagCall(e,this.#e(t),n,s)}commandOnNode(e,t,n,s){return super.commandOnNode(e,this.#e(t),n,s)}validateNodeValues(e,t,n={}){if(this.schema[e]?._meta?.gramlot_component&&V(n.value))throw new Error("'value' does not accept pointer suffixes");e==="webcomponent"&&it(n);let s=ju(n);if(s)throw new Error(`${e}: attribute '${s}' is excluded from Gramlot`);let i=Fu(e,n);if(i)throw new Error(`${e}: ${i}`);return super.validateNodeValues(e,t,n)}validateNode(e,t={}){if(e._getMeta("gramlot_component")&&V((t.attrs??e.getAttr()).value))throw new Error("'value' does not accept pointer suffixes");e.nodeTag==="webcomponent"&&it(t.attrs??e.getAttr());let n=ju(t.attrs??e.getAttr());if(n)throw new Error(`${e.nodeTag} '${e.label}': attribute '${n}' is excluded from Gramlot`);let s=Fu(e.nodeTag,t.attrs??e.getAttr());if(s)throw new Error(`${e.nodeTag} '${e.label}': ${s}`);return super.validateNode(e,t)}_validateChildren(e,t,n,s){return super._validateChildren(e,t,n.map(i=>i==="html_button"?"button":i),s)}_countsForGrammar(e){return e===this.schema.button||!e?._meta?.gramlot_component&&e!==this.schema.webcomponent&&super._countsForGrammar(e)}setChild(e,t,n,s,i=null){s=Object.fromEntries(Object.entries(s??{}).map(([l,u])=>[l,se(u)instanceof we?this.reference(u):u]));let o=t==="dataSetter"&&s?.value!==null&&typeof s?.value=="object"&&Object.getPrototypeOf(s.value)===Object.prototype?{...s,value:new R(s.value)}:s;return super.setChild(e,t,n,o,i)}#e(e){if(e==="data")throw new Error(vm);if(this.schemaTagNames[e.toLowerCase()]===e)return e;let t=r.dialectPrefixes.find(n=>e.startsWith(n));return this.schemaTagNames[e.slice(t.length)]}get renderer_html(){return new Jt(this)}create(){this.setup(this.data),this.main(this.root)}computeLogic(){}promoteNodeValue(e,t,n){let s=t!=null?{_text:t}:null;e.setValue(n,!0,s,!0)}reference(e,t="node"){if(e=se(e),!(e instanceof we)||!["node","dom"].includes(t))throw new TypeError("Reference requires an element and node/dom kind");let n=e.getAttr("__ref");return n==null&&(n=De(),e.setAttr({__ref:n})),{$gramlotRef:n,kind:t}}toTytx(){return W(this.auth===null?this.source:this.source.authorizedCopy(this.auth))}};var xm=new Set(["input","select","textarea"]),Sm=["type","multiple","group"];function Uu(r,e){let t=r.getAttr(e);return r.pointerType(t)?r.getRelativeData(t):t}var _e=class r{static liveWrites=!1;static writesDefault=!0;static preservesUnchangedValue=!1;#e;#t=!1;#r;#s;#n=!1;#i=!1;#a=!1;static for(e,t){let n=r.classFor(t.element,t.attrs);return n?new n(e,t):null}static classFor(e,t){if(e.namespaceURI!==je)return null;if(e.constructor.gramlotComponent)return e.constructor.gramlotComponent.parameters.value?.binding!=="twoWay"?null:e.control.type==="radio"?Ba:Ca;if(e.localName==="textarea")return Ke;if(e.localName==="select")return Bn;if(e.localName!=="input")return null;let n=t.type==null?"text":String(t.type).toLowerCase();return Object.hasOwn(qu,n)?qu[n]:Ke}static shape(e,t){return e?.constructor.gramlotComponent?.parameters.value?.binding==="twoWay"&&e.control.type==="radio"?JSON.stringify([t.group??null]):e?.namespaceURI!==je||!xm.has(e.localName)?null:JSON.stringify(Sm.map(n=>t[n]??null))}constructor(e,t){this.#r=e,this.#s=t}get binding(){return this.#r}get element(){return this.#s.element}get node(){return this.binding.node}get eventElement(){return this.element}get resolved(){return this.#s.resolved}get live(){return!!this.resolved.live}get writeEvent(){return this.constructor.liveWrites&&this.live?"input":"change"}project(e,t){if(this.#i){this.#a=!0;return}this.constructor.preservesUnchangedValue&&this.#t&&this.same(this.#e,e)||(this.#e=e,this.#t=!0,!(this.#n&&this.same(this.read(),e))&&(this.constructor.writesDefault&&!this.node.pointerType(this.node.getAttr("value"))&&this.writeDefault(e),this.write(e)))}read(){return this.element.value}write(e){let t=e==null?"":String(e);this.element.value!==t&&(this.element.value=t)}writeDefault(e){let t=e==null?"":String(e);this.element.localName==="textarea"?this.#s.text.data!==t&&(this.#s.text.data=t):this.element.defaultValue!==t&&(this.element.defaultValue=t)}same(e,t){return Object.is(e,t)}commit(e,t=this.read()){if(!this.binding.closed){this.#n=!0;try{this.binding.runtime.renderer.html.writeParameter(this.node,"value",t)}finally{this.#n=!1}}}attach(){for(let e of["input","change","compositionstart","compositionend"])this.eventElement.addEventListener(e,this)}detach(){for(let e of["input","change","compositionstart","compositionend"])this.eventElement.removeEventListener(e,this);this.#a=!1}refresh(){}handleEvent(e){if(!this.binding.closed){if(e.type==="compositionstart"){this.#i=!0;return}if(e.type==="compositionend"){this.#i=!1,this.writeEvent==="input"&&this.commit(e),this.#a&&(this.#a=!1,this.binding.runtime.renderer.project(this.node));return}this.#i||e.isComposing||e.type===this.writeEvent&&this.commit(e)}}},Ca=class extends _e{static writesDefault=!1;static preservesUnchangedValue=!0;get eventElement(){return this.element.control}attach(){this.element.setPageContext(Vu(this)),super.attach()}project(e,t){this.element.shouldProjectControlValue(e)&&super.project(e,t)}same(e,t){return this.element.sameControlValue(e,t)}detach(){this.element.releaseControl(),super.detach()}commit(e){this.binding.closed||this.element.control.disabled||this.element.control.readOnly||zu(this.element,this.element.acceptControlValue(),t=>super.commit(e,t.value))}get writeEvent(){if(this.element.commitOnChange)return"change";let e=this.element.control;return this.live&&(e.localName==="textarea"||["text","password","range","color"].includes(e.type))?"input":"change"}read(){return this.element.readControlValue()}write(e){this.element.writeControlValue(e)}handleEvent(e){if(super.handleEvent(e),!e.composed&&!this.binding.closed&&["input","change"].includes(e.type)){let t=this.element.ownerDocument.defaultView.Event;this.element.dispatchEvent(new t(e.type,{bubbles:!0,composed:!0}))}}},Ke=class extends _e{static liveWrites=!0},Na=class extends _e{static liveWrites=!0;read(){return this.element.value===""?null:Number(this.element.value)}commit(e){this.element.validity.badInput||super.commit(e)}},Oa=class extends _e{static liveWrites=!0;read(){return Number(this.element.value)}},Bn=class extends _e{static writesDefault=!1;read(){return this.element.multiple?[...this.element.selectedOptions].map(e=>e.value):this.element.selectedIndex===-1?null:this.element.value}write(e){let t=this.element;if(t.multiple){if(e!=null&&!Array.isArray(e))throw new TypeError(`${this.node.nodeTag} '${this.node.label}': a multiple select requires an array`);let n=new Set((e??[]).map(String));for(let s of t.options){let i=n.has(s.value);s.selected!==i&&(s.selected=i)}}else e==null?t.selectedIndex!==-1&&(t.selectedIndex=-1):(t.selectedIndex===-1||t.value!==String(e))&&(t.value=String(e))}same(e,t){return Array.isArray(e)?Array.isArray(t)&&t.length===e.length&&t.every((n,s)=>Object.is(n,e[s])):super.same(e,t)}},Kt=class extends _e{read(){return this.element.value===""?null:this.element.value}},Ia=class extends _e{},Ys=class extends _e{static writesDefault=!1;read(){return this.element.checked}write(e){let t=!!e;this.element.checked!==t&&(this.element.checked=t)}same(e,t){return e===!!t}attach(){let e=this.node;if(e.getAttr("checked")!=null&&e.pointerType(e.getAttr("value"))==="^")throw new TypeError(`${e.nodeTag} '${e.label}': checked and a ^ value are two sources`);super.attach()}},Zs=class extends Ys{#e=null;#t=!1;get groups(){return this.binding.runtime.renderer.radioGroups}attach(){let e=this.node,t=this.resolved.group??null,n=Ra(e);if(t!=null){if(e.getAttr("name")!=null)throw new TypeError(`${e.nodeTag} '${e.label}': name and group are two names`);this.#r(t,n)}super.attach(),t!=null&&(this.#e=this.groups.join(this,t,n),this.element.setAttribute("name",this.#e))}detach(){this.#e!==null&&(this.groups.leave(this),this.element.removeAttribute("name"),this.#e=null),super.detach()}refresh(){if(this.#e===null)return;let e=this.resolved.group,t=Ra(this.node);this.groups.nameOf(e,t)!==this.#e&&(this.#r(e,t),this.groups.leave(this),this.#e=this.groups.join(this,e,t),this.element.setAttribute("name",this.#e))}#r(e,t){let n=this.node;if(Uu(n,"value")&&this.groups.peersOf(e,t).some(s=>!s.binding.closed&&s.read()))throw new Error(`${n.nodeTag} '${n.label}': several true values in radio group '${e}'`)}project(e,t){let n=!this.#t;this.#t=!0;let s=this.read();super.project(e,t),!n&&!s&&this.read()&&this.turnOffPeers()}commit(e){let t=this.read();super.commit(e),t&&!this.binding.closed&&this.turnOffPeers()}turnOffPeers(){if(this.#e!==null)for(let e of this.groups.peers(this)){if(this.binding.closed)return;e.binding.closed||(e.element.checked&&(e.element.checked=!1),Uu(e.node,"value")&&e.commit(null))}}},Ba=class extends Zs{static writesDefault=!1;get host(){return super.element}get element(){return this.host.control}project(e,t){this.host.shouldProjectControlValue(e)&&super.project(e,t)}commit(e){this.binding.closed||this.element.disabled||this.element.readOnly||zu(this.host,this.host.acceptControlValue(),()=>super.commit(e))}read(){return this.host.readControlValue()}write(e){this.host.writeControlValue(e)}attach(){this.host.setPageContext(Vu(this)),super.attach(),this.element.addEventListener("keydown",this)}detach(){this.host.releaseControl(),this.element.removeEventListener("keydown",this),super.detach()}handleEvent(e){if(!this.binding.closed){if(e.type==="keydown"){if(this.resolved.group==null||!["ArrowLeft","ArrowUp","ArrowRight","ArrowDown"].includes(e.key))return;let t=this.groups.peersOf(this.resolved.group,Ra(this.node)).filter(a=>!a.binding.closed&&!a.element.disabled),n=t.indexOf(this);if(n<0)return;e.preventDefault();let s=["ArrowLeft","ArrowUp"].includes(e.key)?-1:1,i=t[(n+s+t.length)%t.length];i.element.focus(),i.element.click();return}if(super.handleEvent(e),!e.composed&&!this.binding.closed&&["input","change"].includes(e.type)){let t=this.host.ownerDocument.defaultView.Event;this.host.dispatchEvent(new t(e.type,{bubbles:!0,composed:!0}))}}}},Js=class{#e;#t=new Map;#r=new Map;#s=new WeakMap;#n=0;constructor(e){this.#e=e}join(e,t,n){let s=this.nameOf(t,n);return this.#t.has(s)||this.#t.set(s,new Set),this.#t.get(s).add(e),this.#r.set(e,s),s}leave(e){let t=this.#r.get(e);this.#r.delete(e);let n=this.#t.get(t);n?.delete(e),n?.size===0&&this.#t.delete(t)}peers(e){let t=this.#r.get(e);return[...this.#t.get(t)??[]].filter(n=>n!==e)}peersOf(e,t){return[...this.#t.get(this.nameOf(e,t))??[]]}nameOf(e,t){t!==null&&!this.#s.has(t)&&this.#s.set(t,this.#n++);let n=t===null?"page":`form${this.#s.get(t)}`;return`gramlot-${this.#e.instanceId}-${n}-${e}`}};function Ra(r){for(let e=r;e;e=e.parentNode){let t=e.getAttr()??{};if(t.formId!=null||t.form===!0)return e}return null}var qu={text:Ke,password:Ke,email:Ke,url:Ke,tel:Ke,search:Ke,number:Na,range:Oa,color:Ia,date:Kt,time:Kt,month:Kt,week:Kt,"datetime-local":Kt,checkbox:Ys,radio:Zs,hidden:null,file:null,button:null,submit:null,reset:null,image:null};function Vu(r){let{binding:e,node:t}=r,n=e.runtime.gramlot,s=(i,a,o,l=!1)=>{if(!l&&/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(a)){let{group:u,method:c}=n.src.logicRegistry.resolve(a,t);return c.call(u,t,o)}return e.runtime.inlineCompiler.compile(t,i,a,Object.keys(o),l?`return (${a});`:a)(o)};return{locale:n.locale,timeZone:n.timeZone,createDecimal:yt,isDecimal:fe,getDecimalLibrary:pa,isActive:()=>!e.closed,callLogic:(i,a)=>{let{group:o,method:l}=n.src.logicRegistry.resolve(i,t);return l.call(o,t,a)},format:(i,a)=>n.format(i,a),invoke:s,remote:(i,a,o)=>n.rpc.call("data",i,a,{signal:o}),validationCurrent:()=>{let i=t.getAttr("value"),a=t.pointerType(i)?t.absDatapath(i):null;return()=>!e.closed&&t.getAttr("value")===i&&(a===null||t.absDatapath(i)===a)},finishValidation:({ok:i,result:a,rules:o})=>{if(e.closed)return;if(i)for(let u of a.datachanges)t.getRelativeData(".").update(u);let l=i?"validate_onAccept":"validate_onReject";if(o[l]){let u=c=>console.error("Validation notification failed:",c);try{let c=Object.fromEntries(Object.entries(o).map(([f,h])=>[f.slice(9),h])),d=s(l,o[l],{value:a.value,result:a,validations:c,userChange:!0});d instanceof Promise&&d.catch(u)}catch(c){u(c)}}},checkDataPatch:i=>{if(!(i instanceof R))throw new TypeError("Validation data changes must be a Bag.");if(!(t.getRelativeData(".")instanceof R))throw new TypeError("Validation data changes require a Bag datapath.")}}}function zu(r,e,t){let n=s=>{s.ok&&s.isCurrent()&&(t(s),r.finishValidation(s))};e instanceof Promise?e.then(n).catch(s=>console.error("Validation notification failed:",s)):n(e)}var Ma=Symbol("source text"),Hu={xmlns:"http://www.w3.org/2000/xmlns/",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},Cm=new Set(["allowFullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formNoValidate","hidden","inert","isMap","itemscope","loop","multiple","muted","noModule","noValidate","open","playsInline","readOnly","required","reversed","selected"]),Nm=new Set(["checked","muted","selected","value"]),Om=new Map([["allowfullscreen","allowFullscreen"],["formnovalidate","formNoValidate"],["ismap","isMap"],["nomodule","noModule"],["novalidate","noValidate"],["playsinline","playsInline"],["readonly","readOnly"]]);function Im(r){let e=r.replace(/-([a-z])/g,(t,n)=>n.toUpperCase());return Om.get(e.toLowerCase())??e}var Ks=class{constructor({metadataAttributes:e=[],invokeScript:t=null,callLogic:n=null}={}){this.invokeScript=t,this.callLogic=n,this.metadataAttributes=new Set([...jt,"_text",...e])}definition(e){let t=e.builder,s={...t.schema[t.schemaTag(e.nodeTag)]._meta,...e.getAttr("_meta")},i=e.nodeTag==="webcomponent"?it(e.getAttr()):vn(e.nodeTag,{renderTag:s.render_tag,ns:e.getAttr("ns"),dialectName:t.constructor._name}),a=i==="foreignObject"?Cn:s.render_attributes?.xmlns??e.getAttr("xmlns")??(t instanceof At?Cn:je);return{meta:s,namespace:a,tag:i}}validate(e,t=e.builder){let n=e.value instanceof x,s=n?e.getAttr("_text"):e.value;if(s!=null&&!["string","number","boolean"].includes(typeof s))throw new TypeError("HTML text must be scalar");for(let[o,l]of Object.entries(e.attr))if(!(o==="value"&&this.definition(e).meta.gramlot_component)&&!(this.metadataAttributes.has(o)||["ask","_ask"].includes(o)||l&&typeof l=="object"&&Object.hasOwn(l,"$gramlotRef"))&&l!=null&&!["string","number","boolean"].includes(typeof l))throw new TypeError(`HTML attribute ${o} must be scalar`);let i=Object.fromEntries(Object.entries(e.attr).filter(([o])=>!this.metadataAttributes.has(o))),a=n?e.value.getNodes().map(o=>o.nodeTag).filter(Boolean):[];t.validateNode(e,{value:s,attrs:i,childTags:a})}create(e,t,n=null,s=e.attr,i=null){let{tag:a,namespace:o,meta:l}=this.definition(e);n??=a;let u=o===je?t.createElement(n):t.createElementNS(o,n);if(l.gramlot_component&&u.constructor.gramlotComponent?.tag!==n)throw new Error(`Component collection must be activated before rendering ${n}`);l.gramlot_component?.dataScope&&(u.readDataScope=()=>{if(!e.getAttr("datapath"))throw new Error("Data scope requires an explicit datapath");return e.getRelativeData(".")}),l.gramlot_component?.sourceContext&&u.setSourceContext({publish:(f,h)=>e.publish(f,h),writeParameter:(f,h)=>this.writeParameter(e,f,h),callLogic:(f,h)=>this.callLogic(e,f,h)});let c=t.createTextNode(this.text(e));(o!==je||!l.void)&&u.append(c);let d={element:u,text:c,tag:n};return this.update(d,e,s,Ma,i),d}matches(e,t){let{tag:n,namespace:s}=this.definition(t);return(s===je?e.tag.toLowerCase()===n.toLowerCase():e.tag===n)&&e.element.namespaceURI===s}writeParameter(e,t,n){let s=e.getAttr(t);e.pointerType(s)==="^"&&!V(s)&&!Object.is(e.getRelativeData(s.slice(1)),n)&&e.setRelativeData(s.slice(1),n)}compose(e,t,n){e.text.data=t??"";for(let s of n)e.element.append(s)}update(e,t,n=t.attr,s=Ma,i=null){let{element:a,text:o}=e,l=a.namespaceURI===je,u=this.definition(t).meta.render_attributes??{},c=e.attrs??{},d=g=>(Rr(t,g,t.builder.constructor.dialectPrefixes),Br(t,g,t.builder.constructor.dialectPrefixes),t.builder.renderer_html.adaptAttrs(g)),f=t.parentNode;f?._getMeta("gramlot_component")?.childParameters&&(n=a.ownerDocument.defaultView.customElements.get(f._getMeta("render_tag")).projectChild(a,n,{adapt:d,invoke:(_,w,y)=>this.invokeScript(t,_,w,y),publish:(_,w)=>t.publish(_,w),publishParent:(_,w)=>f.publish(_,w),writeParameter:(_,w)=>this.writeParameter(t,_,w),remove:()=>t.parentBag.popNode(t.label)})),this.definition(t).meta.gramlot_component&&(this.definition(t).meta.gramlot_component.bagStore&&a.setStoreBag(t.getRelativeData(t.getAttr("storepath"))),n=a.projectAttributes(n,d)),n=Object.fromEntries(ge({...n,...u}));let h=_e.classFor(a,n)!==null;s===Ma&&(s=this.text(t));let p=s==null?"":String(s);o.data!==p&&(o.data=p);let m=[...new Set([...Object.keys(c),...Object.keys(n)])];m.sort((g,_)=>(_==="sandbox")-(g==="sandbox"));for(let g of m){if(this.metadataAttributes.has(g)||["ask","_ask"].includes(g)||h&&g==="value")continue;let _=n[g],w=g,y=Im(w),k=l&&Cm.has(y)&&typeof a[y]=="boolean",T=w==="xmlns"?"xmlns":w.includes(":")?w.split(":")[0]:"",v=Object.hasOwn(Hu,T)?Hu[T]:null;if(Object.is(c[g],_)||(_==null||k&&!_?v?a.removeAttributeNS(v,w.split(":").at(-1)):a.removeAttribute(w):v?a.setAttributeNS(v,w,String(_)):a.setAttribute(w,k?"":String(_))),l&&(k||Nm.has(y))&&y in a){let N=y==="value"?_==null?"":String(_):!!_;a[y]!==N&&(a[y]=N)}}i===!1?a.style.visibility!=="hidden"&&(a.style.visibility="hidden"):e.visible===!1&&(n.style==null?a.removeAttribute("style"):a.setAttribute("style",String(n.style))),e.visible=i,e.attrs=n}text(e){return e.value instanceof x?e.getAttr("_text")==null?"":String(e.attr._text):e.value==null?"":String(e.value)}};var Qs=class r{#e;#t;#r=null;#s=0;static for(e,t){return t.element?.constructor.gramlotComponent?.command?new r(e,t):null}constructor(e,t){this.#e=e,this.#t=t}get binding(){return this.#e}get node(){return this.binding.node}get element(){return this.#t.element}get controllers(){let e=this.node.value;return e?.getNodes?e.getNodes().filter(t=>t.nodeTag==="dataController"||t.nodeTag==="dataRpc"):[]}get mechanism(){let e=this.node,t=this.controllers;if(t.length>1)throw new Error(`${e.nodeTag} '${e.label}': several dataController or dataRpc children; a button has one click mechanism`);let n=e.getAttr()??{},s=[];if(t.length&&s.push("controller"),n.action!=null&&s.push("action"),Wu(n).length&&s.push("fire"),s.length>1)throw new Error(`${e.nodeTag} '${e.label}': ${s.join(" and ")} together; a button has one click mechanism`);return s[0]??null}attach(){this.refresh(),this.element.activateCommand=e=>this.onClick(e),this.element.attachCommand(),this.element.addEventListener("click",this)}refresh(){this.mechanism&&this.node.getAttr("type")==null&&this.element.getAttribute("type")!=="button"&&this.element.setAttribute("type","button")}detach(){this.element.removeEventListener("click",this),this.element.releaseCommand(),delete this.element.activateCommand,this.#r?.()}handleEvent(e){this.onClick(e)}onClick(e){if(this.binding.closed||this.element.disabled)return;let t=this.element.commandTarget(e);if(t===null)return;if(t!==this.element)return e.stopPropagation(),t.activateCommand(e);if(!this.element.prepareCommand(e)||!this.mechanism||(e.stopPropagation(),this.element.disabled))return;let s=this.binding.countClick(),i=this.node;for(;i&&i.getAttr("_delay")==null;)i=i.parentNode;let a=i?i.rootBuilder.runtimeValues(i)[1]._delay:0;if(a>0){let o=this.#s+1;this.#r?.(),this.#s=o;let l=setTimeout(()=>{u(),this.#r=null,this.#s=0,this.#n(e,o)},a),u=this.binding.track(()=>this.#r?.());this.#r=()=>{clearTimeout(l),u(),this.#r=null,this.#s=0};return}return this.#r?.(),this.#n(e,s)}#n(e,t){if(this.binding.closed||this.element.disabled)return;let n=this.mechanism;if(!n)return;let s=this.node,i=Bm(e);if(n==="controller")this.binding.runtime.bindingFor(this.controllers[0])?.providers[0]?.invoke({kind:"click",event:e,counter:t});else if(n==="action"){let a=()=>{let[,c]=s.rootBuilder.runtimeValues(s),d=Object.fromEntries(Object.entries(c).filter(([f])=>f!=="ask"));return{...this.binding.runtime.renderer.references.resolveArguments(d),event:e,_counter:t,modifiers:i}},o=c=>{if(this.binding.closed||this.element.disabled||c===null)return;let d={...a(),...c};c&&(d._askResult=c),this.binding.runtime.inlineCompiler.compile(s,"action",s.getAttr("action"),Object.keys(d))(d)},l=s.getAttr("ask"),u=this.binding.runtime.askDialog;if(l&&u.required(this.binding,l,a(),"ask"))return u.show(this.binding,l,a()).then(o);o(void 0)}else{let a={modifier:i,_counter:t},o=s.getAttr("fire");if(o!=null){s.FIRE(o,i||!0,a);return}for(let[l,u]of Wu(s.getAttr())){if(this.binding.closed)return;s.FIRE(u,l.slice(5),a)}}}};function Wu(r){return Object.entries(r??{}).filter(([e,t])=>t!=null&&(e==="fire"||e.startsWith("fire_")))}function Bm(r){return["shift","ctrl","alt","meta"].filter(e=>r[`${e}Key`]).map(e=>e[0].toUpperCase()+e.slice(1)).join("")}var ei="connect_on",Rm=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)+$/,Rn=class{#e;#t;#r;#s;#n;static declared(e){return Object.entries(e.getAttr()??{}).filter(([t,n])=>t.startsWith(ei)&&t.length>ei.length&&n!=null).map(([t,n])=>[t,t.slice(ei.length).toLowerCase(),n])}constructor(e,t,n,s,i=`${ei}${n}`){this.#e=e,this.#t=t,this.#r=n,this.#s=s,this.#n=i}get binding(){return this.#e}get node(){return this.binding.node}get element(){return this.#t.element}get eventName(){return this.#r}get handler(){return this.#s}get attribute(){return this.#n}attach(){this.element.addEventListener(this.eventName,this)}detach(){this.element.removeEventListener(this.eventName,this)}handleEvent(e){if(this.binding.closed)return;let t=this.node,n=this.binding.runtime;if(Rm.test(this.handler)){let{group:s,method:i}=n.logicRegistry.resolve(this.handler,t);i.call(s,t,e);return}n.inlineCompiler.compile(t,this.attribute,this.handler,["event"])({event:e})}};function xt(r,e=new Set){if(!r||typeof r!="object")return;let t=r.ownerDocument?.defaultView?.Node??r.defaultView?.Node;if(se(r)instanceof we||t&&r instanceof t)throw new TypeError("Live Source/DOM references cannot cross a transport boundary");if(e.has(r))throw new TypeError("Transport data cannot contain circular references");e.add(r);let n=r instanceof R?r.getNodes().flatMap(s=>[s.staticValue,s.getAttr()]):Object.values(r);for(let s of n)xt(s,e);e.delete(r)}var Mn=class{constructor(e=null){this.entries=new Map,this.sourceRoot=e}validate(e,t=new Set){let n=new Map,s=i=>{for(let a of i.getNodes()){let o=a.getAttr("__ref");if(o){if(n.has(o))throw new Error("Duplicate Source reference");let l=this.entries.get(o);if(e!==this.sourceRoot&&l&&l.node!==a&&!t.has(l.node))throw new Error("Duplicate Source reference");n.set(o,a)}a.value instanceof x&&s(a.value)}};s(e)}register(e,t){let n=e.getAttr("__ref");if(n){if(this.entries.has(n))throw new Error(`Duplicate Source reference: ${n}`);this.entries.set(n,{node:e,dom:t})}}remove(e){for(let[t,n]of this.entries)n.node===e&&this.entries.delete(t)}resolveArguments(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,n&&typeof n=="object"&&Object.hasOwn(n,"$gramlotRef")?this.resolve(n):n]))}resolve(e){if(!e||!["node","dom"].includes(e.kind))throw new TypeError("Expected a node or DOM reference");let t=this.entries.get(e.$gramlotRef);if(!t)throw new Error("Source reference is not mounted");return t[e.kind]}};var ti=class{constructor(e=null,t=null){this.parent=e,this.segment=t,this.children=new Map,this.registrations=new Set}},$a=class{#e;#t;#r;#s;#n;#i=!0;#a;constructor(e,{path:t,attr:n,recipient:s,order:i,subtree:a=!1}){this.#e=e,this.#t=t,this.#r=n,this.#s=s,this.#n=i,this.#a=a}get router(){return this.#e}get path(){return this.#t}get attr(){return this.#r}get recipient(){return this.#s}get subtree(){return this.#a}get active(){return this.#i}get order(){return this.#n}close(){this.active&&(this.#i=!1,this.router.unregister(this))}},La=class{constructor({evt:e,node:t,path:n,oldvalue:s,attrsDiff:i,reason:a,fired:o,level:l,registration:u}){this.evt=e,this.node=t,this.path=n,this.oldvalue=s,this.attrsDiff=i,this.reason=a,this.fired=o,this.level=l,this.registration=u}},ri=class{#e;#t=new ti;#r=new Map;#s=0;#n=0;constructor(e){this.#e=e}get runtime(){return this.#e}get size(){return this.#s}register({path:e,attr:t=null,recipient:n,subtree:s=!1}){if(typeof e!="string"||e==="")throw new TypeError(`A Data registration requires a path: ${e}`);let i=this.#t;for(let o of e.split(".")){let l=i.children.get(o);l||(l=new ti(i,o),i.children.set(o,l)),i=l}this.#n+=1;let a=new $a(this,{path:e,attr:t,recipient:n,order:this.#n,subtree:s});return i.registrations.add(a),this.#r.set(a,i),this.#s+=1,a}unregister(e){let t=this.#r.get(e);if(t)for(this.#r.delete(e),t.registrations.delete(e),this.#s-=1;t.parent&&!t.children.size&&!t.registrations.size;)t.parent.children.delete(t.segment),t=t.parent}deliver(e){let{pathlist:t}=e;if(!t?.length||t[0]!==Tn||e.reason==="autocreate")return;let n=t.slice(1),s=e.evt==="ins"||e.evt==="del";for(let i of Array.isArray(e.node)?e.node:[e.node]){let a=s?[...n,i.label]:n,o=a.join(".");for(let[l,u]of this.#i(a,e))l.active&&l.recipient.receive(new La({evt:e.evt,node:i,path:o,oldvalue:e.oldvalue??null,attrsDiff:e.attrs_diff??null,reason:e.reason??null,fired:e.fired??!1,level:u,registration:l}))}}#i(e,t){let n=[],s=this.#t;for(let a of e){for(let o of s.registrations)s!==this.#t&&this.#a(o,"child",t)&&n.push([o,"child"]);if(s=s.children.get(a),!s)return n.sort(([o],[l])=>o.order-l.order)}for(let a of s.registrations)this.#a(a,"node",t)&&n.push([a,"node"]);let i=[...s.children.values()];for(;i.length;){let a=i.pop();for(let o of a.registrations)this.#a(o,"container",t)&&n.push([o,"container"]);i.push(...a.children.values())}return n.sort(([a],[o])=>a.order-o.order)}#a(e,t,n){let{evt:s}=n;return e.subtree?t!=="container"||s!=="upd_attrs":e.attr===null?s==="upd_attrs"?!1:!(t==="child"&&n.fired):t==="child"?!1:t==="container"?s!=="upd_attrs":s==="ins"||s==="del"?!0:Object.hasOwn(n.attrs_diff??{},e.attr)}};var ni=class{#e;constructor(e){this.#e=e}get runtime(){return this.#e}install(e){let t=$n(e),n=this.setterNodes(e);Fa(e);for(let s of n){let i=this.runtime.openBinding(s);i.hasStamp("installed")||(this.applySetter(s),i.stamp("installed"))}this.applyDefaults(t.filter(s=>s.nodeTag&&!s._getMeta("data_element")))}setterNodes(e){return $n(e).filter(t=>t.nodeTag==="dataSetter")}applySetter(e){let t=e.absDatapath(e.pathAttribute("destination_path"));if(t===null)return;let n=e.getAttr("value")??null,s=$m(e.getAttr()),i=this.runtime.data;if(n!==null)i.setItem(t,n,s,">",!1,!0,e),n instanceof R&&e.setAttr({value:null},!1);else{let a=i.getNode(t);a?s&&a.setAttr(s,!0):i.setItem(t,null,s,">",!1,!0,e)}}applyDefaults(e){for(let t of e){let n=t.getAttr();for(let[s,i]of Object.entries(n)){if(!Mm(t,s,i))continue;let a=s==="value"?n.default_value??n.default:n[`default_${s}`];a!=null&&this.#t(t,i,a)}this.#r(t,n)}}#t(e,t,n){let s=e.absDatapath(t);if(s===null)return;let[i,a=null]=s.split("?",2),o=this.runtime.data,l=o.getNode(i);if(a===null){if(l&&l.value!==null&&l.value!==void 0)return;o.setItem(i,n,null,">",!1,!0,e)}else if(l){let u=l.getAttr(a);u==null&&l.setAttr({[a]:n},!0)}else o.setItem(i,null,{[a]:n},">",!1,!0,e)}#r(e,t){let n={};for(let[a,o]of Object.entries(t))a.startsWith("attr_")&&(n[a.slice(5)]=V(o)?Dt(e,a):e.pointerType(o)?e.getRelativeData(o):o);if(!Object.keys(n).length)return;let s=[t.value,t.src].find(a=>e.pointerType(a));if(!s)return;let i=e.absDatapath(s);i!==null&&this.runtime.data.getNode(i.split("?",1)[0])?.setAttr(n,!0,!0,!1)}};function Mm(r,e,t){return e==="_meta"||jt.has(e)||e==="default"||e.startsWith("default_")||e.startsWith("attr_")||e.endsWith("_path")?!1:r.pointerType(t)!==null}function $m(r){let e={};for(let[t,n]of Object.entries(Tt(r??{})))jt.has(t)||t.startsWith("_")||t==="destination_path"||t==="value"||n!=null&&(e[t]=n);return Object.keys(e).length?e:null}function Lm(r){let e=r.builder;if(!(e instanceof qe))throw new Error(`dataSetter '${r.label}': dataSetter is not supported inside ${e.constructor._name}`)}function Fa(r){for(let e of $n(r))e.nodeTag==="dataSetter"&&Lm(e),qm(e)}var Pm=["_init","_onStart","_onBuilt","_delay","_timing","_userChanges"],Fm=new Set(["dataFormula","dataController","dataRpc","dataRemote"]),jm=["_onCalling","_onResult","_onError"],Um=["_delay","_timing","_userChanges"],Pa=["_init","_onBuilt","_onStart"];function qm(r){let e=i=>r.getAttr(i)!==null&&r.getAttr(i)!==void 0,t=!r._getMeta("data_element")&&typeof r.getAttr("remote")=="string";if(r.nodeTag!=="dataRpc"){let i=jm.find(a=>e(a)&&!(a==="_onCalling"&&(r.nodeTag==="dataRemote"||t)));if(i){let a=i==="_onCalling"?"dataRpc, dataRemote and remote":"dataRpc";throw new Error(`${r.nodeTag??"fragment"} '${r.label}': '${i}' is allowed only on ${a}`)}}if(Fm.has(r.nodeTag)){let i=Object.entries(r.getAttr()).find(([,o])=>Ue(o));if(i)throw new Error(`${r.nodeTag} '${r.label}': '${i[0]}' is a == expression, not accepted on ${r.nodeTag}`);let a=r.nodeTag==="dataRemote"?Pa.find(e):null;if(a)throw new Error(`dataRemote '${r.label}': '${a}' is not accepted on dataRemote, its resolver loads when the Data is read`);for(let o of Pa){let l=r.getAttr(o);if(!(l==null||typeof l=="boolean"||typeof l=="number"))throw new Error(`${r.nodeTag} '${r.label}': '${o}' accepts true, false, null or a number, not ${JSON.stringify(l)}`)}return}let n=Pm.find(i=>e(i)&&!(i==="_delay"&&!r._getMeta("data_element")&&r.nodeTag!=="html_button")&&!(t&&Um.includes(i)));if(!n)return;let s=Pa.includes(n)?"dataFormula, dataController and dataRpc":"dataFormula, dataController, dataRpc and dataRemote";throw new Error(`${r.nodeTag??"fragment"} '${r.label}': '${n}' is allowed only on ${s}`)}function $n(r){if(r instanceof x)return r.getNodes().flatMap(t=>$n(t));let e=[r];return r.value instanceof x&&e.push(...$n(r.value)),e}var St=class extends Z{static classKwargs={...Z.classKwargs,asBag:!1};constructor({cacheTime:e,onError:t}){super({cacheTime:e??-1}),this.onError=t,this.loading=null,this.loaded=!1,this.writing=!1}resolve({static:e=!1}={}){return!e&&!this.closed&&!this.loading&&!this.writing&&this.expired&&this.refresh(),this.cachedValue}refresh(){if(this.closed)return null;let e=this.startLoad(n=>this.#t(n));if(e===null)return null;let t=()=>{this.loading===e&&(this.loading=null)};return e.then(t,t),this.loading=e,e.catch(n=>{n?.name!=="AbortError"&&this.onError(n)}),e}resolveSync(e){return super.resolve(e)}prepareValue(e){return e}#e(){let e={...this._kw};for(let[t,n]of Object.entries(this.node?.attr??{}))this.constructor.internalParams.has(t)||(e[t]=n);return this._computeEffectiveFingerprint(e)}async#t(e){if(this.closed)return;let t=this.#e(),n=await this.loadAsync(e);if(this.closed||e.ignored)return;let s=this.prepareValue(n);this._lastUpdate=Date.now(),this._lastEffectiveFingerprint=t,this.loaded=!0,this.writing=!0;try{this.node?this.node.setValue(s,this.cacheTime!==0):this.cachedValue=s}finally{this.writing=!1}return s}};var si=class extends St{static internalParams=new Set([...St.internalParams,"binding","method","params","onCalling","onError","sync"]);constructor({binding:e,method:t,params:n,cacheTime:s,onCalling:i=null,onError:a,sync:o=!1}){super({cacheTime:s,onError:a}),this.binding=e,this.sync=o,this.method=t,this.params=n,this.onCalling=i}get closed(){return this.binding.closed}resolve(e={}){return this.sync?e.static||this.loading||this.writing?this.cachedValue:this.expired&&!this.binding.node.requests.calling(this.onCalling)?this.cachedValue:super.resolveSync(e):super.resolve(e)}load(){let e;try{e=this.binding.callSync("data",this.method,this.params)}catch(t){this.onError(t)}return this.loaded=!0,e}startLoad(e){let t=this.binding.node.requests;return t.calling(this.onCalling)?t.submit(this.method,this.params,e):null}loadAsync(e){return this.binding.call("data",e)}};var Vm=new Set(["destination_path","result_path","func","formula","script","if","else","_init","_onStart","_onBuilt","_delay","_timing","_userChanges","_ask","_ask_if","_ask_title","_ask_onCancel","method","timeout","_onCalling","_onResult","_onError","cacheTime","sync"]),Ln=class{#e;#t=null;#r=null;constructor(e){this.#e=e}get binding(){return this.#e}debounce(e,t){this.#r?.();let n=null,s=setTimeout(()=>{n(),this.#r=null,t()},e);n=this.binding.track(()=>clearTimeout(s)),this.#r=()=>{clearTimeout(s),n(),this.#r=null}}startTiming(e,t){if(this.#t?.(),!(e>0))return;let n=setInterval(t,e*1e3),s=this.binding.track(()=>clearInterval(n));this.#t=()=>{clearInterval(n),s(),this.#t=null}}cancel(){this.#r?.(),this.#t?.()}},$r=class{#e;#t=[];#r=new Set;#s;#n=null;#i=!1;constructor(e){this.#e=e,this.#s=new Ln(e),e.track(()=>{this.cancel(),this.#m(),this.#p()})}get binding(){return this.#e}get node(){return this.binding.node}get kind(){throw new Error("Provider.kind is defined by FormulaProvider, ControllerProvider, RpcProvider and RemoteProvider")}register(){let e=this.node,t=e.getAttr("_onStart");if(typeof t=="number"&&!(Number.isFinite(t)&&t>=0))throw new Error(`${e.nodeTag} '${e.label}': _onStart must be true or a delay in ms not below 0: ${t}`);this.#m();let n=this.binding.runtime.router,s=Ve(e,e.getAttr("_timing"));for(let[i,a]of e.pointers()){if(i==="datapath")continue;let o=e.absDatapath(a);if(o===null)continue;let[l,u=null]=o.split("?",2),c=n.register({path:l,attr:u,recipient:this});this.#t.push(c),(i==="_timing"||s.has(i))&&this.#r.add(c)}this.#t.push(...this.binding.runtime.subscriptions.subscribeNode(e,(i,a,o)=>l=>{let u={kind:"subscription",topic:o,payload:l};if(this.#o("_userChanges")&&o!=="node")return;let c=this.#o("_delay");c>0?this.#s.debounce(c,()=>this.invoke(u)):this.invoke(u)})),this.#a(),this.kind==="remote"&&this.invoke({kind:"install",change:null})}receive(e){if(this.#r.has(e.registration)){this.#a();return}if(this.#o("_userChanges")&&e.level!=="node")return;let t={kind:"data",change:e},n=this.#o("_delay");n>0?this.#s.debounce(n,()=>this.invoke(t)):this.invoke(t)}invoke(e){if(this.binding.closed)return;let t=this.node,n=this.kind==="formula",s=this.kind==="rpc",i=this.kind==="remote",a=this.readArguments(e);e.askResult&&(Object.assign(a,e.askResult),a._askResult=e.askResult);let o=t.getAttr("_ask"),l=this.binding.runtime.askDialog;if(o&&!e.askDone&&l.required(this.binding,o,a,"_ask"))return l.show(this.binding,o,a,t.getAttr("_ask_title")??"Warning").then(p=>{if(!this.binding.closed){if(p===null){let m=t.getAttr("_ask_onCancel");m&&this.#l("_ask_onCancel",m,m,a,!0);return}return this.invoke({...e,askDone:!0,askResult:p})}});let[u,c]=[n?"formula":"script",t.getAttr(n?"formula":"script")],d=t.getAttr("_if");if(d&&!this.#l("_if",d,`return (${d})`,a,!1)){if(i&&this.#p(),[u,c]=["_else",t.getAttr("_else")],!c)return;if(s||i){this.#l(u,c,c,a,!0);return}}if(s)return this.#f(a);if(i)return this.#u(a);let f=t.getAttr("func"),h;if(c)h=this.#l(u,c,n?`return ${c}`:c,a,!0);else if(f==null){if(!n)return;h=new R(ii(a))}else{let{group:p,method:m}=this.binding.runtime.logicRegistry.resolve(f,t);h=n?m.call(p,a):m.call(p,t,a)}n&&t.setRelativeData(t.pathAttribute("result_path"),h)}readArguments(e){let t=this.node,[,n]=t.rootBuilder.runtimeValues(t),s=Object.fromEntries(Object.entries(n).filter(([l])=>!Vm.has(l)&&!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),i={...e.kind==="subscription"?e.payload:{},...this.binding.runtime.renderer.references.resolveArguments(s)};e.kind==="subscription"&&(i._subscription_kwargs=e.payload);let a=e.change??null,o=a?a.level:e.kind==="subscription"?e.topic:e.kind;return i._node=a?a.node:null,i._triggerpars={kw:a,trigger_reason:o},i._reason=o,e.kind==="click"&&Object.assign(i,zm(e)),i}cancel(){this.#s.cancel()}#a(){this.#s.startTiming(this.#o("_timing"),()=>this.invoke({kind:"timing",change:null}))}#o(e){let t=this.node,n=t.getAttr(e);return V(n)?Dt(t,e):t.pointerType(n)?t.getRelativeData(n):n??null}#l(e,t,n,s,i){let a=[...i?["_kwargs"]:[],...Gu,...Xu,...Object.keys(ii(s))];return this.binding.runtime.inlineCompiler.compile(this.node,e,t,a,n)({...s,_kwargs:s})}async#f(e){let t=this.node,[n,s,i]=["_onCalling","_onResult","_onError"].map(o=>t.getAttr(o)),a=t.requests;if(a.calling(n?()=>this.#l("_onCalling",n,n,e,!0):null))return a.submit(this.#o("method"),ii(e),o=>this.#h(o,e,s,i))}async#h(e,t,n,s){if(this.binding.closed)return;let i=this.node,a=this.#o("timeout"),o=a>0?setTimeout(()=>{let c=new Error(`${i.nodeTag} '${i.label}': no answer within ${a} ms`);c.name="TimeoutError",e.controller.abort(c)},a):null,l;try{l={result:await this.binding.call("data",e)}}catch(c){l={error:c}}if(clearTimeout(o),this.binding.closed||e.ignored)return;if("error"in l){if(!s)throw l.error;this.#l("_onError",s,s,{...t,error:l.error},!0);return}let{result:u}=l;i.getAttr("result_path")!=null&&i.setRelativeData(i.pathAttribute("result_path"),u),n&&this.#l("_onResult",n,n,{...t,result:u},!0)}#u(e){this.#p();let t=this.#i;this.#i=!1;let n=this.node,s=n.absDatapath(n.pathAttribute("destination_path"));if(s===null)return;let i=n.getAttr("_onCalling"),a=new si({binding:this.binding,method:this.#o("method"),params:ii(e),cacheTime:this.#o("cacheTime"),sync:this.#o("sync")!==!1&&this.binding.runtime.gramlot.rpc.supportsCallSync,onCalling:i?()=>this.#l("_onCalling",i,i,e,!0):null,onError:o=>{throw new Error(`${n.nodeTag} '${n.label}': dataRemote '${a.method}' failed: ${o.message}`,{cause:o})}});this.binding.runtime.data.setResolver(s,a),this.#n={path:s,resolver:a},t&&a.refresh()}#p(){if(!this.#n)return;let{path:e,resolver:t}=this.#n;this.#n=null,this.#i=t.loaded||t.loading!==null;let n=this.binding.runtime.data.getNode(e);n?.resolver===t&&(n.resolver=null)}#m(){for(let e of this.#t.splice(0))e.close();this.#r.clear()}},ai=class extends $r{get kind(){return"formula"}},oi=class extends $r{get kind(){return"controller"}},li=class extends $r{get kind(){return"rpc"}},ui=class extends $r{get kind(){return"remote"}},Gu=["_node","_triggerpars","_reason","_subscription_kwargs","_askResult"],Xu=["_evt","button_counter","button_shift","button_ctrl","button_alt","button_meta"];function ii(r){let e={...r};for(let t of[...Gu,...Xu])delete e[t];return e}function zm({event:r,counter:e}){return{_evt:r,button_counter:e,button_shift:!!r.shiftKey,button_ctrl:!!r.ctrlKey,button_alt:!!r.altKey,button_meta:!!r.metaKey}}var Hm=[[null,/(\W|^)GET (?:\s*)(\^?[\w.#@$?-]+)/g,"$1this.GET('$2')"],[/;SET/g,/(\W|^)SET (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)=(?:\s*)([^;\r\n]*)(;?)/gm,"$1this.SET('$2', $3)$4 "],[/;PUT/g,/(\W|^)PUT (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)=(?:\s*)([^;\r\n]*)(;?)/gm,"$1this.PUT('$2', $3)$4 "],[/;FIRE_AFTER/g,/(\W|^)FIRE_AFTER (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)=(?:\s*)([^;\r\n]*)(;?)/g,"$1this.FIRE_AFTER('$2', $3)$4 "],[/;FIRE_AFTER/g,/(\W|^)FIRE_AFTER (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)(;?)/g,"$1this.FIRE_AFTER('$2')$3 "],[/;FIRE/g,/(\W|^)FIRE (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)=(?:\s*)([^;\r\n]*)(;?)/g,"$1this.FIRE('$2', $3)$4 "],[/;FIRE/g,/(\W|^)FIRE (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)(;?)/g,"$1this.FIRE('$2')$3 "]],Wm=/(\W|^)PUBLISH (?:\s*)(\^?[\w.#@$?-]+)/,Gm=new Set(["arguments","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","eval","export","extends","false","finally","for","function","if","implements","import","in","instanceof","interface","let","new","null","package","private","protected","public","return","static","super","switch","this","throw","true","try","typeof","var","void","while","with","yield"]),ci=class{#e;#t=new Map;constructor(e){this.#e=e}get runtime(){return this.#e}get size(){return[...this.#t.values()].reduce((e,t)=>e+t.size,0)}preprocess(e,t,n){let s=n.trim();if(Wm.test(s))throw new Error(`${Pn(e,t)}: the PUBLISH macro is excluded from Gramlot`);let i=s.replace(/\$(\d+)/g,(a,o)=>`arguments[${parseInt(o,10)-1}]`);for(let[a,o,l]of Hm)a&&(i=i.replace(a,`; ${a.source.slice(1)}`)),i=i.replace(o,l);return i!==s&&console.warn(`${Pn(e,t)}: legacy macros are deprecated; write this.GET(path), this.SET(path, value), this.PUT(path, value), this.FIRE(path, value), this.FIRE_AFTER(path, value) and arguments[n] in place of GET, SET, PUT, FIRE, FIRE_AFTER and $n`),i}compile(e,t,n,s,i=n){if(e.activatedCode(t)!==n)throw new Error(`${Pn(e,t)}: inline code runs only as received with the Source (main or a remote Source); a text written later is not run: use named logic`);let a=this.#t.get(e);a||(a=new Map,this.#t.set(e,a),this.runtime.bindingFor(e).track(()=>this.release(e)));let o=a.get(t);o?.source!==i&&(o={source:i,text:this.preprocess(e,t,i),key:null,run:null},a.set(t,o));let l=s.filter(Xm),u=l.join(",");if(o.key!==u){let c=Ym(e,t,o.text,l);o.key=u,o.run=d=>c.apply(e,l.map(f=>d[f]))}return o.run}compileExpression(e,t,n){let s=n.slice(2).trim(),i=ge(e.getAttr()).filter(([,o])=>!Ue(o)),a=this.compile(e,t,n,[...i.map(([o])=>o).filter(o=>o!=="_F"),"_F"],`return ${s}`);return o=>{let l={};for(let[u,c]of i)Object.hasOwn(o,u)?l[u]=o[u]:l[u]=e.pointerType(c)?e.getRelativeData(c):c;return a({...l,_F:(u,c)=>this.runtime.gramlot.format(u,c)})}}compilePointerExpression(e,t,n,s){let i=this.compile(e,t,n,["_pointerValues","_F"],`return (${s}
59
- )`);return a=>i({_pointerValues:a,_F:(o,l)=>this.runtime.gramlot.format(o,l)})}release(e,t=null){if(t===null){this.#t.delete(e);return}let n=this.#t.get(e);if(n)for(let s of t){n.delete(s);for(let[i]of ge({[s]:null}))n.delete(i)}}};function Xm(r){return/^[A-Za-z_$][\w$]*$/.test(r)&&!Gm.has(r)}function Pn(r,e){return`${r.nodeTag} '${r.label}' ${e?`'${e}'`:"node value"}`}function Ym(r,e,t,n){try{return t.startsWith("function")?new Function(`return (${t}
60
+ :host([role=separator]) button{display:none}`,this.shadowRoot.append(t)}get disabled(){return this.control.disabled}set disabled(e){this.control.disabled=!!e}projectAttributes(e,t){let n=super.projectAttributes(e,t);return this.control.disabled=!!this.parameters.disabled,this.control.readOnly=!!this.parameters.readonly,this.icon.textContent=this.parameters.icon??"",e["aria-label"]!=null?this.control.setAttribute("aria-label",e["aria-label"]):this.control.removeAttribute("aria-label"),n}attachCommand(){}releaseCommand(){}commandTarget(){return this}prepareCommand(){return!this.disabled}}}In.parameters={disabled:{dtype:"B",default:!1,binding:"read"},icon:{dtype:"T",default:"",binding:"read"}};var dm=Rr({name:"button",tag:"gramlot-button",base:In,command:!0,subTags:"*",implementation:r=>class extends r{}}),fm=Rr({name:"toggleButton",tag:"gramlot-toggle-button",base:In,command:!0,subTags:"*",parameters:{value:{dtype:"B",default:!1,binding:"twoWay"},readonly:{dtype:"B",default:!1,binding:"read"}},implementation:r=>class extends r{#e=!1;constructor(){super();let e=this.ownerDocument.createElement("span");e.className="led",e.setAttribute("aria-hidden","true"),this.control.prepend(e),this.writeControlValue(!1)}get commitOnChange(){return!0}readControlValue(){return this.#e}writeControlValue(e){this.#e=e,this.control.setAttribute("aria-pressed",String(e))}prepareCommand(e){return!super.prepareCommand(e)||this.control.readOnly?!1:(this.writeControlValue(!this.#e),this.control.dispatchEvent(new this.ownerDocument.defaultView.Event("change")),!0)}}});function hm(r){return class extends r{constructor(){super(),this.attachShadow({mode:"open"}).append(this.ownerDocument.createElement("slot"))}connectedCallback(){this.slot="menu",this.setAttribute("role","menu")}projectAttributes(e){return Ys(this,e)}}}var pm=Rr({name:"menu",tag:"gramlot-menu",base:hm,subTags:"menuline",implementation:r=>class extends r{}}),mm=Rr({name:"menuline",tag:"gramlot-menu-line",base:In,command:!0,subTags:"*",parameters:{code:{dtype:"T",nullable:!0}},implementation:r=>class extends r{attachCommand(){let e=this.textContent.trim()==="-";if(!e&&!this.parameters.code)throw new TypeError("menuline requires a stable code");this.setAttribute("role",e?"separator":"menuitem"),this.control.tabIndex=-1,this.disabled||=e}get disabled(){return super.disabled||!!this.closest("gramlot-drop-down-button")?.parameters.disabled}set disabled(e){super.disabled=e}prepareCommand(e){return super.prepareCommand(e)?(this.closest("gramlot-drop-down-button").selectCommand(this,e.shiftKey),!0):!1}}}),gm=Rr({name:"dropDownButton",tag:"gramlot-drop-down-button",base:In,command:!0,subTags:"*",parameters:{persist:{dtype:"B",default:!1}},implementation:r=>class extends r{#e=null;#t=null;#r=null;#s=null;#n;#i;#o;constructor(){super();let e=this.ownerDocument;this.control.classList.add("split"),this.#o=e.createElement("span"),this.#o.hidden=!0,this.control.append(this.#o),this.#i=e.createElement("button"),this.#i.type="button",this.#i.className="arrow",this.#i.textContent="\u25BE",this.#i.setAttribute("aria-label","Open menu"),this.#i.setAttribute("aria-haspopup","menu"),this.#i.setAttribute("aria-expanded","false"),this.controlBox.append(this.#i),this.#n=e.createElement("div"),this.#n.className="popup",this.#n.id="menu",this.#n.setAttribute("popover","auto"),this.#i.setAttribute("aria-controls","menu");let t=e.createElement("slot");t.name="menu",this.#n.append(t),this.shadowRoot.append(this.#n),this.#i.addEventListener("click",n=>{n.stopPropagation(),this.#n.matches(":popover-open")?this.closeMenu():this.openMenu()}),this.#i.addEventListener("keydown",n=>{(n.key==="ArrowDown"||n.key==="ArrowUp")&&(n.preventDefault(),this.openMenu(n.key==="ArrowUp"))}),this.addEventListener("keydown",n=>{if(!this.#n.matches(":popover-open"))return;let s=this.menuItems.filter(a=>!a.disabled),i=s.indexOf(n.composedPath().find(a=>s.includes(a))),o;n.key==="ArrowDown"&&(o=(i+1)%s.length),n.key==="ArrowUp"&&(o=(i-1+s.length)%s.length),n.key==="Home"&&(o=0),n.key==="End"&&(o=s.length-1),o!==void 0&&(n.preventDefault(),s[o]?.focus()),(n.key==="Escape"||n.key==="Tab")&&(n.key==="Escape"&&n.preventDefault(),this.closeMenu())}),this.#n.addEventListener("toggle",()=>{let n=this.#n.matches(":popover-open");this.#i.setAttribute("aria-expanded",String(n)),n||(this.#r?.abort(),this.#r=null)})}get menuItems(){return[...this.querySelectorAll(":scope > gramlot-menu > gramlot-menu-line")]}projectAttributes(e,t){let n=super.projectAttributes(e,t);return this.#i.disabled=this.disabled,this.disabled&&this.#n.matches(":popover-open")&&this.closeMenu(),this.#a(),n}attachCommand(){if(this.parameters.persist){if(!this.id)throw new TypeError("dropDownButton persist requires an explicit id");this.#s=`gramlot:command:${this.ownerDocument.location.pathname}${this.ownerDocument.location.search}:${this.id}`;try{this.#e=this.ownerDocument.defaultView.localStorage.getItem(this.#s)}catch{}}this.#a(),this.#t=new this.ownerDocument.defaultView.MutationObserver(()=>this.#a()),this.#t.observe(this,{childList:!0,subtree:!0,characterData:!0})}releaseCommand(){this.#t?.disconnect(),this.#t=null,this.#r?.abort(),this.#r=null,this.#n.matches(":popover-open")&&this.#n.hidePopover()}commandTarget(e){return e?.composedPath().includes(this.#n)?null:this.menuItems.find(t=>t.parameters.code===this.#e)??this}selectCommand(e,t){if(t){if(this.#e=e.parameters.code,this.#s)try{this.ownerDocument.defaultView.localStorage.setItem(this.#s,this.#e)}catch{}this.#a()}this.closeMenu()}#a(){let e=this.menuItems.filter(s=>s.parameters.code).map(s=>s.parameters.code);if(new Set(e).size!==e.length)throw new TypeError("Dropdown menu codes must be unique");let t=this.commandTarget(),n=t!==this;this.caption.hidden=n,this.#o.hidden=!n,this.#o.textContent=n?t.textContent:"",this.icon.textContent=n?t.parameters.icon:this.parameters.icon}openMenu(e=!1){if(this.disabled)return;let t=this.menuItems.filter(i=>!i.disabled);if(!t.length)return;this.#n.showPopover(),this.#i.setAttribute("aria-expanded","true");let n=()=>Uu(this.#n,this.controlBox);n(),this.#r?.abort(),this.#r=new this.ownerDocument.defaultView.AbortController;let s={signal:this.#r.signal,capture:!0};this.ownerDocument.defaultView.addEventListener("resize",n,s),this.ownerDocument.addEventListener("scroll",n,s),t[e?t.length-1:0].focus()}closeMenu(){this.#n.matches(":popover-open")&&(this.#n.hidePopover(),this.#i.setAttribute("aria-expanded","false"),this.#r?.abort(),this.#r=null,this.#i.focus())}}}),Js=Fu({name:"buttons",components:[dm,fm,gm,pm,mm]});function qu(r){if(r!=null&&(typeof r!="string"||/[{}]/.test(r.replaceAll("{}",""))))throw new RangeError("This formatter mask supports only {} placeholders")}function Qs(r,e){return qu(e),e==null?r:e.replaceAll("{}",()=>r)}function bm(r){if(r instanceof Date)return vt(r);if(fe(r))return"N";if(typeof r=="number")return Number.isInteger(r)?"L":"R";throw new TypeError("Formatting requires finite JavaScript numbers, TYTX Decimal values or valid Date objects")}function _m(r,e,{pattern:t="short",locale:n,timeZone:s}){if(!["short","medium","long","full"].includes(t))throw new RangeError("Temporal formatting currently supports short, medium, long and full only");if(e==="DHZ"&&(typeof s!="string"||!s))throw new TypeError("DHZ formatting currently requires an explicit timeZone");let i={timeZone:e==="DHZ"?s:"UTC"};return e!=="H"&&(i.dateStyle=t),e!=="D"&&(i.timeStyle=t),new Intl.DateTimeFormat(n,i).format(r)}function Ks(r){let e=/^(-|\()?(#,##0|0+)(?:\.(0*#*))?(\))?$/.exec(r);if(!e||e[1]==="("!=(e[4]===")")||r.endsWith("."))throw new RangeError(`Unsupported numeric pattern section: ${r}`);let t=e[3]??"";return{prefix:e[1]??"",suffix:e[4]??"",intl:{useGrouping:e[2].startsWith("#,##")?"always":!1,minimumIntegerDigits:e[2].replace("#,##","").length,minimumFractionDigits:t.replaceAll("#","").length,maximumFractionDigits:t.length}}}function wm(r){let e=r.split(";");if(e.length>3)throw new RangeError("Numeric patterns support at most three sections");let t=Ks(e[0]);if(t.prefix||t.suffix)throw new RangeError("Positive-section affixes are not implemented");let n=e.length===3?e[1]:null;n!==null&&n!==""&&n!=="-"&&Ks(n);let s=e.length>1?Ks(e.at(-1)):null;return{positive:t,zero:n,negative:s}}function Vu(r,e={},t={}){if(r===null)return"";if(typeof e=="string"&&(e={pattern:e}),!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Format options must be a pattern string or an options object");for(let g of Object.keys(e))if(!["pattern","locale","mask","dtype","timeZone"].includes(g))throw new RangeError(`Unsupported format option: ${g}`);e={...e,locale:e.locale??t.locale,timeZone:e.timeZone??t.timeZone};let n=e.dtype===void 0?bm(r):e.dtype,s=["D","H","DHZ"].includes(n);if(!s&&!["L","R","N"].includes(n))throw new RangeError(`Unsupported format dtype: ${n}`);if(s){if(!(r instanceof Date)||!Number.isFinite(r.getTime()))throw new TypeError(`${n} requires a valid Date object`)}else if(!(typeof r=="number"&&Number.isFinite(r))&&!(fe(r)&&!["NaN","Infinity","-Infinity"].includes(r.toString())))throw new TypeError(`${n} formatting requires finite JavaScript numbers or TYTX Decimal values`);if(n==="L"&&!Number.isInteger(r))throw new TypeError("L formatting requires an integer");let{pattern:i,locale:o,mask:a}=e;if(!s&&typeof i!="string")throw new TypeError("Numeric formatting currently requires an explicit pattern");if(typeof o!="string"||!o)throw new TypeError("Formatting currently requires an explicit locale");if(!(s?Intl.DateTimeFormat:Intl.NumberFormat).supportedLocalesOf([o]).length)throw new RangeError(`Unsupported format locale: ${o}`);if(qu(a),s){let g=_m(r,n,e);return Qs(g,a)}let{positive:u,zero:c,negative:d}=wm(i),f=fe(r),h=f?r.eq(0):r===0,p=f?r.lt(0):r<0;if(f&&new Intl.NumberFormat("en",{useGrouping:!1}).format("9007199254740993")!=="9007199254740993")throw new Error("This browser cannot format Decimal without precision loss");let m;if(h&&c!==null){if(c==="")return"";if(c==="-")m="-";else{let g=Ks(c);m=g.prefix+new Intl.NumberFormat(o,g.intl).format(0)+g.suffix}}else{let g=p&&d?d:u,b=f?(p&&d?r.abs():r).toString():p&&d?-r:r===0?0:r;m=g.prefix+new Intl.NumberFormat(o,u.intl).format(b)+g.suffix}return Qs(m,a)}var Ue="http://www.w3.org/1999/xhtml",On="http://www.w3.org/2000/svg",ym=new Set(["default","default_value","live","group","visible","action","fire","ask","_ask","_ask_if","_ask_title","_ask_onCancel","if","else","_init","_onStart","_onBuilt","_delay","_timing","_userChanges","remote","_cachedRemote","_onRemote","_onCalling","onClose","onDrag","onDrop","dropTargetCb","onDragEnd","dropTarget","dropTypes","dragTags","dropTags","effectAllowed","dropEffect","dragClass"]),vm=["default_","attr_","fire_","connect_on","subscribe_","selfsubscribe_","formsubscribe_","remote_"],Em={table:["width","border"],editor:["height"],embed:["width","height"],img:["width","height"],canvas:["width","height"]},km=["format","mask","locale","timeZone","places","dtype"],Am=new Set(["href","src","action","formaction","xlink:href","xlink_href"]);function Dt(r){return Object.fromEntries(Object.entries(r).filter(([e,t])=>!(t&&typeof t=="object"&&Object.hasOwn(t,"$gramlotRef"))&&!ym.has(e)&&!vm.some(n=>e.startsWith(n))))}function $r(r,e,t=[]){for(let[n,s]of Object.entries(e)){let i=t.find(a=>n.startsWith(a))??"",o=n.slice(i.length);if(["style","class","_class"].includes(o)&&s!=null&&typeof s!="string")throw new TypeError(`${r.nodeTag} '${r.label}': '${n}' must be a string or null`)}}function Lr(r,e,t=[]){if(r.nodeTag==="script"){let n=[["",r.staticValue],...he(r.getAttr()).filter(([s])=>["src","href","xlink:href","xlink_href","_text"].includes(s.slice((t.find(i=>s.startsWith(i))??"").length).toLowerCase()))];for(let[s,i]of n)if(r.pointerType(i)||Me(i))throw new Error(`script '${r.label}': '${s}' must be literal Source; script code and URLs cannot come from Data`)}if(e.onClose!=null&&!r.parentNode?._getMeta("gramlot_component")?.childParameters?.onClose)throw new Error("onClose is only supported on a tab/stack panel");for(let[n,s]of Object.entries(Pr(Dt(e)))){let i=t.find(a=>n.startsWith(a)),o=i?n.slice(i.length):n;if(/^on./i.test(o))throw new Error(`${r.nodeTag} '${r.label}': '${n}' has the form of a native event handler, run by the browser outside Gramlot; write connect_${o} for an event, or rename the attribute`);if(Am.has(o.toLowerCase())&&Tm(s))throw new Error(`${r.nodeTag} '${r.label}': '${n}' holds a javascript: URL, run by the browser as code; write connect_onclick or the action of a button instead`)}}function Tm(r){return typeof r=="string"&&/^javascript:/i.test(r.replace(/[\t\n\r]/g,"").replace(/^[\u0000-\u0020]+/,""))}function Hu(r,e,t=[]){if(r.nodeTag!=="iframe")return e;let n=a=>{let l=t.find(u=>a.startsWith(u))??"";return[l,a.slice(l.length).toLowerCase()]},s=Object.fromEntries(he(r.getAttr())),i=[...Object.keys(s),...Object.keys(e)].find(a=>n(a)[1]==="srcdoc");if(i===void 0||Object.keys(s).some(a=>n(a)[1]==="sandbox")||r.pointerType(r.value)===null&&!(Object.hasOwn(s,i)&&(r.pointerType(s[i])!==null||Me(s[i]))))return e;let o=Object.fromEntries(Object.entries(e).filter(([a])=>n(a)[1]!=="sandbox"));return{[`${n(i)[0]}sandbox`]:"",...o}}function Pr(r){return Object.fromEntries(Object.entries(r).filter(([,e])=>e!=null))}function Bn(r){return Object.fromEntries(Object.entries(r).map(([e,t])=>e.startsWith("xmlns_")?[`xmlns:${e.slice(6)}`,t]:e.startsWith("data_")||e.startsWith("aria_")?[e.replaceAll("_","-"),t]:[e,t]))}function ei(r){let{_meta:e,...t}=r;return Bn(Pr(Dt(t)))}function zu(r,e){let t=Em[String(r).toLowerCase()]??[],n={},s={};for(let[i,o]of Object.entries(e))t.includes(i)?s[i]=o:n[i]=o;return[n,s]}function Mr(r){return String(r)}function Rn(r,e,t=null){let n={...e},{mask:s,format:i,locale:o,timeZone:a,dtype:l,places:u}=n;for(let d of km)delete n[d];let c=d=>{if(t&&i!=null){if(u!=null)throw new RangeError("places is not implemented; specify precision in format");return t(d,{pattern:i,mask:s,...o==null?{}:{locale:o},...a==null?{}:{timeZone:a},...l==null?{}:{dtype:l}})}if(typeof d=="boolean"&&(d=Mr(d)),s==null)return d;let f=d==null?"":Mr(d);return f===""?f:Qs(f,s)};return Array.isArray(r)?(Object.hasOwn(n,"_text")&&(n._text=c(n._text)),[r,n]):[c(r),n]}function Me(r){return typeof r=="string"&&r.startsWith("==")}function xm(r,e,t=r){let n=new Map,s=new Set,i=new Map;for(let[a,l]of e){if(typeof a!="string")continue;let u=V(l)?.pointer??l;i.set(a,u instanceof Z?u.resolve():r.pointerType(u)?t.getRelativeData(u):Me(u)?null:u)}let o=a=>{if(n.has(a))return n.get(a);if(!e.has(a))throw new Error(`Source attribute '${a}' does not exist`);if(s.has(a))throw new Error(`cyclic attribute dependency: ${[...s,a].join(" -> ")}`);s.add(a);let l=e.get(a),u=V(l),c=u?i.get(a):null,d,f=h=>h?o(h):c;try{if(u)if(u.expression){let h=zr(u.body),p=h.slots.map(f);d=r.rootBuilder.evaluatePointerExpression(r,a,l,h,p)}else d=Hr(u.body,f),c==null&&(d=null);else d=i.get(a);return n.set(a,d),d}finally{s.delete(a)}};return{resolve:o}}function St(r,e,t=r){let n=new Map([...Object.entries(r.getAttr()),...he(r.getAttr())]);return xm(r,n,t).resolve(e)}var Dm={dataFormula:["formula","_if","_else","_ask_if","_ask_onCancel"],dataController:["script","_if","_else","_ask_if","_ask_onCancel"],dataRpc:["_ask_if","_ask_onCancel","_if","_else","_onCalling","_onResult","_onError"],dataRemote:["_if","_else","_onCalling"]},Po=["_cachedRemote","_if","_else","_onRemote","_onCalling","_delay","_timing","_userChanges"],Sm=["_if","_else","_onRemote","_onCalling"],Fo=class{#e;#t=null;#r=null;#s=!1;constructor(e){this.#e=e}get inflight(){return this.#t?.view??null}get pending(){let e=this.#r;return e?Object.freeze({method:e.method,get params(){return P(e.text)}}):null}calling(e){if(!e)return!0;let t=!1,n=this.#s;this.#s=!0;try{t=e()!==!1}finally{this.#s=n,!t&&!this.#t&&this.#n()}return t}submit(e,t,n){try{let s=W(t);return this.#t?this.#r?Promise.resolve(void 0):new Promise((i,o)=>{this.#r={method:e,text:s,perform:n,resolve:i,reject:o}}):(this.#r?.resolve(void 0),this.#r=null,this.#i(e,t,s,n))}catch(s){return Promise.reject(s)}}submitSync(e,t){if(this.#t)throw new Error("A synchronous call cannot start while a request of the node is in flight");if(!this.#e.matches(e))throw new TypeError(`Method name must match ${this.#e.pattern}, not ${JSON.stringify(e)}`);return t()}#n(){let e=this.#r;if(!e)return;this.#r=null;let t;try{t=this.#i(e.method,P(e.text),e.text,e.perform)}catch(n){t=Promise.reject(n)}t.then(e.resolve,e.reject)}#i(e,t,n,s){if(!this.#e.matches(e))return Promise.reject(new TypeError(`Method name must match ${this.#e.pattern}, not ${JSON.stringify(e)}`));let i=new AbortController,o={method:e,params:t,text:n,controller:i,ignored:!1};o.view=Object.freeze({method:e,get params(){return P(n)},sentAt:Date.now(),cancel:()=>this.#a(o)}),this.#t=o,i.signal.addEventListener("abort",()=>this.#o(o),{once:!0});let a;try{a=Promise.resolve(s(o))}catch(l){a=Promise.reject(l)}return a.then(()=>this.#o(o),()=>this.#o(o)),a}#o(e){this.#t===e&&(this.#t=null,this.#n())}#a(e){this.#t===e&&(e.ignored=!0,this.#t=null,this.#s||this.#n())}};function Wu(r){return typeof r=="string"&&r.startsWith("==")}var Jt=class extends we{#e=new Set;#t=null;#r=null;get requests(){return this.#r??=new Fo(this.rootBuilder.nameSyntax)}codeAttributes(){let e=[...Dm[this.nodeTag]??[],...Object.entries(this.parentNode?._getMeta("gramlot_component")?.childParameters??{}).filter(([,n])=>n.inline).map(([n])=>n),...this._getMeta("gramlot_component")?.command?["action","_ask_if"]:[],...typeof this.getAttr("remote")=="string"?Sm:[]],t=[];for(let[n,s]of Object.entries(this.getAttr()??{}))typeof s=="string"&&(e.includes(n)||n==="validate_call"||n==="validate__onResult"||n==="validate_onAccept"||n==="validate_onReject"||/^validate_\w+_if$/.test(n)||n.startsWith("connect_on")||n.startsWith("subscribe_")||n.startsWith("selfsubscribe_"))&&t.push([n,s]);for(let n of["ask","_ask"]){let s=this.getAttr(n);if(s&&typeof s=="object")for(let i of["_if","askIf"])typeof s[i]=="string"&&t.push([`${n}.${i}`,s[i]])}for(let[n,s]of he(this.getAttr()))if(Wu(s)&&t.push([n,s]),this.nodeTag==="script"&&typeof s=="string"){let i=this.builder.constructor.dialectPrefixes.find(o=>n.startsWith(o))??"";["src","href","xlink:href","xlink_href","_text"].includes(n.slice(i.length).toLowerCase())&&t.push([n,s])}return(Wu(this.staticValue)||this.nodeTag==="script"&&typeof this.staticValue=="string")&&t.push(["",this.staticValue]),t}activateCode(){let e=new Map;for(let[t,n]of this.codeAttributes()){if(this.pointerType(n))throw new Error(`${this.nodeTag} '${this.label}': '${t}' is inline code and cannot be the pointer '${n}'; inline code is never read from Data`);e.set(t,n)}for(let[t,n]of[...he(this.getAttr()),["datapath",this.getAttr("datapath")]])V(n)?.expression&&e.set(t,n);this.#t=e}activatedCode(e){return this.#t?.get(e)??null}remote(e,t={}){let n=this.rootBuilder.nameSyntax;if(typeof e!="string"||!(this.pointerType(e)||n.matches(e)))throw new TypeError(`${this.nodeTag} '${this.label}': remote name must be a pointer or match ${n.pattern}, not ${JSON.stringify(e)}`);let s=Object.keys(t).find(o=>o.startsWith("_")&&!Po.includes(o));if(s)throw new TypeError(`${this.nodeTag} '${this.label}': remote parameter '${s}' is not accepted; the control attributes are ${Po.join(", ")}`);let i={remote:e};for(let[o,a]of Object.entries(t))i[Po.includes(o)?o:`remote_${o}`]=a;return this.setAttr(i),Tn(this)}publish(e,t={}){return this.rootBuilder.binding.subscriptions.publishNode(this,e,t)}pointers(){let e=this.getAttr("datapath"),t=V(e)?He(this,e):new Set,n=super.pointers().filter(([s,i])=>!t.has(s)&&!this.#i(s,i)).map(([s,i])=>[s,V(i)?.pointer??i]);for(let s of t){let i=this.getAttr(s);this.pointerType(i)==="^"&&n.push(["datapath",V(i)?.pointer??i])}return n}runtimeToEvaluate(){let e=super.runtimeToEvaluate();for(let[t,n]of e)if(this.pointerType(n)){if(V(n)){if(typeof t!="string")throw new Error(`${this.nodeTag} '${this.label}': pointer suffixes belong to attributes; use format/mask for node text`);this.absDatapath(n)===null&&e.set(t,new jt(()=>St(this,t)));continue}this.#i(t,n)?e.set(t,n.slice(1)):this.absDatapath(n)===null&&e.set(t,null)}return e}pathAttribute(e){let t=this.getAttr(e);return V(t)?St(this,e):this.pointerType(t)&&this.#i(e,t)?t.slice(1):t}getRelativeData(e,t=null,n={}){return this.absDatapath(e)===null?null:super.getRelativeData(e,t,n)}setRelativeData(e,t,n={}){this.#o(e),super.setRelativeData(e,t,n)}PUT(e,t){this.#o(e),this.data.setItem(this.absDatapath(e),t,null,">",!1,!0,this,!1,!1)}FIRE(e,t=!0,n=null){t===null&&(t=!0),this.#o(e);let s=this.absDatapath(e);if(s.includes("?")){this.#s(s,t);return}this.data.getNode(s)?.setValue(null,!1);try{this.fireEvent(e,t,{attributes:n})}finally{this.data.getNode(s)?.setValue(null,!1)}}#s(e,t){let[n,s]=e.split("?",2),i=this.data;i.getNode(n)?.setAttr({[s]:null},!1);try{let o=i.getNode(n);o?o.setValue(o.staticValue,!0,{[s]:t},!0,!0,!0,!0):i.setItem(n,null,{[s]:t},">",!0,!0,!0,!0)}finally{i.getNode(n)?.setAttr({[s]:null},!1)}}FIRE_AFTER(e,t=!0,n=10){this.#o(e);let s=this.rootBuilder?.binding?.bindingFor(this)??null,i=null,o=setTimeout(()=>{i?.(),this.FIRE(e,t)},n);return i=s?.track(()=>clearTimeout(o))??null,()=>{clearTimeout(o),i?.()}}absDatapath(e){e=V(e)?.pointer??e;let t=this.pointerType(e)?e.slice(1):e;if(t.startsWith("#")&&t.includes("?")){let[n,s]=t.split("?",2),i=super.absDatapath(n);return i===null?null:`${i}?${s}`}return super.absDatapath(e)}_composeRelativeDatapath(e,t){let n=this;for(;n!==null&&e.startsWith(".");){let s=n.getAttr("datapath");if(this.pointerType(s)&&(s=this.#n(n,s),s===null))return null;if(s!=null&&(e=e==="."?s:s+e),e.startsWith("#"))return n.parentNode._resolveSymbolicDatapath(e,t);n=n.parentNode}if(e.startsWith("."))throw new Error(`unresolved relative datapath: ${t}`);return e}_finalizeAbsPath(e,t){return e===null?null:super._finalizeAbsPath(e,t)}_resolveSymbolicDatapath(e,t){let n=e.slice(1).split(".",1)[0];if(n==="FORM"||n==="ANCHOR")return super._resolveSymbolicDatapath(e,t);let s=this.rootBuilder?.binding;if(!s)return super._resolveSymbolicDatapath(e,t);let i=s.nodeIds.get(n);if(!i)throw new Error(`#<id>: cannot resolve ${t}`);let o=e.slice(n.length+2);return i.absDatapath(o?`.${o}`:".")}#n(e,t){if(V(t)){let i=St(e,"datapath",e.parentNode);return i==null||i===""?null:i}let n=e.parentNode.absDatapath(t);if(n===null)return null;let s=this.data.getItem(n);return s==null||s===""?null:s}#i(e,t){return V(t)||typeof e!="string"||!e.endsWith("_path")?!1:(this.#e.has(e)||(this.#e.add(e),console.warn(`${this.nodeTag} '${this.label}': '${e}' holds a bare Data path; the pointer symbol of '${t}' is removed`)),!0)}#o(e){if(this.absDatapath(e)===null)throw new Error(`${this.nodeTag} '${this.label}': write on a null path: '${e}'`)}},le=class r extends D{get nodeClass(){return Jt}authorizedCopy(e){let t=new this.constructor;for(let n of this.getNodes()){let s=n.getAttr("auth")??null;if(s!==null){if(typeof s!="string")throw new TypeError(`${n.nodeTag} '${n.label}': 'auth' must be a string rule, not ${typeof s}`);if(e(s)!==null)continue}let i=n.staticValue;i instanceof r&&(i=i.authorizedCopy(e));let{auth:o,...a}=n.getAttr(),l=t.setItem(n.label,i,a,">",!1,!1,null,!1,!0,null,n.nodeTag);l.xmlTag=n.xmlTag}return t}activateCode(){for(let e of this.getNodes())e.activateCode(),e.staticValue instanceof r&&e.staticValue.activateCode();return this}};if((Re(le.tytxSuffix).GramlotBuilderBag??le)!==le)throw new Error("TYTX subtype name 'GramlotBuilderBag' is already registered for another class");Ft(le.tytxSuffix,{...Re(le.tytxSuffix),GramlotBuilderBag:le});var Cm=new Set(["animate","animateMotion","animateTransform","circle","ellipse","feBlend","feColorMatrix","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feGaussianBlur","feImage","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","image","line","metadata","path","polygon","polyline","rect","set","stop","use"]),Mn=class extends Xt{constructor(e,t){super(e),this._owner=t}get owner(){return this._owner}_handleMeta(e,t){let n=this.owner.evaluateExpressions(e,t);Lr(e,n);let[s,i]=super._handleMeta(e,n);return $r(e,i),e._getMeta("subbuilder")?[s,Xs(ei(i))]:[s,i]}adaptAttrs(e){let{_meta:t,...n}=e;return Bn(super.adaptAttrs(Pr(Dt(n))))}renderedItem(e,t,n,s={}){if(this.owner.renderType==="object")return this.owner.renderedItem(e,t,n,s);let{_text:i,...o}=n;return t=this.owner.expressionValue(e,t),Array.isArray(t)&&i!=null&&(t=[this._escapeText(Mr(i)),...t]),Cm.has(s.tag)?`${s.pretty?" ".repeat(this._nodeDepth(e,s.depthOffset??0)):""}<${s.tag}${this._formatAttrs(o)} />${s.pretty?`
61
+ `:""}`:super.renderedItem(e,t,o,s)}};var Kt=class extends Gt{#e=new WeakMap;#t=new WeakMap;get inlineCompiler(){return null}getRender(e){return this.renders.has(e)||(e instanceof Tt?this.addRender(e,this):e instanceof xt&&this.addRender(e,new Mn(e,this))),super.getRender(e)}render(e,t={}){if(e._getMeta("data_element"))return null;let[n,s]=e.rootBuilder.runtimeValues(e),i=this.getRender(e.builder),[o,a]=i._handleMeta(e,s);return e._getMeta("subbuilder")||(a=i.adaptAttrs(a)),i.renderedItem(e,e.value instanceof D?this.renderChildren(e.value,t):n,a,{tag:o,...t})}_handleMeta(e,t){let n=this.builder.constructor.dialectPrefixes,s=this.evaluateExpressions(e,t);Lr(e,s,n);let[i,o]=super._handleMeta(e,Hu(e,s,n));if($r(e,o,n),e.nodeTag==="webcomponent"){i=at(e.getAttr());let{code:u,...c}=o;o=c}if(e._getMeta("subbuilder")){let u=ei(o);return e._getMeta("subbuilder")==="html"&&(u.xmlns=On),[i,u]}let[a,l]=zu(i,o);return Object.keys(l).length&&this.#e.set(e,l),[i,a]}evaluateExpressions(e,t){let n=this.inlineCompiler,s=(o,a)=>n?n.compileExpression(e,o,a)(t):null,i={...t};for(let[o,a]of he(e.getAttr()))Me(a)&&Object.hasOwn(i,o)&&(i[o]=s(o,a));return Me(e.value)&&this.#t.set(e,s("",e.value)),i}expressionValue(e,t){return Me(e.value)?this.#t.get(e)??null:t}restoreNativeAttributes(e,t){let n=this.#e.get(e);return n?(this.#e.delete(e),{...t,...Pr(n)}):t}adaptAttrs(e){let{_meta:t,...n}=e,s=`${this.builder.constructor._name}_`,i=this.builder.constructor.dialectPrefixes,o={},a={};for(let[l,u]of Object.entries(Dt(n))){if(u==null)continue;if(l.startsWith(s))throw new Error(`${l}: the attribute prefix '${s}' is not accepted; use the prefix '${i[0]}'`);let c=i.find(d=>l.startsWith(d));c?o[l.slice(c.length)]=u:a[l]=u}return Bn({...super.adaptAttrs(a),...o})}renderedItem(e,t,n,s={}){let i;[t,i]=Rn(this.expressionValue(e,t),this.restoreNativeAttributes(e,n));let{_text:o,...a}=i;Array.isArray(t)&&o!=null&&(t=[this._escapeText(Mr(o)),...t]);let l=e.parentNode?._getMeta("subbuilder")==="html"?{xmlns:Ue,...a}:a;return super.renderedItem(e,t,l,s)}finalize(e,t=null,n={}){if(!n.doctype)return super.finalize(e,t,n);let s=this._composeStringFragments(e),i=this.builder.source.getNodes().filter(o=>!o._getMeta("data_element"));return i.length===1&&i[0].nodeTag==="html"||(s=`<html>${s}</html>`),super.finalize(`<!doctype html>${s}`,t,n)}};var Gu={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"binding",version:null,title:"Gramlot binding",description:"Gramlot Data declarations and the plain HTML button; loaded after the HTML grammar."},abstracts:{},elements:{dataSetter:{doc:"Initial Data value, written literally at destination_path.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination_path",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"value",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"any"},has_default:!0,default:null},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataFormula:{doc:"Computed Data value written at result_path; formula is inline, func is a name.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"result_path",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"formula",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"params",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataController:{doc:"Side effects on Data; script is inline, func is a name.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"script",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"func",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"params",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataRpc:{doc:"Server endpoint called through gramlot.rpc; the value is written at result_path when given.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"method",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"result_path",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"str"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"timeout",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"int"},{kind:"type",module:"builtins",name:"float"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"params",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},dataRemote:{doc:"Data node resolved by a server endpoint through gramlot.rpc, on first read and again when cacheTime expires; with sync (default) the read waits for the answer when the transport supports it.",sub_tags:"",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"destination_path",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"method",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"cacheTime",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"union",items:[{kind:"type",module:"builtins",name:"int"},{kind:"type",module:"builtins",name:"float"},{kind:"type",module:"builtins",name:"NoneType"}]},has_default:!0,default:null},{name:"sync",kind:"positional_or_keyword",role:"attribute",annotation:{kind:"type",module:"builtins",name:"bool"},has_default:!0,default:!0},{name:"params",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{data_element:!0}},html_button:{doc:"Plain native HTML button without Gramlot click mechanisms.",sub_tags:"a,abbr,area,audio,b,bdi,bdo,br,button,canvas,cite,code,data,datalist,del_,dfn,em,embed,i,iframe,img,input,ins,kbd,label,link,map,mark,meta,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,selectedcontent,slot,small,span,strong,sub,sup,template,textarea,time,u,var,video,wbr",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"kwargs",kind:"var_keyword",role:"attribute",annotation:null,has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:{render_tag:"button"}}}};var Xu={document_format:{name:"builder_grammar",version:"1.1"},grammar:{name:"webcomponent",version:null,title:"Gramlot webcomponent",description:"An explicitly loaded autonomous custom element."},abstracts:{},elements:{webcomponent:{doc:"Create the custom-element tag named by literal code.",sub_tags:"*",parent_tags:null,inherits_from:null,ns:null,attributes:{parameters:[{name:"code",kind:"keyword_only",role:"attribute",annotation:{kind:"type",module:"builtins",name:"str"},has_default:!1},{name:"attr",kind:"var_keyword",role:"attribute",annotation:{kind:"any"},has_default:!1}],accepts_var_keyword:!0,accepts_var_positional:!1},node_label:null,collection_key:null,_meta:null}}};function xe(){return Array.from(globalThis.crypto.getRandomValues(new Uint8Array(16)),r=>r.toString(16).padStart(2,"0")).join("")}var Om="data is forbidden: write dataSetter for a Data value or html_data for the HTML5 <data> element",Bm=new Set,Rm=new Set(["serverpath","dbenv","shared_id"]),Mm=["formsubscribe_"],$m={dataSetter:"destination_path",dataFormula:"result_path",dataRpc:"result_path",dataRemote:"destination_path"},Lm={dataFormula:"formula",dataController:"script"};function Yu(r,e){if(["input","textarea","select","webcomponent"].includes(r)&&V(e.value))return"'value' does not accept pointer suffixes; use an ordinary value pointer";if(r==="html_button"&&Object.keys(e).some(s=>["action","ask","_delay","fire"].includes(s)||s.startsWith("fire_")))return"plain HTML button: use button for action, ask, fire or _delay";if(Object.hasOwn(e,"ask")&&!["button","toggleButton","dropDownButton","menuline"].includes(r))return"'ask' is supported on buttons";if(Object.hasOwn(e,"_ask")&&!["dataController","dataFormula","dataRpc"].includes(r))return"'_ask' requires a controller, formula or RPC";if(["dataSetter","dataRemote"].includes(r)&&Object.keys(e).some(s=>s.startsWith("subscribe_")||s.startsWith("selfsubscribe_")))return"topic subscriptions are supported on controllers, formulas, RPCs and rendered elements";let t=$m[r];if(t&&String(e[t]??"").includes("?"))return`'${t}' does not accept '?attr': '${e[t]}'`;let n=Lm[r];return n&&e[n]!=null&&e.func!=null?`'func' and '${n}' cannot be declared on the same node`:n&&e._if!=null&&e.func!=null?"'_if' is inline and cannot be declared with 'func': write the condition in the method":null}function Zu(r){return Object.keys(r).find(e=>Rm.has(e)||Mm.some(t=>e.startsWith(t)))}var qe=class r extends Tt{static _name="gramlot";static _sourceClass=le;static{this.defineGrammar(Gu)}static{this.defineGrammar(Xu)}static{this.defineGrammar(Js.toDocument())}static get dialectPrefixes(){let e=[];for(let t=Object.getPrototypeOf(r);t&&t!==Function.prototype;t=Object.getPrototypeOf(t))Object.hasOwn(t,"_name")&&t._name&&e.push(`${t._name}_`);return e}constructor(e=null,{collections:t=[],auth:n=null,nameSyntax:s=Nn}={}){if(!(s instanceof Yt))throw new TypeError(`nameSyntax must be a NameSyntax, not ${s}`);super(e),this._binding=null,this._auth=n,this._nameSyntax=s;for(let i of t)this.loadCollection(i)}get auth(){return this._auth}get nameSyntax(){return this._nameSyntax}get binding(){return this._binding}set binding(e){this._binding=e}evaluatePointerExpression(e,t,n,s,i){return this.binding?this.binding.inlineCompiler.compilePointerExpression(e,t,n,s.text)(i):null}nodeById(e){if(!this.binding)return super.nodeById(e);let t=this.binding.nodeIds.get(e);if(!t)throw new Error(`nodeId not found: ${e}`);return t.builder.wrapSource(t)}loadCollection(e){return this.loadGrammar(e instanceof Zt?e.toDocument():e),this}schemaTag(e){let t=e.toLowerCase(),n=r.dialectPrefixes;if(t.startsWith(`${r._name}_`))throw new Error(`${e}: the tag prefix '${r._name}_' is not accepted; use the prefix '${n[0]}'`);if(Bm.has(t))throw new Error(`${e}: excluded from Gramlot`);let s=this.schemaTagNames[t];if(s)return s;for(let i of n)if(t.startsWith(i)&&this.schemaTagNames[t.slice(i.length)])return t;return null}bagCall(e,t,n,s){return super.bagCall(e,this.#e(t),n,s)}commandOnNode(e,t,n,s){return super.commandOnNode(e,this.#e(t),n,s)}validateNodeValues(e,t,n={}){if(this.schema[e]?._meta?.gramlot_component&&V(n.value))throw new Error("'value' does not accept pointer suffixes");e==="webcomponent"&&at(n);let s=Zu(n);if(s)throw new Error(`${e}: attribute '${s}' is excluded from Gramlot`);let i=Yu(e,n);if(i)throw new Error(`${e}: ${i}`);return super.validateNodeValues(e,t,n)}validateNode(e,t={}){if(e._getMeta("gramlot_component")&&V((t.attrs??e.getAttr()).value))throw new Error("'value' does not accept pointer suffixes");e.nodeTag==="webcomponent"&&at(t.attrs??e.getAttr());let n=Zu(t.attrs??e.getAttr());if(n)throw new Error(`${e.nodeTag} '${e.label}': attribute '${n}' is excluded from Gramlot`);let s=Yu(e.nodeTag,t.attrs??e.getAttr());if(s)throw new Error(`${e.nodeTag} '${e.label}': ${s}`);return super.validateNode(e,t)}_validateChildren(e,t,n,s){return super._validateChildren(e,t,n.map(i=>i==="html_button"?"button":i),s)}_countsForGrammar(e){return e===this.schema.button||!e?._meta?.gramlot_component&&e!==this.schema.webcomponent&&super._countsForGrammar(e)}setChild(e,t,n,s,i=null){s=Object.fromEntries(Object.entries(s??{}).map(([l,u])=>[l,te(u)instanceof we?this.reference(u):u]));let a=t==="dataSetter"&&s?.value!==null&&typeof s?.value=="object"&&Object.getPrototypeOf(s.value)===Object.prototype?{...s,value:new C(s.value)}:s;return super.setChild(e,t,n,a,i)}#e(e){if(e==="data")throw new Error(Om);if(this.schemaTagNames[e.toLowerCase()]===e)return e;let t=r.dialectPrefixes.find(n=>e.startsWith(n));return this.schemaTagNames[e.slice(t.length)]}get renderer_html(){return new Kt(this)}create(){this.setup(this.data),this.main(this.root)}computeLogic(){}promoteNodeValue(e,t,n){let s=t!=null?{_text:t}:null;e.setValue(n,!0,s,!0)}reference(e,t="node"){if(e=te(e),!(e instanceof we)||!["node","dom"].includes(t))throw new TypeError("Reference requires an element and node/dom kind");let n=e.getAttr("__ref");return n==null&&(n=xe(),e.setAttr({__ref:n})),{$gramlotRef:n,kind:t}}toTytx(){return W(this.auth===null?this.source:this.source.authorizedCopy(this.auth))}};function $n(r){return typeof r=="string"&&!["null","true","false"].includes(r)&&/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(r)}function Qt(r,e,t,n){let{group:s,method:i}=r.logicRegistry.resolve(t,e);return i.call(s,e,n)}function Qe(r,e,t,n,s,i=Object.keys(s)){return $n(n)?Qt(r,e,n,s):r.inlineCompiler.compile(e,t,n,i)(s)}var Pm=new Set(["input","select","textarea"]),Fm=["type","multiple","group"];function Ju(r,e){let t=r.getAttr(e);return r.pointerType(t)?r.getRelativeData(t):t}var be=class r{static liveWrites=!1;static writesDefault=!0;static preservesUnchangedValue=!1;#e;#t=!1;#r;#s;#n=!1;#i=!1;#o=!1;static for(e,t){let n=r.classFor(t.element,t.attrs);return n?new n(e,t):null}static classFor(e,t){if(e.namespaceURI!==Ue)return null;if(e.constructor.gramlotComponent)return e.constructor.gramlotComponent.parameters.value?.binding!=="twoWay"?null:e.control.type==="radio"?Ho:jo;if(e.localName==="textarea")return et;if(e.localName==="select")return Ln;if(e.localName!=="input")return null;let n=t.type==null?"text":String(t.type).toLowerCase();return Object.hasOwn(Ku,n)?Ku[n]:et}static shape(e,t){return e?.constructor.gramlotComponent?.parameters.value?.binding==="twoWay"&&e.control.type==="radio"?JSON.stringify([t.group??null]):e?.namespaceURI!==Ue||!Pm.has(e.localName)?null:JSON.stringify(Fm.map(n=>t[n]??null))}constructor(e,t){this.#r=e,this.#s=t}get binding(){return this.#r}get element(){return this.#s.element}get node(){return this.binding.node}get eventElement(){return this.element}get resolved(){return this.#s.resolved}get live(){return!!this.resolved.live}get writeEvent(){return this.constructor.liveWrites&&this.live?"input":"change"}project(e,t){if(this.#i){this.#o=!0;return}this.constructor.preservesUnchangedValue&&this.#t&&this.same(this.#e,e)||(this.#e=e,this.#t=!0,!(this.#n&&this.same(this.read(),e))&&(this.constructor.writesDefault&&!this.node.pointerType(this.node.getAttr("value"))&&this.writeDefault(e),this.write(e)))}read(){return this.element.value}write(e){let t=e==null?"":String(e);this.element.value!==t&&(this.element.value=t)}writeDefault(e){let t=e==null?"":String(e);this.element.localName==="textarea"?this.#s.text.data!==t&&(this.#s.text.data=t):this.element.defaultValue!==t&&(this.element.defaultValue=t)}same(e,t){return Object.is(e,t)}commit(e,t=this.read()){if(!this.binding.closed){this.#n=!0;try{this.binding.runtime.renderer.html.writeParameter(this.node,"value",t)}finally{this.#n=!1}}}attach(){for(let e of["input","change","compositionstart","compositionend"])this.eventElement.addEventListener(e,this)}detach(){for(let e of["input","change","compositionstart","compositionend"])this.eventElement.removeEventListener(e,this);this.#o=!1}refresh(){}handleEvent(e){if(!this.binding.closed){if(e.type==="compositionstart"){this.#i=!0;return}if(e.type==="compositionend"){this.#i=!1,this.writeEvent==="input"&&this.commit(e),this.#o&&(this.#o=!1,this.binding.runtime.renderer.project(this.node));return}this.#i||e.isComposing||e.type===this.writeEvent&&this.commit(e)}}},jo=class extends be{static writesDefault=!1;static preservesUnchangedValue=!0;get eventElement(){return this.element.control}attach(){this.element.setPageContext(Qu(this)),super.attach()}project(e,t){this.element.shouldProjectControlValue(e)&&super.project(e,t)}same(e,t){return this.element.sameControlValue(e,t)}detach(){this.element.releaseControl(),super.detach()}commit(e){this.binding.closed||this.element.control.disabled||this.element.control.readOnly||ec(this.element,this.element.acceptControlValue(),t=>super.commit(e,t.value))}get writeEvent(){return this.element.commitOnChange?"change":(this.resolved.live??this.element.parameters.live)&&this.element.liveWrites?"input":"change"}read(){return this.element.readControlValue()}write(e){this.element.writeControlValue(e)}handleEvent(e){if(super.handleEvent(e),!e.composed&&!this.binding.closed&&["input","change"].includes(e.type)){let t=this.element.ownerDocument.defaultView.Event;this.element.dispatchEvent(new t(e.type,{bubbles:!0,composed:!0}))}}},et=class extends be{static liveWrites=!0},Uo=class extends be{static liveWrites=!0;read(){return this.element.value===""?null:Number(this.element.value)}commit(e){this.element.validity.badInput||super.commit(e)}},qo=class extends be{static liveWrites=!0;read(){return Number(this.element.value)}},Ln=class extends be{static writesDefault=!1;read(){return this.element.multiple?[...this.element.selectedOptions].map(e=>e.value):this.element.selectedIndex===-1?null:this.element.value}write(e){let t=this.element;if(t.multiple){if(e!=null&&!Array.isArray(e))throw new TypeError(`${this.node.nodeTag} '${this.node.label}': a multiple select requires an array`);let n=new Set((e??[]).map(String));for(let s of t.options){let i=n.has(s.value);s.selected!==i&&(s.selected=i)}}else e==null?t.selectedIndex!==-1&&(t.selectedIndex=-1):(t.selectedIndex===-1||t.value!==String(e))&&(t.value=String(e))}same(e,t){return Array.isArray(e)?Array.isArray(t)&&t.length===e.length&&t.every((n,s)=>Object.is(n,e[s])):super.same(e,t)}},er=class extends be{read(){return this.element.value===""?null:this.element.value}},Vo=class extends be{},ti=class extends be{static writesDefault=!1;read(){return this.element.checked}write(e){let t=!!e;this.element.checked!==t&&(this.element.checked=t)}same(e,t){return e===!!t}attach(){let e=this.node;if(e.getAttr("checked")!=null&&e.pointerType(e.getAttr("value"))==="^")throw new TypeError(`${e.nodeTag} '${e.label}': checked and a ^ value are two sources`);super.attach()}},ri=class extends ti{#e=null;#t=!1;get groups(){return this.binding.runtime.renderer.radioGroups}attach(){let e=this.node,t=this.resolved.group??null,n=zo(e);if(t!=null){if(e.getAttr("name")!=null)throw new TypeError(`${e.nodeTag} '${e.label}': name and group are two names`);this.#r(t,n)}super.attach(),t!=null&&(this.#e=this.groups.join(this,t,n),this.element.setAttribute("name",this.#e))}detach(){this.#e!==null&&(this.groups.leave(this),this.element.removeAttribute("name"),this.#e=null),super.detach()}refresh(){if(this.#e===null)return;let e=this.resolved.group,t=zo(this.node);this.groups.nameOf(e,t)!==this.#e&&(this.#r(e,t),this.groups.leave(this),this.#e=this.groups.join(this,e,t),this.element.setAttribute("name",this.#e))}#r(e,t){let n=this.node;if(Ju(n,"value")&&this.groups.peersOf(e,t).some(s=>!s.binding.closed&&s.read()))throw new Error(`${n.nodeTag} '${n.label}': several true values in radio group '${e}'`)}project(e,t){let n=!this.#t;this.#t=!0;let s=this.read();super.project(e,t),!n&&!s&&this.read()&&this.turnOffPeers()}commit(e){let t=this.read();super.commit(e),t&&!this.binding.closed&&this.turnOffPeers()}turnOffPeers(){if(this.#e!==null)for(let e of this.groups.peers(this)){if(this.binding.closed)return;e.binding.closed||(e.element.checked&&(e.element.checked=!1),Ju(e.node,"value")&&e.commit(null))}}},Ho=class extends ri{static writesDefault=!1;get host(){return super.element}get element(){return this.host.control}project(e,t){this.host.shouldProjectControlValue(e)&&super.project(e,t)}commit(e){this.binding.closed||this.element.disabled||this.element.readOnly||ec(this.host,this.host.acceptControlValue(),()=>super.commit(e))}read(){return this.host.readControlValue()}write(e){this.host.writeControlValue(e)}attach(){this.host.setPageContext(Qu(this)),super.attach(),this.element.addEventListener("keydown",this)}detach(){this.host.releaseControl(),this.element.removeEventListener("keydown",this),super.detach()}handleEvent(e){if(!this.binding.closed){if(e.type==="keydown"){if(this.resolved.group==null||!["ArrowLeft","ArrowUp","ArrowRight","ArrowDown"].includes(e.key))return;let t=this.groups.peersOf(this.resolved.group,zo(this.node)).filter(o=>!o.binding.closed&&!o.element.disabled),n=t.indexOf(this);if(n<0)return;e.preventDefault();let s=["ArrowLeft","ArrowUp"].includes(e.key)?-1:1,i=t[(n+s+t.length)%t.length];i.element.focus(),i.element.click();return}if(super.handleEvent(e),!e.composed&&!this.binding.closed&&["input","change"].includes(e.type)){let t=this.host.ownerDocument.defaultView.Event;this.host.dispatchEvent(new t(e.type,{bubbles:!0,composed:!0}))}}}},ni=class{#e;#t=new Map;#r=new Map;#s=new WeakMap;#n=0;constructor(e){this.#e=e}join(e,t,n){let s=this.nameOf(t,n);return this.#t.has(s)||this.#t.set(s,new Set),this.#t.get(s).add(e),this.#r.set(e,s),s}leave(e){let t=this.#r.get(e);this.#r.delete(e);let n=this.#t.get(t);n?.delete(e),n?.size===0&&this.#t.delete(t)}peers(e){let t=this.#r.get(e);return[...this.#t.get(t)??[]].filter(n=>n!==e)}peersOf(e,t){return[...this.#t.get(this.nameOf(e,t))??[]]}nameOf(e,t){t!==null&&!this.#s.has(t)&&this.#s.set(t,this.#n++);let n=t===null?"page":`form${this.#s.get(t)}`;return`gramlot-${this.#e.instanceId}-${n}-${e}`}};function zo(r){for(let e=r;e;e=e.parentNode){let t=e.getAttr()??{};if(t.formId!=null||t.form===!0)return e}return null}var Ku={text:et,password:et,email:et,url:et,tel:et,search:et,number:Uo,range:qo,color:Vo,date:er,time:er,month:er,week:er,"datetime-local":er,checkbox:ti,radio:ri,hidden:null,file:null,button:null,submit:null,reset:null,image:null};function Qu(r){let{binding:e,node:t}=r,n=e.runtime.gramlot,s=(i,o,a,l=!1)=>l?e.runtime.inlineCompiler.compile(t,i,o,Object.keys(a),`return (${o});`)(a):Qe(e.runtime,t,i,o,a);return{locale:n.locale,timeZone:n.timeZone,createDecimal:Et,isDecimal:fe,getDecimalLibrary:To,publish:(i,o)=>t.publish(i,o),isActive:()=>!e.closed,callLogic:(i,o)=>Qt(e.runtime,t,i,o),format:(i,o)=>n.format(i,o),invoke:s,remote:(i,o,a)=>n.rpc.call("data",i,o,{signal:a}),validationCurrent:()=>{let i=t.getAttr("value"),o=t.pointerType(i)?t.absDatapath(i):null;return()=>!e.closed&&t.getAttr("value")===i&&(o===null||t.absDatapath(i)===o)},finishValidation:({ok:i,result:o,rules:a})=>{if(e.closed)return;if(i)for(let u of o.datachanges)t.getRelativeData(".").update(u);let l=i?"validate_onAccept":"validate_onReject";if(a[l]){let u=c=>console.error("Validation notification failed:",c);try{let c=Object.fromEntries(Object.entries(a).map(([f,h])=>[f.slice(9),h])),d=s(l,a[l],{value:o.value,result:o,validations:c,userChange:!0});d instanceof Promise&&d.catch(u)}catch(c){u(c)}}},checkDataPatch:i=>{if(!(i instanceof C))throw new TypeError("Validation data changes must be a Bag.");if(!(t.getRelativeData(".")instanceof C))throw new TypeError("Validation data changes require a Bag datapath.")}}}function ec(r,e,t){let n=s=>{s.ok&&s.isCurrent()&&(t(s),r.finishValidation(s))};e instanceof Promise?e.then(n).catch(s=>console.error("Validation notification failed:",s)):n(e)}var Wo=Symbol("source text"),tc={xmlns:"http://www.w3.org/2000/xmlns/",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},jm=new Set(["allowFullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formNoValidate","hidden","inert","isMap","itemscope","loop","multiple","muted","noModule","noValidate","open","playsInline","readOnly","required","reversed","selected"]),Um=new Set(["checked","muted","selected","value"]),qm=new Map([["allowfullscreen","allowFullscreen"],["formnovalidate","formNoValidate"],["ismap","isMap"],["nomodule","noModule"],["novalidate","noValidate"],["playsinline","playsInline"],["readonly","readOnly"]]);function Vm(r){let e=r.replace(/-([a-z])/g,(t,n)=>n.toUpperCase());return qm.get(e.toLowerCase())??e}var si=class{constructor({metadataAttributes:e=[],invokeScript:t=null,callLogic:n=null}={}){this.invokeScript=t,this.callLogic=n,this.metadataAttributes=new Set([...Ut,"_text",...e])}definition(e){let t=e.builder,s={...t.schema[t.schemaTag(e.nodeTag)]._meta,...e.getAttr("_meta")},i=e.nodeTag==="webcomponent"?at(e.getAttr()):An(e.nodeTag,{renderTag:s.render_tag,ns:e.getAttr("ns"),dialectName:t.constructor._name}),o=i==="foreignObject"?On:s.render_attributes?.xmlns??e.getAttr("xmlns")??(t instanceof xt?On:Ue);return{meta:s,namespace:o,tag:i}}validate(e,t=e.builder){let n=e.value instanceof D,s=n?e.getAttr("_text"):e.value;if(s!=null&&!["string","number","boolean"].includes(typeof s))throw new TypeError("HTML text must be scalar");for(let[a,l]of Object.entries(e.attr))if(!(a==="value"&&this.definition(e).meta.gramlot_component)&&!(this.metadataAttributes.has(a)||["ask","_ask"].includes(a)||l&&typeof l=="object"&&Object.hasOwn(l,"$gramlotRef"))&&l!=null&&!["string","number","boolean"].includes(typeof l))throw new TypeError(`HTML attribute ${a} must be scalar`);let i=Object.fromEntries(Object.entries(e.attr).filter(([a])=>!this.metadataAttributes.has(a))),o=n?e.value.getNodes().map(a=>a.nodeTag).filter(Boolean):[];t.validateNode(e,{value:s,attrs:i,childTags:o})}create(e,t,n=null,s=e.attr,i=null){let{tag:o,namespace:a,meta:l}=this.definition(e);n??=o;let u=a===Ue?t.createElement(n):t.createElementNS(a,n);if(l.gramlot_component&&u.constructor.gramlotComponent?.tag!==n)throw new Error(`Component collection must be activated before rendering ${n}`);l.gramlot_component?.dataScope&&(u.readDataScope=()=>{if(!e.getAttr("datapath"))throw new Error("Data scope requires an explicit datapath");return e.getRelativeData(".")}),l.gramlot_component?.sourceContext&&u.setSourceContext({publish:(f,h)=>e.publish(f,h),writeParameter:(f,h)=>this.writeParameter(e,f,h),callLogic:(f,h)=>this.callLogic(e,f,h)});let c=t.createTextNode(this.text(e));(a!==Ue||!l.void)&&u.append(c);let d={element:u,text:c,tag:n};return this.update(d,e,s,Wo,i),d}matches(e,t){let{tag:n,namespace:s}=this.definition(t);return(s===Ue?e.tag.toLowerCase()===n.toLowerCase():e.tag===n)&&e.element.namespaceURI===s}writeParameter(e,t,n){let s=e.getAttr(t);e.pointerType(s)==="^"&&!V(s)&&!Object.is(e.getRelativeData(s.slice(1)),n)&&e.setRelativeData(s.slice(1),n)}compose(e,t,n){e.text.data=t??"";for(let s of n)e.element.append(s)}update(e,t,n=t.attr,s=Wo,i=null){if(t.nodeTag==="script"){for(let[g,b]of t.codeAttributes())if(t.activatedCode(g)!==b)throw new Error(`script '${t.label}': '${g}' runs only as received with the Source`)}let{element:o,text:a}=e,l=o.namespaceURI===Ue,u=this.definition(t).meta.render_attributes??{},c=e.attrs??{},d=g=>(Lr(t,g,t.builder.constructor.dialectPrefixes),$r(t,g,t.builder.constructor.dialectPrefixes),t.builder.renderer_html.adaptAttrs(g)),f=t.parentNode;f?._getMeta("gramlot_component")?.childParameters&&(n=o.ownerDocument.defaultView.customElements.get(f._getMeta("render_tag")).projectChild(o,n,{adapt:d,invoke:(b,y,w)=>this.invokeScript(t,b,y,w),publish:(b,y)=>t.publish(b,y),publishParent:(b,y)=>f.publish(b,y),writeParameter:(b,y)=>this.writeParameter(t,b,y),remove:()=>t.parentBag.popNode(t.label)})),this.definition(t).meta.gramlot_component&&(this.definition(t).meta.gramlot_component.bagStore&&o.setStoreBag(t.getRelativeData(t.getAttr("storepath"))),n=o.projectAttributes(n,d)),n=Object.fromEntries(he({...n,...u}));let h=be.classFor(o,n)!==null;s===Wo&&(s=this.text(t));let p=s==null?"":String(s);a.data!==p&&(a.data=p);let m=[...new Set([...Object.keys(c),...Object.keys(n)])];m.sort((g,b)=>(b==="sandbox")-(g==="sandbox"));for(let g of m){if(this.metadataAttributes.has(g)||["ask","_ask"].includes(g)||h&&g==="value")continue;let b=n[g],y=g,w=Vm(y),k=l&&jm.has(w)&&typeof o[w]=="boolean",A=y==="xmlns"?"xmlns":y.includes(":")?y.split(":")[0]:"",v=Object.hasOwn(tc,A)?tc[A]:null;if(Object.is(c[g],b)||(b==null||k&&!b?v?o.removeAttributeNS(v,y.split(":").at(-1)):o.removeAttribute(y):v?o.setAttributeNS(v,y,String(b)):o.setAttribute(y,k?"":String(b))),l&&(k||Um.has(w))&&w in o){let N=w==="value"?b==null?"":String(b):!!b;o[w]!==N&&(o[w]=N)}}i===!1?o.style.visibility!=="hidden"&&(o.style.visibility="hidden"):e.visible===!1&&(n.style==null?o.removeAttribute("style"):o.setAttribute("style",String(n.style))),e.visible=i,e.attrs=n}text(e){return e.value instanceof D?e.getAttr("_text")==null?"":String(e.attr._text):e.value==null?"":String(e.value)}};var ii=class r{#e;#t;#r=null;#s=0;static for(e,t){return t.element?.constructor.gramlotComponent?.command?new r(e,t):null}constructor(e,t){this.#e=e,this.#t=t}get binding(){return this.#e}get node(){return this.binding.node}get element(){return this.#t.element}get controllers(){let e=this.node.value;return e?.getNodes?e.getNodes().filter(t=>t.nodeTag==="dataController"||t.nodeTag==="dataRpc"):[]}get mechanism(){let e=this.node,t=this.controllers;if(t.length>1)throw new Error(`${e.nodeTag} '${e.label}': several dataController or dataRpc children; a button has one click mechanism`);let n=e.getAttr()??{},s=[];if(t.length&&s.push("controller"),n.action!=null&&s.push("action"),rc(n).length&&s.push("fire"),s.length>1)throw new Error(`${e.nodeTag} '${e.label}': ${s.join(" and ")} together; a button has one click mechanism`);return s[0]??null}attach(){this.refresh(),this.element.activateCommand=e=>this.onClick(e),this.element.attachCommand(),this.element.addEventListener("click",this)}refresh(){this.mechanism&&this.node.getAttr("type")==null&&this.element.getAttribute("type")!=="button"&&this.element.setAttribute("type","button")}detach(){this.element.removeEventListener("click",this),this.element.releaseCommand(),delete this.element.activateCommand,this.#r?.()}handleEvent(e){this.onClick(e)}onClick(e){if(this.binding.closed||this.element.disabled)return;let t=this.element.commandTarget(e);if(t===null)return;if(t!==this.element)return e.stopPropagation(),t.activateCommand(e);if(!this.element.prepareCommand(e)||!this.mechanism||(e.stopPropagation(),this.element.disabled))return;let s=this.binding.countClick(),i=this.node;for(;i&&i.getAttr("_delay")==null;)i=i.parentNode;let o=i?i.rootBuilder.runtimeValues(i)[1]._delay:0;if(o>0){let a=this.#s+1;this.#r?.(),this.#s=a;let l=setTimeout(()=>{u(),this.#r=null,this.#s=0,this.#n(e,a)},o),u=this.binding.track(()=>this.#r?.());this.#r=()=>{clearTimeout(l),u(),this.#r=null,this.#s=0};return}return this.#r?.(),this.#n(e,s)}#n(e,t){if(this.binding.closed||this.element.disabled)return;let n=this.mechanism;if(!n)return;let s=this.node,i=Hm(e);if(n==="controller")this.binding.runtime.bindingFor(this.controllers[0])?.providers[0]?.invoke({kind:"click",event:e,counter:t});else if(n==="action"){let o=()=>{let[,c]=s.rootBuilder.runtimeValues(s),d=Object.fromEntries(Object.entries(c).filter(([f])=>f!=="ask"));return{...this.binding.runtime.renderer.references.resolveArguments(d),event:e,_counter:t,modifiers:i}},a=c=>{if(this.binding.closed||this.element.disabled||c===null)return;let d={...o(),...c};c&&(d._askResult=c),Qe(this.binding.runtime,s,"action",s.getAttr("action"),d)},l=s.getAttr("ask"),u=this.binding.runtime.askDialog;if(l&&u.required(this.binding,l,o(),"ask"))return u.show(this.binding,l,o()).then(a);a(void 0)}else{let o={modifier:i,_counter:t},a=s.getAttr("fire");if(a!=null){s.FIRE(a,i||!0,o);return}for(let[l,u]of rc(s.getAttr())){if(this.binding.closed)return;s.FIRE(u,l.slice(5),o)}}}};function rc(r){return Object.entries(r??{}).filter(([e,t])=>t!=null&&(e==="fire"||e.startsWith("fire_")))}function Hm(r){return["shift","ctrl","alt","meta"].filter(e=>r[`${e}Key`]).map(e=>e[0].toUpperCase()+e.slice(1)).join("")}var oi="connect_on",Pn=class{#e;#t;#r;#s;#n;static declared(e){return Object.entries(e.getAttr()??{}).filter(([t,n])=>t.startsWith(oi)&&t.length>oi.length&&n!=null).map(([t,n])=>[t,t.slice(oi.length).toLowerCase(),n])}constructor(e,t,n,s,i=`${oi}${n}`){this.#e=e,this.#t=t,this.#r=n,this.#s=s,this.#n=i}get binding(){return this.#e}get node(){return this.binding.node}get element(){return this.#t.element}get eventName(){return this.#r}get handler(){return this.#s}get attribute(){return this.#n}attach(){this.element.addEventListener(this.eventName,this)}detach(){this.element.removeEventListener(this.eventName,this)}handleEvent(e){if(this.binding.closed)return;let t=this.node,n=this.binding.runtime;if($n(this.handler))return Qt(n,t,this.handler,e);n.inlineCompiler.compile(t,this.attribute,this.handler,["event"])({event:e})}};function Ct(r,e=new Set){if(!r||typeof r!="object")return;let t=r.ownerDocument?.defaultView?.Node??r.defaultView?.Node;if(te(r)instanceof we||t&&r instanceof t)throw new TypeError("Live Source/DOM references cannot cross a transport boundary");if(e.has(r))throw new TypeError("Transport data cannot contain circular references");e.add(r);let n=r instanceof C?r.getNodes().flatMap(s=>[s.staticValue,s.getAttr()]):Object.values(r);for(let s of n)Ct(s,e);e.delete(r)}var Fn=class{constructor(e=null){this.entries=new Map,this.sourceRoot=e}validate(e,t=new Set){let n=new Map,s=i=>{for(let o of i.getNodes()){let a=o.getAttr("__ref");if(a){if(n.has(a))throw new Error("Duplicate Source reference");let l=this.entries.get(a);if(e!==this.sourceRoot&&l&&l.node!==o&&!t.has(l.node))throw new Error("Duplicate Source reference");n.set(a,o)}o.value instanceof D&&s(o.value)}};s(e)}register(e,t){let n=e.getAttr("__ref");if(n){if(this.entries.has(n))throw new Error(`Duplicate Source reference: ${n}`);this.entries.set(n,{node:e,dom:t})}}remove(e){for(let[t,n]of this.entries)n.node===e&&this.entries.delete(t)}resolveArguments(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,n&&typeof n=="object"&&Object.hasOwn(n,"$gramlotRef")?this.resolve(n):n]))}resolve(e){if(!e||!["node","dom"].includes(e.kind))throw new TypeError("Expected a node or DOM reference");let t=this.entries.get(e.$gramlotRef);if(!t)throw new Error("Source reference is not mounted");return t[e.kind]}};var ai=class{constructor(e=null,t=null){this.parent=e,this.segment=t,this.children=new Map,this.registrations=new Set}},Go=class{#e;#t;#r;#s;#n;#i=!0;#o;constructor(e,{path:t,attr:n,recipient:s,order:i,subtree:o=!1}){this.#e=e,this.#t=t,this.#r=n,this.#s=s,this.#n=i,this.#o=o}get router(){return this.#e}get path(){return this.#t}get attr(){return this.#r}get recipient(){return this.#s}get subtree(){return this.#o}get active(){return this.#i}get order(){return this.#n}close(){this.active&&(this.#i=!1,this.router.unregister(this))}},Xo=class{constructor({evt:e,node:t,path:n,oldvalue:s,attrsDiff:i,reason:o,fired:a,level:l,registration:u}){this.evt=e,this.node=t,this.path=n,this.oldvalue=s,this.attrsDiff=i,this.reason=o,this.fired=a,this.level=l,this.registration=u}},li=class{#e;#t=new ai;#r=new Map;#s=0;#n=0;constructor(e){this.#e=e}get runtime(){return this.#e}get size(){return this.#s}register({path:e,attr:t=null,recipient:n,subtree:s=!1}){if(typeof e!="string"||e==="")throw new TypeError(`A Data registration requires a path: ${e}`);let i=this.#t;for(let a of e.split(".")){let l=i.children.get(a);l||(l=new ai(i,a),i.children.set(a,l)),i=l}this.#n+=1;let o=new Go(this,{path:e,attr:t,recipient:n,order:this.#n,subtree:s});return i.registrations.add(o),this.#r.set(o,i),this.#s+=1,o}unregister(e){let t=this.#r.get(e);if(t)for(this.#r.delete(e),t.registrations.delete(e),this.#s-=1;t.parent&&!t.children.size&&!t.registrations.size;)t.parent.children.delete(t.segment),t=t.parent}deliver(e){let{pathlist:t}=e;if(!t?.length||t[0]!==Sn||e.reason==="autocreate")return;let n=t.slice(1),s=e.evt==="ins"||e.evt==="del";for(let i of Array.isArray(e.node)?e.node:[e.node]){let o=s?[...n,i.label]:n,a=o.join(".");for(let[l,u]of this.#i(o,e))l.active&&l.recipient.receive(new Xo({evt:e.evt,node:i,path:a,oldvalue:e.oldvalue??null,attrsDiff:e.attrs_diff??null,reason:e.reason??null,fired:e.fired??!1,level:u,registration:l}))}}#i(e,t){let n=[],s=this.#t;for(let o of e){for(let a of s.registrations)s!==this.#t&&this.#o(a,"child",t)&&n.push([a,"child"]);if(s=s.children.get(o),!s)return n.sort(([a],[l])=>a.order-l.order)}for(let o of s.registrations)this.#o(o,"node",t)&&n.push([o,"node"]);let i=[...s.children.values()];for(;i.length;){let o=i.pop();for(let a of o.registrations)this.#o(a,"container",t)&&n.push([a,"container"]);i.push(...o.children.values())}return n.sort(([o],[a])=>o.order-a.order)}#o(e,t,n){let{evt:s}=n;return e.subtree?t!=="container"||s!=="upd_attrs":e.attr===null?s==="upd_attrs"?!1:!(t==="child"&&n.fired):t==="child"?!1:t==="container"?s!=="upd_attrs":s==="ins"||s==="del"?!0:Object.hasOwn(n.attrs_diff??{},e.attr)}};var ui=class{#e;constructor(e){this.#e=e}get runtime(){return this.#e}install(e){let t=jn(e),n=this.setterNodes(e);Zo(e);for(let s of n){let i=this.runtime.openBinding(s);i.hasStamp("installed")||(this.applySetter(s),i.stamp("installed"))}this.applyDefaults(t.filter(s=>s.nodeTag&&!s._getMeta("data_element")))}setterNodes(e){return jn(e).filter(t=>t.nodeTag==="dataSetter")}applySetter(e){let t=e.absDatapath(e.pathAttribute("destination_path"));if(t===null)return;let n=e.getAttr("value")??null,s=Wm(e.getAttr()),i=this.runtime.data;if(n!==null)i.setItem(t,n,s,">",!1,!0,e),n instanceof C&&e.setAttr({value:null},!1);else{let o=i.getNode(t);o?s&&o.setAttr(s,!0):i.setItem(t,null,s,">",!1,!0,e)}}applyDefaults(e){for(let t of e){let n=t.getAttr();for(let[s,i]of Object.entries(n)){if(!zm(t,s,i))continue;let o=s==="value"?n.default_value??n.default:n[`default_${s}`];o!=null&&this.#t(t,i,o)}this.#r(t,n)}}#t(e,t,n){let s=e.absDatapath(t);if(s===null)return;let[i,o=null]=s.split("?",2),a=this.runtime.data,l=a.getNode(i);if(o===null){if(l&&l.value!==null&&l.value!==void 0)return;a.setItem(i,n,null,">",!1,!0,e)}else if(l){let u=l.getAttr(o);u==null&&l.setAttr({[o]:n},!0)}else a.setItem(i,null,{[o]:n},">",!1,!0,e)}#r(e,t){let n={};for(let[o,a]of Object.entries(t))o.startsWith("attr_")&&(n[o.slice(5)]=V(a)?St(e,o):e.pointerType(a)?e.getRelativeData(a):a);if(!Object.keys(n).length)return;let s=[t.value,t.src].find(o=>e.pointerType(o));if(!s)return;let i=e.absDatapath(s);i!==null&&this.runtime.data.getNode(i.split("?",1)[0])?.setAttr(n,!0,!0,!1)}};function zm(r,e,t){return e==="_meta"||Ut.has(e)||e==="default"||e.startsWith("default_")||e.startsWith("attr_")||e.endsWith("_path")?!1:r.pointerType(t)!==null}function Wm(r){let e={};for(let[t,n]of Object.entries(Dt(r??{})))Ut.has(t)||t.startsWith("_")||t==="destination_path"||t==="value"||n!=null&&(e[t]=n);return Object.keys(e).length?e:null}function Gm(r){let e=r.builder;if(!(e instanceof qe))throw new Error(`dataSetter '${r.label}': dataSetter is not supported inside ${e.constructor._name}`)}function Zo(r){for(let e of jn(r))e.nodeTag==="dataSetter"&&Gm(e),Km(e)}var Xm=["_init","_onStart","_onBuilt","_delay","_timing","_userChanges"],Ym=new Set(["dataFormula","dataController","dataRpc","dataRemote"]),Zm=["_onCalling","_onResult","_onError"],Jm=["_delay","_timing","_userChanges"],Yo=["_init","_onBuilt","_onStart"];function Km(r){let e=i=>r.getAttr(i)!==null&&r.getAttr(i)!==void 0,t=!r._getMeta("data_element")&&typeof r.getAttr("remote")=="string";if(r.nodeTag!=="dataRpc"){let i=Zm.find(o=>e(o)&&!(o==="_onCalling"&&(r.nodeTag==="dataRemote"||t)));if(i){let o=i==="_onCalling"?"dataRpc, dataRemote and remote":"dataRpc";throw new Error(`${r.nodeTag??"fragment"} '${r.label}': '${i}' is allowed only on ${o}`)}}if(Ym.has(r.nodeTag)){let i=Object.entries(r.getAttr()).find(([,a])=>Me(a));if(i)throw new Error(`${r.nodeTag} '${r.label}': '${i[0]}' is a == expression, not accepted on ${r.nodeTag}`);let o=r.nodeTag==="dataRemote"?Yo.find(e):null;if(o)throw new Error(`dataRemote '${r.label}': '${o}' is not accepted on dataRemote, its resolver loads when the Data is read`);for(let a of Yo){let l=r.getAttr(a);if(!(l==null||typeof l=="boolean"||typeof l=="number"))throw new Error(`${r.nodeTag} '${r.label}': '${a}' accepts true, false, null or a number, not ${JSON.stringify(l)}`)}return}let n=Xm.find(i=>e(i)&&!(i==="_delay"&&!r._getMeta("data_element")&&r.nodeTag!=="html_button")&&!(t&&Jm.includes(i)));if(!n)return;let s=Yo.includes(n)?"dataFormula, dataController and dataRpc":"dataFormula, dataController, dataRpc and dataRemote";throw new Error(`${r.nodeTag??"fragment"} '${r.label}': '${n}' is allowed only on ${s}`)}function jn(r){if(r instanceof D)return r.getNodes().flatMap(t=>jn(t));let e=[r];return r.value instanceof D&&e.push(...jn(r.value)),e}var Ve=class extends Z{static classKwargs={...Z.classKwargs,asBag:!1};constructor({cacheTime:e,onError:t}){super({cacheTime:e??-1}),this.onError=t,this.loading=null,this.loaded=!1,this.writing=!1}resolve({static:e=!1}={}){return!e&&!this.closed&&!this.loading&&!this.writing&&this.expired&&this.refresh(),this.cachedValue}refresh(){if(this.closed)return null;let e=this.startLoad(n=>this.#t(n));if(e===null)return null;let t=()=>{this.loading===e&&(this.loading=null)};return e.then(t,t),this.loading=e,e.catch(n=>{n?.name!=="AbortError"&&this.onError(n)}),e}resolveSync(e){return super.resolve(e)}prepareValue(e){return e}#e(){let e={...this._kw};for(let[t,n]of Object.entries(this.node?.attr??{}))this.constructor.internalParams.has(t)||(e[t]=n);return this._computeEffectiveFingerprint(e)}async#t(e){if(this.closed)return;let t=this.#e(),n=await this.loadAsync(e);if(this.closed||e.ignored)return;let s=this.prepareValue(n);this._lastUpdate=Date.now(),this._lastEffectiveFingerprint=t,this.loaded=!0,this.writing=!0;try{this.node?this.node.setValue(s,this.cacheTime!==0):this.cachedValue=s}finally{this.writing=!1}return s}};var ci=class extends Ve{static internalParams=new Set([...Ve.internalParams,"binding","method","params","onCalling","onError","sync"]);constructor({binding:e,method:t,params:n,cacheTime:s,onCalling:i=null,onError:o,sync:a=!1}){super({cacheTime:s,onError:o}),this.binding=e,this.sync=a,this.method=t,this.params=n,this.onCalling=i}get closed(){return this.binding.closed}resolve(e={}){return this.sync?e.static||this.loading||this.writing?this.cachedValue:this.expired&&!this.binding.node.requests.calling(this.onCalling)?this.cachedValue:super.resolveSync(e):super.resolve(e)}load(){let e;try{e=this.binding.callSync("data",this.method,this.params)}catch(t){this.onError(t)}return this.loaded=!0,e}startLoad(e){let t=this.binding.node.requests;return t.calling(this.onCalling)?t.submit(this.method,this.params,e):null}loadAsync(e){return this.binding.call("data",e)}};var Qm=new Set(["destination_path","result_path","func","formula","script","if","else","_init","_onStart","_onBuilt","_delay","_timing","_userChanges","_ask","_ask_if","_ask_title","_ask_onCancel","method","timeout","_onCalling","_onResult","_onError","cacheTime","sync"]),Un=class{#e;#t=null;#r=null;constructor(e){this.#e=e}get binding(){return this.#e}debounce(e,t){this.#r?.();let n=null,s=setTimeout(()=>{n(),this.#r=null,t()},e);n=this.binding.track(()=>clearTimeout(s)),this.#r=()=>{clearTimeout(s),n(),this.#r=null}}startTiming(e,t){if(this.#t?.(),!(e>0))return;let n=setInterval(t,e*1e3),s=this.binding.track(()=>clearInterval(n));this.#t=()=>{clearInterval(n),s(),this.#t=null}}cancel(){this.#r?.(),this.#t?.()}},Fr=class{#e;#t=[];#r=new Set;#s;#n=null;#i=!1;constructor(e){this.#e=e,this.#s=new Un(e),e.track(()=>{this.cancel(),this.#m(),this.#p()})}get binding(){return this.#e}get node(){return this.binding.node}get kind(){throw new Error("Provider.kind is defined by FormulaProvider, ControllerProvider, RpcProvider and RemoteProvider")}register(){let e=this.node,t=e.getAttr("_onStart");if(typeof t=="number"&&!(Number.isFinite(t)&&t>=0))throw new Error(`${e.nodeTag} '${e.label}': _onStart must be true or a delay in ms not below 0: ${t}`);this.#m();let n=this.binding.runtime.router,s=He(e,e.getAttr("_timing"));for(let[i,o]of e.pointers()){if(i==="datapath")continue;let a=e.absDatapath(o);if(a===null)continue;let[l,u=null]=a.split("?",2),c=n.register({path:l,attr:u,recipient:this});this.#t.push(c),(i==="_timing"||s.has(i))&&this.#r.add(c)}this.#t.push(...this.binding.runtime.subscriptions.subscribeNode(e,(i,o,a)=>l=>{let u={kind:"subscription",topic:a,payload:l};if(this.#a("_userChanges")&&a!=="node")return;let c=this.#a("_delay");c>0?this.#s.debounce(c,()=>this.invoke(u)):this.invoke(u)})),this.#o(),this.kind==="remote"&&this.invoke({kind:"install",change:null})}receive(e){if(this.#r.has(e.registration)){this.#o();return}if(this.#a("_userChanges")&&e.level!=="node")return;let t={kind:"data",change:e},n=this.#a("_delay");n>0?this.#s.debounce(n,()=>this.invoke(t)):this.invoke(t)}invoke(e){if(this.binding.closed)return;let t=this.node,n=this.kind==="formula",s=this.kind==="rpc",i=this.kind==="remote",o=this.readArguments(e);e.askResult&&(Object.assign(o,e.askResult),o._askResult=e.askResult);let a=t.getAttr("_ask"),l=this.binding.runtime.askDialog;if(a&&!e.askDone&&l.required(this.binding,a,o,"_ask"))return l.show(this.binding,a,o,t.getAttr("_ask_title")??"Warning").then(p=>{if(!this.binding.closed){if(p===null){let m=t.getAttr("_ask_onCancel");m&&this.#l("_ask_onCancel",m,m,o,!0);return}return this.invoke({...e,askDone:!0,askResult:p})}});let[u,c]=[n?"formula":"script",t.getAttr(n?"formula":"script")],d=t.getAttr("_if");if(d&&!this.#l("_if",d,`return (${d})`,o,!1)){if(i&&this.#p(),[u,c]=["_else",t.getAttr("_else")],!c)return;if(s||i){this.#l(u,c,c,o,!0);return}}if(s)return this.#f(o);if(i)return this.#u(o);let f=t.getAttr("func"),h;if(c)h=this.#l(u,c,n?`return ${c}`:c,o,!0);else if(f==null){if(!n)return;h=new C(di(o))}else{let{group:p,method:m}=this.binding.runtime.logicRegistry.resolve(f,t);h=n?m.call(p,o):m.call(p,t,o)}n&&t.setRelativeData(t.pathAttribute("result_path"),h)}readArguments(e){let t=this.node,[,n]=t.rootBuilder.runtimeValues(t),s=Object.fromEntries(Object.entries(n).filter(([l])=>!Qm.has(l)&&!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),i={...e.kind==="subscription"?e.payload:{},...this.binding.runtime.renderer.references.resolveArguments(s)};e.kind==="subscription"&&(i._subscription_kwargs=e.payload);let o=e.change??null,a=o?o.level:e.kind==="subscription"?e.topic:e.kind;return i._node=o?o.node:null,i._triggerpars={kw:o,trigger_reason:a},i._reason=a,e.kind==="click"&&Object.assign(i,eg(e)),i}cancel(){this.#s.cancel()}#o(){this.#s.startTiming(this.#a("_timing"),()=>this.invoke({kind:"timing",change:null}))}#a(e){let t=this.node,n=t.getAttr(e);return V(n)?St(t,e):t.pointerType(n)?t.getRelativeData(n):n??null}#l(e,t,n,s,i){let o=[...i?["_kwargs"]:[],...nc,...sc,...Object.keys(di(s))];return["_onCalling","_onResult","_onError","_ask_onCancel"].includes(e)?Qe(this.binding.runtime,this.node,e,t,{...s,_kwargs:s},o):this.binding.runtime.inlineCompiler.compile(this.node,e,t,o,n)({...s,_kwargs:s})}async#f(e){let t=this.node,[n,s,i]=["_onCalling","_onResult","_onError"].map(a=>t.getAttr(a)),o=t.requests;if(o.calling(n?()=>this.#l("_onCalling",n,n,e,!0):null))return o.submit(this.#a("method"),di(e),a=>this.#h(a,e,s,i))}async#h(e,t,n,s){if(this.binding.closed)return;let i=this.node,o=this.#a("timeout"),a=o>0?setTimeout(()=>{let c=new Error(`${i.nodeTag} '${i.label}': no answer within ${o} ms`);c.name="TimeoutError",e.controller.abort(c)},o):null,l;try{l={result:await this.binding.call("data",e)}}catch(c){l={error:c}}if(clearTimeout(a),this.binding.closed||e.ignored)return;if("error"in l){if(!s)throw l.error;this.#l("_onError",s,s,{...t,error:l.error},!0);return}let{result:u}=l;i.getAttr("result_path")!=null&&i.setRelativeData(i.pathAttribute("result_path"),u),n&&this.#l("_onResult",n,n,{...t,result:u},!0)}#u(e){this.#p();let t=this.#i;this.#i=!1;let n=this.node,s=n.absDatapath(n.pathAttribute("destination_path"));if(s===null)return;let i=n.getAttr("_onCalling"),o=new ci({binding:this.binding,method:this.#a("method"),params:di(e),cacheTime:this.#a("cacheTime"),sync:this.#a("sync")!==!1&&this.binding.runtime.gramlot.rpc.supportsCallSync,onCalling:i?()=>this.#l("_onCalling",i,i,e,!0):null,onError:a=>{throw new Error(`${n.nodeTag} '${n.label}': dataRemote '${o.method}' failed: ${a.message}`,{cause:a})}});this.binding.runtime.data.setResolver(s,o),this.#n={path:s,resolver:o},t&&o.refresh()}#p(){if(!this.#n)return;let{path:e,resolver:t}=this.#n;this.#n=null,this.#i=t.loaded||t.loading!==null;let n=this.binding.runtime.data.getNode(e);n?.resolver===t&&(n.resolver=null)}#m(){for(let e of this.#t.splice(0))e.close();this.#r.clear()}},fi=class extends Fr{get kind(){return"formula"}},hi=class extends Fr{get kind(){return"controller"}},pi=class extends Fr{get kind(){return"rpc"}},mi=class extends Fr{get kind(){return"remote"}},nc=["_node","_triggerpars","_reason","_subscription_kwargs","_askResult"],sc=["_evt","button_counter","button_shift","button_ctrl","button_alt","button_meta"];function di(r){let e={...r};for(let t of[...nc,...sc])delete e[t];return e}function eg({event:r,counter:e}){return{_evt:r,button_counter:e,button_shift:!!r.shiftKey,button_ctrl:!!r.ctrlKey,button_alt:!!r.altKey,button_meta:!!r.metaKey}}var tg=[[null,/(\W|^)GET (?:\s*)(\^?[\w.#@$?-]+)/g,"$1this.GET('$2')"],[/;SET/g,/(\W|^)SET (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)=(?:\s*)([^;\r\n]*)(;?)/gm,"$1this.SET('$2', $3)$4 "],[/;PUT/g,/(\W|^)PUT (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)=(?:\s*)([^;\r\n]*)(;?)/gm,"$1this.PUT('$2', $3)$4 "],[/;FIRE_AFTER/g,/(\W|^)FIRE_AFTER (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)=(?:\s*)([^;\r\n]*)(;?)/g,"$1this.FIRE_AFTER('$2', $3)$4 "],[/;FIRE_AFTER/g,/(\W|^)FIRE_AFTER (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)(;?)/g,"$1this.FIRE_AFTER('$2')$3 "],[/;FIRE/g,/(\W|^)FIRE (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)=(?:\s*)([^;\r\n]*)(;?)/g,"$1this.FIRE('$2', $3)$4 "],[/;FIRE/g,/(\W|^)FIRE (?:\s*)(\^?[\w.#@$?-]+)(?:\s*)(;?)/g,"$1this.FIRE('$2')$3 "]],rg=/(\W|^)PUBLISH (?:\s*)(\^?[\w.#@$?-]+)/,ng=new Set(["arguments","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","eval","export","extends","false","finally","for","function","if","implements","import","in","instanceof","interface","let","new","null","package","private","protected","public","return","static","super","switch","this","throw","true","try","typeof","var","void","while","with","yield"]),gi=class{#e;#t=new Map;constructor(e){this.#e=e}get runtime(){return this.#e}get size(){return[...this.#t.values()].reduce((e,t)=>e+t.size,0)}preprocess(e,t,n){let s=n.trim();if(rg.test(s))throw new Error(`${qn(e,t)}: the PUBLISH macro is excluded from Gramlot`);let i=s.replace(/\$(\d+)/g,(o,a)=>`arguments[${parseInt(a,10)-1}]`);for(let[o,a,l]of tg)o&&(i=i.replace(o,`; ${o.source.slice(1)}`)),i=i.replace(a,l);return i!==s&&console.warn(`${qn(e,t)}: legacy macros are deprecated; write this.GET(path), this.SET(path, value), this.PUT(path, value), this.FIRE(path, value), this.FIRE_AFTER(path, value) and arguments[n] in place of GET, SET, PUT, FIRE, FIRE_AFTER and $n`),i}compile(e,t,n,s,i=n){if(e.activatedCode(t)!==n)throw new Error(`${qn(e,t)}: inline code runs only as received with the Source (main or a remote Source); a text written later is not run: use named logic`);let o=this.#t.get(e);o||(o=new Map,this.#t.set(e,o),this.runtime.bindingFor(e).track(()=>this.release(e)));let a=o.get(t);a?.source!==i&&(a={source:i,text:this.preprocess(e,t,i),key:null,run:null},o.set(t,a));let l=s.filter(sg),u=l.join(",");if(a.key!==u){let c=ig(e,t,a.text,l);a.key=u,a.run=d=>c.apply(e,l.map(f=>d[f]))}return a.run}compileExpression(e,t,n){let s=n.slice(2).trim(),i=he(e.getAttr()).filter(([,a])=>!Me(a)),o=this.compile(e,t,n,[...i.map(([a])=>a).filter(a=>a!=="_F"),"_F"],`return ${s}`);return a=>{let l={};for(let[u,c]of i)Object.hasOwn(a,u)?l[u]=a[u]:l[u]=e.pointerType(c)?e.getRelativeData(c):c;return o({...l,_F:(u,c)=>this.runtime.gramlot.format(u,c)})}}compilePointerExpression(e,t,n,s){let i=this.compile(e,t,n,["_pointerValues","_F"],`return (${s}
62
+ )`);return o=>i({_pointerValues:o,_F:(a,l)=>this.runtime.gramlot.format(a,l)})}release(e,t=null){if(t===null){this.#t.delete(e);return}let n=this.#t.get(e);if(n)for(let s of t){n.delete(s);for(let[i]of he({[s]:null}))n.delete(i)}}};function sg(r){return/^[A-Za-z_$][\w$]*$/.test(r)&&!ng.has(r)}function qn(r,e){return`${r.nodeTag} '${r.label}' ${e?`'${e}'`:"node value"}`}function ig(r,e,t,n){try{return t.startsWith("function")?new Function(`return (${t}
60
63
  )`)():new Function(...n,`${t}
61
- `)}catch(s){throw s instanceof EvalError?new EvalError(`${Pn(r,e)}: inline code blocked by the Content Security Policy of the page (no 'unsafe-eval'); move the code to named logic (a method of the page's class Logic) or serve the page with the permissive CSP profile, which allows 'unsafe-eval'`,{cause:s}):new SyntaxError(`${Pn(r,e)}: ${s.message} in the inline code:
62
- ${t}`,{cause:s})}}var di=class{#e;#t;#r=null;#s=null;constructor(e){this.#e=e,this.#t=new Ln(e)}get binding(){return this.#e}get node(){return this.binding.node}get closed(){return this.binding.closed}register(){this.#t.startTiming(this.#i("_timing"),()=>this.update())}receive(e){if(this.#i("_userChanges")&&e.level!=="node")return;let t=this.#i("_delay");t>0?this.#t.debounce(t,()=>this.update()):this.update()}async update(){if(this.closed||!this.binding.hasStamp("start"))return;let e=this.node,[,t]=e.rootBuilder.runtimeValues(e),n=t.remote,s={};for(let[l,u]of Object.entries(t))l.startsWith("remote_")&&(s[l.slice(7)]=u);let i=e.getAttr("_if");if(i&&!this.#a("_if",i,`return (${i})`,s)){let l=e.getAttr("_else");l&&this.#a("_else",l,l,s);return}let a;try{let l=W(s);if(t._cachedRemote&&this.#n(n,l))return;let u=e.getAttr("_onCalling");if(!e.requests.calling(u?()=>this.#a("_onCalling",u,u,s):null))return;a=await this.binding.runtime.gramlot.src.remoteSource(e,n,s)}catch(l){throw new Error(`${e.nodeTag} '${e.label}': remote '${n}' failed: ${l.message}`,{cause:l})}let o=e.getAttr("_onRemote");a&&o&&this.#a("_onRemote",o,o,s)}fragmentMounted(e,t){this.#r=e,this.#s=t}#n(e,t){let n=this.node.requests.inflight;return n?n.method===e&&W(n.params)===t:e===this.#r&&t===this.#s}#i(e){let[,t]=this.node.rootBuilder.runtimeValues(this.node);return t[e]??null}#a(e,t,n,s){return this.binding.runtime.inlineCompiler.compile(this.node,e,t,Object.keys(s),n)(s)}};var Zm=new Set(["title","msg","fields","_if","askIf"]),Jm=new Set(["name","lbl","tag","type","default_value","required","min","max","step","placeholder"]),fi=class{#e;#t=null;#r=new Map;constructor(e){this.#e=e}get runtime(){return this.#e}required(e,t,n,s){let i=(a,o)=>typeof o=="boolean"?o:e.runtime.inlineCompiler.compile(e.node,a,o,Object.keys(n),`return (${o});`)(n);if(typeof t=="string"){let a=e.node.getAttr("_ask_if");return!a||!!i("_ask_if",a)}return t?.askIf&&i(`${s}.askIf`,t.askIf),!t?._if||!!i(`${s}._if`,t._if)}show(e,t,n,s="Parameters"){let i=typeof t=="string"?{msg:t,title:s}:t;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("ask requires text or a parameter description");for(let d of Object.keys(i))if(!Zm.has(d))throw new Error(`Unsupported ask option: ${d}`);let a=i.fields??[];if(!Array.isArray(a))throw new TypeError("ask fields must be an array");let o=new Set;for(let d of a){if(!d||!/^[A-Za-z_]\w*$/.test(d.name)||o.has(d.name))throw new Error("ask fields require distinct simple names");o.add(d.name);for(let f of Object.keys(d))if(!Jm.has(f))throw new Error(`Unsupported ask field option: ${f}`);if(d.tag&&!["input","textarea"].includes(d.tag))throw new Error(`Unsupported ask widget: ${d.tag}`);if(d.type&&!["text","number","date","checkbox","email","password","url","tel"].includes(d.type))throw new Error(`Unsupported ask input type: ${d.type}`)}let l=this.runtime.gramlot,u=this.#s(),c=this.#r;return new Promise((d,f)=>{let h=`ask_${De()}`,p=!1,m=()=>{},g=(_,w=null)=>{if(p)return;p=!0;let y=_?Object.fromEntries(a.map(k=>[k.name,l.data.getItem(`${h}.${k.name}`)])):null;c.delete(h),m();try{l.src.source.popNode(h),l.data.getNode(h)&&l.data.popNode(h),w?f(w):d(y)}catch(k){f(k)}};c.set(h,{finish:g}),m=e.track(()=>g(!1));try{let _=new qe,w=_.root.dialog({nodeId:h,datapath:h,request:h,connect_oncancel:`${u}.cancel`,connect_onclose:`${u}.cancel`,class:"gramlot-ask","aria-labelledby":`${h}_title`,style:"border:1px solid #aab4c2;border-radius:8px;padding:16px;max-width:32rem;width:calc(100% - 48px);font:inherit;"});w.h2(i.title??s,{id:`${h}_title`,style:"font-size:1.1em;margin:0 0 12px;"}),i.msg&&w.p(i.msg);let y=w.form({request:h,connect_onsubmit:`${u}.confirm`});for(let v of a){y.dataSetter({destination_path:`.${v.name}`,value:Object.hasOwn(n,v.name)?n[v.name]:v.default_value??(v.type==="checkbox"?!1:"")});let N=y.div({style:"margin:8px 0;"});N.html_label(v.lbl??v.name,{for:`${h}_${v.name}`,style:"display:block;margin-bottom:4px;"});let L={id:`${h}_${v.name}`,value:`^.${v.name}`,live:!0};for(let U of["required","min","max","step","placeholder"])v[U]!==void 0&&(L[U]=v[U]);v.tag==="textarea"?N.textarea(L):N.input({...L,type:v.type??"text"})}let k=y.div({style:"display:flex;justify-content:flex-end;gap:8px;margin-top:16px;"});k.html_button("Cancel",{type:"button",request:h,connect_onclick:`${u}.cancel`}),k.html_button("Confirm",{type:"submit",autofocus:a.length===0}),l.src.source.setItem(h,l.src.prepareSource(_.source));let T=l.src.binding.nodeIds.get(h);l.dom.getDomNode(T).showModal()}catch(_){g(!1,_)}})}#s(){if(this.#t===null){let e=`ask_${De()}`,t=this.#r;class n{confirm(i,a){a.preventDefault(),t.get(i.getAttr("request"))?.finish(!0)}cancel(i,a){a.preventDefault(),t.get(i.getAttr("request"))?.finish(!1)}}this.runtime.logicRegistry.register(n,{group:e,resource:"gramlot:ask"}),this.#t=e}return this.#t}};var Yu={dataFormula:ai,dataController:oi,dataRpc:li,dataRemote:ui},Km=["datapath","_anchor","nodeId","form","formId"],Lr=class{#e;#t=new Map;#r=new Map;#s;#n;#i;#a;#o;#l=`gramlot-data-${De()}`;#f=!1;constructor(e,{subscriptions:t}){this.#e=e,this.#o=t,this.#s=new ri(this),this.#n=new ni(this),this.#i=new ci(this),this.#a=new fi(this)}get gramlot(){return this.#e}get subscriptions(){return this.#o}get builder(){return this.gramlot.src.builder}get renderer(){return this.gramlot.src.renderer}get logicRegistry(){return this.gramlot.src.logicRegistry}get data(){return this.builder.data}get root(){return this.data.parent}get size(){return this.#t.size}get disposed(){return this.#f}get router(){return this.#s}get installer(){return this.#n}get inlineCompiler(){return this.#i}get askDialog(){return this.#a}get nodeIds(){return this.#r}attach(){this.root.subscribe(this.#l,{any:e=>this.receiveData(e)})}receiveData(e){this.router.deliver(e)}bindingFor(e){return this.#t.get(e)??null}openBinding(e){if(this.disposed)throw new Error("BindingRuntime is disposed");let t=this.bindingFor(e);return t||(t=new ja(this,e),this.#t.set(e,t)),t}closeBranch(e){let t=[];if(e.value instanceof x)for(let s of e.value.getNodes())try{this.closeBranch(s)}catch(i){t.push(i)}let n=this.bindingFor(e);if(n){this.#t.delete(e);let s=e.getAttr("nodeId");this.nodeIds.get(s)===e&&this.nodeIds.delete(s);try{n.close()}catch(i){t.push(i)}}if(t.length)throw new AggregateError(t,"Source branch close failed")}rebindBranch(e){let t=this.#d(e);for(let n of t)this.bindingFor(n)?.rebind();for(let n of t)this.renderer.project(n);for(let n of t)this.bindingFor(n)?.remote?.update()}handleSourceEvent(e){let{evt:t,node:n}=e,s=[],i=a=>{try{this.closeBranch(a)}catch(o){s.push(o)}};try{if(t==="ins")this.#h(n);else if(t==="del")for(let a of Array.isArray(n)?n:[n])i(a);else if(t==="upd_value"||t==="upd_value_attr"){if(e.oldvalue instanceof x)for(let a of e.oldvalue.getNodes())i(a);this.inlineCompiler.release(n,[""]),t==="upd_value_attr"?this.#m(n,e.attrs_diff):this.#c(n).rebind(),n.value instanceof x&&this.#h(n.value)}else if(t==="upd_attrs")this.#m(n,e.attrs_diff);else throw new Error(`Unsupported Source event: ${t}`)}catch(a){throw s.length?new AggregateError([...s,a],"Source event failed"):a}return s}branchBuilt(e){let t=[];for(let n of this.#d(e)){let s=this.bindingFor(n);!s||s.hasStamp("built")||!this.renderer.attached(n)||(s.stamp("built"),t.push(s))}for(let n of t)this.renderer.attached(n.node)&&this.#p(n,"built","_onBuilt");if(this.gramlot.state==="started")for(let n of t)this.renderer.attached(n.node)&&this.#u(n)}pageStarted(){for(let e of[...this.#t.values()])!e.closed&&e.hasStamp("built")&&this.#u(e)}dispose(){if(this.disposed)return;this.#f=!0,this.root.unsubscribe(this.#l,{any:!0}),this.nodeIds.clear();let e=[];for(let[t,n]of[...this.#t.entries()].reverse()){this.#t.delete(t);try{n.close()}catch(s){e.push(s)}}if(e.length)throw new AggregateError(e,"Binding cleanup failed")}#h(e){if(!(e instanceof x)&&this.bindingFor(e))return;let t=e instanceof x?e.getNodes().flatMap(i=>this.#d(i)):this.#d(e),n=new Set(t.filter(i=>this.bindingFor(i))),s=new Map;for(let i of t){let a=i.getAttr("nodeId");if(a!=null){if(s.has(a)||this.nodeIds.has(a)&&this.nodeIds.get(a)!==i)throw new Error(`Duplicate nodeId '${a}'`);s.set(a,i)}}for(let[i,a]of s)this.nodeIds.set(i,a);try{this.installer.install(e);for(let i of t)this.openBinding(i);for(let i of t)this.bindingFor(i).registerPointers()}catch(i){let a=[i];for(let o of t.filter(l=>!n.has(l)).reverse()){let l=o.getAttr("nodeId");s.get(l)===o&&this.nodeIds.get(l)===o&&this.nodeIds.delete(l);let u=this.bindingFor(o);if(u){this.#t.delete(o);try{u.close()}catch(c){a.push(c)}}}throw a.length>1?new AggregateError(a,"Source branch installation failed"):i}for(let i of t){let a=this.bindingFor(i);if(!(!a||a.hasStamp("init")||!this.renderer.attached(i))&&(a.stamp("init"),Zu(i.getAttr("_init"))))for(let o of a.providers)o.invoke({kind:"init",change:null})}}#u(e){e.hasStamp("start")||(e.stamp("start"),this.#p(e,"start","_onStart"),e.remote?.update())}#p(e,t,n){let s=e.node.getAttr(n);if(Zu(s))for(let i of e.providers){if(typeof s!="number"||s<=0){i.invoke({kind:t,change:null});continue}let a=null,o=setTimeout(()=>{a(),i.invoke({kind:t,change:null})},s);a=e.track(()=>clearTimeout(o))}}#m(e,t){let n=this.#c(e);if(this.inlineCompiler.release(e,Object.keys(t)),Object.hasOwn(t,"nodeId")){let{old:s,new:i}=t.nodeId;if(i!=null&&this.nodeIds.has(i)&&this.nodeIds.get(i)!==e)throw new Error(`Duplicate nodeId '${i}'`);this.nodeIds.get(s)===e&&this.nodeIds.delete(s),i!=null&&this.nodeIds.set(i,e)}Km.some(s=>Object.hasOwn(t,s))?this.rebindBranch(e):n.rebind()}#c(e){let t=this.bindingFor(e);if(!t)throw new Error(`${e.nodeTag??"fragment"} '${e.label}': the node has no NodeBinding (its installation failed); remove it from the Source and insert it again`);return t}#d(e){let t=[e];if(e.value instanceof x)for(let n of e.value.getNodes())t.push(...this.#d(n));return t}};function Zu(r){return r===!0||typeof r=="number"}var ja=class{#e;#t;#r=!1;#s=[];#n=[];#i=new Set;#a=null;#o=null;#l=new Set;#f=new Set;#h=0;#u=new Set;constructor(e,t){this.#e=e,this.#t=t}get runtime(){return this.#e}get node(){return this.#t}get closed(){return this.#r}get registrations(){return[...this.#n]}get providers(){return this.#a?[this.#a]:[]}get remote(){return this.#o}get clickCount(){return this.#h}countClick(){return++this.#h}hasStamp(e){return this.#i.has(e)}stamp(e){this.#i.add(e)}registerPointers(){this.node._getMeta("data_element")&&(this.runtime.renderer.references.remove(this.node),this.runtime.renderer.references.register(this.node,null));let e=this.node,t=e._getMeta("data_element");if(t&&!Yu[e.nodeTag])return;!t&&typeof e.getAttr("remote")=="string"&&(this.#o??=new di(this));let n=new Set;if(e._getMeta("gramlot_component")?.bagStore){let i=e.getAttr("storepath");if(typeof i!="string"||!i||/^[\^=]/.test(i)||i.includes("?"))throw new TypeError("storepath requires a plain Bag data path");let a=e.absDatapath(i);this.#n.push(this.runtime.router.register({path:a,recipient:this,subtree:!0}))}let s=this.remote?Ve(e,e.getAttr("_timing")):new Set;if(this.remote){for(let[i,a]of Object.entries(e.getAttr()))if(i.startsWith("remote_"))for(let o of Ve(e,a))n.add(o)}for(let[i,a]of e.pointers()){if(t&&i!=="datapath")continue;let l=(i==="datapath"?e.parentNode:e).absDatapath(a);if(l===null)continue;let[u,c=null]=l.split("?",2),d=this.runtime.router.register({path:u,attr:c,recipient:this});this.#n.push(d),i==="datapath"&&this.#u.add(d),this.remote&&(i==="remote"||i.startsWith("remote_")||n.has(i))&&this.#l.add(d),this.remote&&(i==="_timing"||s.has(i))&&this.#f.add(d)}if(!t){this.#p(),this.remote?.register();return}this.#a??=new Yu[e.nodeTag](this),this.#a.register()}#p(){let e=this.node;this.#n.push(...this.runtime.subscriptions.subscribeNode(e,(t,n)=>{if(typeof n!="string"||!n)throw new TypeError(`${t} requires a handler`);return s=>{if(this.closed)return;if(/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)+$/.test(n)){let{group:l,method:u}=this.runtime.logicRegistry.resolve(n,e);return u.call(l,e,s)}let[,i]=e.rootBuilder.runtimeValues(e),a=Object.fromEntries(Object.entries(i).filter(([l])=>!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),o={...this.runtime.renderer.references.resolveArguments(a),p_0:s};return this.runtime.inlineCompiler.compile(e,t,n,Object.keys(o))(o)}}))}rebind(){this.#m(),this.registerPointers()}receive(e){if(this.#u.has(e.registration)){this.runtime.rebindBranch(this.node);return}this.#l.has(e.registration)&&this.remote.receive(e),this.#f.has(e.registration)&&this.remote.register(),this.runtime.renderer.project(this.node,e)}track(e){if(this.closed)throw new Error(`NodeBinding of '${this.node.label}' is closed`);return this.#s.push(e),()=>{let t=this.#s.indexOf(e);t!==-1&&this.#s.splice(t,1)}}async call(e,t){let{controller:n}=t,s=this.track(()=>n.abort());try{let i=await this.runtime.gramlot.rpc.call(e,t.method,t.params,{signal:n.signal});if(n.signal.aborted)throw n.signal.reason;return i}finally{s()}}callSync(e,t,n){return this.node.requests.submitSync(t,()=>this.runtime.gramlot.rpc.callSync(e,t,n))}close(){if(this.closed)return;this.#r=!0,this.node._getMeta("data_element")&&this.runtime.renderer.references.remove(this.node),this.#m();let e=[];for(let t of this.#s.splice(0).reverse())try{t()}catch(n){e.push(n)}if(e.length)throw new AggregateError(e,`NodeBinding of '${this.node.label}' cleanup failed`)}#m(){for(let e of this.#n.splice(0))e.close();this.#u.clear(),this.#l.clear(),this.#f.clear()}};var hi=class{constructor(e){this.renderer=e}prepare(e,t){let n=this.renderer.records.get(e);if(!n||n.resolved.draggable!==!0)return null;let s=e._getMeta("gramlot_component")?.dragSource?n.element.getDragContext(t):{dragValues:{},item:void 0,path:void 0};if(s===null)return null;let{dragValues:i,item:a,path:o}=s;if(n.resolved.onDrag){let u=this.renderer.html.callLogic(e,n.resolved.onDrag,{dragValues:i,item:a,path:o});if(u&&typeof u.then=="function")throw new TypeError("onDrag must run synchronously");if(u===!1)return null}return xt(i),{dragValues:Object.fromEntries(Object.entries(i).map(([u,c])=>{if(u.startsWith("text/")||u==="dragTags"){if(typeof c!="string")throw new TypeError(`${u} drag data must be text`);return[u,c]}return[u,P(W(c))]})),item:a,path:o}}};var Ct=class{static isTarget(e){return e.dropTarget===!0||!!e.dropTargetCb||Object.entries(e).some(([t,n])=>t.startsWith("dropTargetCb_")&&!!n)}static acceptedTypes(e,t="",n=[]){let s=t.split(",").map(i=>i.trim()).filter(Boolean).map(i=>{let a=i.split("*").map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"));return new RegExp(`^${a.join(".*")}$`)});return e.filter(i=>i!=="dragTags"&&(n.includes(i)||s.some(a=>a.test(i))))}static acceptsTags(e="",t=""){if(!t.trim())return!0;let n=new Set(e.split(",").map(s=>s.trim()).filter(Boolean));return n.size?t.split(",").some(s=>s.split(" AND ").every(i=>(i=i.trim(),!i||i==="!"?!1:i.startsWith("!")?!n.has(i.slice(1)):n.has(i)))):!1}static acceptsEffect(e="all",t="move"){let n={all:["copy","move","link"],none:[],copy:["copy"],move:["move"],link:["link"],copyMove:["copy","move"],copyLink:["copy","link"],linkMove:["link","move"]};if(!Object.hasOwn(n,e))throw new TypeError(`Invalid effectAllowed: ${e}`);if(!["copy","move","link"].includes(t))throw new TypeError(`Invalid dropEffect: ${t}`);return n[e].includes(t)}static evaluate(e,t,n,s,i=[]){let a=this.acceptedTypes(e,s.dropTypes,i),o=s.dropEffect??"move",l=this.isTarget(s)&&a.length>0&&this.acceptsTags(t,s.dropTags)&&this.acceptsEffect(n,o);return{accepted:l,types:a,dropEffect:l?o:"none"}}};var Ju=["dragstart","dragover","dragleave","drop","dragend"],pi=class{#e;#t;#r=null;#s=null;#n=null;#i;constructor(e){this.#e=e,this.#t=e.destination.ownerDocument;for(let t of Ju)this.#t.addEventListener(t,this);this.#i=()=>this.#_("none"),this.#t.defaultView.addEventListener("pagehide",this.#i)}handleEvent(e){e.type==="dragstart"?this.#l(e):e.type==="dragend"?this.#_(e.dataTransfer.dropEffect):e.type==="dragleave"?this.#c():e.type==="dragover"?this.#u(e):e.type==="drop"&&this.#p(e)}#a(e,t){for(let n of e.composedPath()){let s=this.#e.elements.get(n);if(s&&t(s.resolved))return s}return null}#o(e,t){return e.node._getMeta("gramlot_component")?.dragSource?e.element.getDragContext(t):{element:e.element,item:void 0,path:void 0}}#l(e){let t=this.#a(e,n=>n.draggable===!0);if(t){this.#_("none");try{let n=this.#e.prepareDrag(t.node,e);if(!n||!t.element.isConnected||this.#e.records.get(t.node)!==t){e.preventDefault();return}let s=this.#o(t,e);if(!s){e.preventDefault();return}let i=new Map(Object.entries(n.dragValues).filter(([u])=>u!=="dragTags").map(([u,c])=>[u,u.startsWith("text/")?c:W(c)]));if(!i.size){e.preventDefault();return}let a=t.resolved.effectAllowed??"all";Ct.acceptsEffect(a,"move");let o="";for(let u=t;u;u=u.parent)if(u.resolved?.dragTags!=null){o=u.resolved.dragTags;break}let l=this.#r={record:t,wires:i,effectAllowed:a,phase:"active",tags:[o,n.dragValues.dragTags].filter(Boolean).join(","),endTopic:this.#e.binding.gramlot._subscriptions.topicFor(t.node,"endDrag"),source:{pageId:this.#e.binding.gramlot.pageId??null,sourcePath:t.node.fullpath,itemPath:n.path??null},preview:null,release:null};e.dataTransfer.clearData();for(let[u,c]of i)e.dataTransfer.setData(u,c);e.dataTransfer.effectAllowed=a,this.#n=this.#t.createElement("style"),this.#n.textContent=".canBeDropped{outline:2px solid var(--gramlot-brand-blue,#3766b5);outline-offset:-2px}.cannotBeDropped{outline:2px dashed currentColor;outline-offset:-2px}.draggedItem{opacity:.75}",this.#t.head.append(this.#n),this.#f(l,s.element,e.dataTransfer),l.release=this.#e.onDispose(t.node,()=>this.#_("none"))}catch(n){e.preventDefault(),this.#g(),this.#b(n)}}}#f(e,t,n){let s=t.cloneNode(!0);s.removeAttribute("id");for(let i of s.querySelectorAll("[id]"))i.removeAttribute("id");s.setAttribute("aria-hidden","true"),s.classList.add(...(e.record.resolved.dragClass??"draggedItem").split(/\s+/).filter(Boolean)),Object.assign(s.style,{position:"fixed",left:"-10000px",top:"0",width:`${t.getBoundingClientRect().width}px`,pointerEvents:"none"}),t.parentNode.append(s),e.preview=s,n.setDragImage(s,0,0)}#h(e){let t=this.#r,n=this.#a(e,u=>Ct.isTarget(u));if(!n)return null;let s=this.#o(n,e);if(!s)return{record:n,element:n.element,accepted:!1};let i=Ct.evaluate([...t.wires.keys()],t.tags,t.effectAllowed,n.resolved),o={dropValues:Object.fromEntries(i.types.map(u=>[u,u.startsWith("text/")?t.wires.get(u):P(t.wires.get(u))])),item:s.item,path:s.path,source:{...t.source},selfdrop:n===t.record,dropEffect:i.dropEffect,dataAvailable:!0},l=i.accepted&&this.#e.checkDropTarget(n.node,o)&&this.#e.records.get(n.node)===n&&s.element.isConnected;return{record:n,element:s.element,accepted:l,context:o}}#u(e){if(!this.#r){this.#a(e,t=>Ct.isTarget(t))&&(e.preventDefault(),e.dataTransfer.dropEffect="none");return}if(e.preventDefault(),this.#r.phase!=="active"){e.dataTransfer.dropEffect="none";return}try{let t=this.#r,n=this.#h(e);if(this.#r!==t){e.dataTransfer.dropEffect="none";return}e.dataTransfer.dropEffect=n?.accepted?n.context.dropEffect:"none",this.#c(),n&&this.#m(n.element,n.accepted)}catch(t){e.dataTransfer.dropEffect="none",this.#r&&(this.#r.phase="rejected"),this.#d(),this.#b(t)}}async#p(e){if(!this.#r){this.#a(e,n=>Ct.isTarget(n))&&e.preventDefault();return}if(e.preventDefault(),this.#r.phase!=="active")return;let t=this.#r;try{let n=this.#h(e);if(this.#r!==t){e.dataTransfer.dropEffect="none";return}if(t.phase="dropped",this.#d(),!n?.accepted){e.dataTransfer.dropEffect="none";return}e.dataTransfer.dropEffect=n.context.dropEffect,n.record.node.publish("onDrop",n.context),await this.#e.invokeDrop(n.record.node,n.context)}catch(n){this.#r===t&&(t.phase="rejected",this.#d()),this.#b(n)}}#m(e,t){let n=t?"canBeDropped":"cannotBeDropped",s=(e.getAttribute("part")??"").split(/\s+/).filter(Boolean);this.#s={element:e,name:n,hadClass:e.classList.contains(n),hadPart:s.includes(n)},e.classList.add(n),s.includes(n)||e.setAttribute("part",[...s,n].join(" "))}#c(){if(!this.#s)return;let{element:e,name:t,hadClass:n,hadPart:s}=this.#s;n||e.classList.remove(t),s||e.setAttribute("part",(e.getAttribute("part")??"").split(/\s+/).filter(i=>i!==t).join(" ")),this.#s=null}#d(){this.#c(),this.#r&&(this.#r.preview?.remove(),this.#r.preview=null,this.#r.wires.clear())}#g(){let e=this.#r;return this.#d(),this.#r=null,e?.release?.(),this.#n?.remove(),this.#n=null,e}#_(e){let t=this.#g();!t||this.#e.disposed||this.#e.endDrag(t.record.node,{source:{...t.source},dropEffect:e},t.endTopic).catch(n=>this.#b(n))}#b(e){console.error("Gramlot drag/drop failed:",e)}dispose(){this.#g();for(let e of Ju)this.#t.removeEventListener(e,this);this.#t.defaultView.removeEventListener("pagehide",this.#i)}};var Fn=class extends Jt{static renderType="object";#e=new Set;#t=new WeakMap;#r=new WeakMap;#s=new WeakMap;constructor(e,t,n,{binding:s}={}){if(super(e),!(e instanceof ye)||!(t instanceof le)||n?.nodeType!==1)throw new TypeError("GramlotRenderer requires a BuilderBase, GramlotBuilderBag and HTML destination");if(!(s instanceof Lr))throw new TypeError("GramlotRenderer requires a BindingRuntime");if(!(t._builder instanceof ye))throw new TypeError("SourceBag requires builder ownership");this._binding=s,this.source=t,this.destination=n,this.html=new Ks({metadataAttributes:["__ref"],callLogic:(i,a,o)=>{let{group:l,method:u}=s.gramlot.src.logicRegistry.resolve(a,i);return u.call(l,i,o)},invokeScript:(i,a,o,l)=>this.inlineCompiler.compile(i,a,o,i.parentNode._getMeta("gramlot_component").childParameters[a].inline)(l)}),this.records=new Map,this.references=new Mn(t),this.pending=[],this.building=!1,this.disposed=!1,this.elements=new WeakMap,this.dragPreparation=new hi(this),this.instanceId=De(),this.radioGroups=new Js(this),this.dragDrop=new pi(this),this.subscription=`html-source-renderer-${this.instanceId}`,t.subscribe(this.subscription,{any:i=>this.receive(i)})}get binding(){return this._binding}prepareDrag(e,t){return this.dragPreparation.prepare(e,t)}checkDropTarget(e,{dropValues:t,item:n,path:s,source:i,selfdrop:a,dropEffect:o,dataAvailable:l}){let u=this.records.get(e);if(!u)return!1;if(!u.resolved.dropTargetCb)return!0;let c=this.html.callLogic(e,u.resolved.dropTargetCb,{dropValues:t,item:n,path:s,source:i,selfdrop:a,dropEffect:o,dataAvailable:l});if(typeof c!="boolean")throw new TypeError("dropTargetCb must return a boolean synchronously");return c}async invokeDrop(e,{dropValues:t,item:n,path:s,source:i,selfdrop:a,dropEffect:o,dataAvailable:l}){let u=this.records.get(e);!u||!u.resolved.onDrop||Object.keys(t).length===0||await this.html.callLogic(e,u.resolved.onDrop,{dropValues:t,item:n,path:s,source:i,selfdrop:a,dropEffect:o,dataAvailable:l})}async endDrag(e,{source:t,dropEffect:n},s){let i={source:t,dropEffect:n},a=[],o=this.records.get(e);try{o&&!o.binding.closed&&o.resolved.onDragEnd&&await this.html.callLogic(e,o.resolved.onDragEnd,i)}catch(l){a.push(l)}try{this.binding.gramlot.publish(s,i)}catch(l){a.push(l)}if(a.length)throw new AggregateError(a,"Drag completion notification failed")}get inlineCompiler(){return this.binding.inlineCompiler}evaluateExpressions(e,t){let n=this.#r.get(e)??super.evaluateExpressions(e,t),s=e._getMeta("gramlot_component");if(s?.presentationDefaults.length){let i=e.getAttr();this.#s.set(e,Object.fromEntries(Object.entries(n).filter(([a])=>Object.hasOwn(i,a)&&s.presentationDefaults.some(o=>a.startsWith(o)))))}if(s&&(s.parameters.value?.binding==="twoWay"||s.presentationDefaults.length)){let i=[];for(let a=e.parentNode;a;a=a.parentNode)this.#s.has(a)&&i.unshift(this.#s.get(a));n=Object.assign({},...i,n)}return this.#r.delete(e),this.#t.set(e,n),n}render(e,t={}){if(!(e instanceof Zt))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(e._getMeta("data_element")||!this.binding.bindingFor(e)&&this.#o(e))return null;if(e.nodeTag)this.html.validate(e,e._getMeta("subbuilder")?e.parentBag._builder:e.builder);else if(!(e.value instanceof x))throw new TypeError("Source fragments must contain child SourceBags");return e.nodeTag?super.render(e,t):this.renderFragment(e,t)}renderFragment(e,{document:t=this.destination.ownerDocument,...n}={}){let s=t.createDocumentFragment(),i={node:e,binding:this.#c(e),container:null,parent:null,children:new Set,cleanup:[],start:t.createComment("source-fragment"),end:t.createComment("/source-fragment")};this.records.set(e,i),this.elements.set(s,i),s.append(i.start);for(let a of e.value.getNodes()){let o=this.render(a,{document:t,...n});if(o===null)continue;s.append(o);let l=this.elements.get(o);l&&(l.parent=i,i.children.add(a))}return s.append(i.end),s}renderedItem(e,t,n,{tag:s,document:i=this.destination.ownerDocument}={}){let a=n;t=this.expressionValue(e,t),this.getRender(e.builder)===this&&(a=this.restoreNativeAttributes(e,n),e._getMeta("gramlot_component")||([t,a]=On(t,a,(h,p)=>this._binding.gramlot.format(h,p)))),a=this.componentAttributes(e,a);let o=Array.isArray(t)?t:[],l=Array.isArray(t)?a._text:t,u=this.#t.get(e),c={node:e,binding:this.#c(e),container:null,parent:null,children:new Set,cleanup:[],resolved:u,...this.html.create(e,i,s,a,u.visible??null)};this.html.compose(c,l,o),c.shape=_e.shape(c.element,u),this.records.set(e,c),this.elements.set(c.element,c);let d=_e.for(c.binding,c);d&&(c.control=d,d.attach(),c.cleanup.push(()=>d.detach()),this.#u(c,e,a,null));let f=Qs.for(c.binding,c);f&&(c.button=f,f.attach(),c.cleanup.push(()=>f.detach())),this.#p(c),this.references?.register(e,c.element);for(let h of o){let p=this.elements.get(h);p&&(p.parent=c,p.container=c.element,c.children.add(p.node))}return c.element}validateCandidate(e,{replacingNode:t=null}={}){if(!(e instanceof le))throw new TypeError("Source values must be GramlotBuilderBags");let n=new Set,s=i=>{if(!n.has(i)){n.add(i);for(let a of this.records.get(i)?.children??[])s(a);if(i.value instanceof x)for(let a of i.value.getNodes())s(a)}};for(let i of this.records.get(t)?.children??[])s(i);if(t?.value instanceof x)for(let i of t.value.getNodes())s(i);return this.#n(e,t?t.nodeTag:null),Fa(e),this.references?.validate(e,n),e}#n(e,t=null){let n=new Set,s=(i,a=null)=>{if(!(i instanceof le)||n.has(i))throw new TypeError("Source values must be unshared, acyclic GramlotBuilderBags");if(!(i._builder instanceof ye))throw new TypeError("SourceBag requires builder ownership");n.add(i);for(let o of i.getNodes()){if(!(o instanceof Zt))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(!(o.builder instanceof ye))throw new TypeError("SourceBagNode requires builder ownership");if(o.resolver)throw new TypeError("Source resolvers are outside this port");if(o._getMeta("data_element"))o.builder.validateNode(o);else if(o.nodeTag){let l=o._getMeta("subbuilder")?i._builder:o.builder;this.html.validate(o,l),o._getMeta("subbuilder")||o.builder.validateParent(o.nodeTag,a)}else{if(!(o.value instanceof x))throw new TypeError("Source fragments must contain child SourceBags");if(Object.keys(o.attr).some(l=>l!=="_meta"))throw new TypeError("Fragment attributes are unsupported")}o.value instanceof x&&s(o.value,o._getMeta("subbuilder")?null:o.nodeTag??a)}};s(e,t)}freeze(e){e=se(e);let t=this.records.get(e);if(!t||this.disposed)throw new Error("Freeze requires a mounted Source node");t.frozen=!0}unfreeze(e){e=se(e);let t=this.records.get(e);if(!t||this.disposed)throw new Error("Unfreeze requires a mounted Source node");let n=s=>{delete s.frozen;for(let i of s.children)n(this.records.get(i))};n(t),!this.#i(e)&&(this.attached(e)?this.#d(e):this.remove(e))}#i(e){for(;e;){let t=this.records.get(e);if(t?.frozen)return!0;e=e.parentBag?.parentNode??t?.parent?.node}return!1}receive(e){if(!this.disposed){if(Array.isArray(e.node)){let t=e.node.filter(n=>!this.#e.has(n));if(!t.length)return;e={...e,node:t}}else if(this.#e.has(e.node))return;if(this.pending.push(e),!this.building){this.building=!0;try{for(;this.pending.length;){let t=this.pending.shift();if(t.evt!=="del"&&!this.attached(t.node))continue;t.evt!=="del"&&t.evt!=="upd_attrs"&&this.#l(t);let n=this.binding.handleSourceEvent(t);try{this.#a(t,n)}catch(s){if(!n.length)throw s;n.push(s)}if(n.length)throw n.length===1?n[0]:new AggregateError(n,"Source cleanup failed")}}catch(t){throw this.pending.length=0,t}finally{this.building=!1}}}}#a(e,t){if(e.evt==="del"){for(let n of Array.isArray(e.node)?e.node:[e.node]){if(this.#i(n))continue;let s=this.records.get(n)?.parent??null;try{this.remove(n)}catch(i){t.push(i)}this.#m(s)}return}if(!this.#i(e.node))if(e.evt==="ins")this.insert(e.node);else if(e.evt.startsWith("upd_"))this.update(e.node,e.evt);else throw new Error(`Unsupported Source event: ${e.evt}`)}attached(e){let t=e.parentBag;for(;t&&t!==this.source;)t=t.parentNode?.parentBag;return t===this.source}#o(e){let t=new Set(this.pending.flatMap(n=>Array.isArray(n.node)?n.node:[n.node]));for(let n=e;n;n=n.parentBag?.parentNode)if(t.has(n))return!0;return!1}#l(e){let t=n=>{if(!(n instanceof Zt))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(n.value instanceof x){if(!(n.value instanceof le))throw new TypeError("Source values must be GramlotBuilderBags");for(let s of n.value.getNodes())t(s)}};t(e.node)}insert(e){if(!this.attached(e)||this.records.has(e))return;if(e._getMeta("data_element")){this.records.get(e.parentBag?.parentNode)?.button?.refresh(),this.binding.branchBuilt(e);return}let t=this.records.get(e.parentBag?.parentNode),n=t?.element??t?.container??this.destination,s=e.parentBag.getNodes(),i=t?.end??null;for(let a=s.indexOf(e)+1;a<s.length;a++){let o=this.records.get(s[a]);if(o){i=o.element??o.start;break}}this.buildNode(e,n,i,t)}buildNode(e,t,n=null,s=null){this.#e.add(e);let i;try{i=this.render(e,{document:t.ownerDocument})}catch(o){this.#f(e,o)}finally{this.#e.delete(e)}let a=this.records.get(e);return t.insertBefore(i,n),a.parent=s,this.assignContainer(a,t),s?.children.add(e),this.#m(s),this.binding.branchBuilt(e),a}#f(e,t){let n=[t],s=[],i=a=>{if(s.push(a),a.value instanceof x)for(let o of a.value.getNodes())i(o)};i(e);for(let a of s.reverse())try{this.remove(a)}catch(o){n.push(o)}throw n.length===1?t:new AggregateError(n,"Source build and cleanup failed")}assignContainer(e,t){e.container=t;let n=e.element??t;for(let s of e.children){let i=this.records.get(s);i&&this.assignContainer(i,n)}}update(e,t){let n=this.records.get(e);if(!n){this.insert(e);return}let s=e.value==null||["string","number","boolean"].includes(typeof e.value),i=t==="upd_value"&&s&&n.element&&n.children.size===0&&this.html.matches(n,e);(t==="upd_attrs"||i)&&n.element&&this.html.matches(n,e)?(e.nodeTag&&this.html.validate(e,e._getMeta("subbuilder")?e.parentBag._builder:e.builder),this.project(e),t==="upd_attrs"&&this.records.get(e)===n&&(this.references?.remove(e),this.references?.register(e,n.element))):this.#d(e)}project(e,t=null){let n=this.records.get(e);if(!n?.element)return;let s=this.getRender(e.builder),i=this.#s.get(e),[a,o]=e.rootBuilder.runtimeValues(e),[,l]=s._handleMeta(e,o),u=this.#t.get(e);if(n.shape!==_e.shape(n.element,u)){if(this.#i(e))return;this.#r.set(e,u);try{this.#d(e)}finally{this.#r.delete(e)}return}n.resolved=u;let c=e._getMeta("subbuilder")?l:s.adaptAttrs(l),d=e.value instanceof x,f=d?[]:this.expressionValue(e,a);s===this&&(c=this.restoreNativeAttributes(e,c),e._getMeta("gramlot_component")||([f,c]=On(f,c,(p,m)=>this._binding.gramlot.format(p,m)))),c=this.componentAttributes(e,c),this.html.update(n,e,c,d?c._text:f,u.visible??null),this.#u(n,e,c,t),n.control?.refresh(),n.button?.refresh(),this.#p(n);let h=this.#s.get(e);if(h){let p=new Set([...Object.keys(i??{}),...Object.keys(h)].filter(m=>!Object.is(i?.[m],h[m])));p.size&&this.#h(e,p)}(n.element.localName==="option"||n.element.localName==="optgroup")&&this.#m(n.parent)}#h(e,t){if(e.value instanceof x)for(let n of e.value.getNodes()){let s=n._getMeta("gramlot_component"),i=n.getAttr(),a=t;s?.presentationDefaults.length?a=new Set([...t].filter(o=>!Object.hasOwn(i,o))):s?.parameters.value?.binding==="twoWay"&&[...t].some(o=>!Object.hasOwn(i,o))&&this.project(n),a.size&&this.#h(n,a)}}componentAttributes(e,t){let n=e._getMeta("gramlot_component"),s=e.parentNode?._getMeta("gramlot_component")?.childParameters;if(!n&&!s)return t;let i=this.#t.get(e),a=Object.fromEntries([...new Set([...Object.keys(n?.parameters??{}),...Object.keys(s??{}),...Object.keys(i).filter(o=>o.startsWith("validate_"))])].filter(o=>Object.hasOwn(i,o)).map(o=>[o,i[o]]));return{...t,...a}}#u(e,t,n,s){if(!e.control)return;let i=t.getAttr("value")!=null;(i||e.valueDeclared)&&e.control.project(n.value??null,s),e.valueDeclared=i}#p(e){let t=new Map(Rn.declared(e.node).map(n=>[n[0],n]));if(!e.events){if(!t.size)return;e.events=new Map,e.cleanup.push(()=>{for(let n of e.events.values())n.detach();e.events.clear()})}for(let[n,s]of[...e.events])t.get(n)?.[2]!==s.handler&&(s.detach(),e.events.delete(n));for(let[n,[,s,i]]of t){if(e.events.has(n))continue;let a=new Rn(e.binding,e,s,i,n);a.attach(),e.events.set(n,a)}}#m(e){for(let t=e;t;t=t.parent){if(t.control instanceof Bn){this.project(t.node);return}if(t.element&&t.element.localName!=="optgroup")return}}getDomNode(e){let t=se(e),n=this.records.get(t);return n&&this.attached(t)?n.element??null:null}getBaseSourceNode(e){for(let t=e;t;t=t.parentNode){let n=t.nodeType===1?this.elements.get(t):null;if(n)return this.attached(n.node)?n.node:null}return null}#c(e){let t=this.binding.bindingFor(e);if(!t)throw new Error(`${e.nodeTag??"fragment"} '${e.label}': rendered without an open NodeBinding`);return t}#d(e){let t=this.records.get(e),n=t.element?.nextSibling??t.end?.nextSibling??null,s=t.container,i=t.parent,a=null;try{this.remove(e)}catch(o){a=o}try{this.buildNode(e,s,n,i)}catch(o){throw a?new AggregateError([a,o],"Source replacement cleanup and commit failed"):o}if(a)throw a}onDispose(e,t){let n=this.records.get(e);if(!n)throw new Error("Source node is not mounted");return n.cleanup.push(t),()=>{let s=n.cleanup.indexOf(t);s!==-1&&n.cleanup.splice(s,1)}}remove(e){let t=this.records.get(e);if(!t)return;let n=[];for(let s of[...t.children])try{this.remove(s)}catch(i){n.push(i)}for(let s of t.cleanup.splice(0).reverse())try{s()}catch(i){n.push(i)}if(this.references?.remove(e),t.element&&this.elements.delete(t.element),t.element?.remove(),t.start?.remove(),t.end?.remove(),t.parent?.children.delete(e),this.records.delete(e),this.#t.delete(e),this.#s.delete(e),n.length)throw new AggregateError(n,"Source cleanup failed")}dispose(){if(this.disposed)return;this.disposed=!0,this.dragDrop.dispose(),this.source.unsubscribe(this.subscription,{any:!0}),this.pending.length=0;let e=[],t=[...this.records.entries()].filter(([,n])=>!n.parent).map(([n])=>n);for(let n of t)try{this.remove(n)}catch(s){e.push(s)}if(e.length)throw new AggregateError(e,"Renderer cleanup failed")}};var Qm=new Set(["page","constructor"]);function Ku(r,e){if(r===null)return[];let t=r.split("/");for(let n of t)if(Qm.has(n))throw new Error(`${e}: a logic group cannot be named '${n}' (group '${r}')`);return t}var eg=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function tg(r){return/^[\w$]/.test(r)?eg.has(r):r!==")"&&r!=="]"}function rg(r,e){let t=!1;for(let n=e+1;n<r.length;n++){let s=r[n];if(s===`
63
- `)return-1;if(s==="\\"){n++;continue}if(s==="[")t=!0;else if(s==="]")t=!1;else if(s==="/"&&!t)return n}return-1}function ng(r){let e=0,t="",n="";for(let s=r.indexOf("{");s<r.length;s++){let i=r[s];if(i==="/"&&r[s+1]==="/"){if(s=r.indexOf(`
64
- `,s),s<0)break;continue}if(i==="/"&&r[s+1]==="*"){let a=r.indexOf("*/",s+2);if(a>=0){s=a+1;continue}}if(i==="/"&&tg(n)){let a=rg(r,s);if(a>=0){s=a,n=")";continue}}if(i==='"'||i==="'"||i==="`"){let a=s+1;for(;a<r.length&&r[a]!==i;)a+=r[a]==="\\"?2:1;e===1&&(t+=r.slice(s+1,a)==="constructor"?" constructor":' ""'),s=a,n=")";continue}if(/[\w$]/.test(i)){let a=s+1;for(;a<r.length&&/[\w$]/.test(r[a]);)a++;e===1&&(t+=r.slice(s,a)),n=r.slice(s,a),s=a-1;continue}if(/\s/.test(i)||(n=i),i==="{"){++e===2&&(t+=" {}");continue}if(i==="}"){e--;continue}e===1&&(t+=i)}return/(?<![\w$.#])(?<!\bstatic\s+)constructor\s*\(/.test(t)}function Qu(r,e){if(r===void 0)return[];if(typeof r!="function"||!/^class\b/.test(Function.prototype.toString.call(r)))throw new Error(`${e}: the module exports no class Logic`);if(Object.getPrototypeOf(r)!==Function.prototype||Object.getPrototypeOf(r.prototype)!==Object.prototype)throw new Error(`${e}: class Logic cannot extend another class`);if(ng(Function.prototype.toString.call(r)))throw new Error(`${e}: class Logic cannot declare a constructor; state lives on the group or the page`);let t=[];for(let n of Reflect.ownKeys(r.prototype)){if(n==="constructor")continue;if(typeof n=="symbol")throw new Error(`${e}: class Logic cannot declare symbol keys (${String(n)})`);let s=Object.getOwnPropertyDescriptor(r.prototype,n);if(s.get||s.set)throw new Error(`${e}: class Logic cannot declare the accessor '${n}'`);if(typeof s.value!="function")throw new Error(`${e}: Logic.prototype.${n} is not a method`);if(n==="page")throw new Error(`${e}: a logic method cannot be named 'page'`);t.push([n,s.value])}return t}function ec(r,e,t){Object.defineProperty(r,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}var Qt=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get page(){return this.#t}},Pr=class{#e;#t=new Map;constructor(e){this.#e=e,e.logic=new Qt(this,e)}get gramlot(){return this.#e}static check(e){let t=new Map;for(let{group:n,resource:s}of e){let i=Ku(n,s);for(let a=0;a<i.length;a++){let o=i.slice(0,a).join("/");t.has(o)||t.set(o,new Set),t.get(o).add(i[a])}}for(let{logicClass:n,group:s,resource:i}of e){let a=t.get(s??"")??new Set;for(let[o]of Qu(n,i))if(a.has(o))throw new Error(`${i}: the logic method '${o}' has the name of a child group`)}}register(e,{group:t=null,resource:n}){let s=Ku(t,n),i=Qu(e,n),a=this.#e.logic;for(let o of s){let l=Object.getOwnPropertyDescriptor(a,o)?.value;if(l===void 0){let u=new Qt(this,this.#e);ec(a,o,u),a=u}else if(l instanceof Qt)a=l;else throw new Error(`${n}: the group '${o}' has the name of a logic method`)}for(let[o,l]of i){if(Object.getOwnPropertyDescriptor(a,o)?.value instanceof Qt)throw new Error(`${n}: the logic method '${o}' has the name of a child group`);ec(a,o,l)}this.#t.has(a)||this.#t.set(a,[]),this.#t.get(a).push(n)}resolve(e,t){let n=e.split("."),s=n.pop(),i=this.#e.logic;for(let o=0;o<n.length;o++)if(i=Object.getOwnPropertyDescriptor(i,n[o])?.value,!(i instanceof Qt))throw new Error(`${t.nodeTag} '${t.label}': named logic '${e}' not found: no resource was registered for the group '${n.slice(0,o+1).join("/")}'`);let a=Object.getOwnPropertyDescriptor(i,s)?.value;if(typeof a!="function"){let o=this.#t.get(i)??[],l=n.length?`the group '${n.join("/")}'`:"the page logic";throw new Error(`${t.nodeTag} '${t.label}': named logic '${e}' not found: ${l} has no method '${s}' (resources: ${o.join(", ")||"none"})`)}return{group:i,method:a}}};var jn=class extends Se{constructor(e,{collections:t,destination:n,subscriptions:s,nameSyntax:i}){super(e),e.src=this,this.logicRegistry=new Pr(e),this.builder=new qe(null,{collections:t,nameSyntax:i}),this.binding=new Lr(e,{subscriptions:s}),this.builder.binding=this.binding,this.binding.attach(),this.source=this.builder.source,this.renderer=new Fn(this.builder,this.source,n,{binding:this.binding})}startSource(e){if(!["ready","failed"].includes(this.gramlot.state))throw new Error(`Cannot start embedded Source while Gramlot is ${this.gramlot.state}`);try{return this.mountMainSource(e)}catch(t){throw this.gramlot.state="failed",t}}mountMainSource(e){let t=this.prepareSource(e);this.renderer.validateCandidate(t);try{this.source.setItem("main",t)}catch(n){throw this.binding.bindingFor(this.source.getNode("main"))||this.source.popNode("main"),n}return this.gramlot.state="started",this.binding.pageStarted(),this.binding.subscriptions.ready(),this.gramlot}prepareSource(e,t=this.builder){if(e instanceof x){if(!(e instanceof le))throw new TypeError("Source values must be GramlotBuilderBags");return e.bindBuilder(t).activateCode()}if(typeof e!="string")throw new TypeError("Source value did not decode to SourceBag");let n=va(e,t);if(!(n instanceof le))throw new TypeError("Source values must be GramlotBuilderBags");return n.activateCode()}async remoteSource(e,t,n={}){if(!this.gramlot.rpc.transport?.call)throw new Error("Remote Source is unavailable without a server transport");let i=this.binding.bindingFor(e);if(this.gramlot.state!=="started"||!i)throw new Error("Remote Source target is not mounted");return await e.requests.submit(t,n,a=>this.#e(e,i,a))??!1}async#e(e,t,n){if(t.closed||this.gramlot.state==="disposed")return!1;let s=!1,i=()=>this.gramlot.state!=="disposed"&&!n.ignored&&!t.closed;try{let a=await t.call("source",n);if(!i())return!1;let o=this.prepareSource(a,e.builder);return i()?(this.renderer.validateCandidate(o,{replacingNode:e}),s=!0,e.setValue(o,!0,{_text:null},!0),t.remote?.fragmentMounted(n.method,n.text),!0):!1}catch(a){if(!s&&!i())return!1;throw a}}};var Un=class extends Error{name="RpcError";constructor({code:e,name:t,message:n,details:s}){super(n),this.code=e,this.remoteName=t,s!==void 0&&(this.details=s)}},qn=class extends Se{constructor(e,{rpcUrl:t,closeUrl:n,document:s,transport:i}){super(e),this.transport=i===!1?null:i??e.serverAdapter.createTransport({rpcUrl:t,closeUrl:n,document:s}),this.remoteRequests=new Map}get supportsCallSync(){return this.transport?.supportsCallSync===!0}callSync(e,t,n={}){if(!this.supportsCallSync)throw new Error(`rpc '${t}': the transport of this page has no synchronous call`);if(xt(n),this.gramlot.abort.signal.aborted)throw this.gramlot.abort.signal.reason;let s=De(),i=P(this.transport.callSync(W({id:s,pageId:this.gramlot.pageId,contentType:e,name:t,params:n})));if(i.id!==s)throw new Error("rpc response id mismatch");if(i.error)throw new Un(i.error);return i.value}async call(e,t,n={},{signal:s=null}={}){if(!this.transport?.call)throw new Error(`rpc '${t}' is unavailable without a server transport`);xt(n);let i=De(),a=W({id:i,pageId:this.gramlot.pageId,contentType:e,name:t,params:n}),o=s?[this.gramlot.abort.signal,s]:[this.gramlot.abort.signal],l=o.find(f=>f.aborted);if(l)throw l.reason;let u=new AbortController,c=f=>u.abort(f.target.reason);for(let f of o)f.addEventListener("abort",c,{once:!0});let d=new Promise((f,h)=>{u.signal.addEventListener("abort",()=>{this.remoteRequests.delete(i),h(u.signal.reason)},{once:!0})});this.remoteRequests.set(i,u);try{let f=P(await Promise.race([this.transport.call(a,u.signal),d]));if(f.id!==i)throw new Error("rpc response id mismatch");if(f.error)throw new Un(f.error);return f.value}finally{this.remoteRequests.delete(i);for(let f of o)f.removeEventListener("abort",c)}}};var Vn=class extends Se{setTouchMode(e="auto"){if(!["auto","on","off"].includes(e))throw new TypeError(`Invalid touch mode: ${e}`);let t=this.gramlot.src.renderer.destination.ownerDocument.documentElement;e==="auto"?t.removeAttribute("data-gramlot-touch"):t.setAttribute("data-gramlot-touch",e)}reference(e){return this.gramlot.src.renderer.references.resolve(e)}getBaseSourceNode(e){return this.gramlot.src.renderer.getBaseSourceNode(e)}getDomNode(e){return this.gramlot.src.renderer.getDomNode(e)}};var tc="gramlot:publish",mi=class{#e;#t;#r;#s=De();#n=new Map;#i=!1;#a;#o;#l;#f;constructor(e,t){this.#e=e,this.#r=t,this.#t=t.defaultView,this.#a=s=>this.#m(s),this.#o=s=>{if(s.target?.localName!=="iframe")return;let i=this.#g(s.target);i&&(this.#u(i.window),this.#c(i,{kind:"hello"}))},this.#t.addEventListener("message",this.#a),this.#l=()=>this.#h(),this.#f=()=>this.ready(),this.#t.addEventListener("pagehide",this.#l),this.#t.addEventListener("pageshow",this.#f),t.addEventListener("load",this.#o,!0);let n=this.#d();n&&this.#c(n,{kind:"hello"})}ready(){if(this.#i||this.#e.state!=="started")return;let e=this.#d();e&&this.#c(e,{kind:"ready"});for(let t of this.#r.getElementsByTagName("iframe")){let n=this.#g(t);n&&this.#c(n,{kind:"hello"})}}prepare(e,t){let n=[];if(e.parent){let a=this.#d();if(!a)throw new Error("This page has no parent frame");n.push(a)}if(e.iframe!==void 0){let a=e.iframe,o=se(a),l=typeof a=="string"?this.#r.getElementById(a):o instanceof we?this.#e.dom.getDomNode(o):null,u=this.#g(l);if(!u)throw new Error("iframe destination must be an active Gramlot iframe ID or Source reference");n.push(u)}let s=n.map(a=>{let o=this.#n.get(a.window);if(!o||o.origin!==a.origin)throw new Error("Destination page is not ready");return{...a,session:o.session}});xt(t);let i=W(t);return()=>{if(!this.#i)for(let a of s){let o=this.#b(a.window);if(!o||o.origin!==a.origin||this.#n.get(a.window)?.session!==a.session)throw new Error("Destination page disconnected before publication");this.#c(a,{kind:"publish",recipient:a.session,topic:e.topic,wire:i})}}}dispose(){this.#i||(this.#h(),this.#i=!0,this.#t.removeEventListener("message",this.#a),this.#t.removeEventListener("pagehide",this.#l),this.#t.removeEventListener("pageshow",this.#f),this.#r.removeEventListener("load",this.#o,!0))}#h(){for(let[e,t]of this.#n)this.#c({window:e,origin:t.origin},{kind:"close"});for(let e of this.#n.keys())this.#u(e)}#u(e){this.#n.get(e)?.release?.(),this.#n.delete(e)}#p(e,t){this.#u(e.window);let n={session:t,origin:e.origin};e.node&&(n.release=this.#e.src.binding.bindingFor(e.node).track(()=>{this.#c(e,{kind:"close"}),this.#u(e.window)})),this.#n.set(e.window,n)}#m(e){if(this.#i||e.data?.type!==tc)return;let t=this.#b(e.source);if(!t||e.origin!==t.origin)return;let n=e.data;if(!(typeof n.session!="string"||!n.session)){if(n.kind==="hello")this.#u(t.window),n.ready===!0&&this.#p(t,n.session),this.#e.state==="started"&&this.#c(t,{kind:"ready"});else if(n.kind==="ready"){let s=this.#n.get(t.window)?.session!==n.session;this.#p(t,n.session),s&&this.#e.state==="started"&&this.#c(t,{kind:"ready"})}else if(n.kind==="close")this.#n.get(t.window)?.session===n.session&&this.#u(t.window);else if(n.kind==="publish"){if(this.#e.state!=="started"||n.recipient!==this.#s||this.#n.get(t.window)?.session!==n.session||typeof n.topic!="string"||!n.topic||typeof n.wire!="string")return;this.#e.publish(n.topic,P(n.wire))}}}#c(e,t){e.window.postMessage({type:tc,session:this.#s,ready:this.#e.state==="started",...t},e.origin==="null"?"*":e.origin)}#d(){let e=this.#t.parent;return e===this.#t?null:{window:e,origin:this.#_(this.#r.referrer||this.#r.baseURI)}}#g(e){if(e?.localName!=="iframe"||!e.isConnected||!e.contentWindow)return null;let t=this.#e.dom.getBaseSourceNode(e);if(!t||!this.#e.src.binding.bindingFor(t)||this.#e.dom.getDomNode(t)!==e)return null;let n=e.getAttribute("sandbox"),i=n!==null&&!n.split(/\s+/).includes("allow-same-origin")?"null":this.#_(e.hasAttribute("srcdoc")?this.#r.baseURI:e.getAttribute("src")||this.#r.baseURI);return{window:e.contentWindow,origin:i,node:t}}#_(e){let t=new URL(e,this.#r.baseURI);return t.protocol==="file:"?"null":t.origin}#b(e){let t=this.#d();if(t?.window===e)return t;for(let n of this.#r.getElementsByTagName("iframe")){let s=this.#g(n);if(s?.window===e)return s}return null}};var gi=class extends Se{#e=new Map;#t=new WeakSet;#r=new WeakMap;#s=0;#n=!1;#i;attach(e){this.#i=new mi(this.gramlot,e)}ready(){this.#i.ready()}subscribe(e,t){if(this.#l(),this.#o(e),typeof t!="function")throw new TypeError("subscribe requires a callback");let n=Object.freeze({});return this.#t.add(n),this.#e.has(e)||this.#e.set(e,new Map),this.#e.get(e).set(n,t),n}unsubscribe(e){if(!this.#t.has(e))throw new TypeError("Unknown subscription registration");for(let[t,n]of this.#e)n.delete(e)&&!n.size&&this.#e.delete(t)}publish(e,t={}){if(this.#l(),!t||typeof t!="object"||Array.isArray(t))throw new TypeError("publish requires one object of named data");if(typeof e=="string")return this.#a(e,t);if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("publish requires a topic string or descriptor");if(Object.keys(e).some(i=>!["topic","nodeId","parent","iframe"].includes(i)))throw new Error("This publication route is not implemented yet");if(this.#o(e.topic),e.parent!==void 0&&typeof e.parent!="boolean")throw new TypeError("parent must be boolean");if(e.iframe==="*")throw new Error("Recursive iframe broadcast is not implemented yet");if((e.parent||e.iframe!==void 0)&&Object.hasOwn(e,"nodeId"))throw new Error("Interframe node addressing is not implemented yet");let s=e.parent||e.iframe!==void 0?this.#i.prepare(e,t):null;if(Object.hasOwn(e,"nodeId")){let i=this.gramlot.src.binding.nodeIds.get(e.nodeId);if(!i)throw new Error(`nodeId not found: ${e.nodeId}`);return this.publishNode(i,e.topic,t)}this.#a(e.topic,t),s?.()}topicFor(e,t){this.#o(t),e=se(e);let n=this.gramlot.src.binding.bindingFor(e);if(!n||n.closed)throw new Error("Topic target is not an active Source node of this page");let s=e.getAttr("nodeId");return s==null&&(this.#r.has(e)||this.#r.set(e,`gramlot-self-${++this.#s}`),s=this.#r.get(e)),`${s}_${t}`}publishNode(e,t,n={}){return this.publish(this.topicFor(e,t),n)}subscribeNode(e,t){let n=[];for(let[s,i]of Object.entries(e.getAttr())){let a=s.startsWith("selfsubscribe_")?"selfsubscribe_":s.startsWith("subscribe_")?"subscribe_":null;if(!a)continue;let o=a==="selfsubscribe_"?this.topicFor(e,s.slice(a.length)):s.slice(a.length);this.#o(o),n.push([o,t(s,i,o)])}return this.#l(),n.map(([s,i])=>{let a=this.subscribe(s,i);return{close:()=>this.unsubscribe(a)}})}dispose(){this.#n=!0,this.#i.dispose(),this.#e.clear()}#a(e,t){this.#o(e);let n=this.#e.get(e);if(n)for(let[s,i]of[...n]){if(this.#n)break;n.has(s)&&i(t)}}#o(e){if(typeof e!="string"||!e)throw new TypeError("A topic must be a nonempty string")}#l(){if(this.#n)throw new Error("Gramlot subscriptions are disposed")}};var rc=2e3;function sg(r){if(!(r instanceof Date))return String(r??"");let e=r.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}var zn=class{constructor(e,t){this.gramlot=e,this.document=t}branch(e){let t=this.gramlot.data.getItem(e);if(!(t instanceof R))throw new Error(`gramlot.utl.inout: no data Bag at '${e}'`);return t}mailText(e){let t=[],n=(s,i)=>{for(let a of s.getNodes()){let o=i+a.label;a.value instanceof R?n(a.value,`${o}.`):t.push(`${o}: ${sg(a.value)}`)}};return n(this.branch(e),""),t.join(`
65
- `)}mailtoUrl(e,t){let n=`mailto:${encodeURIComponent(t)}?subject=${encodeURIComponent(this.document.title)}&body=${encodeURIComponent(this.mailText(e))}`;if(n.length>rc)throw new Error(`gramlot.utl.inout.sendMail: the email of '${e}' is ${n.length} characters long, over the mailto: limit of ${rc}; send it with sendHttp or save it as a file`);return n}sendMail(e,t){this.open(this.mailtoUrl(e,t))}async sendHttp(e,t){let n=JSON.stringify(this.branch(e).asDict(!1,!1,!0)),s=await this.document.defaultView.fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:n});if(!s.ok)throw new Error(`gramlot.utl.inout.sendHttp: ${t} answered ${s.status}`);return s}save(e,t){this.saveText(this.branch(e).toTytx(),t,"application/json")}restore(e){let t=this.document.createElement("input");return t.type="file",t.accept=".json,application/json",new Promise((n,s)=>{t.addEventListener("change",async()=>{try{let i=P(await t.files[0].text());if(!(i instanceof R))throw new TypeError("the file must contain a typed Bag");this.gramlot.data.setItem(e,i),n(i)}catch(i){s(new Error(`gramlot.utl.inout.restore: the file is not a saved Gramlot branch: ${i.message}`,{cause:i}))}},{once:!0}),t.click()})}download(e,t,n){if(!["json","xml"].includes(n))throw new Error(`gramlot.utl.inout.download: format '${n}' is not 'json' or 'xml'`);let s=this.branch(e);if(n==="json")this.saveText(s.toJson(!1),t,"application/json");else{let i=e.split(".").at(-1);this.saveText(`<?xml version='1.0' encoding='UTF-8'?>
66
- <${i}>${s.toXml()}</${i}>`,t,"application/xml")}}saveText(e,t,n){let s=this.document.defaultView,i=s.URL.createObjectURL(new s.Blob([e],{type:n}));this.open(i,t),s.setTimeout(()=>s.URL.revokeObjectURL(i),1e3)}open(e,t=null){let n=this.document.createElement("a");n.href=e,t!==null&&(n.download=t),n.click()}};var Hn=class extends Se{constructor(e,t){super(e),this.inout=new zn(e,t)}};var Wn=class{constructor({pageId:e,rpcUrl:t="/gramlot/rpc",closeUrl:n="/gramlot/close",rootId:s="gramlot-root",capabilities:i=[],element:a=null,document:o=a?.ownerDocument??globalThis.document,transport:l=null,collections:u=[],locale:c=null,timeZone:d=null,devices:f=[],serverAdapter:h=new ot,nameSyntax:p=null}={}){Hs.register(o.defaultView);for(let g of u)g instanceof Yt&&g.register(o.defaultView);this.pageId=e;let m=c==null||d==null?o.defaultView.Intl.DateTimeFormat().resolvedOptions():null;this.devices=Object.freeze([...f]),this.locale=c??m.locale,this.timeZone=d??m.timeZone,Object.defineProperty(this,"_subscriptions",{value:new gi(this)}),this.capabilities=Object.freeze([...i]),this.serverAdapter=h,this.src=new jn(this,{collections:u,destination:a??o.getElementById(s),subscriptions:this._subscriptions,nameSyntax:p===null?xn:Xt.fromJSON(p)}),this.data=this.src.builder.data,this.rpc=new qn(this,{rpcUrl:t,closeUrl:n,document:o,transport:l}),this.dom=new Vn(this),this.utl=new Hn(this,o),this.state="ready",this._subscriptions.attach(o),this.abort=new AbortController,this.rpc.transport&&(this.pagehide=g=>{g.persisted||this.dispose({beacon:!0})},o.defaultView.addEventListener("pagehide",this.pagehide),this.window=o.defaultView)}publish(e,t={}){return this._subscriptions.publish(e,t)}subscribe(e,t){return this._subscriptions.subscribe(e,t)}unsubscribe(e){this._subscriptions.unsubscribe(e)}format(e,t){return Bu(e,t,{locale:this.locale,timeZone:this.timeZone})}start(){return this.state==="disposed"?Promise.reject(new Error("Gramlot is disposed")):this.rpc.transport?this.loading?this.loading:this.state==="started"?Promise.resolve(this):(this.state="loading",this.loading=this.loadMain().finally(()=>{this.loading=null}),this.loading):Promise.reject(new Error("This Gramlot instance has no server transport"))}async loadMain(){let e;try{e=await this.rpc.call("source","main")}catch(t){throw this.state==="disposed"?new Error("Gramlot was disposed during main",{cause:t}):(this.state="failed",t)}if(this.state==="disposed")throw new Error("Gramlot was disposed during main");try{return this.src.mountMainSource(e)}catch(t){throw this.state!=="disposed"&&(this.state="failed"),t}}dispose({beacon:e=!1}={}){if(this.state!=="disposed"){this.state="disposed",this._subscriptions.dispose(),this.pagehide&&this.window.removeEventListener("pagehide",this.pagehide),this.abort.abort();try{try{this.src.binding.dispose()}finally{this.src.renderer.dispose()}}finally{this.rpc.transport&&(this.rpc.transport.close(this.pageId,{beacon:e}),this.rpc.transport.dispose())}}}};var Ua=class{constructor({config:e,resources:t,document:n=globalThis.document}){this.config=e,this.resources=t,this.document=n,this.serverAdapter=new ot}async run(){let{config:e,resources:t,document:n}=this,s=n.defaultView;t.serverAdapter!==void 0&&(this.serverAdapter=await this.loadServerAdapter(t.serverAdapter));for(let c of t.css){let d=n.createElement("link");d.rel="stylesheet",d.href=c,n.head.append(d)}let i=!1,a=c=>{c.persisted||i||(i=!0,this.closePage())};s.addEventListener("pagehide",a);let o,l;try{let c=await Promise.allSettled(t.js.map(({url:d})=>import(new URL(d,n.baseURI).href)));if(i||(o=t.js.map(({url:d,group:f},h)=>{let p=c[h];if(p.status==="rejected")throw new Error(`${d}: import failed: ${p.reason?.message??p.reason}`,{cause:p.reason});return{logicClass:p.value.Logic,group:f,resource:d}}),Pr.check(o),l=await Promise.all((t.collections??[]).map(async d=>{try{return(await import(new URL(d,n.baseURI).href)).default}catch(f){throw new Error(`${d}: collection import failed: ${f.message}`,{cause:f})}})),i))return null;for(let d of l)d.register(s)}catch(c){throw this.closePage(),c}finally{s.removeEventListener("pagehide",a)}let u=new Wn({...e,document:n,serverAdapter:this.serverAdapter,collections:[...e.collections??[],...l.map(c=>c.toDocument())]});for(let{logicClass:c,group:d,resource:f}of o)u.src.logicRegistry.register(c,{group:d,resource:f});return s.gramlot=u,await u.start(),u}async loadServerAdapter(e){let t;try{t=await import(new URL(e,this.document.baseURI).href)}catch(n){throw new Error(`${e}: server adapter import failed: ${n.message}`,{cause:n})}return new t.default}closePage(){let e=this.serverAdapter.createTransport({...this.config,document:this.document});e.close(this.config.pageId,{beacon:!0}),e.dispose()}};var _i=Symbol("gramlot.source"),qa=Symbol("gramlot.endpoint"),ig=new Map([[_i,"registerSource"],[qa,"registerEndpoint"]]);function nc(r,e,t,n){let s=ig.get(t);if(e==="main")throw new TypeError(`${s} cannot declare main`);let i=Object.getOwnPropertyDescriptor(r.prototype,e)?.value;if(typeof i!="function")throw new TypeError(`${s} requires an own method of ${r.name}: ${String(e)}`);if(i[t])throw new TypeError(`${t===_i?"Source method":"Endpoint"} already registered: ${e}`);if(i[_i]||i[qa])throw new TypeError(`${e} is declared both as Source method and endpoint`);i[t]={auth:n}}var bi=class{static registerSource(e,{auth:t=null}={}){nc(this,e,_i,t)}static registerEndpoint(e,{auth:t=null}={}){nc(this,e,qa,t)}},Gn=class extends bi{static title="Gramlot";static devices=[];static locale=null;static timeZone=null;static installable=!1;static appIcon=null;manifest({baseUrl:e="./"}={}){let{title:t,appIcon:n}=this.constructor;if(typeof n!="string"||!n)throw new TypeError("An installable Page needs appIcon");return{id:e,name:t,short_name:t,start_url:e,scope:e,display:"standalone",icons:[{src:e+n.replace(/^\/+/,""),sizes:"512x512",type:"image/png"}]}}static css=[];static css_theme=null;static css_requires="";static js_requires="";static sourceBuilder=qe;main(e){throw new Error("Page.main(root) must be implemented")}};var Fr=class extends Gn{static shellId="frame";static datapath=null;main(e){let t=e.div({id:this.constructor.shellId,datapath:this.constructor.datapath,class:"frame-page",height:"100vh",display:"flex",flex_direction:"column",min_height:0}),n=t.borderContainer({node_label:"frame",height:"100%",flex:"1",min_height:0});for(let s of["top","bottom","left","right","center"])if(this[s]!==void 0){let i=n.contentPane({region:s,node_label:s});this[s](i)}this.behavior(t)}center(e){}behavior(e){}};var Xn=class extends Fr{static title="Application";static shellId="index";static datapath="index";static navigation=null;main(e){let{navigation:t,datapath:n}=this.constructor;if(!(t instanceof R))throw new TypeError("IndexPage.navigation must be a Bag");e.dataSetter({destination_path:`${n}.navigation`,value:t}),e.dataSetter({destination_path:`${n}.navigationSelection`,value:null}),e.dataSetter({destination_path:`${n}.active`,value:null}),e.dataSetter({destination_path:`${n}.opened`,value:new R}),super.main(e)}left(e){e.setAttr({width:"240px",splitter:!0,drawer:!0,drawer_label:"Navigation"}),e.tree({node_label:"tree",storepath:`${this.constructor.datapath}.navigation`,labelAttribute:"title",hideValues:!0,selectedPath:`^${this.constructor.datapath}.navigationSelection`})}center(e){e.tabContainer({node_label:"tabs",height:"100%",selectedPage:`^${this.constructor.datapath}.active`})}behavior(e){e.dataController({func:"indexMount",_onStart:!0,shell_id:this.constructor.shellId})}index_panel(e,{selection:t}){this.panel(e,t.getNode("#0"))}panel(e,t){e.iframe({src:t.attr.url,title:t.attr.title??t.label,width:"100%",height:"100%",border:0})}};Xn.registerSource("index_panel");function Va(r,e,t=()=>{},n=()=>{},{state:s=e.builder.data.getItem(e.getAttr("datapath")),createEntry:i=null,onLoad:a=()=>{}}={}){let o=s.getItem("navigation");if(!(o instanceof R))throw new TypeError("IndexPage navigation must be a Bag");let l=e.value.getNode("frame.center.tabs"),u=e.builder,c=new Map,d=!1,f=!1,h=0,p=null,m=s.getItem("opened");for(let T of m.getNodes()){let{url:v,path:N,title:L}=T.attr,U=l.value.getNode(T.label),ve={url:v,path:N,title:L,pane:U,node:o.getNode(N),loading:!1};n(ve),c.set(v,ve),h++}let g=T=>{if(!d){f=!0;try{s.setItem("active",T.url),s.setItem("navigationSelection",T.path),t(c,T.url)}finally{f=!1}}};async function _(T){let v=o.getNode(T);if(!v)throw new Error(`Unknown index navigation path: ${T}`);let N=v.attr.url;if(N==null)return;if(typeof N!="string"||!N)throw new TypeError("IndexPage URL must be nonempty text");p=N;let L=c.get(N);if(L){L.path=T,g(L);return}for(;l.value!==null&&l.value.getNode(`page${h}`);)h++;let U=se(u.wrapSource(l).contentPane({node_label:`page${h++}`,title:v.attr.title??v.label,pageName:N,height:"100%"})),ve=s.getItem("active");L={url:N,path:T,node:v,pane:U,title:v.attr.title??v.label,loading:!0},c.set(N,L);try{if(g(L),a(N,"loading"),i)await i(L);else{let Y=new R;if(Y.setItem(v.label,null,{...v.attr}),!await r.binding.gramlot.src.remoteSource(U,"index_panel",{selection:Y}))throw new Error("Panel loading was cancelled")}if(d)return;L.loading=!1,m.setItem(U.label,null,{url:N,path:L.path,title:L.title}),n(L),p===N&&(a(N,"ready"),g(L))}catch(Y){if(c.delete(N),m.getNode(U.label)&&m.popNode(U.label),U.parentBag&&U.parentBag.popNode(U.label),!d&&p===N){a(N,"error",Y);let re=c.get(ve);if(p=re?.url??null,re)g(re);else{f=!0;try{s.setItem("active",null),s.setItem("navigationSelection",null),t(c,null)}finally{f=!1}}}}}let w=`${e.getAttr("id")}-selection`;s.subscribe(w,{any:T=>{if(!(f||d)){if(T.node===s.getNode("navigationSelection")){let v=s.getItem("navigationSelection");v!==null&&_(v)}else if(T.node===s.getNode("active")){let v=c.get(s.getItem("active"));v&&(p=v.url,g(v))}}}});let y=()=>{if(!d){d=!0,s.unsubscribe(w,{any:!0});for(let T of c.values())T.loading&&T.pane.parentBag&&T.pane.parentBag.popNode(T.pane.label)}};r.onDispose(e,y);let k=c.get(s.getItem("active"));return k?g(k):s.getItem("navigationSelection")!==null&&_(s.getItem("navigationSelection")),{entries:c,dispose:y}}var wi=class{indexMount(e,{shell_id:t}){let n=this.page.src.renderer,s=n.destination.ownerDocument.getElementById(t);this.index=Va(n,n.elements.get(s).node)}};var za=class r extends St{static internalParams=new Set([...St.internalParams,"gramlot","method","params","onError"]);#e=!1;#t=null;constructor({gramlot:e,method:t,directory:n,onError:s}){super({cacheTime:-1,onError:s}),this.gramlot=e,this.method=t,this.params={directory:n},this.children=new Set}get closed(){return this.#e}startLoad(e){if(this.loading)return this.loading;let t=new AbortController;return this.#t=t,e({controller:t,method:this.method,params:this.params,ignored:!1})}async loadAsync({controller:e,method:t,params:n}){let{signal:s}=e,i,a=new Promise((o,l)=>{i=()=>l(s.reason),s.addEventListener("abort",i,{once:!0})});try{let o=await Promise.race([this.gramlot.rpc.call("data",t,n,{signal:s}),a]);if(s.aborted)throw s.reason;return o}finally{s.removeEventListener("abort",i),this.#t===e&&(this.#t=null)}}prepareValue(e){if(!(e instanceof R))throw new TypeError("Directory navigation must return a Bag");for(let t of this.children)t.abort();this.children.clear();for(let t of e.getNodes())if(t.attr.directory!==void 0){let n=new r({gramlot:this.gramlot,method:this.method,directory:t.attr.directory,onError:this.onError});this.children.add(n),e.setResolver(t.label,n)}return e}abort(){this.#e=!0,this.#t?.abort();for(let e of this.children)e.abort();this.children.clear()}};function er(r,e){return e===2?r%4===0&&(r%100!==0||r%400===0)?29:28:[4,6,9,11].includes(e)?30:31}function Ce(r,e,t){if(![r,e,t].every(Number.isInteger)||r<1||r>9999||e<1||e>12||t<1||t>er(r,e))throw new RangeError("Date must exist in Gregorian years 0001\u20139999.");return`${String(r).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function tr(r){if(typeof r!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(r))throw new RangeError("Expected a civil date in YYYY-MM-DD format.");let e=r.split("-").map(Number);return Ce(...e),e}function Yn(r,e,t){let n=r-1,s=365*n+Math.floor(n/4)-Math.floor(n/100)+Math.floor(n/400)+t-1;for(let i=1;i<e;i++)s+=er(r,i);return s}function Zn(r,e){let t=Yn(...tr(r))+e;if(!Number.isSafeInteger(t)||t<0||t>Yn(9999,12,31))throw new RangeError("Date offset exceeds Gregorian years 0001\u20139999.");let n=1,s=1e4;for(;s-n>1;){let a=Math.floor((n+s)/2);Yn(a,1,1)<=t?n=a:s=a}t-=Yn(n,1,1);let i=1;for(;t>=er(n,i);)t-=er(n,i++);return Ce(n,i,t+1)}function Ha(r){return Zn(r,-(Yn(...tr(r))%7))}function sc(r,e,t=0,n=1){let s=r*12+e-1+t,i=Math.floor(s/12),a=(s%12+12)%12+1,o=s+n-1,l=Math.floor(o/12),u=(o%12+12)%12+1;return{start:Ce(i,a,1),end:Ce(l,u,er(l,u))}}var Wa={it:{months:{gennaio:1,febbraio:2,marzo:3,aprile:4,maggio:5,giugno:6,luglio:7,agosto:8,settembre:9,ottobre:10,novembre:11,dicembre:12,gen:1,feb:2,mar:3,apr:4,mag:5,giu:6,lug:7,ago:8,set:9,ott:10,nov:11,dic:12},weekdays:{luned\u00EC:0,marted\u00EC:1,mercoled\u00EC:2,gioved\u00EC:3,venerd\u00EC:4,sabato:5,domenica:6,lun:0,mar:1,mer:2,gio:3,ven:4,sab:5,dom:6},quarters:{"1\xBA trimestre":1,"2\xBA trimestre":2,"3\xBA trimestre":3,"4\xBA trimestre":4,"1\xB0 trimestre":1,"2\xB0 trimestre":2,"3\xB0 trimestre":3,"4\xB0 trimestre":4,t1:1,t2:2,t3:3,t4:4,q1:1,q2:2,q3:3,q4:4},keywords:{today:["oggi"],yesterday:["ieri"],tomorrow:["domani"],this_week:["questa settimana","settimana"],last_week:["settimana scorsa"],next_week:["settimana prossima"],this_month:["questo mese","mese"],last_month:["mese scorso"],next_month:["mese prossimo"],last:["scorso","scorsa"],next:["prossimo","prossima"],articles:["il","lo","la"],from:["da","dal","dalla","tra","fra"],to:["a","al","alla","e"],no_period:["-","senza periodo","sempre"]},date_order:{default:"DMY"}},en:{months:{january:1,february:2,march:3,april:4,may:5,june:6,july:7,august:8,september:9,october:10,november:11,december:12,jan:1,feb:2,mar:3,apr:4,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},weekdays:{monday:0,tuesday:1,wednesday:2,thursday:3,friday:4,saturday:5,sunday:6,mon:0,tue:1,wed:2,thu:3,fri:4,sat:5,sun:6},quarters:{"1st quarter":1,"2nd quarter":2,"3rd quarter":3,"4th quarter":4,q1:1,q2:2,q3:3,q4:4},keywords:{today:["today"],yesterday:["yesterday"],tomorrow:["tomorrow"],this_week:["this week","week"],last_week:["last week"],next_week:["next week"],this_month:["this month","month"],last_month:["last month"],next_month:["next month"],last:["last"],next:["next"],articles:["the"],from:["from","between"],to:["to","and"],no_period:["no period","always"]},date_order:{default:"MDY",GB:"DMY",AU:"DMY",IE:"DMY",NZ:"DMY",IN:"DMY"}}};function ic(r){if(typeof r!="string")throw new RangeError("A supported locale is required.");let e=r.replaceAll("-","_"),t=e.indexOf("_"),n=(t<0?e:e.slice(0,t)).toLowerCase(),s=(t<0?"":e.slice(t+1)).toUpperCase();if(!Object.hasOwn(Wa,n))throw new RangeError(`Unsupported locale: ${r}`);let i=Wa[n];return{dictionary:i,phrases:o=>[...new Set([...i.keywords[o],...Wa.en.keywords[o]])],order:i.date_order[s]??i.date_order.default}}var rr=/^(?:\d{4}|\d{2})$/,ac=/^\d{1,2}$/,Jn=(r,e)=>({ok:!1,error:{code:r,message:e}}),sr=(r="UNRECOGNIZED_EXPRESSION",e="Text is not a supported date expression.")=>{throw Object.assign(new SyntaxError(e),{code:r})},uc=(r,e)=>Object.hasOwn(r,e);function nr(r,e){if(r.length===4)return Number(r);let t=e.year+e.twoDigitYearAhead-100;return t+((Number(r)-t)%100+100)%100}function ag(r,e){if(r.includes(";")){let s=r.split(";").map(i=>i.trim());return s.length!==2?sr("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:s,range:!0}}if(e.phrases("no_period").includes(r))return{bounds:["",""],range:!0};let t=e.phrases("to"),n=e.phrases("from");for(let s of t)if(r.startsWith(`${s} `))return{bounds:["",r.slice(s.length+1).trim()],range:!0};for(let s of t){let i=` ${s} `;if(!r.includes(i))continue;for(let o of n)if(r.startsWith(`${o} `)){r=r.slice(o.length+1);break}let a=r.split(i).map(o=>o.trim());return a.length!==2?sr("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:a,range:!0}}for(let s of n)if(r.startsWith(`${s} `))return{bounds:[r.slice(s.length+1).trim(),""],range:!0};return{bounds:[r,r],range:!1}}function og(r,e,t){let n=[[r,0]],s=/^(.+?)\s*([+-])\s*(\d+)$/.exec(r);s&&n.push([s[1],Number(s[2]+s[3])]);let i={today:0,yesterday:-1,tomorrow:1,this_week:0,last_week:-1,next_week:1,this_month:0,last_month:-1,next_month:1};for(let[a,o]of n)for(let[l,u]of Object.entries(i))if(e.phrases(l).includes(a)){if(l.endsWith("_week"))return Zn(Ha(e.workdate),(u+o)*7+(t?6:0));if(l.endsWith("_month")){let c=sc(e.year,e.month,u+o);return t?c.end:c.start}return Zn(e.workdate,u+o)}return null}function lg(r,e,t){let n=Object.entries(e.dictionary.quarters).sort((s,i)=>i[0].length-s[0].length);for(let[s,i]of n){let a;if(r===s)a=null;else if(r.startsWith(s)&&rr.test(r.slice(s.length).trim()))a=nr(r.slice(s.length).trim(),e);else if(r.endsWith(s)&&rr.test(r.slice(0,-s.length).trim()))a=nr(r.slice(0,-s.length).trim(),e);else continue;return{year:a,month:t?i*3:i*3-2}}return null}function oc(r,e){if(uc(e.months,r))return e.months[r];let t=/^m(\d{1,2})$/.exec(r);return t&&Number(t[1])>=1&&Number(t[1])<=12?Number(t[1]):null}function ug(r,e){let t=r.split(/\s+/),n=t.map((u,c)=>oc(u,e.dictionary)?c:-1).filter(u=>u>=0);if(!n.length)return null;if(n.length!==1)return sr();let s=n[0],i=oc(t[s],e.dictionary),a=t.slice(0,s),o=t.slice(s+1),l=[...a,...o];if(l.length===1&&e.phrases("last").includes(l[0]))return{year:e.year-(i>e.month?1:0),month:i};if(l.length===1&&e.phrases("next").includes(l[0]))return{year:e.year+(i<e.month?1:0),month:i};if(!l.length)return{year:null,month:i};if(!a.length&&o.length===1&&rr.test(o[0]))return{year:nr(o[0],e),month:i};if(a.length===1&&ac.test(a[0])){if(!o.length)return Ce(e.year,i,Number(a[0]));if(o.length===1&&rr.test(o[0]))return Ce(nr(o[0],e),i,Number(a[0]))}return!a.length&&o.length===2&&ac.test(o[0])&&rr.test(o[1])?Ce(nr(o[1],e),i,Number(o[0])):sr()}function cg(r,e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(r);if(t)return Ce(...t.slice(1).map(Number));let n=/^(\d{1,4})[/\-. ]+(\d{1,4})[/\-. ]+(\d{1,4})$/.exec(r),s={};if(n)e.order.split("").forEach((o,l)=>{s[o]=n[l+1]});else if(/^(?:\d{6}|\d{8})$/.test(r)){let o=r.length===8?4:2;for(let l of e.order){let u=l==="Y"?o:2;s[l]=r.slice(0,u),r=r.slice(u)}}else return null;if(!rr.test(s.Y)||s.D.length>2||s.M.length>2)return sr();let i=Number(s.D),a=Number(s.M);return n&&a>12&&i<=12&&([i,a]=[a,i]),Ce(nr(s.Y,e),a,i)}function lc(r,e,t){if(!r)return null;let n=e.phrases("articles");if(r=r.split(/\s+/).filter(i=>!n.includes(i)).join(" "),!r)return sr();if(rr.test(r))return Ce(nr(r,e),t?12:1,t?31:1);let s=og(r,e,t)??lg(r,e,t)??ug(r,e);return s!==null?s:uc(e.dictionary.weekdays,r)?Zn(Ha(e.workdate),e.dictionary.weekdays[r]):cg(r,e)??sr()}function dg(r,e,t){if(r===null||typeof r=="string")return r;let n=r.year??t.year,s=typeof e=="string"?tr(e)[0]:e?.year,i=typeof e=="string"?tr(e)[1]:e?.month;return s&&(n>s&&(n=s),n===s&&r.month>i&&n--),Ce(n,r.month,1)}function fg(r,e,t){if(r===null||typeof r=="string")return r;let n=r.year??t.year;if(e!==null){let[s,i]=tr(e);n<s&&(n=s),n===s&&i>r.month&&n++}return Ce(n,r.month,er(n,r.month))}function hg(r,e={}){if(!e||typeof e!="object"||Array.isArray(e))return Jn("INVALID_CONTEXT","Options must provide a civil workdate and supported locale.");let t;try{let{locale:n="it-IT",workdate:s,twoDigitYearAhead:i=20}=e,[a,o]=tr(s);if(!Number.isInteger(i)||i<0||i>99)throw new RangeError("twoDigitYearAhead must be an integer from 0 to 99.");t={...ic(n),workdate:s,year:a,month:o,twoDigitYearAhead:i}}catch(n){return Jn("INVALID_CONTEXT",n.message)}if(typeof r!="string")return Jn("INVALID_INPUT","Expression must be a string.");try{let n=r.toLowerCase().trim().replaceAll(",",""),{bounds:s,range:i}=ag(n,t),a=lc(s[1],t,!0),o=lc(s[0],t,!1),l=dg(o,a,t),u=fg(a,l,t);return!i&&typeof o=="string"&&l===u?{ok:!0,kind:"date",date:l}:{ok:!0,kind:"period",start:l,end:u}}catch(n){if(n instanceof RangeError)return Jn("INVALID_DATE",n.message);if(n instanceof SyntaxError)return Jn(n.code,n.message);throw n}}export{R as Bag,Pe as BagNode,Vn as DomHandler,bi as Exposed,Fr as FramePage,Wn as Gramlot,qe as GramlotBuilder,Jt as GramlotHtmlRenderer,Fn as GramlotRenderer,In as GramlotSvgRenderer,Se as Handler,jr as HttpTransport,zn as InOut,wi as IndexLogic,Xn as IndexPage,za as NavigationResolver,Gn as Page,Ua as PageBootstrap,Mn as References,Un as RpcError,qn as RpcHandler,ot as ServerAdapter,jn as SourceHandler,Hn as UtilitiesHandler,yt as createDecimal,Va as mountIndexPage,hg as parseDateExpression};
64
+ `)}catch(s){throw s instanceof EvalError?new EvalError(`${qn(r,e)}: inline code blocked by the Content Security Policy of the page (no 'unsafe-eval'); move the code to named logic (a method of the page's class Logic) or serve the page with the permissive CSP profile, which allows 'unsafe-eval'`,{cause:s}):new SyntaxError(`${qn(r,e)}: ${s.message} in the inline code:
65
+ ${t}`,{cause:s})}}var bi=class{#e;#t;#r=!1;#s=null;#n=null;constructor(e){this.#e=e,this.#t=new Un(e)}get binding(){return this.#e}get node(){return this.binding.node}get closed(){return this.#r||this.binding.closed}close(){this.#r=!0,this.#t.cancel()}register(){this.#t.startTiming(this.#o("_timing"),()=>this.update())}receive(e){if(this.#o("_userChanges")&&e.level!=="node")return;let t=this.#o("_delay");t>0?this.#t.debounce(t,()=>this.update()):this.update()}async update(){if(this.closed||!this.binding.hasStamp("start"))return;let e=this.node,[,t]=e.rootBuilder.runtimeValues(e),n=t.remote,s={};for(let[l,u]of Object.entries(t))l.startsWith("remote_")&&(s[l.slice(7)]=u);let i=e.getAttr("_if");if(i&&!this.#a("_if",i,`return (${i})`,s)){let l=e.getAttr("_else");l&&this.#a("_else",l,l,s);return}let o;try{let l=W(s);if(t._cachedRemote&&this.#i(n,l))return;let u=e.getAttr("_onCalling");if(!e.requests.calling(u?()=>this.#a("_onCalling",u,u,s):null))return;o=await this.binding.runtime.gramlot.src.remoteSource(e,n,s)}catch(l){throw new Error(`${e.nodeTag} '${e.label}': remote '${n}' failed: ${l.message}`,{cause:l})}let a=e.getAttr("_onRemote");!this.closed&&o&&a&&this.#a("_onRemote",a,a,s)}fragmentMounted(e,t){this.#s=e,this.#n=t}#i(e,t){let n=this.node.requests.inflight;return n?n.method===e&&W(n.params)===t:e===this.#s&&t===this.#n}#o(e){let[,t]=this.node.rootBuilder.runtimeValues(this.node);return t[e]??null}#a(e,t,n,s){return e==="_onRemote"?Qe(this.binding.runtime,this.node,e,t,s):this.binding.runtime.inlineCompiler.compile(this.node,e,t,Object.keys(s),n)(s)}};var og=new Set(["title","msg","fields","_if","askIf"]),ag=new Set(["name","lbl","tag","type","default_value","required","min","max","step","placeholder"]),_i=class{#e;#t=null;#r=new Map;constructor(e){this.#e=e}get runtime(){return this.#e}required(e,t,n,s){let i=(o,a)=>typeof a=="boolean"?a:e.runtime.inlineCompiler.compile(e.node,o,a,Object.keys(n),`return (${a});`)(n);if(typeof t=="string"){let o=e.node.getAttr("_ask_if");return!o||!!i("_ask_if",o)}return t?.askIf&&i(`${s}.askIf`,t.askIf),!t?._if||!!i(`${s}._if`,t._if)}show(e,t,n,s="Parameters"){let i=typeof t=="string"?{msg:t,title:s}:t;if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("ask requires text or a parameter description");for(let d of Object.keys(i))if(!og.has(d))throw new Error(`Unsupported ask option: ${d}`);let o=i.fields??[];if(!Array.isArray(o))throw new TypeError("ask fields must be an array");let a=new Set;for(let d of o){if(!d||!/^[A-Za-z_]\w*$/.test(d.name)||a.has(d.name))throw new Error("ask fields require distinct simple names");a.add(d.name);for(let f of Object.keys(d))if(!ag.has(f))throw new Error(`Unsupported ask field option: ${f}`);if(d.tag&&!["input","textarea"].includes(d.tag))throw new Error(`Unsupported ask widget: ${d.tag}`);if(d.type&&!["text","number","date","checkbox","email","password","url","tel"].includes(d.type))throw new Error(`Unsupported ask input type: ${d.type}`)}let l=this.runtime.gramlot,u=this.#s(),c=this.#r;return new Promise((d,f)=>{let h=`ask_${xe()}`,p=!1,m=()=>{},g=(b,y=null)=>{if(p)return;p=!0;let w=b?Object.fromEntries(o.map(k=>[k.name,l.data.getItem(`${h}.${k.name}`)])):null;c.delete(h),m();try{l.src.source.popNode(h),l.data.getNode(h)&&l.data.popNode(h),y?f(y):d(w)}catch(k){f(k)}};c.set(h,{finish:g}),m=e.track(()=>g(!1));try{let b=new qe,y=b.root.dialog({nodeId:h,datapath:h,request:h,connect_oncancel:`${u}.cancel`,connect_onclose:`${u}.cancel`,class:"gramlot-ask","aria-labelledby":`${h}_title`,style:"border:1px solid #aab4c2;border-radius:8px;padding:16px;max-width:32rem;width:calc(100% - 48px);font:inherit;"});y.h2(i.title??s,{id:`${h}_title`,style:"font-size:1.1em;margin:0 0 12px;"}),i.msg&&y.p(i.msg);let w=y.form({request:h,connect_onsubmit:`${u}.confirm`});for(let v of o){w.dataSetter({destination_path:`.${v.name}`,value:Object.hasOwn(n,v.name)?n[v.name]:v.default_value??(v.type==="checkbox"?!1:"")});let N=w.div({style:"margin:8px 0;"});N.html_label(v.lbl??v.name,{for:`${h}_${v.name}`,style:"display:block;margin-bottom:4px;"});let L={id:`${h}_${v.name}`,value:`^.${v.name}`,live:!0};for(let U of["required","min","max","step","placeholder"])v[U]!==void 0&&(L[U]=v[U]);v.tag==="textarea"?N.textarea(L):N.input({...L,type:v.type??"text"})}let k=w.div({style:"display:flex;justify-content:flex-end;gap:8px;margin-top:16px;"});k.html_button("Cancel",{type:"button",request:h,connect_onclick:`${u}.cancel`}),k.html_button("Confirm",{type:"submit",autofocus:o.length===0}),l.src.source.setItem(h,l.src.prepareSource(b.source));let A=l.src.binding.nodeIds.get(h);l.dom.getDomNode(A).showModal()}catch(b){g(!1,b)}})}#s(){if(this.#t===null){let e=`ask_${xe()}`,t=this.#r;class n{confirm(i,o){o.preventDefault(),t.get(i.getAttr("request"))?.finish(!0)}cancel(i,o){o.preventDefault(),t.get(i.getAttr("request"))?.finish(!1)}}this.runtime.logicRegistry.register(n,{group:e,resource:"gramlot:ask"}),this.#t=e}return this.#t}};var ic={dataFormula:fi,dataController:hi,dataRpc:pi,dataRemote:mi},lg=["datapath","_anchor","nodeId","form","formId"],jr=class{#e;#t=new Map;#r=new Map;#s;#n;#i;#o;#a;#l=`gramlot-data-${xe()}`;#f=!1;constructor(e,{subscriptions:t}){this.#e=e,this.#a=t,this.#s=new li(this),this.#n=new ui(this),this.#i=new gi(this),this.#o=new _i(this)}get gramlot(){return this.#e}get subscriptions(){return this.#a}get builder(){return this.gramlot.src.builder}get renderer(){return this.gramlot.src.renderer}get logicRegistry(){return this.gramlot.src.logicRegistry}get data(){return this.builder.data}get root(){return this.data.parent}get size(){return this.#t.size}get disposed(){return this.#f}get router(){return this.#s}get installer(){return this.#n}get inlineCompiler(){return this.#i}get askDialog(){return this.#o}get nodeIds(){return this.#r}attach(){this.root.subscribe(this.#l,{any:e=>this.receiveData(e)})}receiveData(e){this.router.deliver(e)}bindingFor(e){return this.#t.get(e)??null}openBinding(e){if(this.disposed)throw new Error("BindingRuntime is disposed");let t=this.bindingFor(e);return t||(t=new Jo(this,e),this.#t.set(e,t)),t}closeBranch(e){let t=[];if(e.value instanceof D)for(let s of e.value.getNodes())try{this.closeBranch(s)}catch(i){t.push(i)}let n=this.bindingFor(e);if(n){this.#t.delete(e);let s=e.getAttr("nodeId");this.nodeIds.get(s)===e&&this.nodeIds.delete(s);try{n.close()}catch(i){t.push(i)}}if(t.length)throw new AggregateError(t,"Source branch close failed")}rebindBranch(e){let t=this.#d(e);for(let n of t)this.bindingFor(n)?.rebind();for(let n of t)this.renderer.project(n);for(let n of t)this.bindingFor(n)?.remote?.update()}handleSourceEvent(e){let{evt:t,node:n}=e,s=[],i=o=>{try{this.closeBranch(o)}catch(a){s.push(a)}};try{if(t==="ins")this.#h(n);else if(t==="del")for(let o of Array.isArray(n)?n:[n])i(o);else if(t==="upd_value"||t==="upd_value_attr"){if(e.oldvalue instanceof D)for(let o of e.oldvalue.getNodes())i(o);this.inlineCompiler.release(n,[""]),t==="upd_value_attr"?this.#m(n,e.attrs_diff):this.#c(n).rebind(),n.value instanceof D&&this.#h(n.value)}else if(t==="upd_attrs")this.#m(n,e.attrs_diff);else throw new Error(`Unsupported Source event: ${t}`)}catch(o){throw s.length?new AggregateError([...s,o],"Source event failed"):o}return s}branchBuilt(e){let t=[];for(let n of this.#d(e)){let s=this.bindingFor(n);!s||s.hasStamp("built")||!this.renderer.attached(n)||(s.stamp("built"),t.push(s))}for(let n of t)this.renderer.attached(n.node)&&this.#p(n,"built","_onBuilt");if(this.gramlot.state==="started")for(let n of t)this.renderer.attached(n.node)&&this.#u(n)}pageStarted(){for(let e of[...this.#t.values()])!e.closed&&e.hasStamp("built")&&this.#u(e)}dispose(){if(this.disposed)return;this.#f=!0,this.root.unsubscribe(this.#l,{any:!0}),this.nodeIds.clear();let e=[];for(let[t,n]of[...this.#t.entries()].reverse()){this.#t.delete(t);try{n.close()}catch(s){e.push(s)}}if(e.length)throw new AggregateError(e,"Binding cleanup failed")}#h(e){if(!(e instanceof D)&&this.bindingFor(e))return;let t=e instanceof D?e.getNodes().flatMap(i=>this.#d(i)):this.#d(e),n=new Set(t.filter(i=>this.bindingFor(i))),s=new Map;for(let i of t){let o=i.getAttr("nodeId");if(o!=null){if(s.has(o)||this.nodeIds.has(o)&&this.nodeIds.get(o)!==i)throw new Error(`Duplicate nodeId '${o}'`);s.set(o,i)}}for(let[i,o]of s)this.nodeIds.set(i,o);try{for(let i of t)this.openBinding(i);this.installer.install(e);for(let i of t)this.bindingFor(i).registerPointers()}catch(i){let o=[i];for(let a of t.filter(l=>!n.has(l)).reverse()){let l=a.getAttr("nodeId");s.get(l)===a&&this.nodeIds.get(l)===a&&this.nodeIds.delete(l);let u=this.bindingFor(a);if(u){this.#t.delete(a);try{u.close()}catch(c){o.push(c)}}}throw o.length>1?new AggregateError(o,"Source branch installation failed"):i}for(let i of t){let o=this.bindingFor(i);if(!(!o||o.hasStamp("init")||!this.renderer.attached(i))&&(o.stamp("init"),oc(i.getAttr("_init"))))for(let a of o.providers)a.invoke({kind:"init",change:null})}}#u(e){e.hasStamp("start")||(e.stamp("start"),this.#p(e,"start","_onStart"),e.remote?.update())}#p(e,t,n){let s=e.node.getAttr(n);if(oc(s))for(let i of e.providers){if(typeof s!="number"||s<=0){i.invoke({kind:t,change:null});continue}let o=null,a=setTimeout(()=>{o(),i.invoke({kind:t,change:null})},s);o=e.track(()=>clearTimeout(a))}}#m(e,t){let n=this.#c(e);if(this.inlineCompiler.release(e,Object.keys(t)),Object.hasOwn(t,"nodeId")){let{old:s,new:i}=t.nodeId;if(i!=null&&this.nodeIds.has(i)&&this.nodeIds.get(i)!==e)throw new Error(`Duplicate nodeId '${i}'`);this.nodeIds.get(s)===e&&this.nodeIds.delete(s),i!=null&&this.nodeIds.set(i,e)}lg.some(s=>Object.hasOwn(t,s))?this.rebindBranch(e):n.rebind()}#c(e){let t=this.bindingFor(e);if(!t)throw new Error(`${e.nodeTag??"fragment"} '${e.label}': the node has no NodeBinding (its installation failed); remove it from the Source and insert it again`);return t}#d(e){let t=[e];if(e.value instanceof D)for(let n of e.value.getNodes())t.push(...this.#d(n));return t}};function oc(r){return r===!0||typeof r=="number"}var Jo=class{#e;#t;#r=!1;#s=[];#n=[];#i=new Set;#o=null;#a=null;#l=new Set;#f=new Set;#h=0;#u=new Set;constructor(e,t){this.#e=e,this.#t=t}get runtime(){return this.#e}get node(){return this.#t}get closed(){return this.#r}get registrations(){return[...this.#n]}get providers(){return this.#o?[this.#o]:[]}get remote(){return this.#a}get clickCount(){return this.#h}countClick(){return++this.#h}hasStamp(e){return this.#i.has(e)}stamp(e){this.#i.add(e)}registerPointers(){this.node._getMeta("data_element")&&(this.runtime.renderer.references.remove(this.node),this.runtime.renderer.references.register(this.node,null));let e=this.node,t=e._getMeta("data_element");if(t&&!ic[e.nodeTag])return;!t&&typeof e.getAttr("remote")=="string"?this.#a??=new bi(this):this.#a&&(this.#a.close(),this.#a=null);let n=new Set;if(e._getMeta("gramlot_component")?.bagStore){let i=e.getAttr("storepath");if(typeof i!="string"||!i||/^[\^=]/.test(i)||i.includes("?"))throw new TypeError("storepath requires a plain Bag data path");let o=e.absDatapath(i);this.#n.push(this.runtime.router.register({path:o,recipient:this,subtree:!0}))}let s=this.remote?He(e,e.getAttr("_timing")):new Set;if(this.remote){for(let[i,o]of Object.entries(e.getAttr()))if(i.startsWith("remote_"))for(let a of He(e,o))n.add(a)}for(let[i,o]of e.pointers()){if(t&&i!=="datapath")continue;let l=(i==="datapath"?e.parentNode:e).absDatapath(o);if(l===null)continue;let[u,c=null]=l.split("?",2),d=this.runtime.router.register({path:u,attr:c,recipient:this});this.#n.push(d),i==="datapath"&&this.#u.add(d),this.remote&&(i==="remote"||i.startsWith("remote_")||n.has(i))&&this.#l.add(d),this.remote&&(i==="_timing"||s.has(i))&&this.#f.add(d)}if(!t){this.#p(),this.remote?.register();return}this.#o??=new ic[e.nodeTag](this),this.#o.register()}#p(){let e=this.node;this.#n.push(...this.runtime.subscriptions.subscribeNode(e,(t,n)=>{if(typeof n!="string"||!n)throw new TypeError(`${t} requires a handler`);return s=>{if(this.closed)return;if($n(n))return Qt(this.runtime,e,n,s);let[,i]=e.rootBuilder.runtimeValues(e),o=Object.fromEntries(Object.entries(i).filter(([l])=>!l.startsWith("subscribe_")&&!l.startsWith("selfsubscribe_"))),a={...this.runtime.renderer.references.resolveArguments(o),p_0:s};return this.runtime.inlineCompiler.compile(e,t,n,Object.keys(a))(a)}}))}rebind(){this.#m(),this.registerPointers()}receive(e){if(this.#u.has(e.registration)){this.runtime.rebindBranch(this.node);return}this.#l.has(e.registration)&&this.remote.receive(e),this.#f.has(e.registration)&&this.remote.register(),this.runtime.renderer.project(this.node,e)}track(e){if(this.closed)throw new Error(`NodeBinding of '${this.node.label}' is closed`);return this.#s.push(e),()=>{let t=this.#s.indexOf(e);t!==-1&&this.#s.splice(t,1)}}async call(e,t){let{controller:n}=t,s=this.track(()=>n.abort());try{let i=await this.runtime.gramlot.rpc.call(e,t.method,t.params,{signal:n.signal});if(n.signal.aborted)throw n.signal.reason;return i}finally{s()}}callSync(e,t,n){return this.node.requests.submitSync(t,()=>this.runtime.gramlot.rpc.callSync(e,t,n))}close(){if(this.closed)return;this.#r=!0,this.#a?.close(),this.node._getMeta("data_element")&&this.runtime.renderer.references.remove(this.node),this.#m();let e=[];for(let t of this.#s.splice(0).reverse())try{t()}catch(n){e.push(n)}if(e.length)throw new AggregateError(e,`NodeBinding of '${this.node.label}' cleanup failed`)}#m(){for(let e of this.#n.splice(0))e.close();this.#u.clear(),this.#l.clear(),this.#f.clear()}};var wi=class{constructor(e){this.renderer=e}prepare(e,t){let n=this.renderer.records.get(e);if(!n||n.resolved.draggable!==!0)return null;let s=e._getMeta("gramlot_component")?.dragSource?n.element.getDragContext(t):{dragValues:{},item:void 0,path:void 0};if(s===null)return null;let{dragValues:i,item:o,path:a}=s;if(n.resolved.onDrag){let u=this.renderer.html.callLogic(e,n.resolved.onDrag,{dragValues:i,item:o,path:a});if(u&&typeof u.then=="function")throw new TypeError("onDrag must run synchronously");if(u===!1)return null}return Ct(i),{dragValues:Object.fromEntries(Object.entries(i).map(([u,c])=>{if(u.startsWith("text/")||u==="dragTags"){if(typeof c!="string")throw new TypeError(`${u} drag data must be text`);return[u,c]}return[u,P(W(c))]})),item:o,path:a}}};var Nt=class{static isTarget(e){return e.dropTarget===!0||!!e.dropTargetCb||Object.entries(e).some(([t,n])=>t.startsWith("dropTargetCb_")&&!!n)}static acceptedTypes(e,t="",n=[]){let s=t.split(",").map(i=>i.trim()).filter(Boolean).map(i=>{let o=i.split("*").map(a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"));return new RegExp(`^${o.join(".*")}$`)});return e.filter(i=>i!=="dragTags"&&(n.includes(i)||s.some(o=>o.test(i))))}static acceptsTags(e="",t=""){if(!t.trim())return!0;let n=new Set(e.split(",").map(s=>s.trim()).filter(Boolean));return n.size?t.split(",").some(s=>s.split(" AND ").every(i=>(i=i.trim(),!i||i==="!"?!1:i.startsWith("!")?!n.has(i.slice(1)):n.has(i)))):!1}static acceptsEffect(e="all",t="move"){let n={all:["copy","move","link"],none:[],copy:["copy"],move:["move"],link:["link"],copyMove:["copy","move"],copyLink:["copy","link"],linkMove:["link","move"]};if(!Object.hasOwn(n,e))throw new TypeError(`Invalid effectAllowed: ${e}`);if(!["copy","move","link"].includes(t))throw new TypeError(`Invalid dropEffect: ${t}`);return n[e].includes(t)}static evaluate(e,t,n,s,i=[]){let o=this.acceptedTypes(e,s.dropTypes,i),a=s.dropEffect??"move",l=this.isTarget(s)&&o.length>0&&this.acceptsTags(t,s.dropTags)&&this.acceptsEffect(n,a);return{accepted:l,types:o,dropEffect:l?a:"none"}}};var ac=["dragstart","dragover","dragleave","drop","dragend"],yi=class{#e;#t;#r=null;#s=null;#n=null;#i;constructor(e){this.#e=e,this.#t=e.destination.ownerDocument;for(let t of ac)this.#t.addEventListener(t,this);this.#i=()=>this.#b("none"),this.#t.defaultView.addEventListener("pagehide",this.#i)}handleEvent(e){e.type==="dragstart"?this.#l(e):e.type==="dragend"?this.#b(e.dataTransfer.dropEffect):e.type==="dragleave"?this.#c():e.type==="dragover"?this.#u(e):e.type==="drop"&&this.#p(e)}#o(e,t){for(let n of e.composedPath()){let s=this.#e.elements.get(n);if(s&&t(s.resolved))return s}return null}#a(e,t){return e.node._getMeta("gramlot_component")?.dragSource?e.element.getDragContext(t):{element:e.element,item:void 0,path:void 0}}#l(e){let t=this.#o(e,n=>n.draggable===!0);if(t){this.#b("none");try{let n=this.#e.prepareDrag(t.node,e);if(!n||!t.element.isConnected||this.#e.records.get(t.node)!==t){e.preventDefault();return}let s=this.#a(t,e);if(!s){e.preventDefault();return}let i=new Map(Object.entries(n.dragValues).filter(([u])=>u!=="dragTags").map(([u,c])=>[u,u.startsWith("text/")?c:W(c)]));if(!i.size){e.preventDefault();return}let o=t.resolved.effectAllowed??"all";Nt.acceptsEffect(o,"move");let a="";for(let u=t;u;u=u.parent)if(u.resolved?.dragTags!=null){a=u.resolved.dragTags;break}let l=this.#r={record:t,wires:i,effectAllowed:o,phase:"active",tags:[a,n.dragValues.dragTags].filter(Boolean).join(","),endTopic:this.#e.binding.gramlot._subscriptions.topicFor(t.node,"endDrag"),source:{pageId:this.#e.binding.gramlot.pageId??null,sourcePath:t.node.fullpath,itemPath:n.path??null},preview:null,release:null};e.dataTransfer.clearData();for(let[u,c]of i)e.dataTransfer.setData(u,c);e.dataTransfer.effectAllowed=o,this.#n=this.#t.createElement("style"),this.#n.textContent=".canBeDropped{outline:2px solid var(--gramlot-brand-blue,#3766b5);outline-offset:-2px}.cannotBeDropped{outline:2px dashed currentColor;outline-offset:-2px}.draggedItem{opacity:.75}",this.#t.head.append(this.#n),this.#f(l,s.element,e.dataTransfer),l.release=this.#e.onDispose(t.node,()=>this.#b("none"))}catch(n){e.preventDefault(),this.#g(),this.#_(n)}}}#f(e,t,n){let s=t.cloneNode(!0);s.removeAttribute("id");for(let i of s.querySelectorAll("[id]"))i.removeAttribute("id");s.setAttribute("aria-hidden","true"),s.classList.add(...(e.record.resolved.dragClass??"draggedItem").split(/\s+/).filter(Boolean)),Object.assign(s.style,{position:"fixed",left:"-10000px",top:"0",width:`${t.getBoundingClientRect().width}px`,pointerEvents:"none"}),t.parentNode.append(s),e.preview=s,n.setDragImage(s,0,0)}#h(e){let t=this.#r,n=this.#o(e,u=>Nt.isTarget(u));if(!n)return null;let s=this.#a(n,e);if(!s)return{record:n,element:n.element,accepted:!1};let i=Nt.evaluate([...t.wires.keys()],t.tags,t.effectAllowed,n.resolved),a={dropValues:Object.fromEntries(i.types.map(u=>[u,u.startsWith("text/")?t.wires.get(u):P(t.wires.get(u))])),item:s.item,path:s.path,source:{...t.source},selfdrop:n===t.record,dropEffect:i.dropEffect,dataAvailable:!0},l=i.accepted&&this.#e.checkDropTarget(n.node,a)&&this.#e.records.get(n.node)===n&&s.element.isConnected;return{record:n,element:s.element,accepted:l,context:a}}#u(e){if(!this.#r){this.#o(e,t=>Nt.isTarget(t))&&(e.preventDefault(),e.dataTransfer.dropEffect="none");return}if(e.preventDefault(),this.#r.phase!=="active"){e.dataTransfer.dropEffect="none";return}try{let t=this.#r,n=this.#h(e);if(this.#r!==t){e.dataTransfer.dropEffect="none";return}e.dataTransfer.dropEffect=n?.accepted?n.context.dropEffect:"none",this.#c(),n&&this.#m(n.element,n.accepted)}catch(t){e.dataTransfer.dropEffect="none",this.#r&&(this.#r.phase="rejected"),this.#d(),this.#_(t)}}async#p(e){if(!this.#r){this.#o(e,n=>Nt.isTarget(n))&&e.preventDefault();return}if(e.preventDefault(),this.#r.phase!=="active")return;let t=this.#r;try{let n=this.#h(e);if(this.#r!==t){e.dataTransfer.dropEffect="none";return}if(t.phase="dropped",this.#d(),!n?.accepted){e.dataTransfer.dropEffect="none";return}e.dataTransfer.dropEffect=n.context.dropEffect,n.record.node.publish("onDrop",n.context),await this.#e.invokeDrop(n.record.node,n.context)}catch(n){this.#r===t&&(t.phase="rejected",this.#d()),this.#_(n)}}#m(e,t){let n=t?"canBeDropped":"cannotBeDropped",s=(e.getAttribute("part")??"").split(/\s+/).filter(Boolean);this.#s={element:e,name:n,hadClass:e.classList.contains(n),hadPart:s.includes(n)},e.classList.add(n),s.includes(n)||e.setAttribute("part",[...s,n].join(" "))}#c(){if(!this.#s)return;let{element:e,name:t,hadClass:n,hadPart:s}=this.#s;n||e.classList.remove(t),s||e.setAttribute("part",(e.getAttribute("part")??"").split(/\s+/).filter(i=>i!==t).join(" ")),this.#s=null}#d(){this.#c(),this.#r&&(this.#r.preview?.remove(),this.#r.preview=null,this.#r.wires.clear())}#g(){let e=this.#r;return this.#d(),this.#r=null,e?.release?.(),this.#n?.remove(),this.#n=null,e}#b(e){let t=this.#g();!t||this.#e.disposed||this.#e.endDrag(t.record.node,{source:{...t.source},dropEffect:e},t.endTopic).catch(n=>this.#_(n))}#_(e){console.error("Gramlot drag/drop failed:",e)}dispose(){this.#g();for(let e of ac)this.#t.removeEventListener(e,this);this.#t.defaultView.removeEventListener("pagehide",this.#i)}};var Vn=class extends Kt{static renderType="object";#e=new Set;#t=new WeakMap;#r=new WeakMap;#s=new WeakMap;constructor(e,t,n,{binding:s}={}){if(super(e),!(e instanceof ye)||!(t instanceof le)||n?.nodeType!==1)throw new TypeError("GramlotRenderer requires a BuilderBase, GramlotBuilderBag and HTML destination");if(!(s instanceof jr))throw new TypeError("GramlotRenderer requires a BindingRuntime");if(!(t._builder instanceof ye))throw new TypeError("SourceBag requires builder ownership");this._binding=s,this.source=t,this.destination=n,this.html=new si({metadataAttributes:["__ref"],callLogic:(i,o,a)=>{let{group:l,method:u}=s.gramlot.src.logicRegistry.resolve(o,i);return u.call(l,i,a)},invokeScript:(i,o,a,l)=>Qe(s,i,o,a,l,i.parentNode._getMeta("gramlot_component").childParameters[o].inline)}),this.records=new Map,this.references=new Fn(t),this.pending=[],this.building=!1,this.disposed=!1,this.elements=new WeakMap,this.dragPreparation=new wi(this),this.instanceId=xe(),this.radioGroups=new ni(this),this.dragDrop=new yi(this),this.subscription=`html-source-renderer-${this.instanceId}`,t.subscribe(this.subscription,{any:i=>this.receive(i)})}get binding(){return this._binding}prepareDrag(e,t){return this.dragPreparation.prepare(e,t)}checkDropTarget(e,{dropValues:t,item:n,path:s,source:i,selfdrop:o,dropEffect:a,dataAvailable:l}){let u=this.records.get(e);if(!u)return!1;if(!u.resolved.dropTargetCb)return!0;let c=this.html.callLogic(e,u.resolved.dropTargetCb,{dropValues:t,item:n,path:s,source:i,selfdrop:o,dropEffect:a,dataAvailable:l});if(typeof c!="boolean")throw new TypeError("dropTargetCb must return a boolean synchronously");return c}async invokeDrop(e,{dropValues:t,item:n,path:s,source:i,selfdrop:o,dropEffect:a,dataAvailable:l}){let u=this.records.get(e);!u||!u.resolved.onDrop||Object.keys(t).length===0||await this.html.callLogic(e,u.resolved.onDrop,{dropValues:t,item:n,path:s,source:i,selfdrop:o,dropEffect:a,dataAvailable:l})}async endDrag(e,{source:t,dropEffect:n},s){let i={source:t,dropEffect:n},o=[],a=this.records.get(e);try{a&&!a.binding.closed&&a.resolved.onDragEnd&&await this.html.callLogic(e,a.resolved.onDragEnd,i)}catch(l){o.push(l)}try{this.binding.gramlot.publish(s,i)}catch(l){o.push(l)}if(o.length)throw new AggregateError(o,"Drag completion notification failed")}get inlineCompiler(){return this.binding.inlineCompiler}evaluateExpressions(e,t){let n=this.#r.get(e)??super.evaluateExpressions(e,t),s=e._getMeta("gramlot_component");if(s?.presentationDefaults.length){let i=e.getAttr();this.#s.set(e,Object.fromEntries(Object.entries(n).filter(([o])=>Object.hasOwn(i,o)&&s.presentationDefaults.some(a=>o.startsWith(a)))))}if(s&&(s.parameters.value?.binding==="twoWay"||s.presentationDefaults.length)){let i=[];for(let o=e.parentNode;o;o=o.parentNode)this.#s.has(o)&&i.unshift(this.#s.get(o));n=Object.assign({},...i,n)}return this.#r.delete(e),this.#t.set(e,n),n}render(e,t={}){if(!(e instanceof Jt))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(e._getMeta("data_element")||!this.binding.bindingFor(e)&&this.#a(e))return null;if(e.nodeTag)this.html.validate(e,e._getMeta("subbuilder")?e.parentBag._builder:e.builder);else if(!(e.value instanceof D))throw new TypeError("Source fragments must contain child SourceBags");return e.nodeTag?super.render(e,t):this.renderFragment(e,t)}renderFragment(e,{document:t=this.destination.ownerDocument,...n}={}){let s=t.createDocumentFragment(),i={node:e,binding:this.#c(e),container:null,parent:null,children:new Set,cleanup:[],start:t.createComment("source-fragment"),end:t.createComment("/source-fragment")};this.records.set(e,i),this.elements.set(s,i),s.append(i.start);for(let o of e.value.getNodes()){let a=this.render(o,{document:t,...n});if(a===null)continue;s.append(a);let l=this.elements.get(a);l&&(l.parent=i,i.children.add(o))}return s.append(i.end),s}renderedItem(e,t,n,{tag:s,document:i=this.destination.ownerDocument}={}){let o=n;t=this.expressionValue(e,t),this.getRender(e.builder)===this&&(o=this.restoreNativeAttributes(e,n),e._getMeta("gramlot_component")||([t,o]=Rn(t,o,(h,p)=>this._binding.gramlot.format(h,p)))),o=this.componentAttributes(e,o);let a=Array.isArray(t)?t:[],l=Array.isArray(t)?o._text:t,u=this.#t.get(e),c={node:e,binding:this.#c(e),container:null,parent:null,children:new Set,cleanup:[],resolved:u,...this.html.create(e,i,s,o,u.visible??null)};this.html.compose(c,l,a),c.shape=be.shape(c.element,u),this.records.set(e,c),this.elements.set(c.element,c);let d=be.for(c.binding,c);d&&(c.control=d,d.attach(),c.cleanup.push(()=>d.detach()),this.#u(c,e,o,null));let f=ii.for(c.binding,c);f&&(c.button=f,f.attach(),c.cleanup.push(()=>f.detach())),this.#p(c),this.references?.register(e,c.element);for(let h of a){let p=this.elements.get(h);p&&(p.parent=c,p.container=c.element,c.children.add(p.node))}return c.element}validateCandidate(e,{replacingNode:t=null}={}){if(!(e instanceof le))throw new TypeError("Source values must be GramlotBuilderBags");let n=new Set,s=i=>{if(!n.has(i)){n.add(i);for(let o of this.records.get(i)?.children??[])s(o);if(i.value instanceof D)for(let o of i.value.getNodes())s(o)}};for(let i of this.records.get(t)?.children??[])s(i);if(t?.value instanceof D)for(let i of t.value.getNodes())s(i);return this.#n(e,t?t.nodeTag:null),Zo(e),this.references?.validate(e,n),e}#n(e,t=null){let n=new Set,s=(i,o=null)=>{if(!(i instanceof le)||n.has(i))throw new TypeError("Source values must be unshared, acyclic GramlotBuilderBags");if(!(i._builder instanceof ye))throw new TypeError("SourceBag requires builder ownership");n.add(i);for(let a of i.getNodes()){if(!(a instanceof Jt))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(!(a.builder instanceof ye))throw new TypeError("SourceBagNode requires builder ownership");if(a.resolver)throw new TypeError("Source resolvers are outside this port");if(a._getMeta("data_element"))a.builder.validateNode(a);else if(a.nodeTag){let l=a._getMeta("subbuilder")?i._builder:a.builder;this.html.validate(a,l),a._getMeta("subbuilder")||a.builder.validateParent(a.nodeTag,o)}else{if(!(a.value instanceof D))throw new TypeError("Source fragments must contain child SourceBags");if(Object.keys(a.attr).some(l=>l!=="_meta"))throw new TypeError("Fragment attributes are unsupported")}a.value instanceof D&&s(a.value,a._getMeta("subbuilder")?null:a.nodeTag??o)}};s(e,t)}freeze(e){e=te(e);let t=this.records.get(e);if(!t||this.disposed)throw new Error("Freeze requires a mounted Source node");t.frozen=!0}unfreeze(e){e=te(e);let t=this.records.get(e);if(!t||this.disposed)throw new Error("Unfreeze requires a mounted Source node");let n=s=>{delete s.frozen;for(let i of s.children)n(this.records.get(i))};n(t),!this.#i(e)&&(this.attached(e)?this.#d(e):this.remove(e))}#i(e){for(;e;){let t=this.records.get(e);if(t?.frozen)return!0;e=e.parentBag?.parentNode??t?.parent?.node}return!1}receive(e){if(!this.disposed){if(Array.isArray(e.node)){let t=e.node.filter(n=>!this.#e.has(n));if(!t.length)return;e={...e,node:t}}else if(this.#e.has(e.node))return;if(this.pending.push(e),!this.building){this.building=!0;try{for(;this.pending.length;){let t=this.pending.shift();if(t.evt!=="del"&&!this.attached(t.node))continue;t.evt!=="del"&&t.evt!=="upd_attrs"&&this.#l(t);let n=this.binding.handleSourceEvent(t);try{this.#o(t,n)}catch(s){if(!n.length)throw s;n.push(s)}if(n.length)throw n.length===1?n[0]:new AggregateError(n,"Source cleanup failed")}}catch(t){throw this.pending.length=0,t}finally{this.building=!1}}}}#o(e,t){if(e.evt==="del"){for(let n of Array.isArray(e.node)?e.node:[e.node]){if(this.#i(n))continue;let s=this.records.get(n)?.parent??null;try{this.remove(n)}catch(i){t.push(i)}this.#m(s)}return}if(!this.#i(e.node))if(e.evt==="ins")this.insert(e.node);else if(e.evt.startsWith("upd_"))this.update(e.node,e.evt);else throw new Error(`Unsupported Source event: ${e.evt}`)}attached(e){let t=e.parentBag;for(;t&&t!==this.source;)t=t.parentNode?.parentBag;return t===this.source}#a(e){let t=new Set(this.pending.flatMap(n=>Array.isArray(n.node)?n.node:[n.node]));for(let n=e;n;n=n.parentBag?.parentNode)if(t.has(n))return!0;return!1}#l(e){let t=n=>{if(!(n instanceof Jt))throw new TypeError("Source children must be GramlotBuilderBagNodes");if(n.value instanceof D){if(!(n.value instanceof le))throw new TypeError("Source values must be GramlotBuilderBags");for(let s of n.value.getNodes())t(s)}};t(e.node)}insert(e){if(!this.attached(e)||this.records.has(e))return;if(e._getMeta("data_element")){this.records.get(e.parentBag?.parentNode)?.button?.refresh(),this.binding.branchBuilt(e);return}let t=this.records.get(e.parentBag?.parentNode),n=t?.element??t?.container??this.destination,s=e.parentBag.getNodes(),i=t?.end??null;for(let o=s.indexOf(e)+1;o<s.length;o++){let a=this.records.get(s[o]);if(a){i=a.element??a.start;break}}this.buildNode(e,n,i,t)}buildNode(e,t,n=null,s=null){this.#e.add(e);let i;try{i=this.render(e,{document:t.ownerDocument})}catch(a){this.#f(e,a)}finally{this.#e.delete(e)}let o=this.records.get(e);return t.insertBefore(i,n),o.parent=s,this.assignContainer(o,t),s?.children.add(e),this.#m(s),this.binding.branchBuilt(e),o}#f(e,t){let n=[t],s=[],i=o=>{if(s.push(o),o.value instanceof D)for(let a of o.value.getNodes())i(a)};i(e);for(let o of s.reverse())try{this.remove(o)}catch(a){n.push(a)}throw n.length===1?t:new AggregateError(n,"Source build and cleanup failed")}assignContainer(e,t){e.container=t;let n=e.element??t;for(let s of e.children){let i=this.records.get(s);i&&this.assignContainer(i,n)}}update(e,t){let n=this.records.get(e);if(!n){this.insert(e);return}let s=e.value==null||["string","number","boolean"].includes(typeof e.value),i=t==="upd_value"&&s&&n.element&&n.children.size===0&&this.html.matches(n,e);(t==="upd_attrs"||i)&&n.element&&this.html.matches(n,e)?(e.nodeTag&&this.html.validate(e,e._getMeta("subbuilder")?e.parentBag._builder:e.builder),this.project(e),t==="upd_attrs"&&this.records.get(e)===n&&(this.references?.remove(e),this.references?.register(e,n.element))):this.#d(e)}project(e,t=null){let n=this.records.get(e);if(!n?.element)return;let s=this.getRender(e.builder),i=this.#s.get(e),[o,a]=e.rootBuilder.runtimeValues(e),[,l]=s._handleMeta(e,a),u=this.#t.get(e);if(n.shape!==be.shape(n.element,u)){if(this.#i(e))return;this.#r.set(e,u);try{this.#d(e)}finally{this.#r.delete(e)}return}n.resolved=u;let c=e._getMeta("subbuilder")?l:s.adaptAttrs(l),d=e.value instanceof D,f=d?[]:this.expressionValue(e,o);s===this&&(c=this.restoreNativeAttributes(e,c),e._getMeta("gramlot_component")||([f,c]=Rn(f,c,(p,m)=>this._binding.gramlot.format(p,m)))),c=this.componentAttributes(e,c),this.html.update(n,e,c,d?c._text:f,u.visible??null),this.#u(n,e,c,t),n.control?.refresh(),n.button?.refresh(),this.#p(n);let h=this.#s.get(e);if(h){let p=new Set([...Object.keys(i??{}),...Object.keys(h)].filter(m=>!Object.is(i?.[m],h[m])));p.size&&this.#h(e,p)}(n.element.localName==="option"||n.element.localName==="optgroup")&&this.#m(n.parent)}#h(e,t){if(e.value instanceof D)for(let n of e.value.getNodes()){let s=n._getMeta("gramlot_component"),i=n.getAttr(),o=t;s?.presentationDefaults.length?o=new Set([...t].filter(a=>!Object.hasOwn(i,a))):s?.parameters.value?.binding==="twoWay"&&[...t].some(a=>!Object.hasOwn(i,a))&&this.project(n),o.size&&this.#h(n,o)}}componentAttributes(e,t){let n=e._getMeta("gramlot_component"),s=e.parentNode?._getMeta("gramlot_component")?.childParameters;if(!n&&!s)return t;let i=this.#t.get(e),o=Object.fromEntries([...new Set([...Object.keys(n?.parameters??{}),...Object.keys(s??{}),...Object.keys(i).filter(a=>a.startsWith("validate_"))])].filter(a=>Object.hasOwn(i,a)).map(a=>[a,i[a]]));return{...t,...o}}#u(e,t,n,s){if(!e.control)return;let i=t.getAttr("value")!=null;(i||e.valueDeclared)&&e.control.project(n.value??null,s),e.valueDeclared=i}#p(e){let t=new Map(Pn.declared(e.node).map(n=>[n[0],n]));if(!e.events){if(!t.size)return;e.events=new Map,e.cleanup.push(()=>{for(let n of e.events.values())n.detach();e.events.clear()})}for(let[n,s]of[...e.events])t.get(n)?.[2]!==s.handler&&(s.detach(),e.events.delete(n));for(let[n,[,s,i]]of t){if(e.events.has(n))continue;let o=new Pn(e.binding,e,s,i,n);o.attach(),e.events.set(n,o)}}#m(e){for(let t=e;t;t=t.parent){if(t.control instanceof Ln){this.project(t.node);return}if(t.element&&t.element.localName!=="optgroup")return}}getDomNode(e){let t=te(e),n=this.records.get(t);return n&&this.attached(t)?n.element??null:null}getBaseSourceNode(e){for(let t=e;t;t=t.parentNode){let n=t.nodeType===1?this.elements.get(t):null;if(n)return this.attached(n.node)?n.node:null}return null}#c(e){let t=this.binding.bindingFor(e);if(!t)throw new Error(`${e.nodeTag??"fragment"} '${e.label}': rendered without an open NodeBinding`);return t}#d(e){let t=this.records.get(e),n=t.element?.nextSibling??t.end?.nextSibling??null,s=t.container,i=t.parent,o=null;try{this.remove(e)}catch(a){o=a}try{this.buildNode(e,s,n,i)}catch(a){throw o?new AggregateError([o,a],"Source replacement cleanup and commit failed"):a}if(o)throw o}onDispose(e,t){let n=this.records.get(e);if(!n)throw new Error("Source node is not mounted");return n.cleanup.push(t),()=>{let s=n.cleanup.indexOf(t);s!==-1&&n.cleanup.splice(s,1)}}remove(e){let t=this.records.get(e);if(!t)return;let n=[];for(let s of[...t.children])try{this.remove(s)}catch(i){n.push(i)}for(let s of t.cleanup.splice(0).reverse())try{s()}catch(i){n.push(i)}if(this.references?.remove(e),t.element&&this.elements.delete(t.element),t.element?.remove(),t.start?.remove(),t.end?.remove(),t.parent?.children.delete(e),this.records.delete(e),this.#t.delete(e),this.#s.delete(e),n.length)throw new AggregateError(n,"Source cleanup failed")}dispose(){if(this.disposed)return;this.disposed=!0,this.dragDrop.dispose(),this.source.unsubscribe(this.subscription,{any:!0}),this.pending.length=0;let e=[],t=[...this.records.entries()].filter(([,n])=>!n.parent).map(([n])=>n);for(let n of t)try{this.remove(n)}catch(s){e.push(s)}if(e.length)throw new AggregateError(e,"Renderer cleanup failed")}};var ug=new Set(["page","constructor"]);function lc(r,e){if(r===null)return[];let t=r.split("/");for(let n of t)if(ug.has(n))throw new Error(`${e}: a logic group cannot be named '${n}' (group '${r}')`);return t}var cg=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function dg(r){return/^[\w$]/.test(r)?cg.has(r):r!==")"&&r!=="]"}function fg(r,e){let t=!1;for(let n=e+1;n<r.length;n++){let s=r[n];if(s===`
66
+ `)return-1;if(s==="\\"){n++;continue}if(s==="[")t=!0;else if(s==="]")t=!1;else if(s==="/"&&!t)return n}return-1}function hg(r){let e=0,t="",n="";for(let s=r.indexOf("{");s<r.length;s++){let i=r[s];if(i==="/"&&r[s+1]==="/"){if(s=r.indexOf(`
67
+ `,s),s<0)break;continue}if(i==="/"&&r[s+1]==="*"){let o=r.indexOf("*/",s+2);if(o>=0){s=o+1;continue}}if(i==="/"&&dg(n)){let o=fg(r,s);if(o>=0){s=o,n=")";continue}}if(i==='"'||i==="'"||i==="`"){let o=s+1;for(;o<r.length&&r[o]!==i;)o+=r[o]==="\\"?2:1;e===1&&(t+=r.slice(s+1,o)==="constructor"?" constructor":' ""'),s=o,n=")";continue}if(/[\w$]/.test(i)){let o=s+1;for(;o<r.length&&/[\w$]/.test(r[o]);)o++;e===1&&(t+=r.slice(s,o)),n=r.slice(s,o),s=o-1;continue}if(/\s/.test(i)||(n=i),i==="{"){++e===2&&(t+=" {}");continue}if(i==="}"){e--;continue}e===1&&(t+=i)}return/(?<![\w$.#])(?<!\bstatic\s+)constructor\s*\(/.test(t)}function uc(r,e){if(r===void 0)return[];if(typeof r!="function"||!/^class\b/.test(Function.prototype.toString.call(r)))throw new Error(`${e}: the module exports no class Logic`);if(Object.getPrototypeOf(r)!==Function.prototype||Object.getPrototypeOf(r.prototype)!==Object.prototype)throw new Error(`${e}: class Logic cannot extend another class`);if(hg(Function.prototype.toString.call(r)))throw new Error(`${e}: class Logic cannot declare a constructor; state lives on the group or the page`);let t=[];for(let n of Reflect.ownKeys(r.prototype)){if(n==="constructor")continue;if(typeof n=="symbol")throw new Error(`${e}: class Logic cannot declare symbol keys (${String(n)})`);let s=Object.getOwnPropertyDescriptor(r.prototype,n);if(s.get||s.set)throw new Error(`${e}: class Logic cannot declare the accessor '${n}'`);if(typeof s.value!="function")throw new Error(`${e}: Logic.prototype.${n} is not a method`);if(n==="page")throw new Error(`${e}: a logic method cannot be named 'page'`);t.push([n,s.value])}return t}function cc(r,e,t){Object.defineProperty(r,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}var tr=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get page(){return this.#t}},Ur=class{#e;#t=new Map;constructor(e){this.#e=e,e.logic=new tr(this,e)}get gramlot(){return this.#e}static check(e){let t=new Map;for(let{group:n,resource:s}of e){let i=lc(n,s);for(let o=0;o<i.length;o++){let a=i.slice(0,o).join("/");t.has(a)||t.set(a,new Set),t.get(a).add(i[o])}}for(let{logicClass:n,group:s,resource:i}of e){let o=t.get(s??"")??new Set;for(let[a]of uc(n,i))if(o.has(a))throw new Error(`${i}: the logic method '${a}' has the name of a child group`)}}register(e,{group:t=null,resource:n}){let s=lc(t,n),i=uc(e,n),o=this.#e.logic;for(let a of s){let l=Object.getOwnPropertyDescriptor(o,a)?.value;if(l===void 0){let u=new tr(this,this.#e);cc(o,a,u),o=u}else if(l instanceof tr)o=l;else throw new Error(`${n}: the group '${a}' has the name of a logic method`)}for(let[a,l]of i){if(Object.getOwnPropertyDescriptor(o,a)?.value instanceof tr)throw new Error(`${n}: the logic method '${a}' has the name of a child group`);cc(o,a,l)}this.#t.has(o)||this.#t.set(o,[]),this.#t.get(o).push(n)}resolve(e,t){let n=e.split("."),s=n.pop(),i=this.#e.logic;for(let a=0;a<n.length;a++)if(i=Object.getOwnPropertyDescriptor(i,n[a])?.value,!(i instanceof tr))throw new Error(`${t.nodeTag} '${t.label}': named logic '${e}' not found: no resource was registered for the group '${n.slice(0,a+1).join("/")}'`);let o=Object.getOwnPropertyDescriptor(i,s)?.value;if(typeof o!="function"){let a=this.#t.get(i)??[],l=n.length?`the group '${n.join("/")}'`:"the page logic";throw new Error(`${t.nodeTag} '${t.label}': named logic '${e}' not found: ${l} has no method '${s}' (resources: ${a.join(", ")||"none"})`)}return{group:i,method:o}}};var Hn=class extends Se{constructor(e,{collections:t,destination:n,subscriptions:s,nameSyntax:i}){super(e),e.src=this,this.logicRegistry=new Ur(e),this.builder=new qe(null,{collections:t,nameSyntax:i}),this.binding=new jr(e,{subscriptions:s}),this.builder.binding=this.binding,this.binding.attach(),this.source=this.builder.source,this.renderer=new Vn(this.builder,this.source,n,{binding:this.binding})}startSource(e){if(!["ready","failed"].includes(this.gramlot.state))throw new Error(`Cannot start embedded Source while Gramlot is ${this.gramlot.state}`);try{return this.mountMainSource(e)}catch(t){throw this.gramlot.state="failed",t}}mountMainSource(e){let t=this.prepareSource(e);this.renderer.validateCandidate(t);try{this.source.setItem("main",t)}catch(n){throw this.binding.bindingFor(this.source.getNode("main"))||this.source.popNode("main"),n}return this.gramlot.state="started",this.binding.pageStarted(),this.binding.subscriptions.ready(),this.gramlot}prepareSource(e,t=this.builder){if(e instanceof D){if(!(e instanceof le))throw new TypeError("Source values must be GramlotBuilderBags");return e.bindBuilder(t).activateCode()}if(typeof e!="string")throw new TypeError("Source value did not decode to SourceBag");let n=Oo(e,t);if(!(n instanceof le))throw new TypeError("Source values must be GramlotBuilderBags");return n.activateCode()}async remoteSource(e,t,n={}){if(!this.gramlot.rpc.transport?.call)throw new Error("Remote Source is unavailable without a server transport");let i=this.binding.bindingFor(e);if(this.gramlot.state!=="started"||!i)throw new Error("Remote Source target is not mounted");return await e.requests.submit(t,n,o=>this.#e(e,i,o))??!1}async#e(e,t,n){if(t.closed||this.gramlot.state==="disposed")return!1;let s=!1,i=()=>this.gramlot.state!=="disposed"&&!n.ignored&&!t.closed;try{let o=await t.call("source",n);if(!i())return!1;let a=this.prepareSource(o,e.builder);return i()?(this.renderer.validateCandidate(a,{replacingNode:e}),s=!0,e.setValue(a,!0,{_text:null},!0),t.remote?.fragmentMounted(n.method,n.text),!0):!1}catch(o){if(!s&&!i())return!1;throw o}}};var zn=class extends Error{name="RpcError";constructor({code:e,name:t,message:n,details:s}){super(n),this.code=e,this.remoteName=t,s!==void 0&&(this.details=s)}},Wn=class extends Se{constructor(e,{rpcUrl:t,closeUrl:n,document:s,transport:i}){super(e),this.transport=i===!1?null:i??e.serverAdapter.createTransport({rpcUrl:t,closeUrl:n,document:s}),this.remoteRequests=new Map}get supportsCallSync(){return this.transport?.supportsCallSync===!0}callSync(e,t,n={}){if(!this.supportsCallSync)throw new Error(`rpc '${t}': the transport of this page has no synchronous call`);if(Ct(n),this.gramlot.abort.signal.aborted)throw this.gramlot.abort.signal.reason;let s=xe(),i=P(this.transport.callSync(W({id:s,pageId:this.gramlot.pageId,contentType:e,name:t,params:n})));if(i.id!==s)throw new Error("rpc response id mismatch");if(i.error)throw new zn(i.error);return i.value}async call(e,t,n={},{signal:s=null}={}){if(!this.transport?.call)throw new Error(`rpc '${t}' is unavailable without a server transport`);Ct(n);let i=xe(),o=W({id:i,pageId:this.gramlot.pageId,contentType:e,name:t,params:n}),a=s?[this.gramlot.abort.signal,s]:[this.gramlot.abort.signal],l=a.find(f=>f.aborted);if(l)throw l.reason;let u=new AbortController,c=f=>u.abort(f.target.reason);for(let f of a)f.addEventListener("abort",c,{once:!0});let d=new Promise((f,h)=>{u.signal.addEventListener("abort",()=>{this.remoteRequests.delete(i),h(u.signal.reason)},{once:!0})});this.remoteRequests.set(i,u);try{let f=P(await Promise.race([this.transport.call(o,u.signal),d]));if(f.id!==i)throw new Error("rpc response id mismatch");if(f.error)throw new zn(f.error);return f.value}finally{this.remoteRequests.delete(i);for(let f of a)f.removeEventListener("abort",c)}}};var Gn=class extends Se{setTouchMode(e="auto"){if(!["auto","on","off"].includes(e))throw new TypeError(`Invalid touch mode: ${e}`);let t=this.gramlot.src.renderer.destination.ownerDocument.documentElement;e==="auto"?t.removeAttribute("data-gramlot-touch"):t.setAttribute("data-gramlot-touch",e)}reference(e){return this.gramlot.src.renderer.references.resolve(e)}getBaseSourceNode(e){return this.gramlot.src.renderer.getBaseSourceNode(e)}getDomNode(e){return this.gramlot.src.renderer.getDomNode(e)}};var dc="gramlot:publish",vi=class{#e;#t;#r;#s=xe();#n=new Map;#i=!1;#o;#a;#l;#f;constructor(e,t){this.#e=e,this.#r=t,this.#t=t.defaultView,this.#o=s=>this.#m(s),this.#a=s=>{if(s.target?.localName!=="iframe")return;let i=this.#g(s.target);i&&(this.#u(i.window),this.#c(i,{kind:"hello"}))},this.#t.addEventListener("message",this.#o),this.#l=()=>this.#h(),this.#f=()=>this.ready(),this.#t.addEventListener("pagehide",this.#l),this.#t.addEventListener("pageshow",this.#f),t.addEventListener("load",this.#a,!0);let n=this.#d();n&&this.#c(n,{kind:"hello"})}ready(){if(this.#i||this.#e.state!=="started")return;let e=this.#d();e&&this.#c(e,{kind:"ready"});for(let t of this.#r.getElementsByTagName("iframe")){let n=this.#g(t);n&&this.#c(n,{kind:"hello"})}}prepare(e,t){let n=[];if(e.parent){let o=this.#d();if(!o)throw new Error("This page has no parent frame");n.push(o)}if(e.iframe!==void 0){let o=e.iframe,a=te(o),l=typeof o=="string"?this.#r.getElementById(o):a instanceof we?this.#e.dom.getDomNode(a):null,u=this.#g(l);if(!u)throw new Error("iframe destination must be an active Gramlot iframe ID or Source reference");n.push(u)}let s=n.map(o=>{let a=this.#n.get(o.window);if(!a||a.origin!==o.origin)throw new Error("Destination page is not ready");return{...o,session:a.session}});Ct(t);let i=W(t);return()=>{if(!this.#i)for(let o of s){let a=this.#_(o.window);if(!a||a.origin!==o.origin||this.#n.get(o.window)?.session!==o.session)throw new Error("Destination page disconnected before publication");this.#c(o,{kind:"publish",recipient:o.session,topic:e.topic,wire:i})}}}dispose(){this.#i||(this.#h(),this.#i=!0,this.#t.removeEventListener("message",this.#o),this.#t.removeEventListener("pagehide",this.#l),this.#t.removeEventListener("pageshow",this.#f),this.#r.removeEventListener("load",this.#a,!0))}#h(){for(let[e,t]of this.#n)this.#c({window:e,origin:t.origin},{kind:"close"});for(let e of this.#n.keys())this.#u(e)}#u(e){this.#n.get(e)?.release?.(),this.#n.delete(e)}#p(e,t){this.#u(e.window);let n={session:t,origin:e.origin};e.node&&(n.release=this.#e.src.binding.bindingFor(e.node).track(()=>{this.#c(e,{kind:"close"}),this.#u(e.window)})),this.#n.set(e.window,n)}#m(e){if(this.#i||e.data?.type!==dc)return;let t=this.#_(e.source);if(!t||e.origin!==t.origin)return;let n=e.data;if(!(typeof n.session!="string"||!n.session)){if(n.kind==="hello")this.#u(t.window),n.ready===!0&&this.#p(t,n.session),this.#e.state==="started"&&this.#c(t,{kind:"ready"});else if(n.kind==="ready"){let s=this.#n.get(t.window)?.session!==n.session;this.#p(t,n.session),s&&this.#e.state==="started"&&this.#c(t,{kind:"ready"})}else if(n.kind==="close")this.#n.get(t.window)?.session===n.session&&this.#u(t.window);else if(n.kind==="publish"){if(this.#e.state!=="started"||n.recipient!==this.#s||this.#n.get(t.window)?.session!==n.session||typeof n.topic!="string"||!n.topic||typeof n.wire!="string")return;this.#e.publish(n.topic,P(n.wire))}}}#c(e,t){e.window.postMessage({type:dc,session:this.#s,ready:this.#e.state==="started",...t},e.origin==="null"?"*":e.origin)}#d(){let e=this.#t.parent;return e===this.#t?null:{window:e,origin:this.#b(this.#r.referrer||this.#r.baseURI)}}#g(e){if(e?.localName!=="iframe"||!e.isConnected||!e.contentWindow)return null;let t=this.#e.dom.getBaseSourceNode(e);if(!t||!this.#e.src.binding.bindingFor(t)||this.#e.dom.getDomNode(t)!==e)return null;let n=e.getAttribute("sandbox"),i=n!==null&&!n.split(/\s+/).includes("allow-same-origin")?"null":this.#b(e.hasAttribute("srcdoc")?this.#r.baseURI:e.getAttribute("src")||this.#r.baseURI);return{window:e.contentWindow,origin:i,node:t}}#b(e){let t=new URL(e,this.#r.baseURI);return t.protocol==="file:"?"null":t.origin}#_(e){let t=this.#d();if(t?.window===e)return t;for(let n of this.#r.getElementsByTagName("iframe")){let s=this.#g(n);if(s?.window===e)return s}return null}};var Ei=class extends Se{#e=new Map;#t=new WeakSet;#r=new WeakMap;#s=0;#n=!1;#i;attach(e){this.#i=new vi(this.gramlot,e)}ready(){this.#i.ready()}subscribe(e,t){if(this.#l(),this.#a(e),typeof t!="function")throw new TypeError("subscribe requires a callback");let n=Object.freeze({});return this.#t.add(n),this.#e.has(e)||this.#e.set(e,new Map),this.#e.get(e).set(n,t),n}unsubscribe(e){if(!this.#t.has(e))throw new TypeError("Unknown subscription registration");for(let[t,n]of this.#e)n.delete(e)&&!n.size&&this.#e.delete(t)}publish(e,t={}){if(this.#l(),!t||typeof t!="object"||Array.isArray(t))throw new TypeError("publish requires one object of named data");if(typeof e=="string")return this.#o(e,t);if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("publish requires a topic string or descriptor");if(Object.keys(e).some(i=>!["topic","nodeId","parent","iframe"].includes(i)))throw new Error("This publication route is not implemented yet");if(this.#a(e.topic),e.parent!==void 0&&typeof e.parent!="boolean")throw new TypeError("parent must be boolean");if(e.iframe==="*")throw new Error("Recursive iframe broadcast is not implemented yet");if((e.parent||e.iframe!==void 0)&&Object.hasOwn(e,"nodeId"))throw new Error("Interframe node addressing is not implemented yet");let s=e.parent||e.iframe!==void 0?this.#i.prepare(e,t):null;if(Object.hasOwn(e,"nodeId")){let i=this.gramlot.src.binding.nodeIds.get(e.nodeId);if(!i)throw new Error(`nodeId not found: ${e.nodeId}`);return this.publishNode(i,e.topic,t)}this.#o(e.topic,t),s?.()}topicFor(e,t){this.#a(t),e=te(e);let n=this.gramlot.src.binding.bindingFor(e);if(!n||n.closed)throw new Error("Topic target is not an active Source node of this page");let s=e.getAttr("nodeId");return s==null&&(this.#r.has(e)||this.#r.set(e,`gramlot-self-${++this.#s}`),s=this.#r.get(e)),`${s}_${t}`}publishNode(e,t,n={}){return this.publish(this.topicFor(e,t),n)}subscribeNode(e,t){let n=[];for(let[s,i]of Object.entries(e.getAttr())){let o=s.startsWith("selfsubscribe_")?"selfsubscribe_":s.startsWith("subscribe_")?"subscribe_":null;if(!o)continue;let a=o==="selfsubscribe_"?this.topicFor(e,s.slice(o.length)):s.slice(o.length);this.#a(a),n.push([a,t(s,i,a)])}return this.#l(),n.map(([s,i])=>{let o=this.subscribe(s,i);return{close:()=>this.unsubscribe(o)}})}dispose(){this.#n=!0,this.#i.dispose(),this.#e.clear()}#o(e,t){this.#a(e);let n=this.#e.get(e);if(n)for(let[s,i]of[...n]){if(this.#n)break;n.has(s)&&i(t)}}#a(e){if(typeof e!="string"||!e)throw new TypeError("A topic must be a nonempty string")}#l(){if(this.#n)throw new Error("Gramlot subscriptions are disposed")}};var fc=2e3;function pg(r){if(!(r instanceof Date))return String(r??"");let e=r.toISOString();return e.endsWith("T00:00:00.000Z")?e.slice(0,10):e}var Xn=class{constructor(e,t){this.gramlot=e,this.document=t}branch(e){let t=this.gramlot.data.getItem(e);if(!(t instanceof C))throw new Error(`gramlot.utl.inout: no data Bag at '${e}'`);return t}mailText(e){let t=[],n=(s,i)=>{for(let o of s.getNodes()){let a=i+o.label;o.value instanceof C?n(o.value,`${a}.`):t.push(`${a}: ${pg(o.value)}`)}};return n(this.branch(e),""),t.join(`
68
+ `)}mailtoUrl(e,t){let n=`mailto:${encodeURIComponent(t)}?subject=${encodeURIComponent(this.document.title)}&body=${encodeURIComponent(this.mailText(e))}`;if(n.length>fc)throw new Error(`gramlot.utl.inout.sendMail: the email of '${e}' is ${n.length} characters long, over the mailto: limit of ${fc}; send it with sendHttp or save it as a file`);return n}sendMail(e,t){this.open(this.mailtoUrl(e,t))}async sendHttp(e,t){let n=JSON.stringify(this.branch(e).asDict(!1,!1,!0)),s=await this.document.defaultView.fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:n});if(!s.ok)throw new Error(`gramlot.utl.inout.sendHttp: ${t} answered ${s.status}`);return s}save(e,t){this.saveText(this.branch(e).toTytx(),t,"application/json")}restore(e){let t=this.document.createElement("input");return t.type="file",t.accept=".json,application/json",new Promise((n,s)=>{t.addEventListener("change",async()=>{try{let i=P(await t.files[0].text());if(!(i instanceof C))throw new TypeError("the file must contain a typed Bag");this.gramlot.data.setItem(e,i),n(i)}catch(i){s(new Error(`gramlot.utl.inout.restore: the file is not a saved Gramlot branch: ${i.message}`,{cause:i}))}},{once:!0}),t.click()})}download(e,t,n){if(!["json","xml"].includes(n))throw new Error(`gramlot.utl.inout.download: format '${n}' is not 'json' or 'xml'`);let s=this.branch(e);if(n==="json")this.saveText(s.toJson(!1),t,"application/json");else{let i=e.split(".").at(-1);this.saveText(`<?xml version='1.0' encoding='UTF-8'?>
69
+ <${i}>${s.toXml()}</${i}>`,t,"application/xml")}}saveText(e,t,n){let s=this.document.defaultView,i=s.URL.createObjectURL(new s.Blob([e],{type:n}));this.open(i,t),s.setTimeout(()=>s.URL.revokeObjectURL(i),1e3)}open(e,t=null){let n=this.document.createElement("a");n.href=e,t!==null&&(n.download=t),n.click()}};var Yn=class extends Se{constructor(e,t){super(e),this.inout=new Xn(e,t)}};var Zn=class{constructor({pageId:e,rpcUrl:t="/gramlot/rpc",closeUrl:n="/gramlot/close",rootId:s="gramlot-root",capabilities:i=[],element:o=null,document:a=o?.ownerDocument??globalThis.document,transport:l=null,collections:u=[],locale:c=null,timeZone:d=null,devices:f=[],serverAdapter:h=new ut,nameSyntax:p=null}={}){Js.register(a.defaultView);for(let g of u)g instanceof Zt&&g.register(a.defaultView);this.pageId=e;let m=c==null||d==null?a.defaultView.Intl.DateTimeFormat().resolvedOptions():null;this.devices=Object.freeze([...f]),this.locale=c??m.locale,this.timeZone=d??m.timeZone,Object.defineProperty(this,"_subscriptions",{value:new Ei(this)}),this.capabilities=Object.freeze([...i]),this.serverAdapter=h,this.src=new Hn(this,{collections:u,destination:o??a.getElementById(s),subscriptions:this._subscriptions,nameSyntax:p===null?Nn:Yt.fromJSON(p)}),this.data=this.src.builder.data,this.rpc=new Wn(this,{rpcUrl:t,closeUrl:n,document:a,transport:l}),this.dom=new Gn(this),this.utl=new Yn(this,a),this.state="ready",this._subscriptions.attach(a),this.abort=new AbortController,this.rpc.transport&&(this.pagehide=g=>{g.persisted||this.dispose({beacon:!0})},a.defaultView.addEventListener("pagehide",this.pagehide),this.window=a.defaultView)}publish(e,t={}){return this._subscriptions.publish(e,t)}subscribe(e,t){return this._subscriptions.subscribe(e,t)}unsubscribe(e){this._subscriptions.unsubscribe(e)}format(e,t){return Vu(e,t,{locale:this.locale,timeZone:this.timeZone})}start(){return this.state==="disposed"?Promise.reject(new Error("Gramlot is disposed")):this.rpc.transport?this.loading?this.loading:this.state==="started"?Promise.resolve(this):(this.state="loading",this.loading=this.loadMain().finally(()=>{this.loading=null}),this.loading):Promise.reject(new Error("This Gramlot instance has no server transport"))}async loadMain(){let e;try{e=await this.rpc.call("source","main")}catch(t){throw this.state==="disposed"?new Error("Gramlot was disposed during main",{cause:t}):(this.state="failed",t)}if(this.state==="disposed")throw new Error("Gramlot was disposed during main");try{return this.src.mountMainSource(e)}catch(t){throw this.state!=="disposed"&&(this.state="failed"),t}}dispose({beacon:e=!1}={}){if(this.state!=="disposed"){this.state="disposed",this._subscriptions.dispose(),this.pagehide&&this.window.removeEventListener("pagehide",this.pagehide),this.abort.abort();try{try{this.src.binding.dispose()}finally{this.src.renderer.dispose()}}finally{this.rpc.transport&&(this.rpc.transport.close(this.pageId,{beacon:e}),this.rpc.transport.dispose())}}}};var Ko=class{constructor({config:e,resources:t,document:n=globalThis.document}){this.config=e,this.resources=t,this.document=n,this.serverAdapter=new ut}async run(){let{config:e,resources:t,document:n}=this,s=n.defaultView;t.serverAdapter!==void 0&&(this.serverAdapter=await this.loadServerAdapter(t.serverAdapter));for(let c of t.css){let d=n.createElement("link");d.rel="stylesheet",d.href=c,n.head.append(d)}let i=!1,o=c=>{c.persisted||i||(i=!0,this.closePage())};s.addEventListener("pagehide",o);let a,l;try{let c=await Promise.allSettled(t.js.map(({url:d})=>import(new URL(d,n.baseURI).href)));if(i||(a=t.js.map(({url:d,group:f},h)=>{let p=c[h];if(p.status==="rejected")throw new Error(`${d}: import failed: ${p.reason?.message??p.reason}`,{cause:p.reason});return{logicClass:p.value.Logic,group:f,resource:d}}),Ur.check(a),l=await Promise.all((t.collections??[]).map(async d=>{try{return(await import(new URL(d,n.baseURI).href)).default}catch(f){throw new Error(`${d}: collection import failed: ${f.message}`,{cause:f})}})),i))return null;for(let d of l)d.register(s)}catch(c){throw this.closePage(),c}finally{s.removeEventListener("pagehide",o)}let u=new Zn({...e,document:n,serverAdapter:this.serverAdapter,collections:[...e.collections??[],...l.map(c=>c.toDocument())]});for(let{logicClass:c,group:d,resource:f}of a)u.src.logicRegistry.register(c,{group:d,resource:f});return s.gramlot=u,await u.start(),u}async loadServerAdapter(e){let t;try{t=await import(new URL(e,this.document.baseURI).href)}catch(n){throw new Error(`${e}: server adapter import failed: ${n.message}`,{cause:n})}return new t.default}closePage(){let e=this.serverAdapter.createTransport({...this.config,document:this.document});e.close(this.config.pageId,{beacon:!0}),e.dispose()}};var ki=Symbol("gramlot.source"),Qo=Symbol("gramlot.endpoint"),mg=new Map([[ki,"registerSource"],[Qo,"registerEndpoint"]]);function hc(r,e,t,n){let s=mg.get(t);if(e==="main")throw new TypeError(`${s} cannot declare main`);let i=Object.getOwnPropertyDescriptor(r.prototype,e)?.value;if(typeof i!="function")throw new TypeError(`${s} requires an own method of ${r.name}: ${String(e)}`);if(i[t])throw new TypeError(`${t===ki?"Source method":"Endpoint"} already registered: ${e}`);if(i[ki]||i[Qo])throw new TypeError(`${e} is declared both as Source method and endpoint`);i[t]={auth:n}}var Ai=class{static registerSource(e,{auth:t=null}={}){hc(this,e,ki,t)}static registerEndpoint(e,{auth:t=null}={}){hc(this,e,Qo,t)}},Jn=class extends Ai{static title="Gramlot";static devices=[];static locale=null;static timeZone=null;static installable=!1;static appIcon=null;manifest({baseUrl:e="./"}={}){let{title:t,appIcon:n}=this.constructor;if(typeof n!="string"||!n)throw new TypeError("An installable Page needs appIcon");return{id:e,name:t,short_name:t,start_url:e,scope:e,display:"standalone",icons:[{src:e+n.replace(/^\/+/,""),sizes:"512x512",type:"image/png"}]}}static css=[];static css_theme=null;static css_requires="";static js_requires="";static sourceBuilder=qe;main(e){throw new Error("Page.main(root) must be implemented")}};var qr=class extends Jn{static shellId="frame";static datapath=null;main(e){let t=e.div({id:this.constructor.shellId,datapath:this.constructor.datapath,class:"frame-page",height:"100vh",display:"flex",flex_direction:"column",min_height:0}),n=t.borderContainer({node_label:"frame",height:"100%",flex:"1",min_height:0});for(let s of["top","bottom","left","right","center"])if(this[s]!==void 0){let i=n.contentPane({region:s,node_label:s});this[s](i)}this.behavior(t)}center(e){}behavior(e){}};var Kn=class extends qr{static title="Application";static shellId="index";static datapath="index";static navigation=null;main(e){let{navigation:t,datapath:n}=this.constructor;if(!(t instanceof C))throw new TypeError("IndexPage.navigation must be a Bag");e.dataSetter({destination_path:`${n}.navigation`,value:t}),e.dataSetter({destination_path:`${n}.navigationSelection`,value:null}),e.dataSetter({destination_path:`${n}.active`,value:null}),e.dataSetter({destination_path:`${n}.opened`,value:new C}),super.main(e)}left(e){e.setAttr({width:"240px",splitter:!0,drawer:!0,drawer_label:"Navigation"}),e.tree({node_label:"tree",storepath:`${this.constructor.datapath}.navigation`,labelAttribute:"title",hideValues:!0,selectedPath:`^${this.constructor.datapath}.navigationSelection`})}center(e){e.tabContainer({node_label:"tabs",height:"100%",selectedPage:`^${this.constructor.datapath}.active`})}behavior(e){e.dataController({func:"indexMount",_onStart:!0,shell_id:this.constructor.shellId})}index_panel(e,{selection:t}){this.panel(e,t.getNode("#0"))}panel(e,t){e.iframe({src:t.attr.url,title:t.attr.title??t.label,width:"100%",height:"100%",border:0})}};Kn.registerSource("index_panel");function ea(r,e,t=()=>{},n=()=>{},{state:s=e.builder.data.getItem(e.getAttr("datapath")),createEntry:i=null,onLoad:o=()=>{}}={}){let a=s.getItem("navigation");if(!(a instanceof C))throw new TypeError("IndexPage navigation must be a Bag");let l=e.value.getNode("frame.center.tabs"),u=e.builder,c=new Map,d=!1,f=!1,h=0,p=null,m=s.getItem("opened");for(let A of m.getNodes()){let{url:v,path:N,title:L}=A.attr,U=l.value.getNode(A.label),ve={url:v,path:N,title:L,pane:U,node:a.getNode(N),loading:!1};n(ve),c.set(v,ve),h++}let g=A=>{if(!d){f=!0;try{s.setItem("active",A.url),s.setItem("navigationSelection",A.path),t(c,A.url)}finally{f=!1}}};async function b(A){let v=a.getNode(A);if(!v)throw new Error(`Unknown index navigation path: ${A}`);let N=v.attr.url;if(N==null)return;if(typeof N!="string"||!N)throw new TypeError("IndexPage URL must be nonempty text");p=N;let L=c.get(N);if(L){L.path=A,g(L);return}for(;l.value!==null&&l.value.getNode(`page${h}`);)h++;let U=te(u.wrapSource(l).contentPane({node_label:`page${h++}`,title:v.attr.title??v.label,pageName:N,height:"100%"})),ve=s.getItem("active");L={url:N,path:A,node:v,pane:U,title:v.attr.title??v.label,loading:!0},c.set(N,L);try{if(g(L),o(N,"loading"),i)await i(L);else{let Y=new C;if(Y.setItem(v.label,null,{...v.attr}),!await r.binding.gramlot.src.remoteSource(U,"index_panel",{selection:Y}))throw new Error("Panel loading was cancelled")}if(d)return;L.loading=!1,m.setItem(U.label,null,{url:N,path:L.path,title:L.title}),n(L),p===N&&(o(N,"ready"),g(L))}catch(Y){if(c.delete(N),m.getNode(U.label)&&m.popNode(U.label),U.parentBag&&U.parentBag.popNode(U.label),!d&&p===N){o(N,"error",Y);let ne=c.get(ve);if(p=ne?.url??null,ne)g(ne);else{f=!0;try{s.setItem("active",null),s.setItem("navigationSelection",null),t(c,null)}finally{f=!1}}}}}let y=`${e.getAttr("id")}-selection`;s.subscribe(y,{any:A=>{if(!(f||d)){if(A.node===s.getNode("navigationSelection")){let v=s.getItem("navigationSelection");v!==null&&b(v)}else if(A.node===s.getNode("active")){let v=c.get(s.getItem("active"));v&&(p=v.url,g(v))}}}});let w=()=>{if(!d){d=!0,s.unsubscribe(y,{any:!0});for(let A of c.values())A.loading&&A.pane.parentBag&&A.pane.parentBag.popNode(A.pane.label)}};r.onDispose(e,w);let k=c.get(s.getItem("active"));return k?g(k):s.getItem("navigationSelection")!==null&&b(s.getItem("navigationSelection")),{entries:c,dispose:w}}var Ti=class{indexMount(e,{shell_id:t}){let n=this.page.src.renderer,s=n.destination.ownerDocument.getElementById(t);this.index=ea(n,n.elements.get(s).node)}};function xi(r,{datapath:e,value:t,language:n="text",height:s="420px",...i}){if(!e)throw new TypeError("codeMirrorWithOptions requires datapath");let o=r.borderContainer({datapath:e,height:s,class:"gramlot-editor-options"}),a={language:n,indentUnit:4,fontSize:14,fontFamily:"monospace",lineNumbers:!0,lineWrapping:!0,folding:!0,bracketMatching:!0,autoCloseBrackets:!0,autoIndent:!0,autocompletion:!0,highlightActiveLine:!0,highlightSelectionMatches:!0};for(let[d,f]of Object.entries(a))o.dataSetter({destination_path:`.settings.${d}`,value:f});let l=o.contentPane({region:"right",width:"250px",drawer:"close",drawer_label:"Options",drawer_icon:"\u2699",drawer_minimize:!1,padding:"12px",overflow:"auto",class:"gramlot-editor-settings"});l.h3("Editor options"),l.filteringSelect({value:"^.settings.language",lbl:"Language",values:"text:Plain text,python:Python,javascript:JavaScript,typescript:TypeScript,json:JSON,html:HTML,css:CSS,xml:XML,markdown:Markdown,sql:SQL,typst:Typst"}),l.numberTextBox({value:"^.settings.indentUnit",lbl:"Indent spaces",min:1,max:16,dtype:"L",validate_notnull:!0}),l.numberTextBox({value:"^.settings.fontSize",lbl:"Font size",min:8,max:48,dtype:"L",validate_notnull:!0}),l.textbox({value:"^.settings.fontFamily",lbl:"Font family"});let u={lineNumbers:"Line numbers",lineWrapping:"Wrap lines",folding:"Code folding",bracketMatching:"Match brackets",autoCloseBrackets:"Close brackets and quotes",autoIndent:"Automatic indentation",autocompletion:"Local completion",highlightActiveLine:"Highlight current line",highlightSelectionMatches:"Highlight matching selections"};for(let[d,f]of Object.entries(u))l.checkbox({value:`^.settings.${d}`,label:f,display:"block",margin_top:"8px"});return o.contentPane({region:"center",min_height:0}).codeMirror({...i,value:t,height:"100%",...Object.fromEntries(Object.keys(a).map(d=>[d,`^.settings.${d}`]))}),o}var Qn=class r extends Ve{static internalParams=new Set([...Ve.internalParams,"gramlot","method","params","onError"]);#e=!1;#t=null;constructor({gramlot:e,root:t,path:n="",onError:s}){super({cacheTime:-1,onError:s}),this.gramlot=e,this.method="directory_tree",this.params={root:t,path:n},this.children=new Set}get closed(){return this.#e}startLoad(e){if(this.loading)return this.loading;let t=new AbortController;return this.#t=t,e({controller:t,method:this.method,params:this.params,ignored:!1})}async loadAsync({controller:e,method:t,params:n}){let{signal:s}=e,i,o=new Promise((a,l)=>{i=()=>l(s.reason),s.addEventListener("abort",i,{once:!0})});try{let a=await Promise.race([this.gramlot.rpc.call("data",t,n,{signal:s}),o]);if(s.aborted)throw s.reason;return a}finally{s.removeEventListener("abort",i),this.#t===e&&(this.#t=null)}}prepareValue(e){if(!(e instanceof C))throw new TypeError("directory_tree must return a Bag");for(let t of this.children)t.abort();this.children.clear();for(let t of e.getNodes())if(t.attr.is_directory){let n=new r({gramlot:this.gramlot,root:this.params.root,path:t.attr.path,onError:this.onError});this.children.add(n),e.setResolver(t.label,n)}return e}abort(){this.#e=!0,this.#t?.abort();for(let e of this.children)e.abort();this.children.clear()}},es=class{constructor(e,t){this.gramlot=e,this.state=t,this.request=null,this.resolver=null,this.disposed=!1}async open(e){this.request?.abort();let t=this.request=new AbortController;this.state.setItem("status","Opening directory\u2026");try{let n=await this.gramlot.rpc.call("data","workspace_open",{root:e},{signal:t.signal});if(this.disposed||t.signal.aborted)return null;let s=new Qn({gramlot:this.gramlot,root:n.root,onError:o=>this.state.setItem("status",o.message)}),i=s.prepareValue(n.entries);return this.resolver?.abort(),this.resolver=s,this.state.setItem("selectedPath",null),this.state.setItem("store",i),this.state.setItem("root",n.root),this.state.setItem("status",""),n.root}catch(n){return!this.disposed&&!t.signal.aborted&&this.state.setItem("status",n.message),null}finally{this.request===t&&(this.request=null)}}dispose(){this.disposed=!0,this.request?.abort(),this.resolver?.abort()}},rr=class{fileSystemMount(e){this.fileSystems??=new WeakMap;let t=e.parentNode,n=t.getRelativeData("."),s=new es(this.page,n);this.fileSystems.set(n,s),this.page.src.renderer.onDispose(t,()=>s.dispose())}fileSystemOpen(e,{root:t}){if(t)return this.fileSystems.get(e.getRelativeData(".")).open(t)}};function pc(r,{datapath:e,...t}){let n=r.div({datapath:e,class:"gramlot-filesystem",...t});return n.dataSetter({destination_path:".store",value:new C}),n.dataSetter({destination_path:".root",value:null}),n.dataSetter({destination_path:".requestedRoot",value:null}),n.dataSetter({destination_path:".selectedPath",value:null}),n.dataSetter({destination_path:".status",value:""}),n.dataController({func:"fileSystemMount",_onBuilt:!0}),n.dataController({func:"fileSystemOpen",root:"^.requestedRoot"}),n.tree({storepath:".store",selectedPath:"^.selectedPath",labelAttribute:"caption",hideValues:!0,class:"gramlot-filesystem-tree"}),n.div("^.status",{role:"status",class:"gramlot-filesystem-status"}),n}var gg=(r,e)=>"d_"+[...new TextEncoder().encode(JSON.stringify([r,e]))].map(t=>t.toString(16).padStart(2,"0")).join(""),Di=class{constructor(e,t){this.gramlot=e,this.state=t,this.pending=new Map,this.disposed=!1}get documents(){return this.state.getItem("documents")}async open(e,t){let n=gg(e,t),s=this.documents.getNodes().find(a=>!a.value.getItem("isNew")&&a.value.getItem("root")===e&&a.value.getItem("path")===t);if(s)return s.label;if(this.pending.has(n))return this.pending.get(n).promise;let i=new AbortController,o=this.gramlot.rpc.call("data","document_read",{root:e,path:t},{signal:i.signal}).then(a=>{if(this.disposed||i.signal.aborted)return null;let l=new C;for(let[u,c]of Object.entries({...a,root:e,saved:a.content,busy:!1}))l.setItem(u,c);return this.documents.setItem(n,l),n}).finally(()=>this.pending.delete(n));return this.pending.set(n,{request:i,promise:o}),o}newDocument(e,t,n=""){let s=`new_${crypto.randomUUID().replaceAll("-","")}`,i=new C;for(let[o,a]of Object.entries({language:e,root:n,path:`Untitled${t}`,content:"",saved:"",writable:!0,busy:!1,isNew:!0,createHidden:!0,saveRoot:n,savePath:`Untitled${t}`}))i.setItem(o,a);return this.documents.setItem(s,i),s}async create(e){let t=this.documents.getItem(e);if(!t||!t.getItem("isNew")||this.pending.has(e))return!1;let n=t.getItem("saveRoot"),s=t.getItem("savePath");if(t.getItem("path").endsWith(".typ.py")!==s.endsWith(".typ.py"))throw new Error("The .typ.py extension is required for the Typst Python recipe document type.");let i=t.getItem("content"),o=new AbortController;t.setItem("busy",!0);let a=this.gramlot.rpc.call("data","document_create",{root:n,path:s,content:i},{signal:o.signal}).then(l=>this.disposed||o.signal.aborted?!1:(t.setItem("root",l.root),t.setItem("path",l.path),t.setItem("revision",l.revision),t.setItem("saved",i),t.setItem("isNew",!1),t.setItem("createHidden",!0),!0)).finally(()=>{this.pending.delete(e),this.disposed||t.setItem("busy",!1)});return this.pending.set(e,{request:o,promise:a}),a}invalidateRecipe(e){let t=this.documents.getItem(e);t.getItem("path").endsWith(".typ.py")&&(t.getItem("rendering")&&this.pending.get(e)?.request.abort(),t.setItem("previewHidden",!0),t.setItem("typstSource",""),t.setItem("renderStatus","Generate preview to render the current Python recipe."))}async renderRecipe(e){let t=this.documents.getItem(e);if(!t||!t.getItem("path").endsWith(".typ.py")||!t.getItem("writable")||this.pending.has(e))return!1;let n=t.getItem("content"),s=new AbortController;t.setItem("busy",!0),t.setItem("rendering",!0),t.setItem("previewHidden",!0),t.setItem("typstSource",""),t.setItem("renderStatus","Generating Typst on the server\u2026");let i=this.gramlot.rpc.call("data","document_render_typst",{content:n},{signal:s.signal}).then(o=>this.disposed||s.signal.aborted||t.getItem("content")!==n?!1:(t.setItem("typstSource",o.source),t.setItem("previewHidden",!1),t.setItem("renderStatus","Typst generated from the current recipe."),!0)).catch(o=>(!this.disposed&&!s.signal.aborted&&t.setItem("renderStatus",o.message),!1)).finally(()=>{this.pending.delete(e),this.disposed||(t.setItem("rendering",!1),t.setItem("busy",!1))});return this.pending.set(e,{request:s,promise:i}),i}dirty(e){let t=this.documents.getItem(e);return t&&t.getItem("content")!==t.getItem("saved")}async save(e){let t=this.documents.getItem(e);if(!t||t.getItem("isNew")||!this.dirty(e)||!t.getItem("writable")||this.pending.has(e))return!1;let n=t.getItem("content"),s=new AbortController;t.setItem("busy",!0);let i=this.gramlot.rpc.call("data","document_save",{root:t.getItem("root"),path:t.getItem("path"),content:n,revision:t.getItem("revision")},{signal:s.signal}).then(o=>this.disposed||s.signal.aborted?!1:(t.setItem("revision",o.revision),t.setItem("saved",n),!0)).finally(()=>{this.pending.delete(e),this.disposed||t.setItem("busy",!1)});return this.pending.set(e,{request:s,promise:i}),i}revert(e){let t=this.documents.getItem(e);return!t||!this.dirty(e)||this.pending.has(e)?!1:(t.setItem("content",t.getItem("saved")),!0)}canClose(e,t=!1){return!this.pending.has(e)&&(t||!this.dirty(e))}close(e,t=!1){return this.canClose(e,t)?(this.documents.popNode(e),this.state.getItem("active")===e&&this.state.setItem("active",this.documents.getNodes()[0]?.label??null),!0):!1}dispose(){this.disposed=!0;for(let{request:e}of this.pending.values())e.abort()}},Si=class{constructor(e){this.storage=e,this.key="gramlot.ide.recentWorkspaces"}read(){let e=this.storage.getItem(this.key),t=e===null?[]:JSON.parse(e);if(!Array.isArray(t)||t.some(n=>typeof n!="string"||!n))throw new TypeError("Invalid recent workspace preference");return t.slice(0,6)}remember(e){let t=[e,...this.read().filter(n=>n!==e)].slice(0,6);return this.storage.setItem(this.key,JSON.stringify(t)),t}choices(e=this.read()){let t=new C;return e.forEach((n,s)=>t.setItem(`r${s}`,n,{caption:n})),t}};var Ci=class{fileSystemMount(e){return rr.prototype.fileSystemMount.call(this,e)}fileSystemOpen(e,t){return rr.prototype.fileSystemOpen.call(this,e,t)}ideMount(e){this.ideRoot=e.parentNode,this.ideState=e.getRelativeData("."),this.ideDocuments=new Di(this.page,this.ideState),this.idePanels=new Map,this.ideDisposed=!1,this.ideRequested=0,this.ideRecent=new Si(this.page.src.renderer.destination.ownerDocument.defaultView.sessionStorage);let t=this.ideRecent.read();this.ideState.setItem("recent",this.ideRecent.choices(t)),this.ideState.setItem("workspace",t[0]??"");let n=this.ideState.getItem("browser");n.subscribe("ide-browser",{any:s=>{if(s.node===n.getNode("root")){let i=n.getItem("root");this.ideState.setItem("workspace",i),this.ideState.setItem("recent",this.ideRecent.choices(this.ideRecent.remember(i))),this.ideState.setItem("status",`Workspace: ${i}`)}else if(s.node===n.getNode("selectedPath")){let i=n.getItem("selectedPath"),o=i===null?null:n.getItem("store").getNode(i);o&&!o.attr.is_directory&&this.ideOpenDocument(n.getItem("root"),o.attr.path)}}}),this.ideDocuments.documents.subscribe("ide-documents",{any:s=>{if(["content","saved","busy","writable","view","isNew","path","root"].includes(s.node.label))for(let[i,o]of this.idePanels){let a=this.ideDocuments.documents.getItem(i);a&&(s.node===a.getNode("content")&&this.ideDocuments.invalidateRecipe(i),this.ideDocumentState(i),o.setAttr({title:`${this.ideDocuments.dirty(i)?"\u25CF ":""}${a.getItem("path")}`}))}}}),this.page.src.renderer.onDispose(this.ideRoot,()=>{this.ideDisposed=!0,n.unsubscribe("ide-browser",{any:!0}),this.ideDocuments.documents.unsubscribe("ide-documents",{any:!0}),this.ideDocuments.dispose()})}ideOpenWorkspace(){let e=this.ideState.getItem("workspace");e&&e!==this.ideState.getItem("browser.root")&&this.ideState.setItem("browser.requestedRoot",e)}ideDocumentState(e){let t=this.ideDocuments.documents.getItem(e),n=!this.ideDocuments.dirty(e)&&!t.getItem("isNew")||t.getItem("busy");t.setItem("saveDisabled",!!(n||!t.getItem("writable"))),t.setItem("revertDisabled",!!(!this.ideDocuments.dirty(e)||t.getItem("busy"))),t.setItem("displayPath",t.getItem("isNew")?t.getItem("path"):`${t.getItem("root")}/${t.getItem("path")}`),t.setItem("pdfFilename",t.getItem("path").split("/").at(-1).replace(/\.typ(?:\.py)?$/i,".pdf")),t.setItem("renderDisabled",!!(t.getItem("busy")||!t.getItem("writable"))),this.ideHistoryState(t)}async ideOpenDocument(e,t){let n=++this.ideRequested;try{let s=await this.ideDocuments.open(e,t);if(s===null||this.ideDisposed)return;this.ideShowDocument(s),n===this.ideRequested&&(this.ideState.setItem("active",s),this.ideState.setItem("status",`${t}${this.ideDocuments.documents.getItem(s).getItem("writable")?"":" (read only)"}`))}catch(s){this.ideDisposed||this.ideState.setItem("status",s.message)}}ideNew(){let e=this.ideState.getItem("newType"),t=e==="typstRecipe"?"python":e,n={typstRecipe:".typ.py",typst:".typ",markdown:".md",html:".html",python:".py",javascript:".js",typescript:".ts",json:".json",css:".css",sql:".sql",xml:".xml",text:".txt"},s=this.ideDocuments.newDocument(t,n[e],this.ideState.getItem("workspace"));++this.ideRequested,this.ideShowDocument(s),this.ideState.setItem("active",s),this.ideState.setItem("status","New document. Choose directory and name when saving.")}ideShowDocument(e){let n=this.ideDocuments.documents.getItem(e).getItem("path");if(!this.idePanels.has(e)){let s=this.ideDocuments.documents.getItem(e),i=n.endsWith(".typ.py");i&&this.ideDocuments.invalidateRecipe(e),s.setItem("readonly",!s.getItem("writable")),this.ideDocumentState(e),s.setItem("view","code"),s.setItem("createHidden",!0),s.setItem("undoDisabled",!0),s.setItem("redoDisabled",!0);let o=this.ideRoot.value.getNode("frame.center.tabs"),a=te(o.builder.wrapSource(o).contentPane({node_label:e,title:n,pageName:e,documentKey:e,closable:!0,onClose:"ideClose",height:"100%"}));this.idePanels.set(e,a);let l=a.builder.wrapSource(a).div({display:"flex",flex_direction:"column",height:"100%"}),u=l.div({datapath:`.documents.${e}`,display:"flex",align_items:"center",gap:"6px",padding:"4px 12px",height:"40px",flex_shrink:0,box_sizing:"border-box",class:"gramlot-ide-document-toolbar",role:"toolbar","aria-label":`Commands for ${n}`});for(let[w,k,A,v]of[["save","M5 3h12l4 4v14H3V3h2 M7 3v6h10V3 M7 21v-8h10v8","Save","ideSave"],["revert","M3 10a9 9 0 1 1 2 8 M3 4v6h6 M12 7v5l3 2","Revert to saved","ideRevert"],["undo","M9 5 3 11l6 6 M3 11h12a6 6 0 0 1 6 6v2","Undo","ideUndo"],["redo","m15 5 6 6-6 6 M21 11H9a6 6 0 0 0-6 6v2","Redo","ideRedo"]]){let N=u.button({title:A,"aria-label":A,disabled:`^.${w}Disabled`,class:`button--quiet gramlot-ide-${w}`});N.svg({viewBox:"0 0 24 24",width:18,height:18,fill:"none",stroke:"currentColor",stroke_width:1.7,stroke_linecap:"round",stroke_linejoin:"round","aria-hidden":"true"}).path({d:k}),N.dataController({func:v,documentKey:e})}i&&u.button("Generate preview",{disabled:"^.renderDisabled",class:"button--quiet"}).dataController({func:"ideRenderRecipe",documentKey:e}),u.div("^.displayPath",{class:"gramlot-ide-document-path",overflow:"hidden",text_overflow:"ellipsis",white_space:"nowrap",min_width:0,flex:"1"});let c=l.div({datapath:`.documents.${e}`,hidden:"^.createHidden",padding:"8px 12px",display:"flex",gap:"8px",align_items:"end",flex_shrink:0});c.textbox({value:"^.saveRoot",lbl:"Directory",flex:"1",disabled:"^.busy"}),c.textbox({value:"^.savePath",lbl:"File name",flex:"1",disabled:"^.busy"}),c.button("Create file",{disabled:"^.busy"}).dataController({func:"ideCreate",documentKey:e}),c.button("Cancel",{disabled:"^.busy",class:"button--quiet"}).dataController({func:"ideCancelCreate",documentKey:e});let d=l.div({flex:"1",min_height:0}),f=s.getItem("language")==="html",h=s.getItem("language")==="markdown",p=f||h,m=s.getItem("language")==="typst",g=p||m||i,b=g?d.tabContainer({height:"100%",selectedPage:`^.documents.${e}.view`}):null,y=g?b.contentPane({title:"Code",pageName:"code",height:"100%"}):d;if(xi(y,{datapath:`.documents.${e}`,value:"^.content",language:s.getItem("language"),height:"100%",readonly:"^.readonly",nodeId:`editor_${e}`,editorView:"code",selfsubscribe_historyChanged:"ideHistoryChanged"}),l.dataController({func:"ideSave",documentKey:e,[`subscribe_editor_${e}_save`]:!0}),m&&b.contentPane({title:"Preview",pageName:"preview",height:"100%"}).typstPreview({value:`^.documents.${e}.content`,filename:`^.documents.${e}.pdfFilename`,height:"100%"}),i){let w=b.contentPane({title:"Preview",pageName:"preview",height:"100%",display:"flex",flex_direction:"column"});w.div(`^.documents.${e}.renderStatus`,{role:"status",padding:"8px 12px",white_space:"pre-wrap",overflow:"auto",max_height:"30%"}),w.typstPreview({value:`^.documents.${e}.typstSource`,filename:`^.documents.${e}.pdfFilename`,hidden:`^.documents.${e}.previewHidden`,flex:"1",min_height:0}),b.contentPane({title:"Generated Typst",pageName:"generated",height:"100%"}).codeMirror({value:`^.documents.${e}.typstSource`,language:"typst",readonly:!0,height:"100%"})}if(p){let w=b.contentPane({title:"Preview",pageName:"preview",height:"100%",display:"flex",flex_direction:"column"});h&&(s.setItem("allowHtml",!1),w.checkbox({value:`^.documents.${e}.allowHtml`,label:"Allow embedded HTML",class:"gramlot-ide-allow-html",padding:"8px 12px",flex_shrink:0})),w[f?"htmlPreview":"markdownPreview"]({value:`^.documents.${e}.content`,flex:"1",min_height:0,...h?{allowHtml:`^.documents.${e}.allowHtml`}:{}}),b.contentPane({title:"Rich text",pageName:"rich",height:"100%"})[f?"htmlEditor":"markdownEditor"]({datapath:`.documents.${e}`,value:"^.content",readonly:"^.readonly",height:"100%",nodeId:`rich_editor_${e}`,editorView:"rich",selfsubscribe_historyChanged:"ideHistoryChanged"}),l.dataController({func:"ideSave",documentKey:e,[`subscribe_rich_editor_${e}_save`]:!0})}}}async ideRenderRecipe(e,{documentKey:t}){this.ideDocuments.documents.getItem(t).setItem("view","preview"),await this.ideDocuments.renderRecipe(t)}ideCancelCreate(e,{documentKey:t}){this.ideDocuments.documents.getItem(t).setItem("createHidden",!0)}async ideCreate(e,{documentKey:t}){this.ideState.setItem("status","Creating file\u2026");try{let n=await this.ideDocuments.create(t);if(!this.ideDisposed&&n){this.ideState.setItem("status","File created.");let s=this.ideState.getItem("browser");s.getItem("root")&&await this.fileSystems.get(s).open(s.getItem("root"))}}catch(n){this.ideDisposed||this.ideState.setItem("status",n.message)}}async ideSave(e,{documentKey:t=null}={}){let n=t??this.ideState.getItem("active");if(!n||this.ideDocuments.documents.getItem(n).getItem("saveDisabled"))return;let s=this.ideDocuments.documents.getItem(n);if(s.getItem("isNew")){s.setItem("createHidden",!1);return}this.ideState.setItem("status","Saving\u2026");try{let i=await this.ideDocuments.save(n);this.ideDisposed||this.ideState.setItem("status",i?"Saved.":"Document is read only or a request is pending.")}catch(i){this.ideDisposed||this.ideState.setItem("status",i.message)}}ideRevert(e,{documentKey:t}){this.ideDocuments.revert(t)&&this.ideState.setItem("status","Restored the last saved version.")}ideHistoryChanged(e,{canUndo:t,canRedo:n}){let s=e.getRelativeData("."),i=e.getAttr("editorView");s.setItem(`${i}CanUndo`,t),s.setItem(`${i}CanRedo`,n),this.ideHistoryState(s)}ideHistoryState(e){let t=e.getItem("view");e.setItem("undoDisabled",!e.getItem(`${t}CanUndo`)),e.setItem("redoDisabled",!e.getItem(`${t}CanRedo`))}ideEditor(e){let t=this.ideDocuments.documents.getItem(e).getItem("view")==="rich",n=this.page.src.binding.nodeIds.get(`${t?"rich_":""}editor_${e}`);return this.page.src.renderer.records.get(n).element}ideUndo(e,{documentKey:t}){this.ideEditor(t).undo()}ideRedo(e,{documentKey:t}){this.ideEditor(t).redo()}ideClose(e){let t=e.getAttr("documentKey");return this.ideDocuments.canClose(t)?!0:(this.ideState.setItem("status","Save or revert your changes before closing. Pending operations must finish first."),!1)}ideClosed(e,{pageName:t}){this.ideForgetDocument(t)}ideForgetDocument(e,t=!1){let n=this.ideDocuments.documents.getItem(e),s=this.ideState.getItem("browser"),i=s.getItem("selectedPath"),o=i===null?null:s.getItem("store").getNode(i);n&&s.getItem("root")===n.getItem("root")&&o?.attr.path===n.getItem("path")&&s.setItem("selectedPath",null),this.idePanels.delete(e),this.ideDocuments.close(e,t)}};var ta=class r extends Ve{static internalParams=new Set([...Ve.internalParams,"gramlot","method","params","onError"]);#e=!1;#t=null;constructor({gramlot:e,method:t,directory:n,onError:s}){super({cacheTime:-1,onError:s}),this.gramlot=e,this.method=t,this.params={directory:n},this.children=new Set}get closed(){return this.#e}startLoad(e){if(this.loading)return this.loading;let t=new AbortController;return this.#t=t,e({controller:t,method:this.method,params:this.params,ignored:!1})}async loadAsync({controller:e,method:t,params:n}){let{signal:s}=e,i,o=new Promise((a,l)=>{i=()=>l(s.reason),s.addEventListener("abort",i,{once:!0})});try{let a=await Promise.race([this.gramlot.rpc.call("data",t,n,{signal:s}),o]);if(s.aborted)throw s.reason;return a}finally{s.removeEventListener("abort",i),this.#t===e&&(this.#t=null)}}prepareValue(e){if(!(e instanceof C))throw new TypeError("Directory navigation must return a Bag");for(let t of this.children)t.abort();this.children.clear();for(let t of e.getNodes())if(t.attr.directory!==void 0){let n=new r({gramlot:this.gramlot,method:this.method,directory:t.attr.directory,onError:this.onError});this.children.add(n),e.setResolver(t.label,n)}return e}abort(){this.#e=!0,this.#t?.abort();for(let e of this.children)e.abort();this.children.clear()}};function nr(r,e){return e===2?r%4===0&&(r%100!==0||r%400===0)?29:28:[4,6,9,11].includes(e)?30:31}function Ce(r,e,t){if(![r,e,t].every(Number.isInteger)||r<1||r>9999||e<1||e>12||t<1||t>nr(r,e))throw new RangeError("Date must exist in Gregorian years 0001\u20139999.");return`${String(r).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function sr(r){if(typeof r!="string"||!/^\d{4}-\d{2}-\d{2}$/.test(r))throw new RangeError("Expected a civil date in YYYY-MM-DD format.");let e=r.split("-").map(Number);return Ce(...e),e}function ts(r,e,t){let n=r-1,s=365*n+Math.floor(n/4)-Math.floor(n/100)+Math.floor(n/400)+t-1;for(let i=1;i<e;i++)s+=nr(r,i);return s}function rs(r,e){let t=ts(...sr(r))+e;if(!Number.isSafeInteger(t)||t<0||t>ts(9999,12,31))throw new RangeError("Date offset exceeds Gregorian years 0001\u20139999.");let n=1,s=1e4;for(;s-n>1;){let o=Math.floor((n+s)/2);ts(o,1,1)<=t?n=o:s=o}t-=ts(n,1,1);let i=1;for(;t>=nr(n,i);)t-=nr(n,i++);return Ce(n,i,t+1)}function ra(r){return rs(r,-(ts(...sr(r))%7))}function mc(r,e,t=0,n=1){let s=r*12+e-1+t,i=Math.floor(s/12),o=(s%12+12)%12+1,a=s+n-1,l=Math.floor(a/12),u=(a%12+12)%12+1;return{start:Ce(i,o,1),end:Ce(l,u,nr(l,u))}}var na={it:{months:{gennaio:1,febbraio:2,marzo:3,aprile:4,maggio:5,giugno:6,luglio:7,agosto:8,settembre:9,ottobre:10,novembre:11,dicembre:12,gen:1,feb:2,mar:3,apr:4,mag:5,giu:6,lug:7,ago:8,set:9,ott:10,nov:11,dic:12},weekdays:{luned\u00EC:0,marted\u00EC:1,mercoled\u00EC:2,gioved\u00EC:3,venerd\u00EC:4,sabato:5,domenica:6,lun:0,mar:1,mer:2,gio:3,ven:4,sab:5,dom:6},quarters:{"1\xBA trimestre":1,"2\xBA trimestre":2,"3\xBA trimestre":3,"4\xBA trimestre":4,"1\xB0 trimestre":1,"2\xB0 trimestre":2,"3\xB0 trimestre":3,"4\xB0 trimestre":4,t1:1,t2:2,t3:3,t4:4,q1:1,q2:2,q3:3,q4:4},keywords:{today:["oggi"],yesterday:["ieri"],tomorrow:["domani"],this_week:["questa settimana","settimana"],last_week:["settimana scorsa"],next_week:["settimana prossima"],this_month:["questo mese","mese"],last_month:["mese scorso"],next_month:["mese prossimo"],last:["scorso","scorsa"],next:["prossimo","prossima"],articles:["il","lo","la"],from:["da","dal","dalla","tra","fra"],to:["a","al","alla","e"],no_period:["-","senza periodo","sempre"]},date_order:{default:"DMY"}},en:{months:{january:1,february:2,march:3,april:4,may:5,june:6,july:7,august:8,september:9,october:10,november:11,december:12,jan:1,feb:2,mar:3,apr:4,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},weekdays:{monday:0,tuesday:1,wednesday:2,thursday:3,friday:4,saturday:5,sunday:6,mon:0,tue:1,wed:2,thu:3,fri:4,sat:5,sun:6},quarters:{"1st quarter":1,"2nd quarter":2,"3rd quarter":3,"4th quarter":4,q1:1,q2:2,q3:3,q4:4},keywords:{today:["today"],yesterday:["yesterday"],tomorrow:["tomorrow"],this_week:["this week","week"],last_week:["last week"],next_week:["next week"],this_month:["this month","month"],last_month:["last month"],next_month:["next month"],last:["last"],next:["next"],articles:["the"],from:["from","between"],to:["to","and"],no_period:["no period","always"]},date_order:{default:"MDY",GB:"DMY",AU:"DMY",IE:"DMY",NZ:"DMY",IN:"DMY"}}};function gc(r){if(typeof r!="string")throw new RangeError("A supported locale is required.");let e=r.replaceAll("-","_"),t=e.indexOf("_"),n=(t<0?e:e.slice(0,t)).toLowerCase(),s=(t<0?"":e.slice(t+1)).toUpperCase();if(!Object.hasOwn(na,n))throw new RangeError(`Unsupported locale: ${r}`);let i=na[n];return{dictionary:i,phrases:a=>[...new Set([...i.keywords[a],...na.en.keywords[a]])],order:i.date_order[s]??i.date_order.default}}var ir=/^(?:\d{4}|\d{2})$/,bc=/^\d{1,2}$/,ns=(r,e)=>({ok:!1,error:{code:r,message:e}}),ar=(r="UNRECOGNIZED_EXPRESSION",e="Text is not a supported date expression.")=>{throw Object.assign(new SyntaxError(e),{code:r})},yc=(r,e)=>Object.hasOwn(r,e);function or(r,e){if(r.length===4)return Number(r);let t=e.year+e.twoDigitYearAhead-100;return t+((Number(r)-t)%100+100)%100}function bg(r,e){if(r.includes(";")){let s=r.split(";").map(i=>i.trim());return s.length!==2?ar("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:s,range:!0}}if(e.phrases("no_period").includes(r))return{bounds:["",""],range:!0};let t=e.phrases("to"),n=e.phrases("from");for(let s of t)if(r.startsWith(`${s} `))return{bounds:["",r.slice(s.length+1).trim()],range:!0};for(let s of t){let i=` ${s} `;if(!r.includes(i))continue;for(let a of n)if(r.startsWith(`${a} `)){r=r.slice(a.length+1);break}let o=r.split(i).map(a=>a.trim());return o.length!==2?ar("INVALID_RANGE","A range must have exactly two endpoints."):{bounds:o,range:!0}}for(let s of n)if(r.startsWith(`${s} `))return{bounds:[r.slice(s.length+1).trim(),""],range:!0};return{bounds:[r,r],range:!1}}function _g(r,e,t){let n=[[r,0]],s=/^(.+?)\s*([+-])\s*(\d+)$/.exec(r);s&&n.push([s[1],Number(s[2]+s[3])]);let i={today:0,yesterday:-1,tomorrow:1,this_week:0,last_week:-1,next_week:1,this_month:0,last_month:-1,next_month:1};for(let[o,a]of n)for(let[l,u]of Object.entries(i))if(e.phrases(l).includes(o)){if(l.endsWith("_week"))return rs(ra(e.workdate),(u+a)*7+(t?6:0));if(l.endsWith("_month")){let c=mc(e.year,e.month,u+a);return t?c.end:c.start}return rs(e.workdate,u+a)}return null}function wg(r,e,t){let n=Object.entries(e.dictionary.quarters).sort((s,i)=>i[0].length-s[0].length);for(let[s,i]of n){let o;if(r===s)o=null;else if(r.startsWith(s)&&ir.test(r.slice(s.length).trim()))o=or(r.slice(s.length).trim(),e);else if(r.endsWith(s)&&ir.test(r.slice(0,-s.length).trim()))o=or(r.slice(0,-s.length).trim(),e);else continue;return{year:o,month:t?i*3:i*3-2}}return null}function _c(r,e){if(yc(e.months,r))return e.months[r];let t=/^m(\d{1,2})$/.exec(r);return t&&Number(t[1])>=1&&Number(t[1])<=12?Number(t[1]):null}function yg(r,e){let t=r.split(/\s+/),n=t.map((u,c)=>_c(u,e.dictionary)?c:-1).filter(u=>u>=0);if(!n.length)return null;if(n.length!==1)return ar();let s=n[0],i=_c(t[s],e.dictionary),o=t.slice(0,s),a=t.slice(s+1),l=[...o,...a];if(l.length===1&&e.phrases("last").includes(l[0]))return{year:e.year-(i>e.month?1:0),month:i};if(l.length===1&&e.phrases("next").includes(l[0]))return{year:e.year+(i<e.month?1:0),month:i};if(!l.length)return{year:null,month:i};if(!o.length&&a.length===1&&ir.test(a[0]))return{year:or(a[0],e),month:i};if(o.length===1&&bc.test(o[0])){if(!a.length)return Ce(e.year,i,Number(o[0]));if(a.length===1&&ir.test(a[0]))return Ce(or(a[0],e),i,Number(o[0]))}return!o.length&&a.length===2&&bc.test(a[0])&&ir.test(a[1])?Ce(or(a[1],e),i,Number(a[0])):ar()}function vg(r,e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(r);if(t)return Ce(...t.slice(1).map(Number));let n=/^(\d{1,4})[/\-. ]+(\d{1,4})[/\-. ]+(\d{1,4})$/.exec(r),s={};if(n)e.order.split("").forEach((a,l)=>{s[a]=n[l+1]});else if(/^(?:\d{6}|\d{8})$/.test(r)){let a=r.length===8?4:2;for(let l of e.order){let u=l==="Y"?a:2;s[l]=r.slice(0,u),r=r.slice(u)}}else return null;if(!ir.test(s.Y)||s.D.length>2||s.M.length>2)return ar();let i=Number(s.D),o=Number(s.M);return n&&o>12&&i<=12&&([i,o]=[o,i]),Ce(or(s.Y,e),o,i)}function wc(r,e,t){if(!r)return null;let n=e.phrases("articles");if(r=r.split(/\s+/).filter(i=>!n.includes(i)).join(" "),!r)return ar();if(ir.test(r))return Ce(or(r,e),t?12:1,t?31:1);let s=_g(r,e,t)??wg(r,e,t)??yg(r,e);return s!==null?s:yc(e.dictionary.weekdays,r)?rs(ra(e.workdate),e.dictionary.weekdays[r]):vg(r,e)??ar()}function Eg(r,e,t){if(r===null||typeof r=="string")return r;let n=r.year??t.year,s=typeof e=="string"?sr(e)[0]:e?.year,i=typeof e=="string"?sr(e)[1]:e?.month;return s&&(n>s&&(n=s),n===s&&r.month>i&&n--),Ce(n,r.month,1)}function kg(r,e,t){if(r===null||typeof r=="string")return r;let n=r.year??t.year;if(e!==null){let[s,i]=sr(e);n<s&&(n=s),n===s&&i>r.month&&n++}return Ce(n,r.month,nr(n,r.month))}function Ag(r,e={}){if(!e||typeof e!="object"||Array.isArray(e))return ns("INVALID_CONTEXT","Options must provide a civil workdate and supported locale.");let t;try{let{locale:n="it-IT",workdate:s,twoDigitYearAhead:i=20}=e,[o,a]=sr(s);if(!Number.isInteger(i)||i<0||i>99)throw new RangeError("twoDigitYearAhead must be an integer from 0 to 99.");t={...gc(n),workdate:s,year:o,month:a,twoDigitYearAhead:i}}catch(n){return ns("INVALID_CONTEXT",n.message)}if(typeof r!="string")return ns("INVALID_INPUT","Expression must be a string.");try{let n=r.toLowerCase().trim().replaceAll(",",""),{bounds:s,range:i}=bg(n,t),o=wc(s[1],t,!0),a=wc(s[0],t,!1),l=Eg(a,o,t),u=kg(o,l,t);return!i&&typeof a=="string"&&l===u?{ok:!0,kind:"date",date:l}:{ok:!0,kind:"period",start:l,end:u}}catch(n){if(n instanceof RangeError)return ns("INVALID_DATE",n.message);if(n instanceof SyntaxError)return ns(n.code,n.message);throw n}}export{C as Bag,Fe as BagNode,Qn as DirectoryResolver,Gn as DomHandler,Ai as Exposed,es as FileSystemController,rr as FileSystemLogic,qr as FramePage,Zn as Gramlot,qe as GramlotBuilder,Kt as GramlotHtmlRenderer,Vn as GramlotRenderer,Mn as GramlotSvgRenderer,Se as Handler,Vr as HttpTransport,Ci as IdeLogic,Xn as InOut,Ti as IndexLogic,Kn as IndexPage,ta as NavigationResolver,Jn as Page,Ko as PageBootstrap,Fn as References,zn as RpcError,Wn as RpcHandler,ut as ServerAdapter,Hn as SourceHandler,Yn as UtilitiesHandler,xi as codeMirrorWithOptions,Et as createDecimal,pc as fileSystemTree,ea as mountIndexPage,Ag as parseDateExpression};
67
70
  /*! Bundled license information:
68
71
 
69
72
  decimal.js/decimal.mjs: